summaryrefslogtreecommitdiffstats
path: root/chrome/plugin
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-29 19:58:43 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-29 19:58:43 +0000
commit1d99bfac92febc985149d026563e53a0888f76af (patch)
tree21bd18ad4e450bcf891b974f00e5a5fbf7d1ded4 /chrome/plugin
parentc93efc7c5e34959ff4f828f242381b0f6eacf6cf (diff)
downloadchromium_src-1d99bfac92febc985149d026563e53a0888f76af.zip
chromium_src-1d99bfac92febc985149d026563e53a0888f76af.tar.gz
chromium_src-1d99bfac92febc985149d026563e53a0888f76af.tar.bz2
Fix transparent windowless plugin background painting. This would manifest
itself as incorrect ClearType edges. The problem was that we were taking into account the translation from the page coordinate system when blitting the background, but this had already been accounted for in the transformation matrix, resulting in duplicate transformations. The fix simplifies the code by not tranlating into the page coordinate system until later, staying in the plugin coordinate system which is more convenient. This means that the background (which is the same size as the buffer) can just be painted at (0,0) with no fuss and no muss. We don't even need to worry about how much we paint since the clip was already installed. This also corrects some indenting in browser.cc that I noticed. TEST="Attach a file" text in Gmail compose looks weird (sometimes requires selecting it to make this happen). BUG=26080 Review URL: http://codereview.chromium.org/343040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r--chrome/plugin/webplugin_proxy.cc35
1 files changed, 18 insertions, 17 deletions
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc
index 16fb1ee..df02104 100644
--- a/chrome/plugin/webplugin_proxy.cc
+++ b/chrome/plugin/webplugin_proxy.cc
@@ -376,35 +376,36 @@ void WebPluginProxy::Paint(const gfx::Rect& rect) {
#if defined(OS_WIN) || defined(OS_LINUX)
windowless_canvas_->save();
- // The given clip rect is in global coordinates, so install it before the
- // transformation is done for the coordinate system.
+ // The given clip rect is relative to the plugin coordinate system.
SkRect sk_rect = { SkIntToScalar(rect.x()),
SkIntToScalar(rect.y()),
SkIntToScalar(rect.right()),
SkIntToScalar(rect.bottom()) };
windowless_canvas_->clipRect(sk_rect);
- windowless_canvas_->translate(SkIntToScalar(-delegate_->GetRect().x()),
- SkIntToScalar(-delegate_->GetRect().y()));
// Setup the background.
- if (!background_canvas_.get()) {
+ if (background_canvas_.get()) {
+ // When a background canvas is given, we're in transparent mode. This means
+ // the plugin wants to have the image of the page in the canvas it's drawing
+ // into (which is windowless_canvas_) so it can do blending. So we copy the
+ // background bitmap into the windowless_canvas_.
+ const SkBitmap& background_bitmap =
+ background_canvas_->getTopPlatformDevice().accessBitmap(false);
+ windowless_canvas_->drawBitmap(background_bitmap, 0, 0);
+ } else {
+ // In non-transparent mode, the plugin doesn't care what's underneath, so we
+ // can just give it black.
SkPaint black_fill_paint;
black_fill_paint.setARGB(0xFF, 0x00, 0x00, 0x00);
windowless_canvas_->drawPaint(black_fill_paint);
- } else {
- SkIRect src_rect = { rect.x(), rect.y(),
- rect.x() + offset_rect.width(),
- rect.y() + offset_rect.height() };
-
- SkRect dest_rect = { SkIntToScalar(offset_rect.x()),
- SkIntToScalar(offset_rect.y()),
- SkIntToScalar(offset_rect.right()),
- SkIntToScalar(offset_rect.bottom()) };
- const SkBitmap& background_bitmap =
- background_canvas_->getTopPlatformDevice().accessBitmap(false);
- windowless_canvas_->drawBitmapRect(background_bitmap, &src_rect, dest_rect);
}
+ // Bring the windowless_canvas_ into the window coordinate system, which is
+ // how the plugin expects to draw (since the windowless API was originally
+ // designed just for scribbling over the web page).
+ windowless_canvas_->translate(SkIntToScalar(-delegate_->GetRect().x()),
+ SkIntToScalar(-delegate_->GetRect().y()));
+
// Before we send the invalidate, paint so that renderer uses the updated
// bitmap.
delegate_->Paint(windowless_canvas_.get(), offset_rect);