Chromium Code Reviews| Index: chrome/browser/renderer_host/backing_store_mac.mm |
| diff --git a/chrome/browser/renderer_host/backing_store_mac.mm b/chrome/browser/renderer_host/backing_store_mac.mm |
| index d5cc992e33684a6956894c257c513334ca7e9474..0e9dc6a080a62eceafca9146b3af5f3d8838cbf2 100644 |
| --- a/chrome/browser/renderer_host/backing_store_mac.mm |
| +++ b/chrome/browser/renderer_host/backing_store_mac.mm |
| @@ -9,6 +9,7 @@ |
| #include "app/surface/transport_dib.h" |
| #include "base/logging.h" |
| #include "base/mac_util.h" |
| +#include "base/sys_info.h" |
| #include "chrome/browser/renderer_host/render_process_host.h" |
| #include "chrome/browser/renderer_host/render_widget_host.h" |
| #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| @@ -23,6 +24,19 @@ |
| // allows acclerated drawing into the layer and lets scrolling and such happen |
| // all or mostly on the GPU, which is good for performance. |
| +namespace { |
| + |
| +// Returns if this version of OS X has broken CGLayers, see |
|
Mark Mentovai
2010/06/10 20:05:51
“Returns if” implies that this function doesn’t re
Nico
2010/06/10 20:10:30
Done.
|
| +// http://crbug.com/45553 , comments 5 and 6. |
| +bool NeedsLayerWorkaround() { |
| + int32 os_major, os_minor, os_bugfix; |
| + base::SysInfo::OperatingSystemVersionNumbers( |
| + &os_major, &os_minor, &os_bugfix); |
| + return os_major == 10 && os_minor == 5; |
|
Mark Mentovai
2010/06/10 20:05:51
For paranoia’s sake:
return os_major < 10 || (o
Nico
2010/06/10 20:10:30
Uh, no :-)
rohitrao (ping after 24h)
2010/06/10 20:55:08
Why not? The specificity of checking for 10.5 sca
Nico
2010/06/10 21:08:04
'cause Chrome won't run on 10.4 (or OS 9 for that
|
| +} |
| + |
| +} // namespace |
| + |
| BackingStoreMac::BackingStoreMac(RenderWidgetHost* widget, |
| const gfx::Size& size) |
| : BackingStore(widget, size) { |
| @@ -144,13 +158,23 @@ void BackingStoreMac::ScrollBackingStore(int dx, int dy, |
| if ((dx || dy) && abs(dx) < size().width() && abs(dy) < size().height()) { |
| if (cg_layer()) { |
| - scoped_cftyperef<CGLayerRef> new_layer(CreateCGLayer()); |
| + // See http://crbug.com/45553 , comments 5 and 6. |
| + static bool needs_layer_workaround = NeedsLayerWorkaround(); |
| + |
| + scoped_cftyperef<CGLayerRef> new_layer; |
| + CGContextRef layer; |
| - // If the current view is in a window, the replacement must be too. |
| - DCHECK(new_layer); |
| + if (needs_layer_workaround) { |
| + new_layer.reset(CreateCGLayer()); |
| + // If the current view is in a window, the replacement must be too. |
| + DCHECK(new_layer); |
| + |
| + layer = CGLayerGetContext(new_layer); |
| + CGContextDrawLayerAtPoint(layer, CGPointMake(0, 0), cg_layer()); |
| + } else { |
| + layer = CGLayerGetContext(cg_layer()); |
| + } |
| - CGContextRef layer = CGLayerGetContext(new_layer); |
| - CGContextDrawLayerAtPoint(layer, CGPointMake(0, 0), cg_layer()); |
| CGContextSaveGState(layer); |
| CGContextClipToRect(layer, |
| CGRectMake(clip_rect.x(), |
| @@ -159,26 +183,23 @@ void BackingStoreMac::ScrollBackingStore(int dx, int dy, |
| clip_rect.height())); |
| CGContextDrawLayerAtPoint(layer, CGPointMake(dx, -dy), cg_layer()); |
| CGContextRestoreGState(layer); |
| - cg_layer_.swap(new_layer); |
| + |
| + if (needs_layer_workaround) |
| + cg_layer_.swap(new_layer); |
| } else { |
| // We don't have a layer, so scroll the contents of the CGBitmapContext. |
| - scoped_cftyperef<CGContextRef> new_bitmap(CreateCGBitmapContext()); |
| scoped_cftyperef<CGImageRef> bitmap_image( |
| CGBitmapContextCreateImage(cg_bitmap_)); |
| - CGContextDrawImage(new_bitmap, |
| - CGRectMake(0, 0, size().width(), size().height()), |
| - bitmap_image); |
| - CGContextSaveGState(new_bitmap); |
| - CGContextClipToRect(new_bitmap, |
| + CGContextSaveGState(cg_bitmap_); |
| + CGContextClipToRect(cg_bitmap_, |
| CGRectMake(clip_rect.x(), |
| size().height() - clip_rect.bottom(), |
| clip_rect.width(), |
| clip_rect.height())); |
| - CGContextDrawImage(new_bitmap, |
| + CGContextDrawImage(cg_bitmap_, |
| CGRectMake(dx, -dy, size().width(), size().height()), |
| bitmap_image); |
| - CGContextRestoreGState(new_bitmap); |
| - cg_bitmap_.swap(new_bitmap); |
| + CGContextRestoreGState(cg_bitmap_); |
| } |
| } |
| } |