| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "skia/ext/platform_canvas.h" | 5 #include "skia/ext/platform_canvas.h" |
| 6 | 6 |
| 7 #include "skia/ext/bitmap_platform_device.h" | 7 #include "skia/ext/bitmap_platform_device.h" |
| 8 #include "third_party/skia/include/core/SkTypes.h" | 8 #include "third_party/skia/include/core/SkTypes.h" |
| 9 | 9 |
| 10 namespace skia { | 10 namespace skia { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 delete canvas; | 40 delete canvas; |
| 41 canvas = NULL; | 41 canvas = NULL; |
| 42 } | 42 } |
| 43 return canvas; | 43 return canvas; |
| 44 } | 44 } |
| 45 | 45 |
| 46 SkDevice* GetTopDevice(const SkCanvas& canvas) { | 46 SkDevice* GetTopDevice(const SkCanvas& canvas) { |
| 47 return canvas.getTopDevice(true); | 47 return canvas.getTopDevice(true); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool SupportsPlatformPaint(const SkCanvas* canvas) { | 50 PlatformDevice::PlatformPaint PlatformPaintSupport(const SkCanvas* canvas) { |
| 51 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); | 51 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
| 52 return platform_device && platform_device->SupportsPlatformPaint(); | 52 if (!platform_device) |
| 53 return PlatformDevice::PLATFORM_PAINT_UNSUPPORTED; |
| 54 return platform_device->PlatformPaintSupport(); |
| 55 } |
| 56 |
| 57 bool IsPlatformPaintSupported(const SkCanvas* canvas) { |
| 58 return PlatformPaintSupport(canvas) != |
| 59 PlatformDevice::PLATFORM_PAINT_UNSUPPORTED; |
| 53 } | 60 } |
| 54 | 61 |
| 55 PlatformSurface BeginPlatformPaint(SkCanvas* canvas) { | 62 PlatformSurface BeginPlatformPaint(SkCanvas* canvas) { |
| 56 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); | 63 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
| 57 if (platform_device) | 64 if (platform_device) |
| 58 return platform_device->BeginPlatformPaint(); | 65 return platform_device->BeginPlatformPaint(); |
| 59 | 66 |
| 60 return 0; | 67 return 0; |
| 61 } | 68 } |
| 62 | 69 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 86 SkIntToScalar(width), SkIntToScalar(height)); | 93 SkIntToScalar(width), SkIntToScalar(height)); |
| 87 SkPaint paint; | 94 SkPaint paint; |
| 88 // so we don't draw anything on a device that ignores xfermodes | 95 // so we don't draw anything on a device that ignores xfermodes |
| 89 paint.setColor(0); | 96 paint.setColor(0); |
| 90 // install our custom mode | 97 // install our custom mode |
| 91 paint.setXfermode(new SkProcXfermode(MakeOpaqueXfermodeProc))->unref(); | 98 paint.setXfermode(new SkProcXfermode(MakeOpaqueXfermodeProc))->unref(); |
| 92 canvas->drawRect(rect, paint); | 99 canvas->drawRect(rect, paint); |
| 93 } | 100 } |
| 94 | 101 |
| 95 } // namespace skia | 102 } // namespace skia |
| OLD | NEW |