From 19eeebed029fe7262cb5908031e07236bce066a2 Mon Sep 17 00:00:00 2001 From: "brettw@google.com" Date: Fri, 7 Nov 2008 16:45:24 +0000 Subject: [PATCH] Make PlatformCanvasLinux match up with recent changes in the Windows one, which is able to report allocation failures. Review URL: http://codereview.chromium.org/9510 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4991 0039d316-1c4b-4281-b951-d872f2087c98 --- base/gfx/platform_canvas_linux.cc | 9 +++++++-- base/gfx/platform_canvas_linux.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/base/gfx/platform_canvas_linux.cc b/base/gfx/platform_canvas_linux.cc index 63ed3c29a33..5ebeb27d08a 100644 --- a/base/gfx/platform_canvas_linux.cc +++ b/base/gfx/platform_canvas_linux.cc @@ -15,16 +15,21 @@ PlatformCanvasLinux::PlatformCanvasLinux() : SkCanvas() { PlatformCanvasLinux::PlatformCanvasLinux(int width, int height, bool is_opaque) : SkCanvas() { - initialize(width, height, is_opaque); + if (!initialize(width, height, is_opaque)) + CHECK(false); } PlatformCanvasLinux::~PlatformCanvasLinux() { } -void PlatformCanvasLinux::initialize(int width, int height, bool is_opaque) { +bool PlatformCanvasLinux::initialize(int width, int height, bool is_opaque) { SkDevice* device = createPlatformDevice(width, height, is_opaque); + if (!device) + return false; + setDevice(device); device->unref(); // was created with refcount 1, and setDevice also refs + return true; } PlatformDeviceLinux& PlatformCanvasLinux::getTopPlatformDevice() const { diff --git a/base/gfx/platform_canvas_linux.h b/base/gfx/platform_canvas_linux.h index 4030a55b2c7..07f0d2dcc7c 100644 --- a/base/gfx/platform_canvas_linux.h +++ b/base/gfx/platform_canvas_linux.h @@ -27,7 +27,7 @@ class PlatformCanvasLinux : public SkCanvas { virtual ~PlatformCanvasLinux(); // For two-part init, call if you use the no-argument constructor above - void initialize(int width, int height, bool is_opaque); + bool initialize(int width, int height, bool is_opaque); // Returns the platform device pointer of the topmost rect with a non-empty // clip. Both the windows and mac versions have an equivalent of this method;