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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 if (width <= 0 || height <= 0) | 47 if (width <= 0 || height <= 0) |
48 return; | 48 return; |
49 | 49 |
50 SkRect rect; | 50 SkRect rect; |
51 rect.setXYWH(SkIntToScalar(x), SkIntToScalar(y), | 51 rect.setXYWH(SkIntToScalar(x), SkIntToScalar(y), |
52 SkIntToScalar(width), SkIntToScalar(height)); | 52 SkIntToScalar(width), SkIntToScalar(height)); |
53 SkPaint paint; | 53 SkPaint paint; |
54 // so we don't draw anything on a device that ignores xfermodes | 54 // so we don't draw anything on a device that ignores xfermodes |
55 paint.setColor(0); | 55 paint.setColor(0); |
56 // install our custom mode | 56 // install our custom mode |
57 paint.setXfermode(new SkProcXfermode(MakeOpaqueXfermodeProc))->unref(); | 57 skia::RefPtr<SkProcXfermode> xfermode = |
| 58 skia::AdoptRef(new SkProcXfermode(MakeOpaqueXfermodeProc)); |
| 59 paint.setXfermode(xfermode.get()); |
58 canvas->drawRect(rect, paint); | 60 canvas->drawRect(rect, paint); |
59 } | 61 } |
60 | 62 |
61 size_t PlatformCanvasStrideForWidth(unsigned width) { | 63 size_t PlatformCanvasStrideForWidth(unsigned width) { |
62 return 4 * width; | 64 return 4 * width; |
63 } | 65 } |
64 | 66 |
65 SkCanvas* CreateCanvas(SkDevice* device, OnFailureType failureType) { | 67 SkCanvas* CreateCanvas(const skia::RefPtr<SkDevice>& device, OnFailureType failu
reType) { |
66 if (!device) { | 68 if (!device) { |
67 if (CRASH_ON_FAILURE == failureType) | 69 if (CRASH_ON_FAILURE == failureType) |
68 SK_CRASH(); | 70 SK_CRASH(); |
69 return NULL; | 71 return NULL; |
70 } | 72 } |
71 SkAutoUnref aur(device); | 73 return new SkCanvas(device.get()); |
72 return new SkCanvas(device); | |
73 } | 74 } |
74 | 75 |
75 PlatformBitmap::PlatformBitmap() : surface_(0), platform_extra_(0) {} | 76 PlatformBitmap::PlatformBitmap() : surface_(0), platform_extra_(0) {} |
76 | 77 |
77 } // namespace skia | 78 } // namespace skia |
OLD | NEW |