| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 #if defined(OS_MACOSX) | 83 #if defined(OS_MACOSX) |
| 84 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) { | 84 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) { |
| 85 SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); | 85 SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool IsPreviewMetafile(const SkCanvas& canvas) { | 88 bool IsPreviewMetafile(const SkCanvas& canvas) { |
| 89 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); | 89 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); |
| 90 } | 90 } |
| 91 | |
| 92 CGContextRef GetBitmapContext(const SkCanvas& canvas) { | |
| 93 PlatformDevice* platform_device = | |
| 94 GetPlatformDevice(canvas.getTopDevice(true)); | |
| 95 SkIRect clip_bounds; | |
| 96 canvas.getClipDeviceBounds(&clip_bounds); | |
| 97 return platform_device ? | |
| 98 platform_device->GetBitmapContext( | |
| 99 canvas.getTotalMatrix(), clip_bounds) : | |
| 100 nullptr; | |
| 101 } | |
| 102 | |
| 103 #endif | 91 #endif |
| 104 | 92 |
| 105 ScopedPlatformPaint::ScopedPlatformPaint(SkCanvas* canvas) : | 93 ScopedPlatformPaint::ScopedPlatformPaint(SkCanvas* canvas) : |
| 106 canvas_(canvas), | 94 canvas_(canvas), |
| 107 native_drawing_context_(nullptr) { | 95 native_drawing_context_(nullptr) { |
| 108 // TODO(tomhudson) we're assuming non-null canvas? | 96 // TODO(tomhudson) we're assuming non-null canvas? |
| 109 PlatformDevice* platform_device = GetPlatformDevice(canvas->getTopDevice(true)
); | 97 PlatformDevice* platform_device = GetPlatformDevice(canvas->getTopDevice(true)
); |
| 110 if (platform_device) { | 98 if (platform_device) { |
| 111 // Compensate for drawing to a layer rather than the entire canvas | 99 // Compensate for drawing to a layer rather than the entire canvas |
| 112 SkMatrix ctm; | 100 SkMatrix ctm; |
| 113 SkIRect clip_bounds; | 101 SkIRect clip_bounds; |
| 114 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); | 102 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); |
| 115 native_drawing_context_ = platform_device->BeginPlatformPaint(ctm, clip_boun
ds); | 103 native_drawing_context_ = platform_device->BeginPlatformPaint(ctm, clip_boun
ds); |
| 116 } | 104 } |
| 117 } | 105 } |
| 118 | 106 |
| 119 } // namespace skia | 107 } // namespace skia |
| OLD | NEW |