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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 OnFailureType failureType) { | 70 OnFailureType failureType) { |
71 if (!device) { | 71 if (!device) { |
72 if (CRASH_ON_FAILURE == failureType) | 72 if (CRASH_ON_FAILURE == failureType) |
73 SK_CRASH(); | 73 SK_CRASH(); |
74 return nullptr; | 74 return nullptr; |
75 } | 75 } |
76 return base::MakeUnique<SkCanvas>(device.get()); | 76 return base::MakeUnique<SkCanvas>(device.get()); |
77 } | 77 } |
78 | 78 |
79 SkMetaData& GetMetaData(const SkCanvas& canvas) { | 79 SkMetaData& GetMetaData(const SkCanvas& canvas) { |
80 SkBaseDevice* device = canvas.getDevice(); | 80 return const_cast<SkCanvas&>(canvas).getMetaData(); |
81 DCHECK(device != nullptr); | |
82 return device->getMetaData(); | |
83 } | 81 } |
84 | 82 |
85 #if defined(OS_MACOSX) | 83 #if defined(OS_MACOSX) |
86 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) { | 84 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) { |
87 SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); | 85 SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); |
88 } | 86 } |
89 | 87 |
90 bool IsPreviewMetafile(const SkCanvas& canvas) { | 88 bool IsPreviewMetafile(const SkCanvas& canvas) { |
91 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); | 89 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); |
92 } | 90 } |
(...skipping 19 matching lines...) Expand all Loading... |
112 if (platform_device) { | 110 if (platform_device) { |
113 // Compensate for drawing to a layer rather than the entire canvas | 111 // Compensate for drawing to a layer rather than the entire canvas |
114 SkMatrix ctm; | 112 SkMatrix ctm; |
115 SkIRect clip_bounds; | 113 SkIRect clip_bounds; |
116 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); | 114 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); |
117 native_drawing_context_ = platform_device->BeginPlatformPaint(ctm, clip_boun
ds); | 115 native_drawing_context_ = platform_device->BeginPlatformPaint(ctm, clip_boun
ds); |
118 } | 116 } |
119 } | 117 } |
120 | 118 |
121 } // namespace skia | 119 } // namespace skia |
OLD | NEW |