summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-29 16:07:51 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-29 16:07:51 +0000
commit7b7c061b23886de29d656046670edf3ab96247c2 (patch)
tree9a1ea091b976ef7f63df7ab2effeca0add14ff68
parent833a92409df55feb2508743847bf683c74ae4546 (diff)
downloadchromium_src-7b7c061b23886de29d656046670edf3ab96247c2.zip
chromium_src-7b7c061b23886de29d656046670edf3ab96247c2.tar.gz
chromium_src-7b7c061b23886de29d656046670edf3ab96247c2.tar.bz2
[Mac] Root the RenderWidgetHostView in the upper left, not the lower left. This prevents all sorts of fun jank when resizing a window.
BUG=http://crbug.com/23252 TEST=Resize gmail (which is particularly hard on the renderer). The upper left corner of the view should not change, flicker, or jump around. Review URL: http://codereview.chromium.org/244030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27488 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm11
1 files changed, 9 insertions, 2 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index 117a236..e6dc1fa 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -633,6 +633,11 @@ void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) {
backing_store->size().width(),
backing_store->size().height());
+ // Specify the proper y offset to ensure that the view is rooted to the
+ // upper left corner. This can be negative, if the window was resized
+ // smaller and the renderer hasn't yet repainted.
+ int yOffset = NSHeight(view_bounds) - backing_store->size().height();
+
gfx::Rect paint_rect = bitmap_rect.Intersect(damaged_rect);
if (!paint_rect.IsEmpty()) {
// if we have a CGLayer, draw that into the window
@@ -641,7 +646,7 @@ void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) {
[[NSGraphicsContext currentContext] graphicsPort]);
// TODO: add clipping to dirtyRect if it improves drawing performance.
- CGContextDrawLayerAtPoint(context, CGPointMake(0.0, 0.0),
+ CGContextDrawLayerAtPoint(context, CGPointMake(0.0, yOffset),
backing_store->cg_layer());
} else {
// if we haven't created a layer yet, draw the cached bitmap into
@@ -651,7 +656,9 @@ void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) {
[[NSGraphicsContext currentContext] graphicsPort]);
scoped_cftyperef<CGImageRef> image(
CGBitmapContextCreateImage(backing_store->cg_bitmap()));
- CGContextDrawImage(context, bitmap_rect.ToCGRect(), image);
+ CGRect imageRect = bitmap_rect.ToCGRect();
+ imageRect.origin.y = yOffset;
+ CGContextDrawImage(context, imageRect, image);
}
}