OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef SkBitmapDevice_DEFINED | 9 #ifndef SkBitmapDevice_DEFINED |
10 #define SkBitmapDevice_DEFINED | 10 #define SkBitmapDevice_DEFINED |
(...skipping 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 SkBitmapDevice(const SkBitmap& bitmap); | 24 SkBitmapDevice(const SkBitmap& bitmap); |
25 | 25 |
26 /** | 26 /** |
27 * Construct a new device with the specified bitmap as its backend. It is | 27 * Construct a new device with the specified bitmap as its backend. It is |
28 * valid for the bitmap to have no pixels associated with it. In that case, | 28 * valid for the bitmap to have no pixels associated with it. In that case, |
29 * any drawing to this device will have no effect. | 29 * any drawing to this device will have no effect. |
30 */ | 30 */ |
31 SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& devicePrope
rties); | 31 SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& devicePrope
rties); |
32 | 32 |
| 33 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG |
33 /** | 34 /** |
34 * Create a new raster device and have the pixels be automatically | 35 * Create a new raster device and have the pixels be automatically |
35 * allocated. The rowBytes of the device will be computed automatically | 36 * allocated. The rowBytes of the device will be computed automatically |
36 * based on the config and the width. | 37 * based on the config and the width. |
37 * | 38 * |
38 * @param config The desired config for the pixels. If the request cannot | 39 * @param config The desired config for the pixels. If the request cannot |
39 * be met, the closest matching support config will be used
. | 40 * be met, the closest matching support config will be used
. |
40 * @param width width (in pixels) of the device | 41 * @param width width (in pixels) of the device |
41 * @param height height (in pixels) of the device | 42 * @param height height (in pixels) of the device |
42 * @param isOpaque Set to true if it is known that all of the pixels will | 43 * @param isOpaque Set to true if it is known that all of the pixels will |
(...skipping 11 matching lines...) Expand all Loading... |
54 * be met, the closest matching support config will be used
. | 55 * be met, the closest matching support config will be used
. |
55 * @param width width (in pixels) of the device | 56 * @param width width (in pixels) of the device |
56 * @param height height (in pixels) of the device | 57 * @param height height (in pixels) of the device |
57 * @param isOpaque Set to true if it is known that all of the pixels will | 58 * @param isOpaque Set to true if it is known that all of the pixels will |
58 * be drawn to opaquely. Used as an accelerator when drawin
g | 59 * be drawn to opaquely. Used as an accelerator when drawin
g |
59 * these pixels to another device. | 60 * these pixels to another device. |
60 * @param deviceProperties Properties which affect compositing. | 61 * @param deviceProperties Properties which affect compositing. |
61 */ | 62 */ |
62 SkBitmapDevice(SkBitmap::Config config, int width, int height, bool isOpaque
, | 63 SkBitmapDevice(SkBitmap::Config config, int width, int height, bool isOpaque
, |
63 const SkDeviceProperties& deviceProperties); | 64 const SkDeviceProperties& deviceProperties); |
64 | 65 #endif |
65 virtual ~SkBitmapDevice(); | 66 static SkBitmapDevice* Create(const SkImageInfo&, |
| 67 const SkDeviceProperties* = NULL); |
66 | 68 |
67 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE { return 0; } | 69 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE { return 0; } |
68 | 70 |
69 /** Return the width of the device (in pixels). | 71 /** Return the width of the device (in pixels). |
70 */ | 72 */ |
71 virtual int width() const SK_OVERRIDE { return fBitmap.width(); } | 73 virtual int width() const SK_OVERRIDE { return fBitmap.width(); } |
72 /** Return the height of the device (in pixels). | 74 /** Return the height of the device (in pixels). |
73 */ | 75 */ |
74 virtual int height() const SK_OVERRIDE { return fBitmap.height(); } | 76 virtual int height() const SK_OVERRIDE { return fBitmap.height(); } |
75 | 77 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 int scalarsPerPos, const SkPaint& paint) SK_OVERRID
E; | 180 int scalarsPerPos, const SkPaint& paint) SK_OVERRID
E; |
179 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, | 181 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, |
180 const SkPath& path, const SkMatrix* matrix, | 182 const SkPath& path, const SkMatrix* matrix, |
181 const SkPaint& paint) SK_OVERRIDE; | 183 const SkPaint& paint) SK_OVERRIDE; |
182 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCou
nt, | 184 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCou
nt, |
183 const SkPoint verts[], const SkPoint texs[], | 185 const SkPoint verts[], const SkPoint texs[], |
184 const SkColor colors[], SkXfermode* xmode, | 186 const SkColor colors[], SkXfermode* xmode, |
185 const uint16_t indices[], int indexCount, | 187 const uint16_t indices[], int indexCount, |
186 const SkPaint& paint) SK_OVERRIDE; | 188 const SkPaint& paint) SK_OVERRIDE; |
187 /** The SkBaseDevice passed will be an SkBaseDevice which was returned by a
call to | 189 /** The SkBaseDevice passed will be an SkBaseDevice which was returned by a
call to |
188 onCreateCompatibleDevice on this device with kSaveLayer_Usage. | 190 onCreateDevice on this device with kSaveLayer_Usage. |
189 */ | 191 */ |
190 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 192 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
191 const SkPaint&) SK_OVERRIDE; | 193 const SkPaint&) SK_OVERRIDE; |
192 | 194 |
193 /////////////////////////////////////////////////////////////////////////// | 195 /////////////////////////////////////////////////////////////////////////// |
194 | 196 |
195 /** Update as needed the pixel value in the bitmap, so that the caller can | 197 /** Update as needed the pixel value in the bitmap, so that the caller can |
196 access the pixels directly. Note: only the pixels field should be | 198 access the pixels directly. Note: only the pixels field should be |
197 altered. The config/width/height/rowbytes must remain unchanged. | 199 altered. The config/width/height/rowbytes must remain unchanged. |
198 @return the device contents as a bitmap | 200 @return the device contents as a bitmap |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 private: | 255 private: |
254 friend class SkCanvas; | 256 friend class SkCanvas; |
255 friend struct DeviceCM; //for setMatrixClip | 257 friend struct DeviceCM; //for setMatrixClip |
256 friend class SkDraw; | 258 friend class SkDraw; |
257 friend class SkDrawIter; | 259 friend class SkDrawIter; |
258 friend class SkDeviceFilteredPaint; | 260 friend class SkDeviceFilteredPaint; |
259 friend class SkDeviceImageFilterProxy; | 261 friend class SkDeviceImageFilterProxy; |
260 | 262 |
261 friend class SkSurface_Raster; | 263 friend class SkSurface_Raster; |
262 | 264 |
263 void init(SkBitmap::Config config, int width, int height, bool isOpaque); | |
264 | |
265 // used to change the backend's pixels (and possibly config/rowbytes) | 265 // used to change the backend's pixels (and possibly config/rowbytes) |
266 // but cannot change the width/height, so there should be no change to | 266 // but cannot change the width/height, so there should be no change to |
267 // any clip information. | 267 // any clip information. |
268 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRI
DE; | 268 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRI
DE; |
269 | 269 |
270 /** | 270 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG |
271 * Subclasses should override this to implement createCompatibleDevice. | 271 // in support of legacy constructors |
272 */ | 272 void init(SkBitmap::Config config, int width, int height, bool isOpaque); |
273 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, | 273 #endif |
274 int width, int height, | 274 |
275 bool isOpaque, | 275 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; |
276 Usage usage) SK_OVERRIDE; | |
277 | 276 |
278 /** Causes any deferred drawing to the device to be completed. | 277 /** Causes any deferred drawing to the device to be completed. |
279 */ | 278 */ |
280 virtual void flush() SK_OVERRIDE {} | 279 virtual void flush() SK_OVERRIDE {} |
281 | 280 |
282 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; | 281 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; |
283 virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes) SK_OVERRIDE; | 282 virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes) SK_OVERRIDE; |
284 | 283 |
285 SkBitmap fBitmap; | 284 SkBitmap fBitmap; |
286 | 285 |
287 typedef SkBaseDevice INHERITED; | 286 typedef SkBaseDevice INHERITED; |
288 }; | 287 }; |
289 | 288 |
290 #endif // SkBitmapDevice_DEFINED | 289 #endif // SkBitmapDevice_DEFINED |
OLD | NEW |