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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ptr_util.h" | |
9 #include "build/build_config.h" | 8 #include "build/build_config.h" |
10 #include "skia/ext/platform_device.h" | 9 #include "skia/ext/platform_device.h" |
11 #include "third_party/skia/include/core/SkMetaData.h" | 10 #include "third_party/skia/include/core/SkMetaData.h" |
12 #include "third_party/skia/include/core/SkTypes.h" | 11 #include "third_party/skia/include/core/SkTypes.h" |
13 | 12 |
14 namespace { | 13 namespace { |
15 | 14 |
16 #if defined(OS_MACOSX) | 15 #if defined(OS_MACOSX) |
17 const char kIsPreviewMetafileKey[] = "CrIsPreviewMetafile"; | 16 const char kIsPreviewMetafileKey[] = "CrIsPreviewMetafile"; |
18 | 17 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 58 } |
60 | 59 |
61 bool SupportsPlatformPaint(const SkCanvas* canvas) { | 60 bool SupportsPlatformPaint(const SkCanvas* canvas) { |
62 return GetPlatformDevice(canvas->getTopDevice(true)) != nullptr; | 61 return GetPlatformDevice(canvas->getTopDevice(true)) != nullptr; |
63 } | 62 } |
64 | 63 |
65 size_t PlatformCanvasStrideForWidth(unsigned width) { | 64 size_t PlatformCanvasStrideForWidth(unsigned width) { |
66 return 4 * width; | 65 return 4 * width; |
67 } | 66 } |
68 | 67 |
69 std::unique_ptr<SkCanvas> CreateCanvas(const sk_sp<SkBaseDevice>& device, | 68 SkCanvas* CreateCanvas(const sk_sp<SkBaseDevice>& device, |
70 OnFailureType failureType) { | 69 OnFailureType failureType) { |
71 if (!device) { | 70 if (!device) { |
72 if (CRASH_ON_FAILURE == failureType) | 71 if (CRASH_ON_FAILURE == failureType) |
73 SK_CRASH(); | 72 SK_CRASH(); |
74 return nullptr; | 73 return nullptr; |
75 } | 74 } |
76 return base::MakeUnique<SkCanvas>(device.get()); | 75 return new SkCanvas(device.get()); |
77 } | 76 } |
78 | 77 |
79 SkMetaData& GetMetaData(const SkCanvas& canvas) { | 78 SkMetaData& GetMetaData(const SkCanvas& canvas) { |
80 SkBaseDevice* device = canvas.getDevice(); | 79 SkBaseDevice* device = canvas.getDevice(); |
81 DCHECK(device != nullptr); | 80 DCHECK(device != nullptr); |
82 return device->getMetaData(); | 81 return device->getMetaData(); |
83 } | 82 } |
84 | 83 |
85 #if defined(OS_MACOSX) | 84 #if defined(OS_MACOSX) |
86 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) { | 85 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) { |
(...skipping 25 matching lines...) Expand all Loading... |
112 if (platform_device) { | 111 if (platform_device) { |
113 // Compensate for drawing to a layer rather than the entire canvas | 112 // Compensate for drawing to a layer rather than the entire canvas |
114 SkMatrix ctm; | 113 SkMatrix ctm; |
115 SkIRect clip_bounds; | 114 SkIRect clip_bounds; |
116 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); | 115 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); |
117 native_drawing_context_ = platform_device->BeginPlatformPaint(ctm, clip_boun
ds); | 116 native_drawing_context_ = platform_device->BeginPlatformPaint(ctm, clip_boun
ds); |
118 } | 117 } |
119 } | 118 } |
120 | 119 |
121 } // namespace skia | 120 } // namespace skia |
OLD | NEW |