diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 22:38:35 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 22:38:35 +0000 |
commit | 4f1b94fe2cb294b919d6a761f0accc155e7a8b8b (patch) | |
tree | 3f6932403519d178b7f8afca465f7a2a87c9e517 | |
parent | afd20b36dbca10b424d974f50c163879b2afb137 (diff) | |
download | chromium_src-4f1b94fe2cb294b919d6a761f0accc155e7a8b8b.zip chromium_src-4f1b94fe2cb294b919d6a761f0accc155e7a8b8b.tar.gz chromium_src-4f1b94fe2cb294b919d6a761f0accc155e7a8b8b.tar.bz2 |
BackingStoreMac scrolling update and DCHECKs.
Functional change: when a CGBitmapContext is in use instead of a CGLayer,
scroll. CGLayerGetSize(NULL) was just returning (0.0, 0.0), which was causing
no scrolling.
Functional change: avoid entering the scroll blitter if:
(0 < abs(dx) < size_.width() and abs(dy) >= size_.height()) or
(0 < abs(dy) < size_.height() and abs(dx) >= size_.width())
Non-functional change: DCHECK in a few spots that exactly one of a CGLayer and
a CGBitmapContext is present.
BUG=26989
TEST=Things should paint when scrolling.
Review URL: http://codereview.chromium.org/376028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31493 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/backing_store_mac.mm | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/chrome/browser/renderer_host/backing_store_mac.mm b/chrome/browser/renderer_host/backing_store_mac.mm index 44095da..567d8b9 100644 --- a/chrome/browser/renderer_host/backing_store_mac.mm +++ b/chrome/browser/renderer_host/backing_store_mac.mm @@ -56,6 +56,8 @@ size_t BackingStore::MemorySize() { void BackingStore::PaintRect(base::ProcessHandle process, TransportDIB* bitmap, const gfx::Rect& bitmap_rect) { + DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); + scoped_cftyperef<CGDataProviderRef> data_provider( CGDataProviderCreateWithData(NULL, bitmap->memory(), bitmap_rect.width() * bitmap_rect.height() * 4, NULL)); @@ -86,6 +88,8 @@ void BackingStore::PaintRect(base::ProcessHandle process, } } + DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); + if (cg_layer()) { // The CGLayer's origin is in the lower left, but flipping the CTM would // cause the image to get drawn upside down. So we move the rectangle @@ -109,6 +113,8 @@ void BackingStore::ScrollRect(base::ProcessHandle process, int dx, int dy, const gfx::Rect& clip_rect, const gfx::Size& view_size) { + DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); + // "Scroll" the contents of the layer by creating a new CGLayer, // copying the contents of the old one into the new one offset by the scroll // amount, swapping in the new CGLayer, and then painting in the new data. @@ -119,16 +125,14 @@ void BackingStore::ScrollRect(base::ProcessHandle process, // translated by the scroll.) // We assume |clip_rect| is contained within the backing store. - CGSize layer_size = CGLayerGetSize(cg_layer()); - DCHECK(clip_rect.bottom() <= layer_size.height); - DCHECK(clip_rect.right() <= layer_size.width); + DCHECK(clip_rect.bottom() <= size_.height()); + DCHECK(clip_rect.right() <= size_.width()); - if ((dx && abs(dx) < layer_size.width) || - (dy && abs(dy) < layer_size.height)) { + if ((dx || dy) && abs(dx) < size_.width() && abs(dy) < size_.height()) { if (cg_layer()) { CGContextRef context = CGLayerGetContext(cg_layer()); scoped_cftyperef<CGLayerRef> new_layer( - CGLayerCreateWithContext(context, layer_size, NULL)); + CGLayerCreateWithContext(context, size_.ToCGSize(), NULL)); CGContextRef layer = CGLayerGetContext(new_layer); CGContextDrawLayerAtPoint(layer, CGPointMake(0, 0), cg_layer()); CGContextSaveGState(layer); |