diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-24 18:04:58 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-24 18:04:58 +0000 |
commit | 8ccd594df1c045bc26def7ba623e262bd0d43218 (patch) | |
tree | a5a67c8cf3e2db0476de138537f832f6b7bc640c /webkit/plugins | |
parent | ec13ca612aa5f6fed4b33b17802d8141c182b5e9 (diff) | |
download | chromium_src-8ccd594df1c045bc26def7ba623e262bd0d43218.zip chromium_src-8ccd594df1c045bc26def7ba623e262bd0d43218.tar.gz chromium_src-8ccd594df1c045bc26def7ba623e262bd0d43218.tar.bz2 |
Don't copy the Graphics2D when binding a new one. This brings the
implementation in line with the interface documentation (the old behavior would
clobber any content).
The copying behavior was introduced to avoid flickering when resizing. To avoid
this, the PaintManager now doesn't bind the new device until it's been painted
to. This gives flicker-free painting.
This fixes a bug in the paint manager example that made it not paint.
TEST=manual
BUG=86568
Review URL: http://codereview.chromium.org/7215030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90386 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 23 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_2d_impl.cc | 37 |
2 files changed, 30 insertions, 30 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 65faa07..9ae9014 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -1400,29 +1400,6 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance, if (!graphics_2d->BindToInstance(this)) return PP_FALSE; // Can't bind to more than one instance. - // See http://crbug.com/49403: this can be further optimized by keeping the - // old device around and painting from it. - if (bound_graphics_2d()) { - // Start the new image with the content of the old image until the plugin - // repaints. - // Use ImageDataAutoMapper to ensure the image data is valid. - ImageDataAutoMapper mapper(bound_graphics_2d()->image_data()); - if (!mapper.is_valid()) - return PP_FALSE; - const SkBitmap* old_backing_bitmap = - bound_graphics_2d()->image_data()->GetMappedBitmap(); - SkRect old_size = SkRect::MakeWH( - SkScalar(static_cast<float>(old_backing_bitmap->width())), - SkScalar(static_cast<float>(old_backing_bitmap->height()))); - - SkCanvas canvas(*graphics_2d->image_data()->GetMappedBitmap()); - canvas.drawBitmap(*old_backing_bitmap, 0, 0); - - // Fill in any extra space with white. - canvas.clipRect(old_size, SkRegion::kDifference_Op); - canvas.drawARGB(255, 255, 255, 255); - } - bound_graphics_ = graphics_2d; setBackingTextureId(0); // BindToInstance will have invalidated the plugin if necessary. diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc index caf3821..f6294449 100644 --- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc @@ -495,19 +495,42 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas, CGContextDrawImage(canvas, bitmap_rect, image); CGContextRestoreGState(canvas); #else + SkRect sk_plugin_rect = SkRect::MakeXYWH( + SkIntToScalar(plugin_rect.origin().x()), + SkIntToScalar(plugin_rect.origin().y()), + SkIntToScalar(plugin_rect.width()), + SkIntToScalar(plugin_rect.height())); + canvas->save(); + canvas->clipRect(sk_plugin_rect); + + if (instance()->IsFullPagePlugin()) { + // When we're resizing a window with a full-frame plugin, the plugin may + // not yet have bound a new device, which will leave parts of the + // background exposed if the window is getting larger. We want this to + // show white (typically less jarring) rather than black or uninitialized. + // We don't do this for non-full-frame plugins since we specifically want + // the page background to show through. + canvas->save(); + SkRect image_data_rect = SkRect::MakeXYWH( + SkIntToScalar(plugin_rect.origin().x()), + SkIntToScalar(plugin_rect.origin().y()), + SkIntToScalar(image_data_->width()), + SkIntToScalar(image_data_->height())); + canvas->clipRect(image_data_rect, SkRegion::kDifference_Op); + + SkPaint paint; + paint.setXfermodeMode(SkXfermode::kSrc_Mode); + paint.setColor(SK_ColorWHITE); + canvas->drawRect(sk_plugin_rect, paint); + canvas->restore(); + } + SkPaint paint; if (is_always_opaque_) { // When we know the device is opaque, we can disable blending for slightly // more optimized painting. paint.setXfermodeMode(SkXfermode::kSrc_Mode); } - - canvas->save(); - SkRect clip_rect = SkRect::MakeXYWH(SkIntToScalar(plugin_rect.origin().x()), - SkIntToScalar(plugin_rect.origin().y()), - SkIntToScalar(plugin_rect.width()), - SkIntToScalar(plugin_rect.height())); - canvas->clipRect(clip_rect); canvas->drawBitmap(backing_bitmap, SkIntToScalar(plugin_rect.x()), SkIntToScalar(plugin_rect.y()), |