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

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

Issue 1839113002: Limit manual control of platform painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 "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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 result->reset(info, pixels, row_bytes); 60 result->reset(info, pixels, row_bytes);
61 return true; 61 return true;
62 } 62 }
63 63
64 bool SupportsPlatformPaint(const SkCanvas* canvas) { 64 bool SupportsPlatformPaint(const SkCanvas* canvas) {
65 return GetPlatformDevice(GetTopDevice(*canvas)) != nullptr; 65 return GetPlatformDevice(GetTopDevice(*canvas)) != nullptr;
66 } 66 }
67 67
68 PlatformSurface BeginPlatformPaint(SkCanvas* canvas) {
69 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
70 if (platform_device)
71 return platform_device->BeginPlatformPaint();
72
73 return 0;
74 }
75
76 void EndPlatformPaint(SkCanvas* canvas) {
77 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
78 if (platform_device)
79 platform_device->EndPlatformPaint();
80 }
81
82 size_t PlatformCanvasStrideForWidth(unsigned width) { 68 size_t PlatformCanvasStrideForWidth(unsigned width) {
83 return 4 * width; 69 return 4 * width;
84 } 70 }
85 71
86 SkCanvas* CreateCanvas(const skia::RefPtr<SkBaseDevice>& device, OnFailureType f ailureType) { 72 SkCanvas* CreateCanvas(const skia::RefPtr<SkBaseDevice>& device, OnFailureType f ailureType) {
87 if (!device) { 73 if (!device) {
88 if (CRASH_ON_FAILURE == failureType) 74 if (CRASH_ON_FAILURE == failureType)
89 SK_CRASH(); 75 SK_CRASH();
90 return nullptr; 76 return nullptr;
91 } 77 }
(...skipping 17 matching lines...) Expand all
109 95
110 CGContextRef GetBitmapContext(const SkCanvas& canvas) { 96 CGContextRef GetBitmapContext(const SkCanvas& canvas) {
111 SkBaseDevice* device = GetTopDevice(canvas); 97 SkBaseDevice* device = GetTopDevice(canvas);
112 PlatformDevice* platform_device = GetPlatformDevice(device); 98 PlatformDevice* platform_device = GetPlatformDevice(device);
113 return platform_device ? platform_device->GetBitmapContext() : 99 return platform_device ? platform_device->GetBitmapContext() :
114 nullptr; 100 nullptr;
115 } 101 }
116 102
117 #endif 103 #endif
118 104
105 ScopedPlatformPaint::ScopedPlatformPaint(SkCanvas* canvas) :
106 canvas_(canvas),
107 platform_surface_(nullptr) {
108 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
109 if (platform_device)
110 platform_surface_ = platform_device->BeginPlatformPaint();
111 }
112
113 ScopedPlatformPaint::~ScopedPlatformPaint() { }
114
115 PlatformSurface ScopedPlatformPaint::GetPlatformSurface() { return platform_surf ace_; }
116
117
119 118
120 } // namespace skia 119 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698