| 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" |
| 11 #include "skia/ext/platform_device.h" | 11 #include "skia/ext/platform_device.h" |
| 12 #include "skia/ext/refptr.h" |
| 12 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
| 13 | 14 |
| 14 namespace skia { | 15 namespace skia { |
| 15 | 16 |
| 16 typedef SkCanvas PlatformCanvas; | 17 typedef SkCanvas PlatformCanvas; |
| 17 | 18 |
| 18 // | 19 // |
| 19 // Note about error handling. | 20 // Note about error handling. |
| 20 // | 21 // |
| 21 // Creating a canvas can fail at times, most often because we fail to allocate | 22 // Creating a canvas can fail at times, most often because we fail to allocate |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 uint8_t* data, | 65 uint8_t* data, |
| 65 OnFailureType failure_type); | 66 OnFailureType failure_type); |
| 66 #endif | 67 #endif |
| 67 | 68 |
| 68 static inline SkCanvas* CreatePlatformCanvas(int width, | 69 static inline SkCanvas* CreatePlatformCanvas(int width, |
| 69 int height, | 70 int height, |
| 70 bool is_opaque) { | 71 bool is_opaque) { |
| 71 return CreatePlatformCanvas(width, height, is_opaque, 0, CRASH_ON_FAILURE); | 72 return CreatePlatformCanvas(width, height, is_opaque, 0, CRASH_ON_FAILURE); |
| 72 } | 73 } |
| 73 | 74 |
| 74 // Takes ownership of the device, so the caller need not call unref(). | 75 SK_API SkCanvas* CreateCanvas(const skia::RefPtr<SkDevice>& device, |
| 75 SK_API SkCanvas* CreateCanvas(SkDevice* device, OnFailureType failure_type); | 76 OnFailureType failure_type); |
| 76 | 77 |
| 77 static inline SkCanvas* CreateBitmapCanvas(int width, | 78 static inline SkCanvas* CreateBitmapCanvas(int width, |
| 78 int height, | 79 int height, |
| 79 bool is_opaque) { | 80 bool is_opaque) { |
| 80 return CreatePlatformCanvas(width, height, is_opaque, 0, CRASH_ON_FAILURE); | 81 return CreatePlatformCanvas(width, height, is_opaque, 0, CRASH_ON_FAILURE); |
| 81 } | 82 } |
| 82 | 83 |
| 83 static inline SkCanvas* TryCreateBitmapCanvas(int width, | 84 static inline SkCanvas* TryCreateBitmapCanvas(int width, |
| 84 int height, | 85 int height, |
| 85 bool is_opaque) { | 86 bool is_opaque) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 SkBitmap bitmap_; | 180 SkBitmap bitmap_; |
| 180 PlatformSurface surface_; // initialized to 0 | 181 PlatformSurface surface_; // initialized to 0 |
| 181 intptr_t platform_extra_; // initialized to 0, specific to each platform | 182 intptr_t platform_extra_; // initialized to 0, specific to each platform |
| 182 | 183 |
| 183 DISALLOW_COPY_AND_ASSIGN(PlatformBitmap); | 184 DISALLOW_COPY_AND_ASSIGN(PlatformBitmap); |
| 184 }; | 185 }; |
| 185 | 186 |
| 186 } // namespace skia | 187 } // namespace skia |
| 187 | 188 |
| 188 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ | 189 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ |
| OLD | NEW |