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

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

Issue 22796028: Updating Chromium to Skia SkBaseDevice/SkBitmapDevice split (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODOs Created 7 years, 3 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
« no previous file with comments | « skia/ext/lazy_pixel_ref_utils.cc ('k') | skia/ext/platform_canvas.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef SKIA_EXT_PLATFORM_CANVAS_H_ 5 #ifndef SKIA_EXT_PLATFORM_CANVAS_H_
6 #define SKIA_EXT_PLATFORM_CANVAS_H_ 6 #define SKIA_EXT_PLATFORM_CANVAS_H_
7 7
8 // The platform-specific device will include the necessary platform headers 8 // The platform-specific device will include the necessary platform headers
9 // to get the surface type. 9 // to get the surface type.
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 uint8_t* data, 67 uint8_t* data,
68 OnFailureType failure_type); 68 OnFailureType failure_type);
69 #endif 69 #endif
70 70
71 static inline SkCanvas* CreatePlatformCanvas(int width, 71 static inline SkCanvas* CreatePlatformCanvas(int width,
72 int height, 72 int height,
73 bool is_opaque) { 73 bool is_opaque) {
74 return CreatePlatformCanvas(width, height, is_opaque, 0, CRASH_ON_FAILURE); 74 return CreatePlatformCanvas(width, height, is_opaque, 0, CRASH_ON_FAILURE);
75 } 75 }
76 76
77 SK_API SkCanvas* CreateCanvas(const skia::RefPtr<SkDevice>& device, 77 SK_API SkCanvas* CreateCanvas(const skia::RefPtr<SkBaseDevice>& device,
78 OnFailureType failure_type); 78 OnFailureType failure_type);
79 79
80 static inline SkCanvas* CreateBitmapCanvas(int width, 80 static inline SkCanvas* CreateBitmapCanvas(int width,
81 int height, 81 int height,
82 bool is_opaque) { 82 bool is_opaque) {
83 return CreatePlatformCanvas(width, height, is_opaque, 0, CRASH_ON_FAILURE); 83 return CreatePlatformCanvas(width, height, is_opaque, 0, CRASH_ON_FAILURE);
84 } 84 }
85 85
86 static inline SkCanvas* TryCreateBitmapCanvas(int width, 86 static inline SkCanvas* TryCreateBitmapCanvas(int width,
87 int height, 87 int height,
88 bool is_opaque) { 88 bool is_opaque) {
89 return CreatePlatformCanvas(width, height, is_opaque, 0, 89 return CreatePlatformCanvas(width, height, is_opaque, 0,
90 RETURN_NULL_ON_FAILURE); 90 RETURN_NULL_ON_FAILURE);
91 } 91 }
92 92
93 // Return the stride (length of a line in bytes) for the given width. Because 93 // Return the stride (length of a line in bytes) for the given width. Because
94 // we use 32-bits per pixel, this will be roughly 4*width. However, for 94 // we use 32-bits per pixel, this will be roughly 4*width. However, for
95 // alignment reasons we may wish to increase that. 95 // alignment reasons we may wish to increase that.
96 SK_API size_t PlatformCanvasStrideForWidth(unsigned width); 96 SK_API size_t PlatformCanvasStrideForWidth(unsigned width);
97 97
98 // Returns the SkDevice pointer of the topmost rect with a non-empty 98 // Returns the SkBaseDevice pointer of the topmost rect with a non-empty
99 // clip. In practice, this is usually either the top layer or nothing, since 99 // clip. In practice, this is usually either the top layer or nothing, since
100 // we usually set the clip to new layers when we make them. 100 // we usually set the clip to new layers when we make them.
101 // 101 //
102 // This may return NULL, so callers need to check. 102 // This may return NULL, so callers need to check.
103 // 103 //
104 // This is different than SkCanvas' getDevice, because that returns the 104 // This is different than SkCanvas' getDevice, because that returns the
105 // bottommost device. 105 // bottommost device.
106 // 106 //
107 // Danger: the resulting device should not be saved. It will be invalidated 107 // Danger: the resulting device should not be saved. It will be invalidated
108 // by the next call to save() or restore(). 108 // by the next call to save() or restore().
109 SK_API SkDevice* GetTopDevice(const SkCanvas& canvas); 109 SK_API SkBaseDevice* GetTopDevice(const SkCanvas& canvas);
110 110
111 // Returns true if native platform routines can be used to draw on the 111 // Returns true if native platform routines can be used to draw on the
112 // given canvas. If this function returns false, BeginPlatformPaint will 112 // given canvas. If this function returns false, BeginPlatformPaint will
113 // return NULL PlatformSurface. 113 // return NULL PlatformSurface.
114 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); 114 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas);
115 115
116 // Draws into the a native platform surface, |context|. Forwards to 116 // Draws into the a native platform surface, |context|. Forwards to
117 // DrawToNativeContext on a PlatformDevice instance bound to the top device. 117 // DrawToNativeContext on a PlatformDevice instance bound to the top device.
118 // If no PlatformDevice instance is bound, is a no-operation. 118 // If no PlatformDevice instance is bound, is a no-operation.
119 SK_API void DrawToNativeContext(SkCanvas* canvas, 119 SK_API void DrawToNativeContext(SkCanvas* canvas,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 SkBitmap bitmap_; 179 SkBitmap bitmap_;
180 PlatformSurface surface_; // initialized to 0 180 PlatformSurface surface_; // initialized to 0
181 intptr_t platform_extra_; // platform specific, initialized to 0 181 intptr_t platform_extra_; // platform specific, initialized to 0
182 182
183 DISALLOW_COPY_AND_ASSIGN(PlatformBitmap); 183 DISALLOW_COPY_AND_ASSIGN(PlatformBitmap);
184 }; 184 };
185 185
186 } // namespace skia 186 } // namespace skia
187 187
188 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ 188 #endif // SKIA_EXT_PLATFORM_CANVAS_H_
OLDNEW
« no previous file with comments | « skia/ext/lazy_pixel_ref_utils.cc ('k') | skia/ext/platform_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698