Add GPU support for roundrects
This uses the OvalRenderer to render roundrects as "stretched ovals." It adds an
additional shader that handles the straight edges of ellipsoid roundrects better,
and uses the circle shader for roundrects where the two radii are the same. Only
axis-aligned, simple roundrects are supported. Handles fill, stroke and hairline.
R=bsalomon@google.com, robertphillips@google.com, reed@google.com
Author: jvanverth@google.com
Review URL: https://chromiumcodereview.appspot.com/13852049
git-svn-id: http://skia.googlecode.com/svn/trunk@8859 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 299cf3d..0ee17e8 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -21,6 +21,7 @@
#include "SkGlyphCache.h"
#include "SkImageFilter.h"
#include "SkPathEffect.h"
+#include "SkRRect.h"
#include "SkStroke.h"
#include "SkUtils.h"
@@ -707,6 +708,39 @@
///////////////////////////////////////////////////////////////////////////////
+void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
+ const SkPaint& paint) {
+ CHECK_FOR_NODRAW_ANNOTATION(paint);
+ CHECK_SHOULD_DRAW(draw, false);
+
+ bool usePath = !rect.isSimple() || !paint.isAntiAlias();
+ // another two reasons we might need to call drawPath...
+ if (paint.getMaskFilter() || paint.getPathEffect()) {
+ usePath = true;
+ }
+ // until we can rotate rrects...
+ if (!usePath && !fContext->getMatrix().rectStaysRect()) {
+ usePath = true;
+ }
+
+ if (usePath) {
+ SkPath path;
+ path.addRRect(rect);
+ this->drawPath(draw, path, paint, NULL, true);
+ return;
+ }
+
+ GrPaint grPaint;
+ if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
+ return;
+ }
+
+ SkStrokeRec stroke(paint);
+ fContext->drawRRect(grPaint, rect, stroke);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
const SkPaint& paint) {
CHECK_FOR_NODRAW_ANNOTATION(paint);