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 #pragma once | 7 #pragma once |
8 | 8 |
9 // The platform-specific device will include the necessary platform headers | 9 // The platform-specific device will include the necessary platform headers |
10 // to get the surface type. | 10 // to get the surface type. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL); | 56 bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL); |
57 | 57 |
58 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ | 58 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ |
59 defined(__Solaris__) | 59 defined(__Solaris__) |
60 // For two-part init, call if you use the no-argument constructor above | 60 // For two-part init, call if you use the no-argument constructor above |
61 bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL); | 61 bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL); |
62 #endif | 62 #endif |
63 | 63 |
64 // Shared -------------------------------------------------------------------- | 64 // Shared -------------------------------------------------------------------- |
65 | 65 |
66 // These calls should surround calls to platform drawing routines, the | 66 // Returns the SkDevice pointer of the topmost rect with a non-empty |
67 // surface returned here can be used with the native platform routines | |
68 // | |
69 // Call endPlatformPaint when you are done and want to use Skia operations | |
70 // after calling the platform-specific beginPlatformPaint; this will | |
71 // synchronize the bitmap to OS if necessary. | |
72 PlatformDevice::PlatformSurface beginPlatformPaint() const; | |
73 void endPlatformPaint() const; | |
74 | |
75 // Returns the platform device pointer of the topmost rect with a non-empty | |
76 // clip. In practice, this is usually either the top layer or nothing, since | 67 // clip. In practice, this is usually either the top layer or nothing, since |
77 // we usually set the clip to new layers when we make them. | 68 // we usually set the clip to new layers when we make them. |
78 // | 69 // |
79 // If there is no layer that is not all clipped out, this will return a | 70 // If there is no layer that is not all clipped out, this will return a |
80 // dummy device so callers do not have to check. If you are concerned about | 71 // dummy device so callers do not have to check. If you are concerned about |
81 // performance, check the clip before doing any painting. | 72 // performance, check the clip before doing any painting. |
82 // | 73 // |
83 // This is different than SkCanvas' getDevice, because that returns the | 74 // This is different than SkCanvas' getDevice, because that returns the |
84 // bottommost device. | 75 // bottommost device. |
85 // | 76 // |
86 // Danger: the resulting device should not be saved. It will be invalidated | 77 // Danger: the resulting device should not be saved. It will be invalidated |
87 // by the next call to save() or restore(). | 78 // by the next call to save() or restore(). |
88 PlatformDevice& getTopPlatformDevice() const; | 79 SkDevice& getTopDevice() const; |
89 | 80 |
90 // Return the stride (length of a line in bytes) for the given width. Because | 81 // Return the stride (length of a line in bytes) for the given width. Because |
91 // we use 32-bits per pixel, this will be roughly 4*width. However, for | 82 // we use 32-bits per pixel, this will be roughly 4*width. However, for |
92 // alignment reasons we may wish to increase that. | 83 // alignment reasons we may wish to increase that. |
93 static size_t StrideForWidth(unsigned width); | 84 static size_t StrideForWidth(unsigned width); |
94 | 85 |
95 // Allow callers to see the non-virtual function even though we have an | 86 // Allow callers to see the non-virtual function even though we have an |
96 // override of a virtual one. | 87 // override of a virtual one. |
97 // FIXME(brettw) is this necessary? | 88 // FIXME(brettw) is this necessary? |
98 using SkCanvas::clipRect; | 89 using SkCanvas::clipRect; |
(...skipping 24 matching lines...) Expand all Loading... | |
123 // given canvas. If this function returns false, BeginPlatformPaint will | 114 // given canvas. If this function returns false, BeginPlatformPaint will |
124 // return NULL PlatformSurface. | 115 // return NULL PlatformSurface. |
125 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); | 116 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); |
126 | 117 |
127 // These calls should surround calls to platform drawing routines, the | 118 // These calls should surround calls to platform drawing routines, the |
128 // surface returned here can be used with the native platform routines. | 119 // surface returned here can be used with the native platform routines. |
129 // | 120 // |
130 // Call EndPlatformPaint when you are done and want to use skia operations | 121 // Call EndPlatformPaint when you are done and want to use skia operations |
131 // after calling the platform-specific BeginPlatformPaint; this will | 122 // after calling the platform-specific BeginPlatformPaint; this will |
132 // synchronize the bitmap to OS if necessary. | 123 // synchronize the bitmap to OS if necessary. |
133 // | 124 SK_API skia::PlatformSurface BeginPlatformPaint( |
alokp
2011/05/19 18:15:15
nit: the whole line can fit in 80 chars.
Jeff Timanus
2011/05/19 20:38:29
Done.
| |
134 // Note: These functions will eventually replace | 125 SkCanvas* canvas); |
135 // PlatformCanvas::beginPlatformPaint and PlatformCanvas::endPlatformPaint. | |
136 SK_API PlatformDevice::PlatformSurface BeginPlatformPaint(SkCanvas* canvas); | |
137 SK_API void EndPlatformPaint(SkCanvas* canvas); | 126 SK_API void EndPlatformPaint(SkCanvas* canvas); |
138 | 127 |
128 SK_API void DrawToNativeContext(SkCanvas* canvas, PlatformSurface context, | |
129 int x, int y, const PlatformRect* src_rect); | |
130 | |
139 } // namespace skia | 131 } // namespace skia |
140 | 132 |
141 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ | 133 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ |
OLD | NEW |