diff options
author | 2011-09-12 19:52:44 +0000 | |
---|---|---|
committer | 2011-09-12 19:52:44 +0000 | |
commit | 66d57255ad984f8926e4ed9d45bfb00cdfc90f4e (patch) | |
tree | f8e5db0cd3b2a00500a6b668c17f789c29ae88ae | |
parent | dbeeac33329f5fd7dbd3514cd7189ca6ed080476 (diff) |
Replaces SkDevice::setMatrixClip() with markMatrixDirty() and markClipDirty(),
which require no arguments and so may be called without requiring the matrix
and clip to be completely evaluated.
De-inlines virtual functions in SkDevice interface.
git-svn-id: http://skia.googlecode.com/svn/trunk@2250 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkDevice.h | 33 | ||||
-rw-r--r-- | include/gpu/SkGpuDevice.h | 4 | ||||
-rw-r--r-- | include/pdf/SkPDFDevice.h | 2 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 15 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 33 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 11 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 5 |
7 files changed, 65 insertions, 38 deletions
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index d4afd696a7..30f0dec103 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -73,14 +73,14 @@ public: kVector_Capability = 0x2, //!< mask indicating a vector representation kAll_Capabilities = 0x3 }; - virtual uint32_t getDeviceCapabilities() { return 0; } + virtual uint32_t getDeviceCapabilities(); /** Return the width of the device (in pixels). */ - virtual int width() const { return fBitmap.width(); } + virtual int width() const; /** Return the height of the device (in pixels). */ - virtual int height() const { return fBitmap.height(); } + virtual int height() const; /** * Return the bounds of the device in the coordinate space of the root @@ -154,25 +154,22 @@ protected: virtual bool filterTextFlags(const SkPaint& paint, TextFlags*); /** - * 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&); + * 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 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. @@ -290,7 +287,7 @@ private: /** Causes any deferred drawing to the device to be completed. */ - virtual void flush() {} + virtual void flush(); SkBitmap fBitmap; SkIPoint fOrigin; diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h index f5613a7fd8..181ea9f8f9 100644 --- a/include/gpu/SkGpuDevice.h +++ b/include/gpu/SkGpuDevice.h @@ -71,8 +71,8 @@ public: virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); virtual void writePixels(const SkBitmap& bitmap, int x, int y); - virtual void setMatrixClip(const SkMatrix& matrix, const SkRegion& clip, - const SkClipStack&); + virtual void markMatrixDirty(); + virtual void markClipDirty(); virtual void drawPaint(const SkDraw&, const SkPaint& paint); virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count, diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h index 395968b5ac..4080d5612d 100644 --- a/include/pdf/SkPDFDevice.h +++ b/include/pdf/SkPDFDevice.h @@ -163,8 +163,6 @@ public: // 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; diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 1f75aa9ad6..4335f6e28e 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -118,7 +118,9 @@ struct DeviceCM { SkRegion::kDifference_Op); } - fDevice->setMatrixClip(*fMatrix, fClip, clipStack); + //fDevice->setMatrixClip(*fMatrix, fClip, clipStack); + fDevice->markMatrixDirty(); + fDevice->markClipDirty(); #ifdef SK_DEBUG if (!fClip.isEmpty()) { @@ -212,14 +214,19 @@ private: class SkDrawIter : public SkDraw { public: - SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true) { - fCanvas = canvas; + SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true) + : fCanvas(canvas) + , fCurrLayer(NULL) + , fSkipEmptyClips(skipEmptyClips) { + + if (!canvas) { + return; + } canvas->updateDeviceCMCache(); fClipStack = &canvas->getTotalClipStack(); fBounder = canvas->getBounder(); fCurrLayer = canvas->fMCRec->fTopLayer; - fSkipEmptyClips = skipEmptyClips; } bool next() { diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index 69f86ccf52..ffde8de697 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -63,6 +63,18 @@ SkMetaData& SkDevice::getMetaData() { 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(); @@ -94,10 +106,8 @@ void SkDevice::clear(SkColor color) { 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) { } /////////////////////////////////////////////////////////////////////////////// @@ -242,3 +252,20 @@ bool SkDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { return false; } +void SkDevice::markMatrixDirty() { + +} + +void SkDevice::markClipDirty() { + +} + +void SkDevice::gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&, + const SkClipStack&) { + +} + +void SkDevice::flush() { + +} + diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index ecdcd7a080..32ac5af39c 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -338,10 +338,13 @@ void SkGpuDevice::prepareRenderTarget(const SkDraw& draw) { } } -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. +void SkGpuDevice::markMatrixDirty() { + INHERITED::markMatrixDirty(); + fNeedPrepareRenderTarget = true; +} + +void SkGpuDevice::markClipDirty() { + INHERITED::markClipDirty(); fNeedPrepareRenderTarget = true; } diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 8cf1eca3b8..6cb7e4d076 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -1135,11 +1135,6 @@ void SkPDFDevice::setOrigin(int x, int y) { 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); |