summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 15:30:06 +0000
committeramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 15:30:06 +0000
commit0a3f254922d322db1d8537d75d15ca85cbfa9009 (patch)
treefec5df5465bceca9b9f99b72ee9c6546a1a13559
parentadee30da55ddec8b5be4c1146986f2b6d30a3ded (diff)
downloadchromium_src-0a3f254922d322db1d8537d75d15ca85cbfa9009.zip
chromium_src-0a3f254922d322db1d8537d75d15ca85cbfa9009.tar.gz
chromium_src-0a3f254922d322db1d8537d75d15ca85cbfa9009.tar.bz2
If there's no actual window (for example, in some unit tests), don't try to
paint to it. Build fix. BUG=none TEST=none TBR=rohitrao Review URL: http://codereview.chromium.org/174224 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23958 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/backing_store_mac.mm10
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm2
2 files changed, 7 insertions, 5 deletions
diff --git a/chrome/browser/renderer_host/backing_store_mac.mm b/chrome/browser/renderer_host/backing_store_mac.mm
index 8d71b58..b1f2b92 100644
--- a/chrome/browser/renderer_host/backing_store_mac.mm
+++ b/chrome/browser/renderer_host/backing_store_mac.mm
@@ -29,11 +29,11 @@ BackingStore::BackingStore(RenderWidgetHost* widget, const gfx::Size& size)
// window, so extract a CGContext corresponding to that window that we can
// pass to CGLayerCreateWithContext.
NSWindow* containing_window = [widget->view()->GetNativeView() window];
- CHECK(containing_window != NULL);
+ if (!containing_window) // possible in unit tests
+ return;
CGContextRef context = static_cast<CGContextRef>([[containing_window graphicsContext] graphicsPort]);
CGLayerRef layer = CGLayerCreateWithContext(context, size.ToCGSize(), NULL);
cg_layer_.reset(layer);
- CHECK(cg_layer_.get() != NULL);
}
BackingStore::~BackingStore() {
@@ -48,12 +48,12 @@ size_t BackingStore::MemorySize() {
void BackingStore::PaintRect(base::ProcessHandle process,
TransportDIB* bitmap,
const gfx::Rect& bitmap_rect) {
- scoped_cftyperef<CGColorSpaceRef> color_space(CGColorSpaceCreateDeviceRGB());
+ if (!cg_layer()) return;
+ scoped_cftyperef<CGColorSpaceRef> color_space(CGColorSpaceCreateDeviceRGB());
scoped_cftyperef<CGDataProviderRef> data_provider(
CGDataProviderCreateWithData(NULL, bitmap->memory(),
bitmap_rect.width() * bitmap_rect.height() * 4, NULL));
-
scoped_cftyperef<CGImageRef> image(CGImageCreate(bitmap_rect.width(),
bitmap_rect.height(), 8, 32, 4 * bitmap_rect.width(), color_space,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, data_provider,
@@ -75,6 +75,8 @@ void BackingStore::ScrollRect(base::ProcessHandle process,
int dx, int dy,
const gfx::Rect& clip_rect,
const gfx::Size& view_size) {
+ if (!cg_layer()) return;
+
// "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.
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 22bffe5..c047f41 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -548,7 +548,7 @@ void RenderWidgetHostViewMac::SetActive(bool active) {
renderWidgetHostView_->about_to_validate_and_paint_ = false;
dirtyRect = renderWidgetHostView_->invalid_rect_;
- if (backing_store) {
+ if (backing_store && backing_store->cg_layer()) {
NSRect view_bounds = [self bounds];
gfx::Rect damaged_rect([self NSRectToRect:dirtyRect]);