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/include/core/SkDevice.h b/include/core/SkDevice.h
index 4093109..3d915d8 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -259,6 +259,9 @@
                           const SkPaint& paint);
     virtual void drawOval(const SkDraw&, const SkRect& oval,
                           const SkPaint& paint);
+    virtual void drawRRect(const SkDraw&, const SkRRect& rr,
+                           const SkPaint& paint);
+
     /**
      *  If pathIsMutable, then the implementation is allowed to cast path to a
      *  non-const pointer and modify it in place (as an optimization). Canvas
diff --git a/include/core/SkDrawFilter.h b/include/core/SkDrawFilter.h
index 6a50ca7..52cbba9 100644
--- a/include/core/SkDrawFilter.h
+++ b/include/core/SkDrawFilter.h
@@ -31,6 +31,7 @@
         kLine_Type,
         kBitmap_Type,
         kRect_Type,
+        kRRect_Type,
         kOval_Type,
         kPath_Type,
         kText_Type,
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 4d328d1..d8a7f91 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -410,6 +410,17 @@
                         const SkMatrix* localMatrix = NULL);
 
     /**
+     *  Draw a roundrect using a paint.
+     *
+     *  @param paint        describes how to color pixels.
+     *  @param rrect        the roundrect to draw
+     *  @param stroke       the stroke information (width, join, cap)
+     */
+    void drawRRect(const GrPaint& paint,
+                   const SkRRect& rrect,
+                   const SkStrokeRec& stroke);
+
+    /**
      * Draws a path.
      *
      * @param paint         describes how to color pixels.
diff --git a/include/gpu/GrOvalRenderer.h b/include/gpu/GrOvalRenderer.h
index 7e46dac..68e6070 100644
--- a/include/gpu/GrOvalRenderer.h
+++ b/include/gpu/GrOvalRenderer.h
@@ -20,18 +20,20 @@
 class SkStrokeRec;
 
 /*
- * This class wraps helper functions that draw ovals (filled & stroked)
+ * This class wraps helper functions that draw ovals and roundrects (filled & stroked)
  */
 class GrOvalRenderer : public GrRefCnt {
 public:
     SK_DECLARE_INST_COUNT(GrOvalRenderer)
 
-    GrOvalRenderer() {}
-
+    GrOvalRenderer() : fRRectIndexBuffer(NULL) {}
     ~GrOvalRenderer() {}
 
     bool drawOval(GrDrawTarget* target, const GrContext* context, const GrPaint& paint,
                   const GrRect& oval, const SkStrokeRec& stroke);
+    bool drawSimpleRRect(GrDrawTarget* target, GrContext* context, const GrPaint& paint,
+                         const SkRRect& rrect, const SkStrokeRec& stroke);
+
 private:
     bool drawEllipse(GrDrawTarget* target, const GrPaint& paint,
                      const GrRect& ellipse,
@@ -40,6 +42,10 @@
                     const GrRect& circle,
                     const SkStrokeRec& stroke);
 
+    GrIndexBuffer* rRectIndexBuffer(GrGpu* gpu);
+    
+    GrIndexBuffer* fRRectIndexBuffer;
+    
     typedef GrRefCnt INHERITED;
 };
 
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index 8aa7d4a..ab24703 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -73,6 +73,8 @@
                             const SkPoint[], const SkPaint& paint) SK_OVERRIDE;
     virtual void drawRect(const SkDraw&, const SkRect& r,
                           const SkPaint& paint) SK_OVERRIDE;
+    virtual void drawRRect(const SkDraw&, const SkRRect& r,
+                           const SkPaint& paint) SK_OVERRIDE;
     virtual void drawOval(const SkDraw&, const SkRect& oval,
                           const SkPaint& paint) SK_OVERRIDE;
     virtual void drawPath(const SkDraw&, const SkPath& path,