From 46799cd9f0bded51a189d77731b25af159ab4609 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Tue, 22 Feb 2011 20:56:26 +0000 Subject: [PATCH] change virtual setMatrixClip() to take a SkClipStack parameter. git-svn-id: http://skia.googlecode.com/svn/trunk@831 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkDevice.h | 18 ++++++++++++++---- include/gpu/SkGpuDevice.h | 3 ++- include/pdf/SkPDFDevice.h | 3 ++- src/core/SkCanvas.cpp | 8 ++++---- src/core/SkDevice.cpp | 9 +++++---- src/gpu/SkGpuDevice.cpp | 7 ++++--- src/pdf/SkPDFDevice.cpp | 3 ++- 7 files changed, 33 insertions(+), 18 deletions(-) diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index a1e6a64..a790399 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -23,6 +23,7 @@ #include "SkColor.h" #include "SkRefDict.h" +class SkClipStack; class SkDevice; class SkDraw; struct SkIRect; @@ -122,11 +123,20 @@ public: */ virtual SkGpuTexture* accessTexture() { return NULL; } - /** 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. + /** + * 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&); + virtual void setMatrixClip(const SkMatrix&, const SkRegion&, + const SkClipStack&); /** Called when this device gains focus (i.e becomes the current device for drawing). diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h index db65e05..2db3380 100644 --- a/include/gpu/SkGpuDevice.h +++ b/include/gpu/SkGpuDevice.h @@ -77,7 +77,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); + 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, diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h index b6bc7be..5bcc8e3 100644 --- a/include/pdf/SkPDFDevice.h +++ b/include/pdf/SkPDFDevice.h @@ -64,7 +64,8 @@ public: to using those settings. If your subclass overrides this, be sure to call through to the base class as well. */ - virtual void setMatrixClip(const SkMatrix&, const SkRegion&); + virtual void setMatrixClip(const SkMatrix&, const SkRegion&, + const SkClipStack&); virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap) { return false; diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 88b012d..94db24c 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -99,7 +99,7 @@ struct DeviceCM { } void updateMC(const SkMatrix& totalMatrix, const SkRegion& totalClip, - SkRegion* updateClip) { + const SkClipStack& clipStack, SkRegion* updateClip) { int x = fX; int y = fY; int width = fDevice->width(); @@ -126,7 +126,7 @@ struct DeviceCM { SkRegion::kDifference_Op); } - fDevice->setMatrixClip(*fMatrix, fClip); + fDevice->setMatrixClip(*fMatrix, fClip, clipStack); #ifdef SK_DEBUG if (!fClip.isEmpty()) { @@ -610,7 +610,7 @@ void SkCanvas::updateDeviceCMCache() { DeviceCM* layer = fMCRec->fTopLayer; if (NULL == layer->fNext) { // only one layer - layer->updateMC(totalMatrix, totalClip, NULL); + layer->updateMC(totalMatrix, totalClip, fClipStack, NULL); if (fUseExternalMatrix) { layer->updateExternalMatrix(fExternalMatrix, fExternalInverse); @@ -619,7 +619,7 @@ void SkCanvas::updateDeviceCMCache() { SkRegion clip; clip = totalClip; // make a copy do { - layer->updateMC(totalMatrix, clip, &clip); + layer->updateMC(totalMatrix, clip, fClipStack, &clip); if (fUseExternalMatrix) { layer->updateExternalMatrix(fExternalMatrix, fExternalInverse); diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index 8df0e41..2383ed9 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -11,7 +11,7 @@ SkDevice::SkDevice(SkCanvas* canvas, const SkBitmap& bitmap, bool isForLayer) // auto-allocate if we're for offscreen drawing if (isForLayer) { if (NULL == fBitmap.getPixels() && NULL == fBitmap.pixelRef()) { - fBitmap.allocPixels(); + fBitmap.allocPixels(); if (!fBitmap.isOpaque()) { fBitmap.eraseColor(0); } @@ -43,7 +43,7 @@ void SkDevice::getBounds(SkIRect* bounds) const { bool SkDevice::intersects(const SkIRect& r, SkIRect* sect) const { SkIRect bounds; - + this->getBounds(&bounds); return sect ? sect->intersect(r, bounds) : SkIRect::Intersects(r, bounds); } @@ -54,7 +54,8 @@ void SkDevice::eraseColor(SkColor eraseColor) { void SkDevice::onAccessBitmap(SkBitmap* bitmap) {} -void SkDevice::setMatrixClip(const SkMatrix&, const SkRegion&) {} +void SkDevice::setMatrixClip(const SkMatrix&, const SkRegion&, + const SkClipStack&) {} /////////////////////////////////////////////////////////////////////////////// @@ -116,7 +117,7 @@ void SkDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, const SkMatrix& matrix, const SkPaint& paint) { SkBitmap tmp; // storage if we need a subset of bitmap const SkBitmap* bitmapPtr = &bitmap; - + if (srcRect) { if (!bitmap.extractSubset(&tmp, *srcRect)) { return; // extraction failed diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 3bf157b..71c0c48 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -294,8 +294,9 @@ void SkGpuDevice::prepareRenderTarget(const SkDraw& draw) { } } -void SkGpuDevice::setMatrixClip(const SkMatrix& matrix, const SkRegion& clip) { - this->INHERITED::setMatrixClip(matrix, clip); +void SkGpuDevice::setMatrixClip(const SkMatrix& matrix, const SkRegion& clip, + const SkClipStack& clipStack) { + this->INHERITED::setMatrixClip(matrix, clip, clipStack); convert_matrixclip(fContext, matrix, clip); } @@ -912,7 +913,7 @@ void SkGpuDevice::internalDrawBitmap(const SkDraw& draw, } grPaint->setTexture(texture); - + GrRect dstRect(0, 0, GrIntToScalar(srcRect.width()), GrIntToScalar(srcRect.height())); GrRect paintRect; paintRect.setLTRB(GrFixedToScalar((srcRect.fLeft << 16) / bitmap.width()), diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 8a74556..72b2e1b 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -152,7 +152,8 @@ SkPDFDevice::~SkPDFDevice() { } void SkPDFDevice::setMatrixClip(const SkMatrix& matrix, - const SkRegion& region) { + const SkRegion& region, + const SkClipStack&) { // See the comment in the header file above GraphicStackEntry. if (region != fGraphicStack[fGraphicStackIndex].fClip) { while (fGraphicStackIndex > 0) -- 2.7.4