PaintInfo(const CefRenderHandler::RectList& dirtyRects, const void* buffer, int width, int height) { windowRegion.x = 0; windowRegion.y = 0; windowRegion.w = width; windowRegion.h = height; this->buffer = buffer; if (dirtyRects.size() == 1 && dirtyRects[0].x == 0 && dirtyRects[0].y == 0 && dirtyRects[0].width == width && dirtyRects[0].height == height) { regionCount = 0; invalidatedRegions = NULL; } else { regionCount = dirtyRects.size(); for (int x = 0; x < regionCount; ++x) { ChromiumDLL::ChromiumRegionInfo ri; ri.x = dirtyRects[x].x; ri.y = dirtyRects[x].y; ri.w = dirtyRects[x].width; ri.h = dirtyRects[x].height; m_vRegionInfo.push_back(ri); } invalidatedRegions = &m_vRegionInfo[0]; } }
void ClientOSRenderer::OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintElementType type, const CefRenderHandler::RectList& dirtyRects, const void* buffer, int width, int height) { if (!initialized_) Initialize(); if (transparent_) { // Enable alpha blending. glEnable(GL_BLEND); VERIFY_NO_ERROR; } // Enable 2D textures. glEnable(GL_TEXTURE_2D); VERIFY_NO_ERROR; DCHECK_NE(texture_id_, 0U); glBindTexture(GL_TEXTURE_2D, texture_id_); VERIFY_NO_ERROR; if (type == PET_VIEW) { int old_width = view_width_; int old_height = view_height_; view_width_ = width; view_height_ = height; { int linebyte = (((width << 5) + 31) >> 5) << 2; int lineInval = 4 - ((width << 5) >> 3) & 3; } if (show_update_rect_) update_rect_ = dirtyRects[0]; glPixelStorei(GL_UNPACK_ROW_LENGTH, view_width_); VERIFY_NO_ERROR; if (old_width != view_width_ || old_height != view_height_ || (dirtyRects.size() == 1 && dirtyRects[0] == CefRect(0, 0, view_width_, view_height_))) { // Update/resize the whole texture. glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); VERIFY_NO_ERROR; glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); VERIFY_NO_ERROR; test32Bmp(buffer, width, height); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, view_width_, view_height_, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); VERIFY_NO_ERROR; } else { // Update just the dirty rectangles. CefRenderHandler::RectList::const_iterator i = dirtyRects.begin(); for (; i != dirtyRects.end(); ++i) { const CefRect& rect = *i; glPixelStorei(GL_UNPACK_SKIP_PIXELS, rect.x); VERIFY_NO_ERROR; glPixelStorei(GL_UNPACK_SKIP_ROWS, rect.y); VERIFY_NO_ERROR; test32Bmp(buffer, width, height); glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x, rect.y, rect.width, rect.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); VERIFY_NO_ERROR; } } } else if (type == PET_POPUP && popup_rect_.width > 0 &&
void FCEFWebBrowserWindow::OnPaint(CefRenderHandler::PaintElementType Type, const CefRenderHandler::RectList& DirtyRects, const void* Buffer, int Width, int Height) { bool bNeedsRedraw = false; if (UpdatableTextures[Type] == nullptr && FSlateApplication::IsInitialized() && FSlateApplication::Get().GetRenderer().IsValid()) { UpdatableTextures[Type] = FSlateApplication::Get().GetRenderer()->CreateUpdatableTexture(Width,Height); } if (UpdatableTextures[Type] != nullptr) { // Note that with more recent versions of CEF, the DirtyRects will always contain a single element, as it merges all dirty areas into a single rectangle before calling OnPaint // In case that should change in the future, we'll simply update the entire area if DirtyRects is not a single element. FIntRect Dirty = (DirtyRects.size() == 1) ? FIntRect(DirtyRects[0].x, DirtyRects[0].y, DirtyRects[0].x + DirtyRects[0].width, DirtyRects[0].y + DirtyRects[0].height) : FIntRect(); if (Type == PET_VIEW && BufferedVideo.IsValid() ) { // If we're using bufferedVideo, submit the frame to it bNeedsRedraw = BufferedVideo->SubmitFrame(Width, Height, Buffer, Dirty); } else { UpdatableTextures[Type]->UpdateTextureThreadSafeRaw(Width, Height, Buffer, Dirty); if (Type == PET_POPUP && bShowPopupRequested) { bShowPopupRequested = false; bPopupHasFocus = true; FIntPoint PopupSize = FIntPoint(Width, Height); FIntRect PopupRect = FIntRect(PopupPosition, PopupPosition + PopupSize); OnShowPopup().Broadcast(PopupRect); } bNeedsRedraw = true; } } bIsInitialized = true; if (bNeedsRedraw) { NeedsRedrawEvent.Broadcast(); } }
void ClientOSRenderer::OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintElementType type, const CefRenderHandler::RectList& dirtyRects, const void* buffer, int width, int height) { if (!initialized_) Initialize(); if (transparent_) { // Enable alpha blending. glEnable(GL_BLEND); } // Enable 2D textures. glEnable(GL_TEXTURE_2D); ASSERT(texture_id_ != 0); glBindTexture(GL_TEXTURE_2D, texture_id_); if (type == PET_VIEW) { int old_width = view_width_; int old_height = view_height_; view_width_ = width; view_height_ = height; glPixelStorei(GL_UNPACK_ROW_LENGTH, view_width_); if (old_width != view_width_ || old_height != view_height_) { // Update/resize the whole texture. glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, view_width_, view_height_, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); } else { // Update just the dirty rectangles. CefRenderHandler::RectList::const_iterator i = dirtyRects.begin(); for (; i != dirtyRects.end(); ++i) { const CefRect& rect = *i; glPixelStorei(GL_UNPACK_SKIP_PIXELS, rect.x); glPixelStorei(GL_UNPACK_SKIP_ROWS, rect.y); glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x, rect.y, rect.width, rect.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); } } } else if (type == PET_POPUP && popup_rect_.width > 0 && popup_rect_.height > 0) { int skip_pixels = 0, x = popup_rect_.x; int skip_rows = 0, y = popup_rect_.y; int w = width; int h = height; // Adjust the popup to fit inside the view. if (x < 0) { skip_pixels = -x; x = 0; } if (y < 0) { skip_rows = -y; y = 0; } if (x + w > view_width_) w -= x + w - view_width_; if (y + h > view_height_) h -= y + h - view_height_; // Update the popup rectangle. glPixelStorei(GL_UNPACK_ROW_LENGTH, width); glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); } // Disable 2D textures. glDisable(GL_TEXTURE_2D); if (transparent_) { // Disable alpha blending. glDisable(GL_BLEND); } }