aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkDevice.h18
-rw-r--r--include/gpu/SkGpuDevice.h3
-rw-r--r--include/pdf/SkPDFDevice.h3
-rw-r--r--src/core/SkCanvas.cpp8
-rw-r--r--src/core/SkDevice.cpp9
-rw-r--r--src/gpu/SkGpuDevice.cpp7
-rw-r--r--src/pdf/SkPDFDevice.cpp3
7 files changed, 33 insertions, 18 deletions
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index a1e6a64392..a7903993a4 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 db65e05032..2db33800ed 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 b6bc7bed15..5bcc8e3d36 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 88b012defe..94db24cfe5 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 8df0e41d72..2383ed98b8 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 3bf157bfa9..71c0c48e71 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 8a74556c70..72b2e1bf6a 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)