Add ability to ninepatch blurred rounded rectangle
Speed up drawing large blurry round rectangles by converting them to
nine patches.
SkDraw:
Add drawRRect.
SkBitmapDevice:
Call SkDraw::drawRRect instead of converting SkRRect to an SkPath.
SkMaskFilter/SkBlurMaskFilter:
Create a nine patch of a blurred round rect and draw it instead of
drawing the entire thing.
SkPDFDevice:
Override drawRRect to perform the old behavior in
SkBitmapDevice::drawRect.
Depends on https://codereview.chromium.org/52703003
Tests are in https://codereview.chromium.org/52793005
BUG=https://b.corp.google.com/issue?id=11174385
R=reed@google.com, robertphillips@google.com
Review URL: https://codereview.chromium.org/48623006
git-svn-id: http://skia.googlecode.com/svn/trunk/include@12198 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkDraw.h b/core/SkDraw.h
index 9183094..f7ae1c6 100644
--- a/core/SkDraw.h
+++ b/core/SkDraw.h
@@ -24,6 +24,7 @@
class SkRasterClip;
struct SkDrawProcs;
struct SkRect;
+class SkRRect;
class SkDraw {
public:
@@ -34,6 +35,7 @@
void drawPoints(SkCanvas::PointMode, size_t count, const SkPoint[],
const SkPaint&, bool forceUseDevice = false) const;
void drawRect(const SkRect&, const SkPaint&) const;
+ void drawRRect(const SkRRect&, const SkPaint&) const;
/**
* To save on mallocs, we allow a flag that tells us that srcPath is
* mutable, so that we don't have to make copies of it as we transform it.
diff --git a/core/SkMaskFilter.h b/core/SkMaskFilter.h
index 93e2d4b..f4448dd 100644
--- a/core/SkMaskFilter.h
+++ b/core/SkMaskFilter.h
@@ -21,6 +21,7 @@
class SkMatrix;
class SkPath;
class SkRasterClip;
+class SkRRect;
/** \class SkMaskFilter
@@ -162,6 +163,12 @@
const SkMatrix&,
const SkIRect& clipBounds,
NinePatch*) const;
+ /**
+ * Similar to filterRectsToNine, except it performs the work on a round rect.
+ */
+ virtual FilterReturn filterRRectToNine(const SkRRect&, const SkMatrix&,
+ const SkIRect& clipBounds,
+ NinePatch*) const;
private:
friend class SkDraw;
@@ -175,6 +182,14 @@
const SkRasterClip&, SkBounder*, SkBlitter* blitter,
SkPaint::Style style) const;
+ /** Helper method that, given a roundRect in device space, will rasterize it into a kA8_Format
+ mask and then call filterMask(). If this returns true, the specified blitter will be called
+ to render that mask. Returns false if filterMask() returned false.
+ */
+ bool filterRRect(const SkRRect& devRRect, const SkMatrix& devMatrix,
+ const SkRasterClip&, SkBounder*, SkBlitter* blitter,
+ SkPaint::Style style) const;
+
typedef SkFlattenable INHERITED;
};
diff --git a/pdf/SkPDFDevice.h b/pdf/SkPDFDevice.h
index d8e1aa2..8e1f418 100644
--- a/pdf/SkPDFDevice.h
+++ b/pdf/SkPDFDevice.h
@@ -33,6 +33,7 @@
class SkPDFResourceDict;
class SkPDFShader;
class SkPDFStream;
+class SkRRect;
template <typename T> class SkTSet;
// Private classes.
@@ -83,6 +84,8 @@
size_t count, const SkPoint[],
const SkPaint& paint) SK_OVERRIDE;
virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint);
+ virtual void drawRRect(const SkDraw&, const SkRRect& rr,
+ const SkPaint& paint) SK_OVERRIDE;
virtual void drawPath(const SkDraw&, const SkPath& origpath,
const SkPaint& paint, const SkMatrix* prePathMatrix,
bool pathIsMutable) SK_OVERRIDE;