summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-17 06:14:57 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-17 06:14:57 +0000
commit0d1b3ab194f71a6cb7b5efa56fc1cbd080f2bb00 (patch)
treede8656aa31ab5077370ef00e164c868fee468316
parentb83efaa3396231ccfd2d414a018c550f91988431 (diff)
downloadchromium_src-0d1b3ab194f71a6cb7b5efa56fc1cbd080f2bb00.zip
chromium_src-0d1b3ab194f71a6cb7b5efa56fc1cbd080f2bb00.tar.gz
chromium_src-0d1b3ab194f71a6cb7b5efa56fc1cbd080f2bb00.tar.bz2
Avoid flashing when resizing plugins that use PaintManager. Copy the bitmap from the old backing store to the new one so that we have something to display until the plugin repaints. Credit to Darin for tracking this down and the suggested fix.
Review URL: http://codereview.chromium.org/2834052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52811 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/glue/plugins/pepper_device_context_2d.h2
-rw-r--r--webkit/glue/plugins/pepper_plugin_instance.cc20
2 files changed, 22 insertions, 0 deletions
diff --git a/webkit/glue/plugins/pepper_device_context_2d.h b/webkit/glue/plugins/pepper_device_context_2d.h
index 5d9180c..603bd52 100644
--- a/webkit/glue/plugins/pepper_device_context_2d.h
+++ b/webkit/glue/plugins/pepper_device_context_2d.h
@@ -67,6 +67,8 @@ class DeviceContext2D : public Resource {
void ViewInitiatedPaint();
void ViewFlushedPaint();
+ ImageData* image_data() { return image_data_.get(); }
+
private:
// Tracks a call to flush that requires a callback.
class FlushCallbackData {
diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc
index 35f4cca..dcc7ea2 100644
--- a/webkit/glue/plugins/pepper_plugin_instance.cc
+++ b/webkit/glue/plugins/pepper_plugin_instance.cc
@@ -314,6 +314,26 @@ bool PluginInstance::BindGraphicsDeviceContext(PP_Resource device_id) {
if (device_2d) {
if (!device_2d->BindToInstance(this))
return 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 (device_context_2d_.get()) {
+ // Start the new image with the content of the old image until the plugin
+ // repaints.
+ const SkBitmap* old_backing_bitmap =
+ device_context_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(*device_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);
+ }
+
device_context_2d_ = device_2d;
// BindToInstance will have invalidated the plugin if necessary.
}