diff options
Diffstat (limited to 'skia/ext/platform_canvas.cc')
-rw-r--r-- | skia/ext/platform_canvas.cc | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/skia/ext/platform_canvas.cc b/skia/ext/platform_canvas.cc index c48cce4..c6fd17e 100644 --- a/skia/ext/platform_canvas.cc +++ b/skia/ext/platform_canvas.cc @@ -7,14 +7,6 @@ #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() { @@ -29,10 +21,6 @@ SkDevice* PlatformCanvas::setBitmapDevice(const SkBitmap&) { return NULL; } -PlatformDevice& PlatformCanvas::getTopPlatformDevice() const { - return *GetTopPlatformDevice(this); -} - // static size_t PlatformCanvas::StrideForWidth(unsigned width) { return 4 * width; @@ -51,18 +39,32 @@ SkCanvas* CreateBitmapCanvas(int width, int height, bool is_opaque) { return new PlatformCanvas(width, height, is_opaque); } +SkDevice* GetTopDevice(const SkCanvas& canvas) { + SkCanvas::LayerIter iter(const_cast<SkCanvas*>(&canvas), false); + return iter.device(); +} + bool SupportsPlatformPaint(const SkCanvas* canvas) { - // TODO(alokp): Rename PlatformDevice::IsNativeFontRenderingAllowed after - // removing these calls from WebKit. - return GetTopPlatformDevice(canvas)->IsNativeFontRenderingAllowed(); + // TODO(alokp): Rename IsNativeFontRenderingAllowed after removing these + // calls from WebKit. + return IsNativeFontRenderingAllowed(GetTopDevice(*canvas)); } -PlatformDevice::PlatformSurface BeginPlatformPaint(SkCanvas* canvas) { - return GetTopPlatformDevice(canvas)->BeginPlatformPaint(); +PlatformSurface BeginPlatformPaint(SkCanvas* canvas) { + return BeginPlatformPaint(GetTopDevice(*canvas)); } void EndPlatformPaint(SkCanvas* canvas) { - GetTopPlatformDevice(canvas)->EndPlatformPaint(); + EndPlatformPaint(GetTopDevice(*canvas)); +} + +void DrawToNativeContext(SkCanvas* canvas, PlatformSurface context, int x, + int y, const PlatformRect* src_rect) { + DrawToNativeContext(GetTopDevice(*canvas), context, x, y, src_rect); +} + +void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) { + MakeOpaque(GetTopDevice(*canvas), x, y, width, height); } } // namespace skia |