2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2010 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#ifndef SkDevice_DEFINED
|
|
|
|
#define SkDevice_DEFINED
|
|
|
|
|
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkColor.h"
|
|
|
|
|
2011-02-22 20:56:26 +00:00
|
|
|
class SkClipStack;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkDraw;
|
|
|
|
struct SkIRect;
|
|
|
|
class SkMatrix;
|
2011-03-30 21:23:07 +00:00
|
|
|
class SkMetaData;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkRegion;
|
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
// This is an opaque class, not interpreted by skia
|
2011-07-18 15:25:04 +00:00
|
|
|
class SkGpuRenderTarget;
|
|
|
|
|
2011-03-15 21:27:08 +00:00
|
|
|
class SK_API SkDevice : public SkRefCnt {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2012-06-21 20:25:03 +00:00
|
|
|
SK_DECLARE_INST_COUNT(SkDevice)
|
|
|
|
|
2011-06-16 19:10:39 +00:00
|
|
|
/**
|
|
|
|
* Construct a new device with the specified bitmap as its backend. It is
|
|
|
|
* valid for the bitmap to have no pixels associated with it. In that case,
|
|
|
|
* any drawing to this device will have no effect.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2011-06-16 19:10:39 +00:00
|
|
|
SkDevice(const SkBitmap& bitmap);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new raster device and have the pixels be automatically
|
|
|
|
* allocated. The rowBytes of the device will be computed automatically
|
|
|
|
* based on the config and the width.
|
|
|
|
*
|
|
|
|
* @param config The desired config for the pixels. If the request cannot
|
|
|
|
* be met, the closest matching support config will be used.
|
|
|
|
* @param width width (in pixels) of the device
|
|
|
|
* @param height height (in pixels) of the device
|
|
|
|
* @param isOpaque Set to true if it is known that all of the pixels will
|
|
|
|
* be drawn to opaquely. Used as an accelerator when drawing
|
|
|
|
* these pixels to another device.
|
|
|
|
*/
|
|
|
|
SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque = false);
|
|
|
|
|
2011-03-30 21:23:07 +00:00
|
|
|
virtual ~SkDevice();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-06-17 13:10:25 +00:00
|
|
|
/**
|
2011-06-21 12:19:28 +00:00
|
|
|
* Creates a device that is of the same type as this device (e.g. SW-raster,
|
|
|
|
* GPU, or PDF). The backing store for this device is created automatically
|
|
|
|
* (e.g. offscreen pixels or FBO or whatever is appropriate).
|
2011-06-17 13:10:25 +00:00
|
|
|
*
|
2011-06-21 12:19:28 +00:00
|
|
|
* @param width width of the device to create
|
|
|
|
* @param height height of the device to create
|
|
|
|
* @param isOpaque performance hint, set to true if you know that you will
|
|
|
|
* draw into this device such that all of the pixels will
|
|
|
|
* be opaque.
|
2011-06-17 13:10:25 +00:00
|
|
|
*/
|
2012-01-28 01:45:11 +00:00
|
|
|
SkDevice* createCompatibleDevice(SkBitmap::Config config,
|
2011-06-17 13:10:25 +00:00
|
|
|
int width, int height,
|
|
|
|
bool isOpaque);
|
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
SkMetaData& getMetaData();
|
|
|
|
|
2010-10-26 19:47:30 +00:00
|
|
|
enum Capabilities {
|
|
|
|
kGL_Capability = 0x1, //!< mask indicating GL support
|
|
|
|
kVector_Capability = 0x2, //!< mask indicating a vector representation
|
|
|
|
kAll_Capabilities = 0x3
|
|
|
|
};
|
2011-09-13 14:41:06 +00:00
|
|
|
virtual uint32_t getDeviceCapabilities() { return 0; }
|
2010-10-26 19:47:30 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Return the width of the device (in pixels).
|
|
|
|
*/
|
2011-09-13 14:41:06 +00:00
|
|
|
virtual int width() const { return fBitmap.width(); }
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Return the height of the device (in pixels).
|
|
|
|
*/
|
2011-09-13 14:41:06 +00:00
|
|
|
virtual int height() const { return fBitmap.height(); }
|
2011-03-04 22:27:10 +00:00
|
|
|
|
2011-08-30 15:56:11 +00:00
|
|
|
/**
|
|
|
|
* Return the bounds of the device in the coordinate space of the root
|
|
|
|
* canvas. The root device will have its top-left at 0,0, but other devices
|
|
|
|
* such as those associated with saveLayer may have a non-zero origin.
|
|
|
|
*/
|
|
|
|
void getGlobalBounds(SkIRect* bounds) const;
|
2011-08-08 19:41:56 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Returns true if the device's bitmap's config treats every pixels as
|
|
|
|
implicitly opaque.
|
|
|
|
*/
|
|
|
|
bool isOpaque() const { return fBitmap.isOpaque(); }
|
2011-02-07 22:44:43 +00:00
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
/** Return the bitmap config of the device's pixels
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2011-08-08 19:41:56 +00:00
|
|
|
SkBitmap::Config config() const { return fBitmap.getConfig(); }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Return the bitmap associated with this device. Call this each time you need
|
|
|
|
to access the bitmap, as it notifies the subclass to perform any flushing
|
|
|
|
etc. before you examine the pixels.
|
|
|
|
@param changePixels set to true if the caller plans to change the pixels
|
|
|
|
@return the device's bitmap
|
|
|
|
*/
|
|
|
|
const SkBitmap& accessBitmap(bool changePixels);
|
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
/**
|
2011-11-10 22:34:56 +00:00
|
|
|
* DEPRECATED: This will be made protected once WebKit stops using it.
|
2011-11-03 20:29:47 +00:00
|
|
|
* Instead use Canvas' writePixels method.
|
2011-11-10 20:57:43 +00:00
|
|
|
*
|
2011-08-08 19:41:56 +00:00
|
|
|
* Similar to draw sprite, this method will copy the pixels in bitmap onto
|
|
|
|
* the device, with the top/left corner specified by (x, y). The pixel
|
|
|
|
* values in the device are completely replaced: there is no blending.
|
2011-11-10 20:57:43 +00:00
|
|
|
*
|
|
|
|
* Currently if bitmap is backed by a texture this is a no-op. This may be
|
|
|
|
* relaxed in the future.
|
|
|
|
*
|
|
|
|
* If the bitmap has config kARGB_8888_Config then the config8888 param
|
|
|
|
* will determines how the pixel valuess are intepreted. If the bitmap is
|
|
|
|
* not kARGB_8888_Config then this parameter is ignored.
|
2011-04-14 18:40:27 +00:00
|
|
|
*/
|
2011-11-10 20:57:43 +00:00
|
|
|
virtual void writePixels(const SkBitmap& bitmap, int x, int y,
|
2011-11-10 22:34:56 +00:00
|
|
|
SkCanvas::Config8888 config8888 = SkCanvas::kNative_Premul_Config8888);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-07-18 15:25:04 +00:00
|
|
|
/**
|
|
|
|
* Return the device's associated gpu render target, or NULL.
|
2010-12-20 18:26:13 +00:00
|
|
|
*/
|
2011-07-18 15:25:04 +00:00
|
|
|
virtual SkGpuRenderTarget* accessRenderTarget() { return NULL; }
|
2010-12-20 18:26:13 +00:00
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the device's origin: its offset in device coordinates from
|
|
|
|
* the default origin in its canvas' matrix/clip
|
|
|
|
*/
|
|
|
|
const SkIPoint& getOrigin() const { return fOrigin; }
|
|
|
|
|
2012-01-05 17:05:05 +00:00
|
|
|
protected:
|
|
|
|
enum Usage {
|
|
|
|
kGeneral_Usage,
|
2012-06-01 13:15:47 +00:00
|
|
|
kSaveLayer_Usage // <! internal use only
|
2012-01-05 17:05:05 +00:00
|
|
|
};
|
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
struct TextFlags {
|
|
|
|
uint32_t fFlags; // SkPaint::getFlags()
|
|
|
|
SkPaint::Hinting fHinting;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Device may filter the text flags for drawing text here. If it wants to
|
|
|
|
* make a change to the specified values, it should write them into the
|
|
|
|
* textflags parameter (output) and return true. If the paint is fine as
|
|
|
|
* is, then ignore the textflags parameter and return false.
|
|
|
|
*
|
|
|
|
* The baseclass SkDevice filters based on its depth and blitters.
|
|
|
|
*/
|
|
|
|
virtual bool filterTextFlags(const SkPaint& paint, TextFlags*);
|
|
|
|
|
2011-02-22 20:56:26 +00:00
|
|
|
/**
|
2011-09-13 14:41:06 +00:00
|
|
|
* Called with the correct matrix and clip before this device is drawn
|
|
|
|
* to using those settings. If your subclass overrides this, be sure to
|
|
|
|
* call through to the base class as well.
|
|
|
|
*
|
|
|
|
* The clipstack is another view of the clip. It records the actual
|
|
|
|
* geometry that went into building the region. It is present for devices
|
|
|
|
* that want to parse it, but is not required: the region is a complete
|
|
|
|
* picture of the current clip. (i.e. if you regionize all of the geometry
|
|
|
|
* in the clipstack, you will arrive at an equivalent region to the one
|
|
|
|
* passed in).
|
|
|
|
*/
|
|
|
|
virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
|
|
|
|
const SkClipStack&);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Called when this device gains focus (i.e becomes the current device
|
|
|
|
for drawing).
|
|
|
|
*/
|
2011-03-03 13:54:13 +00:00
|
|
|
virtual void gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&,
|
2011-09-13 14:41:06 +00:00
|
|
|
const SkClipStack&) {}
|
2011-02-07 22:44:43 +00:00
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
/** Clears the entire device to the specified color (including alpha).
|
|
|
|
* Ignores the clip.
|
2010-12-20 18:26:13 +00:00
|
|
|
*/
|
2011-08-08 19:41:56 +00:00
|
|
|
virtual void clear(SkColor color);
|
2010-12-20 18:26:13 +00:00
|
|
|
|
|
|
|
/**
|
2011-08-08 19:41:56 +00:00
|
|
|
* Deprecated name for clear.
|
2010-12-20 18:26:13 +00:00
|
|
|
*/
|
2011-08-08 19:41:56 +00:00
|
|
|
void eraseColor(SkColor eraseColor) { this->clear(eraseColor); }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** These are called inside the per-device-layer loop for each draw call.
|
|
|
|
When these are called, we have already applied any saveLayer operations,
|
|
|
|
and are handling any looping from the paint, and any effects from the
|
|
|
|
DrawFilter.
|
|
|
|
*/
|
|
|
|
virtual void drawPaint(const SkDraw&, const SkPaint& paint);
|
|
|
|
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
|
|
|
|
const SkPoint[], const SkPaint& paint);
|
|
|
|
virtual void drawRect(const SkDraw&, const SkRect& r,
|
|
|
|
const SkPaint& paint);
|
2011-03-25 15:08:16 +00:00
|
|
|
/**
|
|
|
|
* If pathIsMutable, then the implementation is allowed to cast path to a
|
|
|
|
* non-const pointer and modify it in place (as an optimization). Canvas
|
|
|
|
* may do this to implement helpers such as drawOval, by placing a temp
|
|
|
|
* path on the stack to hold the representation of the oval.
|
|
|
|
*
|
|
|
|
* If prePathMatrix is not null, it should logically be applied before any
|
|
|
|
* stroking or other effects. If there are no effects on the paint that
|
|
|
|
* affect the geometry/rasterization, then the pre matrix can just be
|
|
|
|
* pre-concated with the current matrix.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawPath(const SkDraw&, const SkPath& path,
|
2010-12-20 18:26:13 +00:00
|
|
|
const SkPaint& paint,
|
|
|
|
const SkMatrix* prePathMatrix = NULL,
|
|
|
|
bool pathIsMutable = false);
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
|
2010-12-20 18:26:13 +00:00
|
|
|
const SkIRect* srcRectOrNull,
|
2008-12-17 15:59:43 +00:00
|
|
|
const SkMatrix& matrix, const SkPaint& paint);
|
|
|
|
virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
|
|
|
|
int x, int y, const SkPaint& paint);
|
2011-08-22 21:30:43 +00:00
|
|
|
/**
|
|
|
|
* Does not handle text decoration.
|
|
|
|
* Decorations (underline and stike-thru) will be handled by SkCanvas.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawText(const SkDraw&, const void* text, size_t len,
|
|
|
|
SkScalar x, SkScalar y, const SkPaint& paint);
|
|
|
|
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
|
|
|
|
const SkScalar pos[], SkScalar constY,
|
|
|
|
int scalarsPerPos, const SkPaint& paint);
|
|
|
|
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
|
|
|
|
const SkPath& path, const SkMatrix* matrix,
|
|
|
|
const SkPaint& paint);
|
2011-11-08 19:00:26 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID
|
2011-03-14 20:30:14 +00:00
|
|
|
virtual void drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len,
|
|
|
|
const SkPoint pos[], const SkPaint& paint,
|
|
|
|
const SkPath& path, const SkMatrix* matrix);
|
|
|
|
#endif
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
|
|
|
|
const SkPoint verts[], const SkPoint texs[],
|
|
|
|
const SkColor colors[], SkXfermode* xmode,
|
|
|
|
const uint16_t indices[], int indexCount,
|
|
|
|
const SkPaint& paint);
|
2011-08-08 19:41:56 +00:00
|
|
|
/** The SkDevice passed will be an SkDevice which was returned by a call to
|
|
|
|
onCreateCompatibleDevice on this device with kSaveLayer_Usage.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
|
|
|
|
const SkPaint&);
|
|
|
|
|
2011-11-03 20:29:47 +00:00
|
|
|
/**
|
|
|
|
* On success (returns true), copy the device pixels into the bitmap.
|
|
|
|
* On failure, the bitmap parameter is left unchanged and false is
|
|
|
|
* returned.
|
|
|
|
*
|
|
|
|
* The device's pixels are converted to the bitmap's config. The only
|
|
|
|
* supported config is kARGB_8888_Config, though this is likely to be
|
|
|
|
* relaxed in the future. The meaning of config kARGB_8888_Config is
|
|
|
|
* modified by the enum param config8888. The default value interprets
|
|
|
|
* kARGB_8888_Config as SkPMColor
|
|
|
|
*
|
|
|
|
* If the bitmap has pixels already allocated, the device pixels will be
|
2012-01-28 01:45:11 +00:00
|
|
|
* written there. If not, bitmap->allocPixels() will be called
|
2011-11-03 20:29:47 +00:00
|
|
|
* automatically. If the bitmap is backed by a texture readPixels will
|
|
|
|
* fail.
|
|
|
|
*
|
|
|
|
* The actual pixels written is the intersection of the device's bounds,
|
|
|
|
* and the rectangle formed by the bitmap's width,height and the specified
|
|
|
|
* x,y. If bitmap pixels extend outside of that intersection, they will not
|
|
|
|
* be modified.
|
|
|
|
*
|
|
|
|
* Other failure conditions:
|
|
|
|
* * If the device is not a raster device (e.g. PDF) then readPixels will
|
|
|
|
* fail.
|
|
|
|
* * If bitmap is texture-backed then readPixels will fail. (This may be
|
|
|
|
* relaxed in the future.)
|
|
|
|
*/
|
|
|
|
bool readPixels(SkBitmap* bitmap,
|
|
|
|
int x, int y,
|
|
|
|
SkCanvas::Config8888 config8888);
|
|
|
|
|
2011-01-25 23:50:57 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-02-07 16:27:57 +00:00
|
|
|
/** Update as needed the pixel value in the bitmap, so that the caller can
|
|
|
|
access the pixels directly. Note: only the pixels field should be
|
|
|
|
altered. The config/width/height/rowbytes must remain unchanged.
|
|
|
|
@param bitmap The device's bitmap
|
|
|
|
@return Echo the bitmap parameter, or an alternate (shadow) bitmap
|
|
|
|
maintained by the subclass.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2012-02-07 16:27:57 +00:00
|
|
|
virtual const SkBitmap& onAccessBitmap(SkBitmap*);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2010-12-20 18:26:13 +00:00
|
|
|
SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
|
|
|
|
// just for subclasses, to assign a custom pixelref
|
|
|
|
SkPixelRef* setPixelRef(SkPixelRef* pr, size_t offset) {
|
|
|
|
fBitmap.setPixelRef(pr, offset);
|
|
|
|
return pr;
|
|
|
|
}
|
2012-01-28 01:45:11 +00:00
|
|
|
|
2011-11-02 19:57:21 +00:00
|
|
|
/**
|
|
|
|
* Implements readPixels API. The caller will ensure that:
|
|
|
|
* 1. bitmap has pixel config kARGB_8888_Config.
|
|
|
|
* 2. bitmap has pixels.
|
|
|
|
* 3. The rectangle (x, y, x + bitmap->width(), y + bitmap->height()) is
|
|
|
|
* contained in the device bounds.
|
|
|
|
*/
|
2011-11-03 20:29:47 +00:00
|
|
|
virtual bool onReadPixels(const SkBitmap& bitmap,
|
|
|
|
int x, int y,
|
|
|
|
SkCanvas::Config8888 config8888);
|
2010-12-20 18:26:13 +00:00
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
/** Called when this device is installed into a Canvas. Balanaced by a call
|
|
|
|
to unlockPixels() when the device is removed from a Canvas.
|
|
|
|
*/
|
|
|
|
virtual void lockPixels();
|
|
|
|
virtual void unlockPixels();
|
|
|
|
|
2012-01-06 14:43:09 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the device allows processing of this imagefilter. If
|
|
|
|
* false is returned, then the filter is ignored. This may happen for
|
|
|
|
* some subclasses that do not support pixel manipulations after drawing
|
|
|
|
* has occurred (e.g. printing). The default implementation returns true.
|
|
|
|
*/
|
|
|
|
virtual bool allowImageFilter(SkImageFilter*);
|
|
|
|
|
2012-01-05 21:15:07 +00:00
|
|
|
/**
|
2012-03-23 15:36:36 +00:00
|
|
|
* Override and return true for filters that the device can handle
|
|
|
|
* intrinsically. Doing so means that SkCanvas will pass-through this
|
|
|
|
* filter to drawSprite and drawDevice (and potentially filterImage).
|
|
|
|
* Returning false means the SkCanvas will have apply the filter itself,
|
|
|
|
* and just pass the resulting image to the device.
|
2012-01-05 21:15:07 +00:00
|
|
|
*/
|
2012-03-23 15:36:36 +00:00
|
|
|
virtual bool canHandleImageFilter(SkImageFilter*);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Related (but not required) to canHandleImageFilter, this method returns
|
|
|
|
* true if the device could apply the filter to the src bitmap and return
|
|
|
|
* the result (and updates offset as needed).
|
|
|
|
* If the device does not recognize or support this filter,
|
|
|
|
* it just returns false and leaves result and offset unchanged.
|
|
|
|
*/
|
|
|
|
virtual bool filterImage(SkImageFilter*, const SkBitmap&, const SkMatrix&,
|
2012-01-05 21:15:07 +00:00
|
|
|
SkBitmap* result, SkIPoint* offset);
|
|
|
|
|
2012-01-28 01:45:11 +00:00
|
|
|
// This is equal kBGRA_Premul_Config8888 or kRGBA_Premul_Config8888 if
|
2011-11-03 20:29:47 +00:00
|
|
|
// either is identical to kNative_Premul_Config8888. Otherwise, -1.
|
|
|
|
static const SkCanvas::Config8888 kPMColorAlias;
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
2011-03-04 22:27:10 +00:00
|
|
|
friend class SkCanvas;
|
2011-08-08 19:41:56 +00:00
|
|
|
friend struct DeviceCM; //for setMatrixClip
|
|
|
|
friend class SkDraw;
|
|
|
|
friend class SkDrawIter;
|
|
|
|
friend class SkDeviceFilteredPaint;
|
2012-01-05 21:15:07 +00:00
|
|
|
friend class DeviceImageFilterProxy;
|
2011-08-08 19:41:56 +00:00
|
|
|
|
2012-05-23 11:44:08 +00:00
|
|
|
/**
|
|
|
|
* postSave is called by SkCanvas to inform the device that it has
|
|
|
|
* just completed a save operation. This allows derived
|
|
|
|
* classes to initialize their state-dependent caches.
|
|
|
|
*/
|
|
|
|
virtual void postSave() {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* preRestore is called by SkCanvas right before it executes a restore
|
|
|
|
* operation. As the partner of postSave, it allows
|
|
|
|
* derived classes to clear their state-dependent caches.
|
|
|
|
*/
|
|
|
|
virtual void preRestore() {};
|
|
|
|
|
2011-10-03 19:03:48 +00:00
|
|
|
// just called by SkCanvas when built as a layer
|
|
|
|
void setOrigin(int x, int y) { fOrigin.set(x, y); }
|
2011-06-17 13:10:25 +00:00
|
|
|
// just called by SkCanvas for saveLayer
|
2012-01-28 01:45:11 +00:00
|
|
|
SkDevice* createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
|
2011-06-17 13:10:25 +00:00
|
|
|
int width, int height,
|
|
|
|
bool isOpaque);
|
2011-03-04 22:27:10 +00:00
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
/**
|
|
|
|
* Subclasses should override this to implement createCompatibleDevice.
|
|
|
|
*/
|
2012-01-28 01:45:11 +00:00
|
|
|
virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config,
|
|
|
|
int width, int height,
|
2011-08-08 19:41:56 +00:00
|
|
|
bool isOpaque,
|
|
|
|
Usage usage);
|
|
|
|
|
|
|
|
/** Causes any deferred drawing to the device to be completed.
|
|
|
|
*/
|
2011-09-13 14:41:06 +00:00
|
|
|
virtual void flush() {}
|
2011-08-08 19:41:56 +00:00
|
|
|
|
2011-01-25 23:50:57 +00:00
|
|
|
SkBitmap fBitmap;
|
2011-03-04 22:27:10 +00:00
|
|
|
SkIPoint fOrigin;
|
2011-03-30 21:23:07 +00:00
|
|
|
SkMetaData* fMetaData;
|
2012-06-21 20:25:03 +00:00
|
|
|
|
|
|
|
typedef SkRefCnt INHERITED;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|