Override drawRRect in fake SkBitmapDevices.
Recent changes to SkBitmapDevice modified ::drawRRect() to take
an optimized drawing case. Some subclasses of SkBitmapDevice were
depending on the old behavior of calling ::drawPath(). Since they
do not draw, attempting to take the drawing path can cause problems.
For these subclasses, call drawPath() in the subclass.
Cherry-pick of https://code.google.com/p/skia/source/detail?r=12247 in Skia.
BUG:11648093
Change-Id: Ie2173907c58c36b28855aba5a71b7ad676cc543e
diff --git a/include/device/xps/SkXPSDevice.h b/include/device/xps/SkXPSDevice.h
index dab8d1f..ca6fd7e 100644
--- a/include/device/xps/SkXPSDevice.h
+++ b/include/device/xps/SkXPSDevice.h
@@ -85,6 +85,11 @@
const SkRect& r,
const SkPaint& paint) SK_OVERRIDE;
+ virtual void drawRRect(
+ const SkDraw&,
+ const SkRRect&,
+ const SkPaint& paint) SK_OVERRIDE;
+
virtual void drawPath(
const SkDraw&,
const SkPath& platonicPath,
diff --git a/src/device/xps/SkXPSDevice.cpp b/src/device/xps/SkXPSDevice.cpp
index 442a51f..f3e1976 100644
--- a/src/device/xps/SkXPSDevice.cpp
+++ b/src/device/xps/SkXPSDevice.cpp
@@ -1203,6 +1203,14 @@
this->internalDrawRect(d, r, true, paint);
}
+void SkXPSDevice::drawRRect(const SkDraw& d,
+ const SkRRect& rr,
+ const SkPaint& paint) {
+ SkPath path;
+ path.addRRect(rr);
+ this->drawPath(d, path, paint, NULL, true);
+}
+
void SkXPSDevice::internalDrawRect(const SkDraw& d,
const SkRect& r,
bool transformRect,
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 05daf63..eb5c00a 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -137,6 +137,7 @@
//-----------------------------------------------------------------------------
// DeferredDevice
//-----------------------------------------------------------------------------
+// FIXME: Derive from SkBaseDevice.
class DeferredDevice : public SkDevice {
public:
explicit DeferredDevice(SkDevice* immediateDevice);
@@ -197,6 +198,9 @@
virtual void drawRect(const SkDraw&, const SkRect& r,
const SkPaint& paint) SK_OVERRIDE
{SkASSERT(0);}
+ virtual void drawRRect(const SkDraw&, const SkRRect& rr,
+ const SkPaint& paint) SK_OVERRIDE
+ {SkASSERT(0);}
virtual void drawPath(const SkDraw&, const SkPath& path,
const SkPaint& paint,
const SkMatrix* prePathMatrix = NULL,
diff --git a/src/utils/SkPictureUtils.cpp b/src/utils/SkPictureUtils.cpp
index 36b62e5..46d4920 100644
--- a/src/utils/SkPictureUtils.cpp
+++ b/src/utils/SkPictureUtils.cpp
@@ -46,6 +46,7 @@
* This device will route all bitmaps (primitives and in shaders) to its PRSet.
* It should never actually draw anything, so there need not be any pixels
* behind its device-bitmap.
+ * FIXME: Derive from SkBaseDevice.
*/
class GatherPixelRefDevice : public SkDevice {
private:
@@ -93,6 +94,10 @@
const SkPaint& paint) SK_OVERRIDE {
this->addBitmapFromPaint(paint);
}
+ virtual void drawRRect(const SkDraw&, const SkRRect&,
+ const SkPaint& paint) SK_OVERRIDE {
+ this->addBitmapFromPaint(paint);
+ }
virtual void drawOval(const SkDraw&, const SkRect&,
const SkPaint& paint) SK_OVERRIDE {
this->addBitmapFromPaint(paint);