Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- InterfaceRenderHandler::InterfaceRenderHandler()
- {
- width = 500;
- height = 500;
- x = 0;
- y = 0;
- size_t size = width * height * 4;
- frameReady = false;
- buffer = new unsigned char[size];
- }
- InterfaceRenderHandler::~InterfaceRenderHandler()
- {
- }
- bool InterfaceRenderHandler::hasFrame()
- {
- return frameReady;
- }
- unsigned char *InterfaceRenderHandler::getFrame()
- {
- if (frameReady)
- {
- frameReady = false;
- return buffer;
- }
- else
- {
- return nullptr;
- }
- }
- bool InterfaceRenderHandler::GetRootScreenRect(CefRefPtr<CefBrowser> browser, CefRect& rect)
- {
- rect.width = width;
- rect.height = height;
- rect.x = x;
- rect.y = y;
- return true;
- }
- bool InterfaceRenderHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect)
- {
- rect.width = width;
- rect.height = height;
- rect.x = x;
- rect.y = y;
- return true;
- }
- void InterfaceRenderHandler::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects, const void* buffer, int width, int height)
- {
- cout << "Frame delivered.\n";
- size_t size = width * height * 4;
- unsigned char *inBuffer = (unsigned char *)buffer;
- memcpy(this->buffer, inBuffer, size);
- frameReady = true;
- }
- InterfaceBrowserClient::InterfaceBrowserClient()
- {
- handler = nullptr;
- }
- InterfaceBrowserClient::InterfaceBrowserClient(CefRenderHandler *renderHandler)
- : handler(renderHandler)
- {
- }
- InterfaceBrowserClient::~InterfaceBrowserClient()
- {
- if (handler != nullptr)
- {
- delete handler;
- }
- }
- CefRefPtr<CefRenderHandler> InterfaceBrowserClient::GetRenderHandler()
- {
- return handler;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement