blob: aad5bf47376719dc2f46390e78227cffece95b6c [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2010 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00003 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00006 */
7
8#ifndef SkDevice_DEFINED
9#define SkDevice_DEFINED
10
11#include "SkRefCnt.h"
12#include "SkBitmap.h"
13#include "SkCanvas.h"
14#include "SkColor.h"
bungeman@google.com532470f2013-01-22 19:25:14 +000015#include "SkDeviceProperties.h"
senorblanco@chromium.org4cb543d2014-03-14 15:44:01 +000016#include "SkImageFilter.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000017
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
commit-bot@chromium.orgb8d00db2013-06-26 19:18:23 +000025class GrRenderTarget;
bsalomon@google.comd9f826c2011-07-18 15:25:04 +000026
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000027class SK_API SkBaseDevice : public SkRefCnt {
reed@android.com8a1c16f2008-12-17 15:59:43 +000028public:
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000029 SK_DECLARE_INST_COUNT(SkBaseDevice)
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000030
reed@google.comaf951c92011-06-16 19:10:39 +000031 /**
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000032 * Construct a new device.
reed@android.com8a1c16f2008-12-17 15:59:43 +000033 */
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000034 SkBaseDevice();
reed@google.comaf951c92011-06-16 19:10:39 +000035
36 /**
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000037 * Construct a new device.
bungeman@google.com532470f2013-01-22 19:25:14 +000038 */
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000039 SkBaseDevice(const SkDeviceProperties& deviceProperties);
bungeman@google.com532470f2013-01-22 19:25:14 +000040
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000041 virtual ~SkBaseDevice();
reed@android.com8a1c16f2008-12-17 15:59:43 +000042
commit-bot@chromium.org15a14052014-02-16 00:59:25 +000043 SkBaseDevice* createCompatibleDevice(const SkImageInfo&);
bsalomon@google.come97f0852011-06-17 13:10:25 +000044
bungeman@google.com88edf1e2011-08-08 19:41:56 +000045 SkMetaData& getMetaData();
46
bungeman@google.com532470f2013-01-22 19:25:14 +000047 /** Return the image properties of the device. */
48 virtual const SkDeviceProperties& getDeviceProperties() const {
49 //Currently, all the properties are leaky.
50 return fLeakyProperties;
51 }
52
reed@google.comd51bfa02011-08-30 15:56:11 +000053 /**
commit-bot@chromium.orgc3bd8af2014-02-13 17:14:46 +000054 * Return ImageInfo for this device. If the canvas is not backed by pixels
55 * (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType.
56 */
57 virtual SkImageInfo imageInfo() const;
58
59 /**
reed@google.comd51bfa02011-08-30 15:56:11 +000060 * Return the bounds of the device in the coordinate space of the root
61 * canvas. The root device will have its top-left at 0,0, but other devices
62 * such as those associated with saveLayer may have a non-zero origin.
63 */
reed@google.comec3ca872013-11-13 16:02:18 +000064 void getGlobalBounds(SkIRect* bounds) const {
65 SkASSERT(bounds);
66 const SkIPoint& origin = this->getOrigin();
67 bounds->setXYWH(origin.x(), origin.y(), this->width(), this->height());
68 }
skia.committer@gmail.com73a5d532013-11-14 07:02:31 +000069
reedf252f642014-06-14 04:24:56 -070070 int width() const {
71 return this->imageInfo().width();
72 }
reed620fc602014-07-07 13:51:48 -070073
reedf252f642014-06-14 04:24:56 -070074 int height() const {
75 return this->imageInfo().height();
76 }
reed620fc602014-07-07 13:51:48 -070077
reedf252f642014-06-14 04:24:56 -070078 bool isOpaque() const {
79 return this->imageInfo().isOpaque();
80 }
skia.committer@gmail.com772c4e62013-08-30 07:01:34 +000081
reed@android.com8a1c16f2008-12-17 15:59:43 +000082 /** Return the bitmap associated with this device. Call this each time you need
83 to access the bitmap, as it notifies the subclass to perform any flushing
84 etc. before you examine the pixels.
85 @param changePixels set to true if the caller plans to change the pixels
86 @return the device's bitmap
87 */
88 const SkBitmap& accessBitmap(bool changePixels);
89
commit-bot@chromium.org4ef54f82014-03-17 17:03:18 +000090 bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, int y);
reed@android.com8a1c16f2008-12-17 15:59:43 +000091
reed@google.com9c135db2014-03-12 18:28:35 +000092 void* accessPixels(SkImageInfo* info, size_t* rowBytes);
93
bsalomon@google.comd9f826c2011-07-18 15:25:04 +000094 /**
95 * Return the device's associated gpu render target, or NULL.
reed@android.comf2b98d62010-12-20 18:26:13 +000096 */
reed89443ab2014-06-27 11:34:19 -070097 virtual GrRenderTarget* accessRenderTarget() { return NULL; }
reed@android.comf2b98d62010-12-20 18:26:13 +000098
bungeman@google.com88edf1e2011-08-08 19:41:56 +000099
100 /**
101 * Return the device's origin: its offset in device coordinates from
102 * the default origin in its canvas' matrix/clip
103 */
104 const SkIPoint& getOrigin() const { return fOrigin; }
105
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000106 /**
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000107 * onAttachToCanvas is invoked whenever a device is installed in a canvas
108 * (i.e., setDevice, saveLayer (for the new device created by the save),
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000109 * and SkCanvas' SkBaseDevice & SkBitmap -taking ctors). It allows the
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000110 * devices to prepare for drawing (e.g., locking their pixels, etc.)
111 */
sugoi@google.come0e385c2013-03-11 18:50:03 +0000112 virtual void onAttachToCanvas(SkCanvas*) {
bsalomon@google.com405d0f42012-08-29 21:26:13 +0000113 SkASSERT(!fAttachedToCanvas);
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000114 this->lockPixels();
115#ifdef SK_DEBUG
116 fAttachedToCanvas = true;
117#endif
118 };
119
120 /**
121 * onDetachFromCanvas notifies a device that it will no longer be drawn to.
122 * It gives the device a chance to clean up (e.g., unlock its pixels). It
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000123 * is invoked from setDevice (for the displaced device), restore and
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000124 * possibly from SkCanvas' dtor.
125 */
126 virtual void onDetachFromCanvas() {
bsalomon@google.com405d0f42012-08-29 21:26:13 +0000127 SkASSERT(fAttachedToCanvas);
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000128 this->unlockPixels();
129#ifdef SK_DEBUG
130 fAttachedToCanvas = false;
131#endif
132 };
133
caryclark@google.comd53f7c22012-01-05 17:05:05 +0000134protected:
135 enum Usage {
136 kGeneral_Usage,
tomhudson@google.com1f902872012-06-01 13:15:47 +0000137 kSaveLayer_Usage // <! internal use only
caryclark@google.comd53f7c22012-01-05 17:05:05 +0000138 };
139
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000140 struct TextFlags {
141 uint32_t fFlags; // SkPaint::getFlags()
142 SkPaint::Hinting fHinting;
143 };
144
145 /**
146 * Device may filter the text flags for drawing text here. If it wants to
147 * make a change to the specified values, it should write them into the
148 * textflags parameter (output) and return true. If the paint is fine as
149 * is, then ignore the textflags parameter and return false.
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000150 */
reed89443ab2014-06-27 11:34:19 -0700151 virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) { return false; }
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000152
robertphillips@google.com3fffb2e2012-10-09 22:30:18 +0000153 /**
bsalomon@google.coma6926b12012-10-10 15:25:50 +0000154 *
155 * DEPRECATED: This will be removed in a future change. Device subclasses
156 * should use the matrix and clip from the SkDraw passed to draw functions.
157 *
robertphillips@google.com3fffb2e2012-10-09 22:30:18 +0000158 * Called with the correct matrix and clip before this device is drawn
159 * to using those settings. If your subclass overrides this, be sure to
160 * call through to the base class as well.
161 *
162 * The clipstack is another view of the clip. It records the actual
163 * geometry that went into building the region. It is present for devices
164 * that want to parse it, but is not required: the region is a complete
165 * picture of the current clip. (i.e. if you regionize all of the geometry
166 * in the clipstack, you will arrive at an equivalent region to the one
167 * passed in).
bsalomon@google.coma6926b12012-10-10 15:25:50 +0000168 */
169 virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000170 const SkClipStack&) {};
robertphillips@google.com3fffb2e2012-10-09 22:30:18 +0000171
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000172 /** Clears the entire device to the specified color (including alpha).
173 * Ignores the clip.
reed@android.comf2b98d62010-12-20 18:26:13 +0000174 */
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000175 virtual void clear(SkColor color) = 0;
reed@android.comf2b98d62010-12-20 18:26:13 +0000176
tfarina@chromium.org62f10482014-01-15 00:19:21 +0000177 SK_ATTR_DEPRECATED("use clear() instead")
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000178 void eraseColor(SkColor eraseColor) { this->clear(eraseColor); }
reed@android.com8a1c16f2008-12-17 15:59:43 +0000179
180 /** These are called inside the per-device-layer loop for each draw call.
181 When these are called, we have already applied any saveLayer operations,
182 and are handling any looping from the paint, and any effects from the
183 DrawFilter.
184 */
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000185 virtual void drawPaint(const SkDraw&, const SkPaint& paint) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000186 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000187 const SkPoint[], const SkPaint& paint) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000188 virtual void drawRect(const SkDraw&, const SkRect& r,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000189 const SkPaint& paint) = 0;
jvanverth@google.com46d3d392013-01-22 13:34:01 +0000190 virtual void drawOval(const SkDraw&, const SkRect& oval,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000191 const SkPaint& paint) = 0;
commit-bot@chromium.orgf2bfd542013-04-25 15:27:00 +0000192 virtual void drawRRect(const SkDraw&, const SkRRect& rr,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000193 const SkPaint& paint) = 0;
commit-bot@chromium.orgf2bfd542013-04-25 15:27:00 +0000194
commit-bot@chromium.orged9806f2014-02-21 02:32:36 +0000195 // Default impl calls drawPath()
196 virtual void drawDRRect(const SkDraw&, const SkRRect& outer,
197 const SkRRect& inner, const SkPaint&);
198
reed@google.com7ff8d812011-03-25 15:08:16 +0000199 /**
200 * If pathIsMutable, then the implementation is allowed to cast path to a
201 * non-const pointer and modify it in place (as an optimization). Canvas
202 * may do this to implement helpers such as drawOval, by placing a temp
203 * path on the stack to hold the representation of the oval.
204 *
205 * If prePathMatrix is not null, it should logically be applied before any
206 * stroking or other effects. If there are no effects on the paint that
207 * affect the geometry/rasterization, then the pre matrix can just be
208 * pre-concated with the current matrix.
209 */
reed@android.com8a1c16f2008-12-17 15:59:43 +0000210 virtual void drawPath(const SkDraw&, const SkPath& path,
reed@android.comf2b98d62010-12-20 18:26:13 +0000211 const SkPaint& paint,
212 const SkMatrix* prePathMatrix = NULL,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000213 bool pathIsMutable = false) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000214 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000215 const SkMatrix& matrix, const SkPaint& paint) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000216 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000217 int x, int y, const SkPaint& paint) = 0;
reed@google.com33535f32012-09-25 15:37:50 +0000218
219 /**
220 * The default impl. will create a bitmap-shader from the bitmap,
221 * and call drawRect with it.
222 */
223 virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
224 const SkRect* srcOrNull, const SkRect& dst,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000225 const SkPaint& paint,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000226 SkCanvas::DrawBitmapRectFlags flags) = 0;
reed@google.com33535f32012-09-25 15:37:50 +0000227
bungeman@google.com52c748b2011-08-22 21:30:43 +0000228 /**
229 * Does not handle text decoration.
230 * Decorations (underline and stike-thru) will be handled by SkCanvas.
231 */
reed@android.com8a1c16f2008-12-17 15:59:43 +0000232 virtual void drawText(const SkDraw&, const void* text, size_t len,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000233 SkScalar x, SkScalar y, const SkPaint& paint) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000234 virtual void drawPosText(const SkDraw&, const void* text, size_t len,
235 const SkScalar pos[], SkScalar constY,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000236 int scalarsPerPos, const SkPaint& paint) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000237 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
238 const SkPath& path, const SkMatrix* matrix,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000239 const SkPaint& paint) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000240 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
241 const SkPoint verts[], const SkPoint texs[],
242 const SkColor colors[], SkXfermode* xmode,
243 const uint16_t indices[], int indexCount,
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000244 const SkPaint& paint) = 0;
fmalitaaa1b9122014-08-28 14:32:24 -0700245 // default implementation unrolls the blob runs.
246 virtual void drawTextBlob(const SkDraw&, const SkTextBlob*, SkScalar x, SkScalar y,
247 const SkPaint& paint);
dandovecfff212014-08-04 10:02:00 -0700248 // default implementation calls drawVertices
dandovb3c9d1c2014-08-12 08:34:29 -0700249 virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColor colors[4],
250 const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
robertphillips@google.com9b051a32013-08-20 20:06:40 +0000251 /** The SkDevice passed will be an SkDevice which was returned by a call to
commit-bot@chromium.org15a14052014-02-16 00:59:25 +0000252 onCreateDevice on this device with kSaveLayer_Usage.
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000253 */
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000254 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
255 const SkPaint&) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000256
commit-bot@chromium.orga713f9c2014-03-17 21:31:26 +0000257 bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y);
bsalomon@google.com6850eab2011-11-03 20:29:47 +0000258
reed@google.com3636ed52011-01-25 23:50:57 +0000259 ///////////////////////////////////////////////////////////////////////////
260
junov@chromium.org1f9767c2012-02-07 16:27:57 +0000261 /** Update as needed the pixel value in the bitmap, so that the caller can
skia.committer@gmail.com772c4e62013-08-30 07:01:34 +0000262 access the pixels directly.
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000263 @return The device contents as a bitmap
reed@android.com8a1c16f2008-12-17 15:59:43 +0000264 */
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000265 virtual const SkBitmap& onAccessBitmap() = 0;
vandebo@chromium.org74b46192012-01-28 01:45:11 +0000266
robertphillips@google.com07f81a52013-09-17 12:26:23 +0000267 /** Called when this device is installed into a Canvas. Balanced by a call
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000268 to unlockPixels() when the device is removed from a Canvas.
269 */
reed89443ab2014-06-27 11:34:19 -0700270 virtual void lockPixels() {}
271 virtual void unlockPixels() {}
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000272
reed@google.com76dd2772012-01-05 21:15:07 +0000273 /**
reed@google.comb55deeb2012-01-06 14:43:09 +0000274 * Returns true if the device allows processing of this imagefilter. If
275 * false is returned, then the filter is ignored. This may happen for
276 * some subclasses that do not support pixel manipulations after drawing
277 * has occurred (e.g. printing). The default implementation returns true.
278 */
reed89443ab2014-06-27 11:34:19 -0700279 virtual bool allowImageFilter(const SkImageFilter*) { return true; }
reed@google.comb55deeb2012-01-06 14:43:09 +0000280
281 /**
reed@google.com8926b162012-03-23 15:36:36 +0000282 * Override and return true for filters that the device can handle
283 * intrinsically. Doing so means that SkCanvas will pass-through this
284 * filter to drawSprite and drawDevice (and potentially filterImage).
285 * Returning false means the SkCanvas will have apply the filter itself,
286 * and just pass the resulting image to the device.
reed@google.com76dd2772012-01-05 21:15:07 +0000287 */
reed89443ab2014-06-27 11:34:19 -0700288 virtual bool canHandleImageFilter(const SkImageFilter*) { return false; }
reed@google.com8926b162012-03-23 15:36:36 +0000289
290 /**
291 * Related (but not required) to canHandleImageFilter, this method returns
292 * true if the device could apply the filter to the src bitmap and return
293 * the result (and updates offset as needed).
294 * If the device does not recognize or support this filter,
295 * it just returns false and leaves result and offset unchanged.
296 */
senorblanco@chromium.org4cb543d2014-03-14 15:44:01 +0000297 virtual bool filterImage(const SkImageFilter*, const SkBitmap&,
298 const SkImageFilter::Context& ctx,
reed89443ab2014-06-27 11:34:19 -0700299 SkBitmap* result, SkIPoint* offset) {
300 return false;
301 }
robertphillips@google.com9b051a32013-08-20 20:06:40 +0000302
commit-bot@chromium.org8128d8c2013-12-19 16:12:25 +0000303protected:
reed@google.com76f10a32014-02-05 15:32:21 +0000304 // default impl returns NULL
305 virtual SkSurface* newSurface(const SkImageInfo&);
skia.committer@gmail.com02d6f542014-02-14 03:02:05 +0000306
commit-bot@chromium.orgc3bd8af2014-02-13 17:14:46 +0000307 // default impl returns NULL
308 virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes);
skia.committer@gmail.com02d6f542014-02-14 03:02:05 +0000309
commit-bot@chromium.org8128d8c2013-12-19 16:12:25 +0000310 /**
commit-bot@chromium.orga713f9c2014-03-17 21:31:26 +0000311 * The caller is responsible for "pre-clipping" the dst. The impl can assume that the dst
312 * image at the specified x,y offset will fit within the device's bounds.
313 *
314 * This is explicitly asserted in readPixels(), the public way to call this.
315 */
316 virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y);
commit-bot@chromium.org2cccf832014-03-12 03:04:08 +0000317
318 /**
commit-bot@chromium.org4cd9e212014-03-07 03:25:16 +0000319 * The caller is responsible for "pre-clipping" the src. The impl can assume that the src
320 * image at the specified x,y offset will fit within the device's bounds.
321 *
322 * This is explicitly asserted in writePixelsDirect(), the public way to call this.
323 */
324 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, int y);
325
326 /**
reed@google.com9c135db2014-03-12 18:28:35 +0000327 * Default impl returns NULL.
328 */
329 virtual void* onAccessPixels(SkImageInfo* info, size_t* rowBytes);
330
331 /**
commit-bot@chromium.org8128d8c2013-12-19 16:12:25 +0000332 * Leaky properties are those which the device should be applying but it isn't.
333 * These properties will be applied by the draw, when and as it can.
334 * If the device does handle a property, that property should be set to the identity value
335 * for that property, effectively making it non-leaky.
336 */
337 SkDeviceProperties fLeakyProperties;
338
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +0000339 /**
340 * PRIVATE / EXPERIMENTAL -- do not call
341 * Construct an acceleration object and attach it to 'picture'
342 */
robertphillips9b14f262014-06-04 05:40:44 -0700343 virtual void EXPERIMENTAL_optimize(const SkPicture* picture);
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +0000344
345 /**
346 * PRIVATE / EXPERIMENTAL -- do not call
347 * This entry point gives the backend an opportunity to take over the rendering
348 * of 'picture'. If optimization data is available (due to an earlier
349 * 'optimize' call) this entry point should make use of it and return true
350 * if all rendering has been done. If false is returned, SkCanvas will
skia.committer@gmail.comeb849e52014-03-17 03:02:17 +0000351 * perform its own rendering pass. It is acceptable for the backend
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +0000352 * to perform some device-specific warm up tasks and then let SkCanvas
353 * perform the main rendering loop (by return false from here).
354 */
reedd5fa1a42014-08-09 11:08:05 -0700355 virtual bool EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const SkMatrix*,
356 const SkPaint*);
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +0000357
reed@android.com8a1c16f2008-12-17 15:59:43 +0000358private:
reed@google.com6f8f2922011-03-04 22:27:10 +0000359 friend class SkCanvas;
robertphillips@google.com3fffb2e2012-10-09 22:30:18 +0000360 friend struct DeviceCM; //for setMatrixClip
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000361 friend class SkDraw;
362 friend class SkDrawIter;
363 friend class SkDeviceFilteredPaint;
senorblanco@chromium.org9c397442012-09-27 21:57:45 +0000364 friend class SkDeviceImageFilterProxy;
reed@google.com9c135db2014-03-12 18:28:35 +0000365 friend class SkDeferredDevice; // for newSurface
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000366
reed@google.com97af1a62012-08-28 12:19:02 +0000367 friend class SkSurface_Raster;
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000368
reed@google.com97af1a62012-08-28 12:19:02 +0000369 // used to change the backend's pixels (and possibly config/rowbytes)
370 // but cannot change the width/height, so there should be no change to
371 // any clip information.
reed@google.comec3ca872013-11-13 16:02:18 +0000372 // TODO: move to SkBitmapDevice
reed89443ab2014-06-27 11:34:19 -0700373 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) {}
robertphillips@google.com9b051a32013-08-20 20:06:40 +0000374
375 // just called by SkCanvas when built as a layer
376 void setOrigin(int x, int y) { fOrigin.set(x, y); }
377 // just called by SkCanvas for saveLayer
commit-bot@chromium.org15a14052014-02-16 00:59:25 +0000378 SkBaseDevice* createCompatibleDeviceForSaveLayer(const SkImageInfo&);
reed@google.com6f8f2922011-03-04 22:27:10 +0000379
commit-bot@chromium.org15a14052014-02-16 00:59:25 +0000380 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) {
381 return NULL;
382 }
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000383
384 /** Causes any deferred drawing to the device to be completed.
385 */
reed89443ab2014-06-27 11:34:19 -0700386 virtual void flush() {}
bungeman@google.com88edf1e2011-08-08 19:41:56 +0000387
senorblancobe129b22014-08-08 07:14:35 -0700388 virtual SkImageFilter::Cache* getImageFilterCache() { return NULL; }
senorblanco55b6d8b2014-07-30 11:26:46 -0700389
robertphillips@google.com9b051a32013-08-20 20:06:40 +0000390 SkIPoint fOrigin;
391 SkMetaData* fMetaData;
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +0000392
robertphillips@google.com9b051a32013-08-20 20:06:40 +0000393#ifdef SK_DEBUG
394 bool fAttachedToCanvas;
395#endif
396
397 typedef SkRefCnt INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000398};
399
reed@android.com8a1c16f2008-12-17 15:59:43 +0000400#endif