diff options
-rw-r--r-- | skia/ext/platform_canvas.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/skia/ext/platform_canvas.cc b/skia/ext/platform_canvas.cc index 1ba6313..dfb40f7 100644 --- a/skia/ext/platform_canvas.cc +++ b/skia/ext/platform_canvas.cc @@ -7,6 +7,14 @@ #include "skia/ext/bitmap_platform_device.h" #include "third_party/skia/include/core/SkTypes.h" +namespace { +skia::PlatformDevice* GetTopPlatformDevice(const SkCanvas* canvas) { + // All of our devices should be our special PlatformDevice. + SkCanvas::LayerIter iter(const_cast<SkCanvas*>(canvas), false); + return static_cast<skia::PlatformDevice*>(iter.device()); +} +} + namespace skia { PlatformCanvas::PlatformCanvas() @@ -22,9 +30,7 @@ SkDevice* PlatformCanvas::setBitmapDevice(const SkBitmap&) { } PlatformDevice& PlatformCanvas::getTopPlatformDevice() const { - // All of our devices should be our special PlatformDevice. - SkCanvas::LayerIter iter(const_cast<PlatformCanvas*>(this), false); - return *static_cast<PlatformDevice*>(iter.device()); + return *GetTopPlatformDevice(this); } // static @@ -46,23 +52,17 @@ SkCanvas* CreateBitmapCanvas(int width, int height, bool is_opaque) { } bool SupportsPlatformPaint(const SkCanvas* canvas) { - // All of our devices should be our special PlatformDevice. - PlatformDevice* device = static_cast<PlatformDevice*>(canvas->getDevice()); // TODO(alokp): Rename PlatformDevice::IsNativeFontRenderingAllowed after // removing these calls from WebKit. - return device->IsNativeFontRenderingAllowed(); + return GetTopPlatformDevice(canvas)->IsNativeFontRenderingAllowed(); } PlatformDevice::PlatformSurface BeginPlatformPaint(SkCanvas* canvas) { - // All of our devices should be our special PlatformDevice. - PlatformDevice* device = static_cast<PlatformDevice*>(canvas->getDevice()); - return device->BeginPlatformPaint(); + return GetTopPlatformDevice(canvas)->BeginPlatformPaint(); } void EndPlatformPaint(SkCanvas* canvas) { - // All of our devices should be our special PlatformDevice. - PlatformDevice* device = static_cast<PlatformDevice*>(canvas->getDevice()); - device->EndPlatformPaint(); + GetTopPlatformDevice(canvas)->EndPlatformPaint(); } } // namespace skia |