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 25 matching lines...) Expand all Loading... |
36 }; | 36 }; |
37 | 37 |
38 #if defined(WIN32) | 38 #if defined(WIN32) |
39 // The shared_section parameter is passed to gfx::PlatformDevice::create. | 39 // The shared_section parameter is passed to gfx::PlatformDevice::create. |
40 // See it for details. | 40 // See it for details. |
41 SK_API SkCanvas* CreatePlatformCanvas(int width, | 41 SK_API SkCanvas* CreatePlatformCanvas(int width, |
42 int height, | 42 int height, |
43 bool is_opaque, | 43 bool is_opaque, |
44 HANDLE shared_section, | 44 HANDLE shared_section, |
45 OnFailureType failure_type); | 45 OnFailureType failure_type); |
| 46 |
| 47 // Draws the top layer of the canvas into the specified HDC. Only works |
| 48 // with a PlatformCanvas with a BitmapPlatformDevice. |
| 49 SK_API void DrawToNativeContext(SkCanvas* canvas, |
| 50 HDC hdc, |
| 51 int x, |
| 52 int y, |
| 53 const RECT* src_rect); |
46 #elif defined(__APPLE__) | 54 #elif defined(__APPLE__) |
47 SK_API SkCanvas* CreatePlatformCanvas(CGContextRef context, | 55 SK_API SkCanvas* CreatePlatformCanvas(CGContextRef context, |
48 int width, | 56 int width, |
49 int height, | 57 int height, |
50 bool is_opaque, | 58 bool is_opaque, |
51 OnFailureType failure_type); | 59 OnFailureType failure_type); |
52 | 60 |
53 SK_API SkCanvas* CreatePlatformCanvas(int width, | 61 SK_API SkCanvas* CreatePlatformCanvas(int width, |
54 int height, | 62 int height, |
55 bool is_opaque, | 63 bool is_opaque, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // | 114 // |
107 // Danger: the resulting device should not be saved. It will be invalidated | 115 // Danger: the resulting device should not be saved. It will be invalidated |
108 // by the next call to save() or restore(). | 116 // by the next call to save() or restore(). |
109 SK_API SkBaseDevice* GetTopDevice(const SkCanvas& canvas); | 117 SK_API SkBaseDevice* GetTopDevice(const SkCanvas& canvas); |
110 | 118 |
111 // Returns true if native platform routines can be used to draw on the | 119 // Returns true if native platform routines can be used to draw on the |
112 // given canvas. If this function returns false, BeginPlatformPaint will | 120 // given canvas. If this function returns false, BeginPlatformPaint will |
113 // return NULL PlatformSurface. | 121 // return NULL PlatformSurface. |
114 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); | 122 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); |
115 | 123 |
116 // Draws into the a native platform surface, |context|. Forwards to | |
117 // DrawToNativeContext on a PlatformDevice instance bound to the top device. | |
118 // If no PlatformDevice instance is bound, is a no-operation. | |
119 SK_API void DrawToNativeContext(SkCanvas* canvas, | |
120 PlatformSurface context, | |
121 int x, | |
122 int y, | |
123 const PlatformRect* src_rect); | |
124 | |
125 // Sets the opacity of each pixel in the specified region to be opaque. | 124 // Sets the opacity of each pixel in the specified region to be opaque. |
126 SK_API void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height); | 125 SK_API void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height); |
127 | 126 |
128 // These calls should surround calls to platform drawing routines, the | 127 // These calls should surround calls to platform drawing routines, the |
129 // surface returned here can be used with the native platform routines. | 128 // surface returned here can be used with the native platform routines. |
130 // | 129 // |
131 // Call EndPlatformPaint when you are done and want to use skia operations | 130 // Call EndPlatformPaint when you are done and want to use skia operations |
132 // after calling the platform-specific BeginPlatformPaint; this will | 131 // after calling the platform-specific BeginPlatformPaint; this will |
133 // synchronize the bitmap to OS if necessary. | 132 // synchronize the bitmap to OS if necessary. |
134 SK_API PlatformSurface BeginPlatformPaint(SkCanvas* canvas); | 133 SK_API PlatformSurface BeginPlatformPaint(SkCanvas* canvas); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 SkBitmap bitmap_; | 178 SkBitmap bitmap_; |
180 PlatformSurface surface_; // initialized to 0 | 179 PlatformSurface surface_; // initialized to 0 |
181 intptr_t platform_extra_; // platform specific, initialized to 0 | 180 intptr_t platform_extra_; // platform specific, initialized to 0 |
182 | 181 |
183 DISALLOW_COPY_AND_ASSIGN(PlatformBitmap); | 182 DISALLOW_COPY_AND_ASSIGN(PlatformBitmap); |
184 }; | 183 }; |
185 | 184 |
186 } // namespace skia | 185 } // namespace skia |
187 | 186 |
188 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ | 187 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ |
OLD | NEW |