blob: 851a1679829daeb201c01d17a94e48ebff9508c2 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#ifndef SkDevice_DEFINED
11#define SkDevice_DEFINED
12
13#include "SkRefCnt.h"
14#include "SkBitmap.h"
15#include "SkCanvas.h"
16#include "SkColor.h"
17
reed@google.com46799cd2011-02-22 20:56:26 +000018class SkClipStack;
reed@android.com8a1c16f2008-12-17 15:59:43 +000019class SkDraw;
20struct SkIRect;
21class SkMatrix;
reed@google.coma7d94852011-03-30 21:23:07 +000022class SkMetaData;
reed@android.com8a1c16f2008-12-17 15:59:43 +000023class SkRegion;
24
bungeman@google.com88edf1e2011-08-08 19:41:56 +000025// This is an opaque class, not interpreted by skia
bsalomon@google.comd9f826c2011-07-18 15:25:04 +000026class SkGpuRenderTarget;
27
ctguil@chromium.org7ffb1b22011-03-15 21:27:08 +000028class SK_API SkDevice : public SkRefCnt {
reed@android.com8a1c16f2008-12-17 15:59:43 +000029public:
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000030 SK_DECLARE_INST_COUNT(SkDevice)
31
reed@google.comaf951c92011-06-16 19:10:39 +000032 /**
33 * Construct a new device with the specified bitmap as its backend. It is
34 * valid for the bitmap to have no pixels associated with it. In that case,
35 * any drawing to this device will have no effect.
reed@android.com8a1c16f2008-12-17 15:59:43 +000036 */
reed@google.comaf951c92011-06-16 19:10:39 +000037 SkDevice(const SkBitmap& bitmap);
38
39 /**
40 * Create a new raster device and have the pixels be automatically
41 * allocated. The rowBytes of the device will be computed automatically
42 * based on the config and the width.
43 *
44 * @param config The desired config for the pixels. If the request cannot
45 * be met, the closest matching support config will be used.
46 * @param width width (in pixels) of the device
47 * @param height height (in pixels) of the device
48 * @param isOpaque Set to true if it is known that all of the pixels will
49 * be drawn to opaquely. Used as an accelerator when drawing
50 * these pixels to another device.
51 */
52 SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque = false);
53
reed@google.coma7d94852011-03-30 21:23:07 +000054 virtual ~SkDevice();
reed@android.com8a1c16f2008-12-17 15:59:43 +000055
mike@reedtribe.orgea4ac972011-04-26 11:48:33 +000056 /**
reed@google.com2d54d062011-06-21 12:19:28 +000057 * Creates a device that is of the same type as this device (e.g. SW-raster,
58 * GPU, or PDF). The backing store for this device is created automatically
59 * (e.g. offscreen pixels or FBO or whatever is appropriate).
bsalomon@google.come97f0852011-06-17 13:10:25 +000060 *
reed@google.com2d54d062011-06-21 12:19:28 +000061 * @param width width of the device to create
62 * @param height height of the device to create
63 * @param isOpaque performance hint, set to true if you know that you will
64 * draw into this device such that all of the pixels will
65 * be opaque.
bsalomon@google.come97f0852011-06-17 13:10:25 +000066 */
vandebo@chromium.org74b46192012-01-28 01:45:11 +000067 SkDevice* createCompatibleDevice(SkBitmap::Config config,
bsalomon@google.come97f0852011-06-17 13:10:25 +000068 int width, int height,
69 bool isOpaque);
70
bungeman@google.com88edf1e2011-08-08 19:41:56 +000071 SkMetaData& getMetaData();
72
vandebo@chromium.org35fc62b2010-10-26 19:47:30 +000073 enum Capabilities {
74 kGL_Capability = 0x1, //!< mask indicating GL support
75 kVector_Capability = 0x2, //!< mask indicating a vector representation
76 kAll_Capabilities = 0x3
77 };
tomhudson@google.com8a0b0292011-09-13 14:41:06 +000078 virtual uint32_t getDeviceCapabilities() { return 0; }
vandebo@chromium.org35fc62b2010-10-26 19:47:30 +000079
reed@android.com8a1c16f2008-12-17 15:59:43 +000080 /** Return the width of the device (in pixels).
81 */
tomhudson@google.com8a0b0292011-09-13 14:41:06 +000082 virtual int width() const { return fBitmap.width(); }
reed@android.com8a1c16f2008-12-17 15:59:43 +000083 /** Return the height of the device (in pixels).
84 */
tomhudson@google.com8a0b0292011-09-13 14:41:06 +000085 virtual int height() const { return fBitmap.height(); }
reed@google.com6f8f2922011-03-04 22:27:10 +000086
reed@google.comd51bfa02011-08-30 15:56:11 +000087 /**
88 * Return the bounds of the device in the coordinate space of the root
89 * canvas. The root device will have its top-left at 0,0, but other devices
90 * such as those associated with saveLayer may have a non-zero origin.
91 */
92 void getGlobalBounds(SkIRect* bounds) const;
bungeman@google.com88edf1e2011-08-08 19:41:56 +000093
reed@android.com8a1c16f2008-12-17 15:59:43 +000094 /** Returns true if the device's bitmap's config treats every pixels as
95 implicitly opaque.
96 */
97 bool isOpaque() const { return fBitmap.isOpaque(); }
reed@google.com3dd42b32011-02-07 22:44:43 +000098
bungeman@google.com88edf1e2011-08-08 19:41:56 +000099 /** Return the bitmap config of the device's pixels
reed@android.com8a1c16f2008-12-17 15:59:43 +0000100 */
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000101 SkBitmap::Config config() const { return fBitmap.getConfig(); }
reed@android.com8a1c16f2008-12-17 15:59:43 +0000102
103 /** Return the bitmap associated with this device. Call this each time you need
104 to access the bitmap, as it notifies the subclass to perform any flushing
105 etc. before you examine the pixels.
106 @param changePixels set to true if the caller plans to change the pixels
107 @return the device's bitmap
108 */
109 const SkBitmap& accessBitmap(bool changePixels);
110
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000111 /**
bsalomon@google.comae0fb052011-11-10 22:34:56 +0000112 * DEPRECATED: This will be made protected once WebKit stops using it.
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000113 * Instead use Canvas' writePixels method.
bsalomon@google.comd58a1cd2011-11-10 20:57:43 +0000114 *
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000115 * Similar to draw sprite, this method will copy the pixels in bitmap onto
116 * the device, with the top/left corner specified by (x, y). The pixel
117 * values in the device are completely replaced: there is no blending.
bsalomon@google.comd58a1cd2011-11-10 20:57:43 +0000118 *
119 * Currently if bitmap is backed by a texture this is a no-op. This may be
120 * relaxed in the future.
121 *
122 * If the bitmap has config kARGB_8888_Config then the config8888 param
123 * will determines how the pixel valuess are intepreted. If the bitmap is
124 * not kARGB_8888_Config then this parameter is ignored.
bsalomon@google.com398109c2011-04-14 18:40:27 +0000125 */
bsalomon@google.comd58a1cd2011-11-10 20:57:43 +0000126 virtual void writePixels(const SkBitmap& bitmap, int x, int y,
bsalomon@google.comae0fb052011-11-10 22:34:56 +0000127 SkCanvas::Config8888 config8888 = SkCanvas::kNative_Premul_Config8888);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000128
bsalomon@google.comd9f826c2011-07-18 15:25:04 +0000129 /**
130 * Return the device's associated gpu render target, or NULL.
reed@android.comf2b98d62010-12-20 18:26:13 +0000131 */
bsalomon@google.comd9f826c2011-07-18 15:25:04 +0000132 virtual SkGpuRenderTarget* accessRenderTarget() { return NULL; }
reed@android.comf2b98d62010-12-20 18:26:13 +0000133
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000134
135 /**
136 * Return the device's origin: its offset in device coordinates from
137 * the default origin in its canvas' matrix/clip
138 */
139 const SkIPoint& getOrigin() const { return fOrigin; }
140
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000141 /**
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000142 * onAttachToCanvas is invoked whenever a device is installed in a canvas
143 * (i.e., setDevice, saveLayer (for the new device created by the save),
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000144 * and SkCanvas' SkDevice & SkBitmap -taking ctors). It allows the
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000145 * devices to prepare for drawing (e.g., locking their pixels, etc.)
146 */
147 virtual void onAttachToCanvas(SkCanvas* canvas) {
bsalomon@google.com405d0f42012-08-29 21:26:13 +0000148 SkASSERT(!fAttachedToCanvas);
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000149 this->lockPixels();
150#ifdef SK_DEBUG
151 fAttachedToCanvas = true;
152#endif
153 };
154
155 /**
156 * onDetachFromCanvas notifies a device that it will no longer be drawn to.
157 * It gives the device a chance to clean up (e.g., unlock its pixels). It
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000158 * is invoked from setDevice (for the displaced device), restore and
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000159 * possibly from SkCanvas' dtor.
160 */
161 virtual void onDetachFromCanvas() {
bsalomon@google.com405d0f42012-08-29 21:26:13 +0000162 SkASSERT(fAttachedToCanvas);
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000163 this->unlockPixels();
164#ifdef SK_DEBUG
165 fAttachedToCanvas = false;
166#endif
167 };
168
caryclark@google.comd53f7c22012-01-05 17:05:05 +0000169protected:
170 enum Usage {
171 kGeneral_Usage,
tomhudson@google.com1f902872012-06-01 13:15:47 +0000172 kSaveLayer_Usage // <! internal use only
caryclark@google.comd53f7c22012-01-05 17:05:05 +0000173 };
174
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000175 struct TextFlags {
176 uint32_t fFlags; // SkPaint::getFlags()
177 SkPaint::Hinting fHinting;
178 };
179
180 /**
181 * Device may filter the text flags for drawing text here. If it wants to
182 * make a change to the specified values, it should write them into the
183 * textflags parameter (output) and return true. If the paint is fine as
184 * is, then ignore the textflags parameter and return false.
185 *
186 * The baseclass SkDevice filters based on its depth and blitters.
187 */
188 virtual bool filterTextFlags(const SkPaint& paint, TextFlags*);
189
reed@google.com46799cd2011-02-22 20:56:26 +0000190 /**
tomhudson@google.com8a0b0292011-09-13 14:41:06 +0000191 * Called with the correct matrix and clip before this device is drawn
192 * to using those settings. If your subclass overrides this, be sure to
193 * call through to the base class as well.
194 *
195 * The clipstack is another view of the clip. It records the actual
196 * geometry that went into building the region. It is present for devices
197 * that want to parse it, but is not required: the region is a complete
198 * picture of the current clip. (i.e. if you regionize all of the geometry
199 * in the clipstack, you will arrive at an equivalent region to the one
200 * passed in).
201 */
202 virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
203 const SkClipStack&);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000204
205 /** Called when this device gains focus (i.e becomes the current device
206 for drawing).
207 */
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000208 virtual void gainFocus(const SkMatrix&, const SkRegion&) {
209 SkASSERT(fAttachedToCanvas);
210 }
reed@google.com3dd42b32011-02-07 22:44:43 +0000211
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000212 /** Clears the entire device to the specified color (including alpha).
213 * Ignores the clip.
reed@android.comf2b98d62010-12-20 18:26:13 +0000214 */
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000215 virtual void clear(SkColor color);
reed@android.comf2b98d62010-12-20 18:26:13 +0000216
217 /**
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000218 * Deprecated name for clear.
reed@android.comf2b98d62010-12-20 18:26:13 +0000219 */
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000220 void eraseColor(SkColor eraseColor) { this->clear(eraseColor); }
reed@android.com8a1c16f2008-12-17 15:59:43 +0000221
222 /** These are called inside the per-device-layer loop for each draw call.
223 When these are called, we have already applied any saveLayer operations,
224 and are handling any looping from the paint, and any effects from the
225 DrawFilter.
226 */
227 virtual void drawPaint(const SkDraw&, const SkPaint& paint);
228 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
229 const SkPoint[], const SkPaint& paint);
230 virtual void drawRect(const SkDraw&, const SkRect& r,
231 const SkPaint& paint);
reed@google.com7ff8d812011-03-25 15:08:16 +0000232 /**
233 * If pathIsMutable, then the implementation is allowed to cast path to a
234 * non-const pointer and modify it in place (as an optimization). Canvas
235 * may do this to implement helpers such as drawOval, by placing a temp
236 * path on the stack to hold the representation of the oval.
237 *
238 * If prePathMatrix is not null, it should logically be applied before any
239 * stroking or other effects. If there are no effects on the paint that
240 * affect the geometry/rasterization, then the pre matrix can just be
241 * pre-concated with the current matrix.
242 */
reed@android.com8a1c16f2008-12-17 15:59:43 +0000243 virtual void drawPath(const SkDraw&, const SkPath& path,
reed@android.comf2b98d62010-12-20 18:26:13 +0000244 const SkPaint& paint,
245 const SkMatrix* prePathMatrix = NULL,
246 bool pathIsMutable = false);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000247 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
reed@android.comf2b98d62010-12-20 18:26:13 +0000248 const SkIRect* srcRectOrNull,
reed@android.com8a1c16f2008-12-17 15:59:43 +0000249 const SkMatrix& matrix, const SkPaint& paint);
250 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
251 int x, int y, const SkPaint& paint);
reed@google.com33535f32012-09-25 15:37:50 +0000252
253 /**
254 * The default impl. will create a bitmap-shader from the bitmap,
255 * and call drawRect with it.
256 */
257 virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
258 const SkRect* srcOrNull, const SkRect& dst,
259 const SkPaint& paint);
260
bungeman@google.com52c748b2011-08-22 21:30:43 +0000261 /**
262 * Does not handle text decoration.
263 * Decorations (underline and stike-thru) will be handled by SkCanvas.
264 */
reed@android.com8a1c16f2008-12-17 15:59:43 +0000265 virtual void drawText(const SkDraw&, const void* text, size_t len,
266 SkScalar x, SkScalar y, const SkPaint& paint);
267 virtual void drawPosText(const SkDraw&, const void* text, size_t len,
268 const SkScalar pos[], SkScalar constY,
269 int scalarsPerPos, const SkPaint& paint);
270 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
271 const SkPath& path, const SkMatrix* matrix,
272 const SkPaint& paint);
djsollen@google.com56c69772011-11-08 19:00:26 +0000273#ifdef SK_BUILD_FOR_ANDROID
djsollen@google.comcd9d69b2011-03-14 20:30:14 +0000274 virtual void drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len,
275 const SkPoint pos[], const SkPaint& paint,
276 const SkPath& path, const SkMatrix* matrix);
277#endif
reed@android.com8a1c16f2008-12-17 15:59:43 +0000278 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
279 const SkPoint verts[], const SkPoint texs[],
280 const SkColor colors[], SkXfermode* xmode,
281 const uint16_t indices[], int indexCount,
282 const SkPaint& paint);
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000283 /** The SkDevice passed will be an SkDevice which was returned by a call to
284 onCreateCompatibleDevice on this device with kSaveLayer_Usage.
285 */
reed@android.com8a1c16f2008-12-17 15:59:43 +0000286 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
287 const SkPaint&);
288
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000289 /**
290 * On success (returns true), copy the device pixels into the bitmap.
291 * On failure, the bitmap parameter is left unchanged and false is
292 * returned.
293 *
294 * The device's pixels are converted to the bitmap's config. The only
295 * supported config is kARGB_8888_Config, though this is likely to be
296 * relaxed in the future. The meaning of config kARGB_8888_Config is
297 * modified by the enum param config8888. The default value interprets
298 * kARGB_8888_Config as SkPMColor
299 *
300 * If the bitmap has pixels already allocated, the device pixels will be
vandebo@chromium.org74b46192012-01-28 01:45:11 +0000301 * written there. If not, bitmap->allocPixels() will be called
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000302 * automatically. If the bitmap is backed by a texture readPixels will
303 * fail.
304 *
305 * The actual pixels written is the intersection of the device's bounds,
306 * and the rectangle formed by the bitmap's width,height and the specified
307 * x,y. If bitmap pixels extend outside of that intersection, they will not
308 * be modified.
309 *
310 * Other failure conditions:
311 * * If the device is not a raster device (e.g. PDF) then readPixels will
312 * fail.
313 * * If bitmap is texture-backed then readPixels will fail. (This may be
314 * relaxed in the future.)
315 */
316 bool readPixels(SkBitmap* bitmap,
317 int x, int y,
318 SkCanvas::Config8888 config8888);
319
reed@google.com3636ed52011-01-25 23:50:57 +0000320 ///////////////////////////////////////////////////////////////////////////
321
junov@chromium.org1f9767c2012-02-07 16:27:57 +0000322 /** Update as needed the pixel value in the bitmap, so that the caller can
323 access the pixels directly. Note: only the pixels field should be
324 altered. The config/width/height/rowbytes must remain unchanged.
325 @param bitmap The device's bitmap
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000326 @return Echo the bitmap parameter, or an alternate (shadow) bitmap
junov@chromium.org1f9767c2012-02-07 16:27:57 +0000327 maintained by the subclass.
reed@android.com8a1c16f2008-12-17 15:59:43 +0000328 */
junov@chromium.org1f9767c2012-02-07 16:27:57 +0000329 virtual const SkBitmap& onAccessBitmap(SkBitmap*);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000330
reed@android.comf2b98d62010-12-20 18:26:13 +0000331 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
332 // just for subclasses, to assign a custom pixelref
333 SkPixelRef* setPixelRef(SkPixelRef* pr, size_t offset) {
334 fBitmap.setPixelRef(pr, offset);
335 return pr;
336 }
vandebo@chromium.org74b46192012-01-28 01:45:11 +0000337
bsalomon@google.comc6980972011-11-02 19:57:21 +0000338 /**
339 * Implements readPixels API. The caller will ensure that:
340 * 1. bitmap has pixel config kARGB_8888_Config.
341 * 2. bitmap has pixels.
342 * 3. The rectangle (x, y, x + bitmap->width(), y + bitmap->height()) is
343 * contained in the device bounds.
bsalomon@google.comc6980972011-11-02 19:57:21 +0000344 */
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000345 virtual bool onReadPixels(const SkBitmap& bitmap,
346 int x, int y,
347 SkCanvas::Config8888 config8888);
reed@android.comf2b98d62010-12-20 18:26:13 +0000348
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000349 /** Called when this device is installed into a Canvas. Balanaced by a call
350 to unlockPixels() when the device is removed from a Canvas.
351 */
352 virtual void lockPixels();
353 virtual void unlockPixels();
354
reed@google.com76dd2772012-01-05 21:15:07 +0000355 /**
reed@google.comb55deeb2012-01-06 14:43:09 +0000356 * Returns true if the device allows processing of this imagefilter. If
357 * false is returned, then the filter is ignored. This may happen for
358 * some subclasses that do not support pixel manipulations after drawing
359 * has occurred (e.g. printing). The default implementation returns true.
360 */
361 virtual bool allowImageFilter(SkImageFilter*);
362
363 /**
reed@google.com8926b162012-03-23 15:36:36 +0000364 * Override and return true for filters that the device can handle
365 * intrinsically. Doing so means that SkCanvas will pass-through this
366 * filter to drawSprite and drawDevice (and potentially filterImage).
367 * Returning false means the SkCanvas will have apply the filter itself,
368 * and just pass the resulting image to the device.
reed@google.com76dd2772012-01-05 21:15:07 +0000369 */
reed@google.com8926b162012-03-23 15:36:36 +0000370 virtual bool canHandleImageFilter(SkImageFilter*);
371
372 /**
373 * Related (but not required) to canHandleImageFilter, this method returns
374 * true if the device could apply the filter to the src bitmap and return
375 * the result (and updates offset as needed).
376 * If the device does not recognize or support this filter,
377 * it just returns false and leaves result and offset unchanged.
378 */
379 virtual bool filterImage(SkImageFilter*, const SkBitmap&, const SkMatrix&,
reed@google.com76dd2772012-01-05 21:15:07 +0000380 SkBitmap* result, SkIPoint* offset);
381
vandebo@chromium.org74b46192012-01-28 01:45:11 +0000382 // This is equal kBGRA_Premul_Config8888 or kRGBA_Premul_Config8888 if
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000383 // either is identical to kNative_Premul_Config8888. Otherwise, -1.
384 static const SkCanvas::Config8888 kPMColorAlias;
385
reed@android.com8a1c16f2008-12-17 15:59:43 +0000386private:
reed@google.com6f8f2922011-03-04 22:27:10 +0000387 friend class SkCanvas;
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000388 friend struct DeviceCM; //for setMatrixClip
389 friend class SkDraw;
390 friend class SkDrawIter;
391 friend class SkDeviceFilteredPaint;
reed@google.com76dd2772012-01-05 21:15:07 +0000392 friend class DeviceImageFilterProxy;
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000393
reed@google.com97af1a62012-08-28 12:19:02 +0000394 friend class SkSurface_Raster;
395 // used to change the backend's pixels (and possibly config/rowbytes)
396 // but cannot change the width/height, so there should be no change to
397 // any clip information.
398 void replaceBitmapBackendForRasterSurface(const SkBitmap&);
399
vandebo@chromium.org5676b4a2011-10-03 19:03:48 +0000400 // just called by SkCanvas when built as a layer
401 void setOrigin(int x, int y) { fOrigin.set(x, y); }
bsalomon@google.come97f0852011-06-17 13:10:25 +0000402 // just called by SkCanvas for saveLayer
vandebo@chromium.org74b46192012-01-28 01:45:11 +0000403 SkDevice* createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
bsalomon@google.come97f0852011-06-17 13:10:25 +0000404 int width, int height,
405 bool isOpaque);
reed@google.com6f8f2922011-03-04 22:27:10 +0000406
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000407 /**
408 * Subclasses should override this to implement createCompatibleDevice.
409 */
vandebo@chromium.org74b46192012-01-28 01:45:11 +0000410 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config,
411 int width, int height,
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000412 bool isOpaque,
413 Usage usage);
414
415 /** Causes any deferred drawing to the device to be completed.
416 */
tomhudson@google.com8a0b0292011-09-13 14:41:06 +0000417 virtual void flush() {}
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000418
reed@google.com3636ed52011-01-25 23:50:57 +0000419 SkBitmap fBitmap;
reed@google.com6f8f2922011-03-04 22:27:10 +0000420 SkIPoint fOrigin;
reed@google.coma7d94852011-03-30 21:23:07 +0000421 SkMetaData* fMetaData;
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +0000422
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000423#ifdef SK_DEBUG
424 bool fAttachedToCanvas;
425#endif
426
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +0000427 typedef SkRefCnt INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000428};
429
430#endif