| 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 "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "skia/ext/platform_device.h" | 9 #include "skia/ext/platform_device.h" |
| 10 #include "third_party/skia/include/core/SkMetaData.h" | 10 #include "third_party/skia/include/core/SkMetaData.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); | 90 SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool IsPreviewMetafile(const SkCanvas& canvas) { | 93 bool IsPreviewMetafile(const SkCanvas& canvas) { |
| 94 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); | 94 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); |
| 95 } | 95 } |
| 96 | 96 |
| 97 CGContextRef GetBitmapContext(const SkCanvas& canvas) { | 97 CGContextRef GetBitmapContext(const SkCanvas& canvas) { |
| 98 SkBaseDevice* device = GetTopDevice(canvas); | 98 SkBaseDevice* device = GetTopDevice(canvas); |
| 99 PlatformDevice* platform_device = GetPlatformDevice(device); | 99 PlatformDevice* platform_device = GetPlatformDevice(device); |
| 100 return platform_device ? platform_device->GetBitmapContext() : | 100 SkIRect clip_bounds; |
| 101 canvas.getClipDeviceBounds(&clip_bounds); |
| 102 return platform_device ? |
| 103 platform_device->GetBitmapContext( |
| 104 canvas.getTotalMatrix(), clip_bounds) : |
| 101 nullptr; | 105 nullptr; |
| 102 } | 106 } |
| 103 | 107 |
| 104 #endif | 108 #endif |
| 105 | 109 |
| 106 ScopedPlatformPaint::ScopedPlatformPaint(SkCanvas* canvas) : | 110 ScopedPlatformPaint::ScopedPlatformPaint(SkCanvas* canvas) : |
| 107 canvas_(canvas), | 111 canvas_(canvas), |
| 108 platform_surface_(nullptr) { | 112 platform_surface_(nullptr) { |
| 113 // TODO(tomhudson) we're assuming non-null canvas? |
| 109 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); | 114 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
| 110 if (platform_device) | 115 if (platform_device) { |
| 111 platform_surface_ = platform_device->BeginPlatformPaint(); | 116 // Compensate for drawing to a layer rather than the entire canvas |
| 117 SkMatrix ctm; |
| 118 SkIRect clip_bounds; |
| 119 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); |
| 120 platform_surface_ = platform_device->BeginPlatformPaint(ctm, clip_bounds); |
| 121 } |
| 112 } | 122 } |
| 113 | 123 |
| 114 } // namespace skia | 124 } // namespace skia |
| OLD | NEW |