mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Windows: Improvements to off-screen rendering support (issue #518).
- Implement support for transparency. Change the backing store to use Skia instead of GDI and to keep alpha values. - Implement support for select popups. Requires a patch to Chromium (content_popups.patch). - Implicitly disable accelerated compositing when using off-screen rendering. - Introduce a new CefMouseEvent structure for representing mouse event information passed to CefBrowser methods. - Merge cef_key_event_modifiers_t into cef_event_flags_t. - Add a new argument to CefBrowser::Invalidate telling the browser whether to invalidate the select popup or the main view. - Add a new cefclient "transparent-painting-enabled" command-line flag to test transparent off-screen rendering. - Add a new cefclient "Transparency" test. - Fix the cefclient off-screen rendering rotation effect to work even when the underlying web content is not updating. - Add unit tests for transparent painting and select popups. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@979 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -4,22 +4,79 @@
|
||||
|
||||
#include "libcef/browser/backing_store_osr.h"
|
||||
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/surface/transport_dib.h"
|
||||
|
||||
BackingStoreOSR::BackingStoreOSR(content::RenderWidgetHost* widget,
|
||||
const gfx::Size& size)
|
||||
: content::BackingStore(widget, size) {
|
||||
bitmap_.Allocate(size.width(), size.height(), true);
|
||||
: content::BackingStore(widget, size),
|
||||
device_(SkBitmap::kARGB_8888_Config, size.width(), size.height(), true),
|
||||
canvas_(&device_) {
|
||||
canvas_.drawColor(SK_ColorWHITE);
|
||||
}
|
||||
|
||||
void BackingStoreOSR::PaintToBackingStore(
|
||||
content::RenderProcessHost* process,
|
||||
TransportDIB::Id bitmap,
|
||||
const gfx::Rect& bitmap_rect,
|
||||
const std::vector<gfx::Rect>& copy_rects,
|
||||
float scale_factor,
|
||||
const base::Closure& completion_callback,
|
||||
bool* scheduled_completion_callback) {
|
||||
*scheduled_completion_callback = false;
|
||||
TransportDIB* dib = process->GetTransportDIB(bitmap);
|
||||
if (!dib)
|
||||
return;
|
||||
|
||||
SkBitmap src_bitmap;
|
||||
src_bitmap.setConfig(SkBitmap::kARGB_8888_Config,
|
||||
bitmap_rect.width(),
|
||||
bitmap_rect.height());
|
||||
src_bitmap.setPixels(dib->memory());
|
||||
|
||||
SkPaint copy_paint;
|
||||
copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
|
||||
for (size_t i = 0; i < copy_rects.size(); i++) {
|
||||
SkIRect src_rect = SkIRect::MakeXYWH(copy_rects[i].x() - bitmap_rect.x(),
|
||||
copy_rects[i].y() - bitmap_rect.y(),
|
||||
copy_rects[i].width(),
|
||||
copy_rects[i].height());
|
||||
SkRect paint_rect = SkRect::MakeXYWH(copy_rects[i].x(),
|
||||
copy_rects[i].y(),
|
||||
copy_rects[i].width(),
|
||||
copy_rects[i].height());
|
||||
canvas_.drawBitmapRect(src_bitmap, &src_rect, paint_rect, ©_paint);
|
||||
}
|
||||
src_bitmap.setPixels(0);
|
||||
}
|
||||
|
||||
bool BackingStoreOSR::CopyFromBackingStore(const gfx::Rect& rect,
|
||||
skia::PlatformBitmap* output) {
|
||||
if (!output->Allocate(rect.width(), rect.height(), true))
|
||||
return false;
|
||||
|
||||
SkPaint copy_paint;
|
||||
copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
|
||||
SkCanvas canvas(output->GetBitmap());
|
||||
canvas.drawColor(SK_ColorWHITE);
|
||||
canvas.drawBitmap(device_.accessBitmap(false), 0, 0, ©_paint);
|
||||
return true;
|
||||
}
|
||||
|
||||
void BackingStoreOSR::ScrollBackingStore(const gfx::Vector2d& delta,
|
||||
const gfx::Rect& clip_rect,
|
||||
const gfx::Size& view_size) {
|
||||
SkIRect subset_rect = SkIRect::MakeXYWH(clip_rect.x(), clip_rect.y(),
|
||||
clip_rect.width(), clip_rect.height());
|
||||
bitmap_.GetBitmap().scrollRect(&subset_rect, delta.x(), delta.y());
|
||||
SkIRect subset_rect = SkIRect::MakeXYWH(clip_rect.x(),
|
||||
clip_rect.y(),
|
||||
clip_rect.width(),
|
||||
clip_rect.height());
|
||||
device_.accessBitmap(true).scrollRect(&subset_rect, delta.x(), delta.y());
|
||||
}
|
||||
|
||||
const void* BackingStoreOSR::getPixels() const {
|
||||
return const_cast<BackingStoreOSR*>(this)->bitmap_.GetBitmap().getPixels();
|
||||
return const_cast<BackingStoreOSR*>(this)->device_.
|
||||
accessBitmap(false).getPixels();
|
||||
}
|
||||
|
Reference in New Issue
Block a user