kVector_Capability = 0x2, //!< mask indicating a vector representation
kAll_Capabilities = 0x3
};
- virtual uint32_t getDeviceCapabilities();
+ virtual uint32_t getDeviceCapabilities() { return 0; }
/** Return the width of the device (in pixels).
*/
- virtual int width() const;
+ virtual int width() const { return fBitmap.width(); }
/** Return the height of the device (in pixels).
*/
- virtual int height() const;
+ virtual int height() const { return fBitmap.height(); }
/**
* Return the bounds of the device in the coordinate space of the root
virtual bool filterTextFlags(const SkPaint& paint, TextFlags*);
/**
- * Let the device know that its matrix has changed; it can query the
- * matrix when it needs it.
- */
- virtual void markMatrixDirty();
-
- /**
- * Let the device know that its clip has changed; it can query the
- * clip (region or stack) when or if it needs it.
- */
- virtual void markClipDirty();
+ * 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&);
/** Called when this device gains focus (i.e becomes the current device
for drawing).
*/
virtual void gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&,
- const SkClipStack&);
+ const SkClipStack&) {}
/** Clears the entire device to the specified color (including alpha).
* Ignores the clip.
/** Causes any deferred drawing to the device to be completed.
*/
- virtual void flush();
+ virtual void flush() {}
SkBitmap fBitmap;
SkIPoint fOrigin;
virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap);
virtual void writePixels(const SkBitmap& bitmap, int x, int y);
- virtual void markMatrixDirty();
- virtual void markClipDirty();
+ virtual void setMatrixClip(const SkMatrix& matrix, const SkRegion& clip,
+ const SkClipStack&);
virtual void drawPaint(const SkDraw&, const SkPaint& paint);
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
// TODO(vandebo): Remove this as soon as Chrome's Platform device goes away.
void setOrigin(int x, int y);
+ virtual void setMatrixClip(const SkMatrix& m, const SkRegion& r,
+ const SkClipStack& c);
private:
typedef SkDevice INHERITED;
SkRegion::kDifference_Op);
}
- //fDevice->setMatrixClip(*fMatrix, fClip, clipStack);
- fDevice->markMatrixDirty();
- fDevice->markClipDirty();
+ fDevice->setMatrixClip(*fMatrix, fClip, clipStack);
#ifdef SK_DEBUG
if (!fClip.isEmpty()) {
class SkDrawIter : public SkDraw {
public:
- SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true)
- : fCanvas(canvas)
- , fCurrLayer(NULL)
- , fSkipEmptyClips(skipEmptyClips) {
-
- if (!canvas) {
- return;
- }
+ SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true) {
+ fCanvas = canvas;
canvas->updateDeviceCMCache();
fClipStack = &canvas->getTotalClipStack();
fBounder = canvas->getBounder();
fCurrLayer = canvas->fMCRec->fTopLayer;
+ fSkipEmptyClips = skipEmptyClips;
}
bool next() {
return *fMetaData;
}
-uint32_t SkDevice::getDeviceCapabilities() {
- return 0;
-}
-
-int SkDevice::width() const {
- return fBitmap.width();
-}
-
-int SkDevice::height() const {
- return fBitmap.height();
-}
-
void SkDevice::lockPixels() {
if (fBitmap.lockPixelsAreWritable()) {
fBitmap.lockPixels();
fBitmap.eraseColor(color);
}
-void SkDevice::onAccessBitmap(SkBitmap* bitmap) {
+void SkDevice::onAccessBitmap(SkBitmap* bitmap) {}
+void SkDevice::setMatrixClip(const SkMatrix& matrix, const SkRegion& region,
+ const SkClipStack& clipStack) {
}
///////////////////////////////////////////////////////////////////////////////
return false;
}
-void SkDevice::markMatrixDirty() {
-
-}
-
-void SkDevice::markClipDirty() {
-
-}
-
-void SkDevice::gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&,
- const SkClipStack&) {
-
-}
-
-void SkDevice::flush() {
-
-}
-
}
}
-void SkGpuDevice::markMatrixDirty() {
- INHERITED::markMatrixDirty();
- fNeedPrepareRenderTarget = true;
-}
-
-void SkGpuDevice::markClipDirty() {
- INHERITED::markClipDirty();
+void SkGpuDevice::setMatrixClip(const SkMatrix& matrix, const SkRegion& clip,
+ const SkClipStack& clipStack) {
+ this->INHERITED::setMatrixClip(matrix, clip, clipStack);
+ // We don't need to set them now because the context may not reflect this device.
fNeedPrepareRenderTarget = true;
}
INHERITED::setOrigin(x, y);
}
+void SkPDFDevice::setMatrixClip(const SkMatrix& m, const SkRegion& r,
+ const SkClipStack& c) {
+ INHERITED::setMatrixClip(m, r, c);
+}
+
void SkPDFDevice::createFormXObjectFromDevice(
SkRefPtr<SkPDFFormXObject>* xobject) {
*xobject = new SkPDFFormXObject(this);