| 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 30 matching lines...) Expand all Loading... |
| 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 bool SupportsPlatformPaint(const SkCanvas* canvas) { |
| 51 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
| 52 return platform_device && platform_device->IsNativeRenderingAllowed(); |
| 53 } |
| 54 |
| 55 bool SupportsDirectPlatformPaint(const SkCanvas* canvas) { |
| 51 // TODO(alokp): Rename IsNativeFontRenderingAllowed after removing these | 56 // TODO(alokp): Rename IsNativeFontRenderingAllowed after removing these |
| 52 // calls from WebKit. | 57 // calls from WebKit. |
| 53 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); | 58 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
| 54 return platform_device && platform_device->IsNativeFontRenderingAllowed(); | 59 return platform_device && platform_device->IsNativeFontRenderingAllowed(); |
| 55 } | 60 } |
| 56 | 61 |
| 57 PlatformSurface BeginPlatformPaint(SkCanvas* canvas) { | 62 PlatformSurface BeginPlatformPaint(SkCanvas* canvas) { |
| 58 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); | 63 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
| 59 if (platform_device) | 64 if (platform_device) |
| 60 return platform_device->BeginPlatformPaint(); | 65 return platform_device->BeginPlatformPaint(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 88 SkIntToScalar(width), SkIntToScalar(height)); | 93 SkIntToScalar(width), SkIntToScalar(height)); |
| 89 SkPaint paint; | 94 SkPaint paint; |
| 90 // 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 |
| 91 paint.setColor(0); | 96 paint.setColor(0); |
| 92 // install our custom mode | 97 // install our custom mode |
| 93 paint.setXfermode(new SkProcXfermode(MakeOpaqueXfermodeProc))->unref(); | 98 paint.setXfermode(new SkProcXfermode(MakeOpaqueXfermodeProc))->unref(); |
| 94 canvas->drawRect(rect, paint); | 99 canvas->drawRect(rect, paint); |
| 95 } | 100 } |
| 96 | 101 |
| 97 } // namespace skia | 102 } // namespace skia |
| OLD | NEW |