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 { |
11 | 11 |
12 SkDevice* GetTopDevice(const SkCanvas& canvas) { | 12 SkBaseDevice* GetTopDevice(const SkCanvas& canvas) { |
13 return canvas.getTopDevice(true); | 13 return canvas.getTopDevice(true); |
14 } | 14 } |
15 | 15 |
16 bool SupportsPlatformPaint(const SkCanvas* canvas) { | 16 bool SupportsPlatformPaint(const SkCanvas* canvas) { |
17 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); | 17 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
18 return platform_device && platform_device->SupportsPlatformPaint(); | 18 return platform_device && platform_device->SupportsPlatformPaint(); |
19 } | 19 } |
20 | 20 |
21 PlatformSurface BeginPlatformPaint(SkCanvas* canvas) { | 21 PlatformSurface BeginPlatformPaint(SkCanvas* canvas) { |
22 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); | 22 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 skia::RefPtr<SkProcXfermode> xfermode = | 57 skia::RefPtr<SkProcXfermode> xfermode = |
58 skia::AdoptRef(new SkProcXfermode(MakeOpaqueXfermodeProc)); | 58 skia::AdoptRef(new SkProcXfermode(MakeOpaqueXfermodeProc)); |
59 paint.setXfermode(xfermode.get()); | 59 paint.setXfermode(xfermode.get()); |
60 canvas->drawRect(rect, paint); | 60 canvas->drawRect(rect, paint); |
61 } | 61 } |
62 | 62 |
63 size_t PlatformCanvasStrideForWidth(unsigned width) { | 63 size_t PlatformCanvasStrideForWidth(unsigned width) { |
64 return 4 * width; | 64 return 4 * width; |
65 } | 65 } |
66 | 66 |
67 SkCanvas* CreateCanvas(const skia::RefPtr<SkDevice>& device, OnFailureType failu
reType) { | 67 SkCanvas* CreateCanvas(const skia::RefPtr<SkBaseDevice>& device, OnFailureType f
ailureType) { |
68 if (!device) { | 68 if (!device) { |
69 if (CRASH_ON_FAILURE == failureType) | 69 if (CRASH_ON_FAILURE == failureType) |
70 SK_CRASH(); | 70 SK_CRASH(); |
71 return NULL; | 71 return NULL; |
72 } | 72 } |
73 return new SkCanvas(device.get()); | 73 return new SkCanvas(device.get()); |
74 } | 74 } |
75 | 75 |
76 PlatformBitmap::PlatformBitmap() : surface_(0), platform_extra_(0) {} | 76 PlatformBitmap::PlatformBitmap() : surface_(0), platform_extra_(0) {} |
77 | 77 |
78 } // namespace skia | 78 } // namespace skia |
OLD | NEW |