Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: skia/ext/platform_canvas.cc

Issue 2476113002: Change call-sites now that SkCanvas is not ref-counted (Closed)
Patch Set: try fixing win again Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "build/build_config.h" 9 #include "build/build_config.h"
9 #include "skia/ext/platform_device.h" 10 #include "skia/ext/platform_device.h"
10 #include "third_party/skia/include/core/SkMetaData.h" 11 #include "third_party/skia/include/core/SkMetaData.h"
11 #include "third_party/skia/include/core/SkTypes.h" 12 #include "third_party/skia/include/core/SkTypes.h"
12 13
13 namespace { 14 namespace {
14 15
15 #if defined(OS_MACOSX) 16 #if defined(OS_MACOSX)
16 const char kIsPreviewMetafileKey[] = "CrIsPreviewMetafile"; 17 const char kIsPreviewMetafileKey[] = "CrIsPreviewMetafile";
17 18
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 59 }
59 60
60 bool SupportsPlatformPaint(const SkCanvas* canvas) { 61 bool SupportsPlatformPaint(const SkCanvas* canvas) {
61 return GetPlatformDevice(canvas->getTopDevice(true)) != nullptr; 62 return GetPlatformDevice(canvas->getTopDevice(true)) != nullptr;
62 } 63 }
63 64
64 size_t PlatformCanvasStrideForWidth(unsigned width) { 65 size_t PlatformCanvasStrideForWidth(unsigned width) {
65 return 4 * width; 66 return 4 * width;
66 } 67 }
67 68
68 SkCanvas* CreateCanvas(const sk_sp<SkBaseDevice>& device, 69 std::unique_ptr<SkCanvas> CreateCanvas(const sk_sp<SkBaseDevice>& device,
69 OnFailureType failureType) { 70 OnFailureType failureType) {
70 if (!device) { 71 if (!device) {
71 if (CRASH_ON_FAILURE == failureType) 72 if (CRASH_ON_FAILURE == failureType)
72 SK_CRASH(); 73 SK_CRASH();
73 return nullptr; 74 return nullptr;
74 } 75 }
75 return new SkCanvas(device.get()); 76 return base::MakeUnique<SkCanvas>(device.get());
76 } 77 }
77 78
78 SkMetaData& GetMetaData(const SkCanvas& canvas) { 79 SkMetaData& GetMetaData(const SkCanvas& canvas) {
79 SkBaseDevice* device = canvas.getDevice(); 80 SkBaseDevice* device = canvas.getDevice();
80 DCHECK(device != nullptr); 81 DCHECK(device != nullptr);
81 return device->getMetaData(); 82 return device->getMetaData();
82 } 83 }
83 84
84 #if defined(OS_MACOSX) 85 #if defined(OS_MACOSX)
85 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) { 86 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) {
(...skipping 25 matching lines...) Expand all
111 if (platform_device) { 112 if (platform_device) {
112 // Compensate for drawing to a layer rather than the entire canvas 113 // Compensate for drawing to a layer rather than the entire canvas
113 SkMatrix ctm; 114 SkMatrix ctm;
114 SkIRect clip_bounds; 115 SkIRect clip_bounds;
115 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds); 116 canvas->temporary_internal_describeTopLayer(&ctm, &clip_bounds);
116 native_drawing_context_ = platform_device->BeginPlatformPaint(ctm, clip_boun ds); 117 native_drawing_context_ = platform_device->BeginPlatformPaint(ctm, clip_boun ds);
117 } 118 }
118 } 119 }
119 120
120 } // namespace skia 121 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698