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" | 8 #include "base/memory/ptr_util.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "skia/ext/platform_device.h" | 10 #include "skia/ext/platform_device.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 void* pixels = canvas->accessTopLayerPixels(&info, &row_bytes); | 51 void* pixels = canvas->accessTopLayerPixels(&info, &row_bytes); |
52 if (!pixels) { | 52 if (!pixels) { |
53 result->reset(); | 53 result->reset(); |
54 return false; | 54 return false; |
55 } | 55 } |
56 | 56 |
57 result->reset(info, pixels, row_bytes); | 57 result->reset(info, pixels, row_bytes); |
58 return true; | 58 return true; |
59 } | 59 } |
60 | 60 |
61 bool SupportsPlatformPaint(const SkCanvas* canvas) { | |
62 return GetPlatformDevice(canvas->getTopDevice(true)) != nullptr; | |
63 } | |
64 | |
65 size_t PlatformCanvasStrideForWidth(unsigned width) { | 61 size_t PlatformCanvasStrideForWidth(unsigned width) { |
66 return 4 * width; | 62 return 4 * width; |
67 } | 63 } |
68 | 64 |
69 std::unique_ptr<SkCanvas> CreateCanvas(const sk_sp<SkBaseDevice>& device, | 65 std::unique_ptr<SkCanvas> CreateCanvas(const sk_sp<SkBaseDevice>& device, |
70 OnFailureType failureType) { | 66 OnFailureType failureType) { |
71 if (!device) { | 67 if (!device) { |
72 if (CRASH_ON_FAILURE == failureType) | 68 if (CRASH_ON_FAILURE == failureType) |
73 SK_CRASH(); | 69 SK_CRASH(); |
74 return nullptr; | 70 return nullptr; |
(...skipping 22 matching lines...) Expand all Loading... |
97 | 93 |
98 // Compensate for drawing to a layer rather than the entire canvas | 94 // Compensate for drawing to a layer rather than the entire canvas |
99 SkMatrix ctm; | 95 SkMatrix ctm; |
100 SkIRect clip_bounds; | 96 SkIRect clip_bounds; |
101 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); | 97 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); |
102 | 98 |
103 return platform_device->BeginPlatformPaint(ctm, clip_bounds); | 99 return platform_device->BeginPlatformPaint(ctm, clip_bounds); |
104 } | 100 } |
105 | 101 |
106 } // namespace skia | 102 } // namespace skia |
OLD | NEW |