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 #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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 PlatformSurface GetPlatformSurface() { return platform_surface_; } | 147 PlatformSurface GetPlatformSurface() { return platform_surface_; } |
148 private: | 148 private: |
149 SkCanvas* canvas_; | 149 SkCanvas* canvas_; |
150 PlatformSurface platform_surface_; | 150 PlatformSurface platform_surface_; |
151 | 151 |
152 // Disallow copy and assign | 152 // Disallow copy and assign |
153 ScopedPlatformPaint(const ScopedPlatformPaint&); | 153 ScopedPlatformPaint(const ScopedPlatformPaint&); |
154 ScopedPlatformPaint& operator=(const ScopedPlatformPaint&); | 154 ScopedPlatformPaint& operator=(const ScopedPlatformPaint&); |
155 }; | 155 }; |
156 | 156 |
157 // PlatformBitmap holds a PlatformSurface that can also be used as an SkBitmap. | |
158 class SK_API PlatformBitmap { | |
159 public: | |
160 PlatformBitmap(); | |
161 ~PlatformBitmap(); | |
162 | |
163 // Returns true if the bitmap was able to allocate its surface. | |
164 bool Allocate(int width, int height, bool is_opaque); | |
165 | |
166 // Returns the platform surface, or 0 if Allocate() did not return true. | |
167 PlatformSurface GetSurface() { return surface_; } | |
168 | |
169 // Return the skia bitmap, which will be empty if Allocate() did not | |
170 // return true. | |
171 // | |
172 // The resulting SkBitmap holds a refcount on the underlying platform surface, | |
173 // so the surface will remain allocated so long as the SkBitmap or its copies | |
174 // stay around. | |
175 const SkBitmap& GetBitmap() { return bitmap_; } | |
176 | |
177 private: | |
178 SkBitmap bitmap_; | |
179 PlatformSurface surface_; // initialized to 0 | |
180 intptr_t platform_extra_; // platform specific, initialized to 0 | |
181 | |
182 DISALLOW_COPY_AND_ASSIGN(PlatformBitmap); | |
183 }; | |
184 | |
185 } // namespace skia | 157 } // namespace skia |
186 | 158 |
187 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ | 159 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ |
OLD | NEW |