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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkDevice_DEFINED
|
|
|
|
#define SkDevice_DEFINED
|
|
|
|
|
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkColor.h"
|
2013-01-22 19:25:14 +00:00
|
|
|
#include "SkDeviceProperties.h"
|
2014-03-14 15:44:01 +00:00
|
|
|
#include "SkImageFilter.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
|
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;
|
|
|
|
|
2013-06-26 19:18:23 +00:00
|
|
|
class GrRenderTarget;
|
2011-07-18 15:25:04 +00:00
|
|
|
|
2013-08-29 11:54:56 +00:00
|
|
|
class SK_API SkBaseDevice : public SkRefCnt {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2013-08-29 11:54:56 +00:00
|
|
|
SK_DECLARE_INST_COUNT(SkBaseDevice)
|
2012-06-21 20:25:03 +00:00
|
|
|
|
2011-06-16 19:10:39 +00:00
|
|
|
/**
|
2013-08-29 11:54:56 +00:00
|
|
|
* Construct a new device.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
SkBaseDevice();
|
2011-06-16 19:10:39 +00:00
|
|
|
|
2013-01-22 19:25:14 +00:00
|
|
|
/**
|
2013-08-29 11:54:56 +00:00
|
|
|
* Construct a new device.
|
2013-01-22 19:25:14 +00:00
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
SkBaseDevice(const SkDeviceProperties& deviceProperties);
|
2013-08-20 20:06:40 +00:00
|
|
|
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual ~SkBaseDevice();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-02-16 00:59:25 +00:00
|
|
|
SkBaseDevice* createCompatibleDevice(const SkImageInfo&);
|
2011-06-17 13:10:25 +00:00
|
|
|
|
2011-08-08 19:41:56 +00:00
|
|
|
SkMetaData& getMetaData();
|
|
|
|
|
2013-01-22 19:25:14 +00:00
|
|
|
/** Return the image properties of the device. */
|
|
|
|
virtual const SkDeviceProperties& getDeviceProperties() const {
|
|
|
|
//Currently, all the properties are leaky.
|
|
|
|
return fLeakyProperties;
|
|
|
|
}
|
|
|
|
|
2014-02-13 17:14:46 +00:00
|
|
|
/**
|
|
|
|
* Return ImageInfo for this device. If the canvas is not backed by pixels
|
|
|
|
* (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType.
|
|
|
|
*/
|
|
|
|
virtual SkImageInfo imageInfo() const;
|
|
|
|
|
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.
|
|
|
|
*/
|
2013-11-13 16:02:18 +00:00
|
|
|
void getGlobalBounds(SkIRect* bounds) const {
|
|
|
|
SkASSERT(bounds);
|
|
|
|
const SkIPoint& origin = this->getOrigin();
|
|
|
|
bounds->setXYWH(origin.x(), origin.y(), this->width(), this->height());
|
|
|
|
}
|
2013-11-14 07:02:31 +00:00
|
|
|
|
2014-06-14 11:24:56 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE
|
|
|
|
virtual int width() const {
|
|
|
|
return this->imageInfo().width();
|
|
|
|
}
|
|
|
|
virtual int height() const {
|
|
|
|
return this->imageInfo().height();
|
|
|
|
}
|
|
|
|
virtual bool isOpaque() const {
|
|
|
|
return this->imageInfo().isOpaque();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
int width() const {
|
|
|
|
return this->imageInfo().width();
|
|
|
|
}
|
|
|
|
int height() const {
|
|
|
|
return this->imageInfo().height();
|
|
|
|
}
|
|
|
|
bool isOpaque() const {
|
|
|
|
return this->imageInfo().isOpaque();
|
|
|
|
}
|
|
|
|
#endif
|
2013-08-30 07:01:34 +00:00
|
|
|
|
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);
|
|
|
|
|
2014-03-17 17:03:18 +00:00
|
|
|
bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, int y);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-03-12 18:28:35 +00:00
|
|
|
void* accessPixels(SkImageInfo* info, size_t* rowBytes);
|
|
|
|
|
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
|
|
|
*/
|
2014-06-27 18:34:19 +00:00
|
|
|
virtual GrRenderTarget* 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-08-23 18:09:54 +00:00
|
|
|
/**
|
2012-07-13 15:36:15 +00:00
|
|
|
* onAttachToCanvas is invoked whenever a device is installed in a canvas
|
|
|
|
* (i.e., setDevice, saveLayer (for the new device created by the save),
|
2013-08-29 11:54:56 +00:00
|
|
|
* and SkCanvas' SkBaseDevice & SkBitmap -taking ctors). It allows the
|
2012-07-13 15:36:15 +00:00
|
|
|
* devices to prepare for drawing (e.g., locking their pixels, etc.)
|
|
|
|
*/
|
2013-03-11 18:50:03 +00:00
|
|
|
virtual void onAttachToCanvas(SkCanvas*) {
|
2012-08-29 21:26:13 +00:00
|
|
|
SkASSERT(!fAttachedToCanvas);
|
2012-07-13 15:36:15 +00:00
|
|
|
this->lockPixels();
|
|
|
|
#ifdef SK_DEBUG
|
|
|
|
fAttachedToCanvas = true;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* onDetachFromCanvas notifies a device that it will no longer be drawn to.
|
|
|
|
* It gives the device a chance to clean up (e.g., unlock its pixels). It
|
2012-08-23 18:09:54 +00:00
|
|
|
* is invoked from setDevice (for the displaced device), restore and
|
2012-07-13 15:36:15 +00:00
|
|
|
* possibly from SkCanvas' dtor.
|
|
|
|
*/
|
|
|
|
virtual void onDetachFromCanvas() {
|
2012-08-29 21:26:13 +00:00
|
|
|
SkASSERT(fAttachedToCanvas);
|
2012-07-13 15:36:15 +00:00
|
|
|
this->unlockPixels();
|
|
|
|
#ifdef SK_DEBUG
|
|
|
|
fAttachedToCanvas = false;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
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.
|
|
|
|
*/
|
2014-06-27 18:34:19 +00:00
|
|
|
virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) { return false; }
|
2011-08-08 19:41:56 +00:00
|
|
|
|
2012-10-09 22:30:18 +00:00
|
|
|
/**
|
2012-10-10 15:25:50 +00:00
|
|
|
*
|
|
|
|
* DEPRECATED: This will be removed in a future change. Device subclasses
|
|
|
|
* should use the matrix and clip from the SkDraw passed to draw functions.
|
|
|
|
*
|
2012-10-09 22:30:18 +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).
|
2012-10-10 15:25:50 +00:00
|
|
|
*/
|
|
|
|
virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkClipStack&) {};
|
2012-10-09 22:30:18 +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
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual void clear(SkColor color) = 0;
|
2010-12-20 18:26:13 +00:00
|
|
|
|
2014-01-15 00:19:21 +00:00
|
|
|
SK_ATTR_DEPRECATED("use clear() instead")
|
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.
|
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual void drawPaint(const SkDraw&, const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPoint[], const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawRect(const SkDraw&, const SkRect& r,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPaint& paint) = 0;
|
2013-01-22 13:34:01 +00:00
|
|
|
virtual void drawOval(const SkDraw&, const SkRect& oval,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPaint& paint) = 0;
|
2013-04-25 15:27:00 +00:00
|
|
|
virtual void drawRRect(const SkDraw&, const SkRRect& rr,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPaint& paint) = 0;
|
2013-04-25 15:27:00 +00:00
|
|
|
|
2014-02-21 02:32:36 +00:00
|
|
|
// Default impl calls drawPath()
|
|
|
|
virtual void drawDRRect(const SkDraw&, const SkRRect& outer,
|
|
|
|
const SkRRect& inner, const SkPaint&);
|
|
|
|
|
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,
|
2013-08-29 11:54:56 +00:00
|
|
|
bool pathIsMutable = false) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkMatrix& matrix, const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
|
2013-08-29 11:54:56 +00:00
|
|
|
int x, int y, const SkPaint& paint) = 0;
|
2012-09-25 15:37:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The default impl. will create a bitmap-shader from the bitmap,
|
|
|
|
* and call drawRect with it.
|
|
|
|
*/
|
|
|
|
virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
|
|
|
|
const SkRect* srcOrNull, const SkRect& dst,
|
2013-08-16 10:24:37 +00:00
|
|
|
const SkPaint& paint,
|
2013-08-29 11:54:56 +00:00
|
|
|
SkCanvas::DrawBitmapRectFlags flags) = 0;
|
2012-09-25 15:37:50 +00:00
|
|
|
|
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,
|
2013-08-29 11:54:56 +00:00
|
|
|
SkScalar x, SkScalar y, const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
|
|
|
|
const SkScalar pos[], SkScalar constY,
|
2013-08-29 11:54:56 +00:00
|
|
|
int scalarsPerPos, const SkPaint& paint) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
|
|
|
|
const SkPath& path, const SkMatrix* matrix,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPaint& paint) = 0;
|
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,
|
2013-08-29 11:54:56 +00:00
|
|
|
const SkPaint& paint) = 0;
|
2013-08-20 20:06:40 +00:00
|
|
|
/** The SkDevice passed will be an SkDevice which was returned by a call to
|
2014-02-16 00:59:25 +00:00
|
|
|
onCreateDevice on this device with kSaveLayer_Usage.
|
2011-08-08 19:41:56 +00:00
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
|
|
|
|
const SkPaint&) = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-03-17 21:31:26 +00:00
|
|
|
bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y);
|
2011-11-03 20:29:47 +00:00
|
|
|
|
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
|
2013-08-30 07:01:34 +00:00
|
|
|
access the pixels directly.
|
2013-08-29 11:54:56 +00:00
|
|
|
@return The device contents as a bitmap
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual const SkBitmap& onAccessBitmap() = 0;
|
2012-01-28 01:45:11 +00:00
|
|
|
|
2013-09-17 12:26:23 +00:00
|
|
|
/** Called when this device is installed into a Canvas. Balanced by a call
|
2011-08-08 19:41:56 +00:00
|
|
|
to unlockPixels() when the device is removed from a Canvas.
|
|
|
|
*/
|
2014-06-27 18:34:19 +00:00
|
|
|
virtual void lockPixels() {}
|
|
|
|
virtual void unlockPixels() {}
|
2011-08-08 19:41:56 +00:00
|
|
|
|
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.
|
|
|
|
*/
|
2014-06-27 18:34:19 +00:00
|
|
|
virtual bool allowImageFilter(const SkImageFilter*) { return true; }
|
2012-01-06 14:43:09 +00:00
|
|
|
|
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
|
|
|
*/
|
2014-06-27 18:34:19 +00:00
|
|
|
virtual bool canHandleImageFilter(const SkImageFilter*) { return false; }
|
2012-03-23 15:36:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-03-14 15:44:01 +00:00
|
|
|
virtual bool filterImage(const SkImageFilter*, const SkBitmap&,
|
|
|
|
const SkImageFilter::Context& ctx,
|
2014-06-27 18:34:19 +00:00
|
|
|
SkBitmap* result, SkIPoint* offset) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-01-05 21:15:07 +00:00
|
|
|
|
2013-12-19 16:12:25 +00:00
|
|
|
protected:
|
2014-02-05 15:32:21 +00:00
|
|
|
// default impl returns NULL
|
|
|
|
virtual SkSurface* newSurface(const SkImageInfo&);
|
2014-02-14 03:02:05 +00:00
|
|
|
|
2014-02-13 17:14:46 +00:00
|
|
|
// default impl returns NULL
|
|
|
|
virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes);
|
2014-02-14 03:02:05 +00:00
|
|
|
|
2014-03-17 21:31:26 +00:00
|
|
|
/**
|
|
|
|
* The caller is responsible for "pre-clipping" the dst. The impl can assume that the dst
|
|
|
|
* image at the specified x,y offset will fit within the device's bounds.
|
|
|
|
*
|
|
|
|
* This is explicitly asserted in readPixels(), the public way to call this.
|
|
|
|
*/
|
|
|
|
virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y);
|
2014-03-12 03:04:08 +00:00
|
|
|
|
2014-03-07 03:25:16 +00:00
|
|
|
/**
|
|
|
|
* The caller is responsible for "pre-clipping" the src. The impl can assume that the src
|
|
|
|
* image at the specified x,y offset will fit within the device's bounds.
|
|
|
|
*
|
|
|
|
* This is explicitly asserted in writePixelsDirect(), the public way to call this.
|
|
|
|
*/
|
|
|
|
virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, int y);
|
|
|
|
|
2014-03-12 18:28:35 +00:00
|
|
|
/**
|
|
|
|
* Default impl returns NULL.
|
|
|
|
*/
|
|
|
|
virtual void* onAccessPixels(SkImageInfo* info, size_t* rowBytes);
|
|
|
|
|
2013-12-19 16:12:25 +00:00
|
|
|
/**
|
|
|
|
* Leaky properties are those which the device should be applying but it isn't.
|
|
|
|
* These properties will be applied by the draw, when and as it can.
|
|
|
|
* If the device does handle a property, that property should be set to the identity value
|
|
|
|
* for that property, effectively making it non-leaky.
|
|
|
|
*/
|
|
|
|
SkDeviceProperties fLeakyProperties;
|
|
|
|
|
2014-03-16 19:46:36 +00:00
|
|
|
/**
|
|
|
|
* PRIVATE / EXPERIMENTAL -- do not call
|
|
|
|
* Construct an acceleration object and attach it to 'picture'
|
|
|
|
*/
|
2014-06-04 12:40:44 +00:00
|
|
|
virtual void EXPERIMENTAL_optimize(const SkPicture* picture);
|
2014-03-16 19:46:36 +00:00
|
|
|
|
2014-04-11 15:54:14 +00:00
|
|
|
/**
|
|
|
|
* PRIVATE / EXPERIMENTAL -- do not call
|
|
|
|
* Purge all discardable optimization information for 'picture'. If
|
|
|
|
* picture is NULL then purge discardable information for all pictures.
|
|
|
|
*/
|
2014-06-04 12:40:44 +00:00
|
|
|
virtual void EXPERIMENTAL_purge(const SkPicture* picture);
|
2014-04-11 15:54:14 +00:00
|
|
|
|
2014-03-16 19:46:36 +00:00
|
|
|
/**
|
|
|
|
* PRIVATE / EXPERIMENTAL -- do not call
|
|
|
|
* This entry point gives the backend an opportunity to take over the rendering
|
|
|
|
* of 'picture'. If optimization data is available (due to an earlier
|
|
|
|
* 'optimize' call) this entry point should make use of it and return true
|
|
|
|
* if all rendering has been done. If false is returned, SkCanvas will
|
2014-03-17 03:02:17 +00:00
|
|
|
* perform its own rendering pass. It is acceptable for the backend
|
2014-03-16 19:46:36 +00:00
|
|
|
* to perform some device-specific warm up tasks and then let SkCanvas
|
|
|
|
* perform the main rendering loop (by return false from here).
|
|
|
|
*/
|
2014-06-04 12:40:44 +00:00
|
|
|
virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* picture);
|
2014-03-16 19:46:36 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
2011-03-04 22:27:10 +00:00
|
|
|
friend class SkCanvas;
|
2012-10-09 22:30:18 +00:00
|
|
|
friend struct DeviceCM; //for setMatrixClip
|
2011-08-08 19:41:56 +00:00
|
|
|
friend class SkDraw;
|
|
|
|
friend class SkDrawIter;
|
|
|
|
friend class SkDeviceFilteredPaint;
|
2012-09-27 21:57:45 +00:00
|
|
|
friend class SkDeviceImageFilterProxy;
|
2014-03-12 18:28:35 +00:00
|
|
|
friend class SkDeferredDevice; // for newSurface
|
2011-08-08 19:41:56 +00:00
|
|
|
|
2012-08-28 12:19:02 +00:00
|
|
|
friend class SkSurface_Raster;
|
2013-08-29 11:54:56 +00:00
|
|
|
|
2012-08-28 12:19:02 +00:00
|
|
|
// used to change the backend's pixels (and possibly config/rowbytes)
|
|
|
|
// but cannot change the width/height, so there should be no change to
|
|
|
|
// any clip information.
|
2013-11-13 16:02:18 +00:00
|
|
|
// TODO: move to SkBitmapDevice
|
2014-06-27 18:34:19 +00:00
|
|
|
virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) {}
|
2012-08-28 12:19:02 +00:00
|
|
|
|
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
|
2014-02-16 00:59:25 +00:00
|
|
|
SkBaseDevice* createCompatibleDeviceForSaveLayer(const SkImageInfo&);
|
2011-03-04 22:27:10 +00:00
|
|
|
|
2014-02-16 00:59:25 +00:00
|
|
|
virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-08-08 19:41:56 +00:00
|
|
|
|
|
|
|
/** Causes any deferred drawing to the device to be completed.
|
|
|
|
*/
|
2014-06-27 18:34:19 +00:00
|
|
|
virtual void flush() {}
|
2011-08-08 19:41:56 +00:00
|
|
|
|
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
|
|
|
|
2012-07-13 15:36:15 +00:00
|
|
|
#ifdef SK_DEBUG
|
|
|
|
bool fAttachedToCanvas;
|
|
|
|
#endif
|
|
|
|
|
2012-06-21 20:25:03 +00:00
|
|
|
typedef SkRefCnt INHERITED;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|