Reverting r12082 (Add bevel-stroke support in GrAARectRenderer) due to GM failures
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 1 Nov 2013 19:22:42 +0000 (19:22 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 1 Nov 2013 19:22:42 +0000 (19:22 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@12091 2bbb7eff-a529-9590-31e7-b0007b416f81

include/gpu/GrContext.h
src/gpu/GrAARectRenderer.cpp
src/gpu/GrAARectRenderer.h
src/gpu/GrContext.cpp
src/gpu/SkGpuDevice.cpp

index f302a44808eba69371f7c67c246a37beda03d9e7..82c440e67cff81a84cb397491582c32fe86573d2 100644 (file)
@@ -396,18 +396,17 @@ public:
     /**
      *  Draw the rect using a paint.
      *  @param paint        describes how to color pixels.
-     *  @param stroke       the stroke information (width, join, cap). 
-     *                      If stroke == NULL, then the rect is filled. 
-     *                      Otherwise, if stroke width == 0, then the stroke
-     *                      is always a single pixel thick, else the rect is 
-     *                      mitered/beveled stroked based on stroke width.
+     *  @param strokeWidth  If strokeWidth < 0, then the rect is filled, else
+     *                      the rect is mitered stroked based on strokeWidth. If
+     *                      strokeWidth == 0, then the stroke is always a single
+     *                      pixel thick.
      *  @param matrix       Optional matrix applied to the rect. Applied before
      *                      context's matrix or the paint's matrix.
      *  The rects coords are used to access the paint (through texture matrix)
      */
     void drawRect(const GrPaint& paint,
                   const SkRect&,
-                  const SkStrokeRec* stroke = NULL,
+                  SkScalar strokeWidth = -1,
                   const SkMatrix* matrix = NULL);
 
     /**
index e3b752db165b19d918948b4be71e50e067d1ce3f..ee7c024fe81aab548e9493dccd3cc721c759e70c 100644 (file)
@@ -289,8 +289,7 @@ static void set_inset_fan(GrPoint* pts, size_t stride,
 
 void GrAARectRenderer::reset() {
     SkSafeSetNull(fAAFillRectIndexBuffer);
-    SkSafeSetNull(fAAMiterStrokeRectIndexBuffer);
-    SkSafeSetNull(fAABevelStrokeRectIndexBuffer);
+    SkSafeSetNull(fAAStrokeRectIndexBuffer);
 }
 
 static const uint16_t gFillAARectIdx[] = {
@@ -341,7 +340,7 @@ GrIndexBuffer* GrAARectRenderer::aaFillRectIndexBuffer(GrGpu* gpu) {
     return fAAFillRectIndexBuffer;
 }
 
-static const uint16_t gMiterStrokeAARectIdx[] = {
+static const uint16_t gStrokeAARectIdx[] = {
     0 + 0, 1 + 0, 5 + 0, 5 + 0, 4 + 0, 0 + 0,
     1 + 0, 2 + 0, 6 + 0, 6 + 0, 5 + 0, 1 + 0,
     2 + 0, 3 + 0, 7 + 0, 7 + 0, 6 + 0, 2 + 0,
@@ -358,98 +357,24 @@ static const uint16_t gMiterStrokeAARectIdx[] = {
     3 + 8, 0 + 8, 4 + 8, 4 + 8, 7 + 8, 3 + 8,
 };
 
-/**
- * As in miter-stroke, index = a + b, and a is the current index, b is the shift
- * from the first index. The index layout:
- * outer AA line: 0~3, 4~7
- * outer edge:    8~11, 12~15
- * inner edge:    16~19
- * inner AA line: 20~23
- * Following comes a bevel-stroke rect and its indices:
- *
- *           4                                 7
- *            ********************************* 
- *          *   ______________________________  *
- *         *  / 12                          15 \  *
- *        *  /                                  \  *
- *     0 *  |8     16_____________________19  11 |  * 3
- *       *  |       |                    |       |  *
- *       *  |       |  ****************  |       |  *
- *       *  |       |  * 20        23 *  |       |  *
- *       *  |       |  *              *  |       |  *
- *       *  |       |  * 21        22 *  |       |  *
- *       *  |       |  ****************  |       |  *
- *       *  |       |____________________|       |  *
- *     1 *  |9    17                      18   10|  * 2
- *        *  \                                  /  * 
- *         *  \13 __________________________14/  *
- *          *                                   *
- *           ********************************** 
- *          5                                  6
- */
-static const uint16_t gBevelStrokeAARectIdx[] = {
-    // Draw outer AA, from outer AA line to outer edge, shift is 0.
-    0 + 0, 1 + 0, 9 + 0, 9 + 0, 8 + 0, 0 + 0,
-    1 + 0, 5 + 0, 13 + 0, 13 + 0, 9 + 0, 1 + 0,
-    5 + 0, 6 + 0, 14 + 0, 14 + 0, 13 + 0, 5 + 0,
-    6 + 0, 2 + 0, 10 + 0, 10 + 0, 14 + 0, 6 + 0,
-    2 + 0, 3 + 0, 11 + 0, 11 + 0, 10 + 0, 2 + 0,
-    3 + 0, 7 + 0, 15 + 0, 15 + 0, 11 + 0, 3 + 0,
-    7 + 0, 4 + 0, 12 + 0, 12 + 0, 15 + 0, 7 + 0,
-    4 + 0, 0 + 0, 8 + 0, 8 + 0, 12 + 0, 4 + 0,
-
-    // Draw the stroke, from outer edge to inner edge, shift is 8.
-    0 + 8, 1 + 8, 9 + 8, 9 + 8, 8 + 8, 0 + 8,
-    1 + 8, 5 + 8, 9 + 8,
-    5 + 8, 6 + 8, 10 + 8, 10 + 8, 9 + 8, 5 + 8,
-    6 + 8, 2 + 8, 10 + 8,
-    2 + 8, 3 + 8, 11 + 8, 11 + 8, 10 + 8, 2 + 8,
-    3 + 8, 7 + 8, 11 + 8,
-    7 + 8, 4 + 8, 8 + 8, 8 + 8, 11 + 8, 7 + 8,
-    4 + 8, 0 + 8, 8 + 8,
-
-    // Draw the inner AA, from inner edge to inner AA line, shift is 16.
-    0 + 16, 1 + 16, 5 + 16, 5 + 16, 4 + 16, 0 + 16,
-    1 + 16, 2 + 16, 6 + 16, 6 + 16, 5 + 16, 1 + 16,
-    2 + 16, 3 + 16, 7 + 16, 7 + 16, 6 + 16, 2 + 16,
-    3 + 16, 0 + 16, 4 + 16, 4 + 16, 7 + 16, 3 + 16,
-};
-
-int GrAARectRenderer::aaStrokeRectIndexCount(bool miterStroke) {
-    return miterStroke ? GR_ARRAY_COUNT(gMiterStrokeAARectIdx) :
-                         GR_ARRAY_COUNT(gBevelStrokeAARectIdx);
+int GrAARectRenderer::aaStrokeRectIndexCount() {
+    return GR_ARRAY_COUNT(gStrokeAARectIdx);
 }
 
-GrIndexBuffer* GrAARectRenderer::aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterStroke) {
-    if (miterStroke) {
-        if (NULL == fAAMiterStrokeRectIndexBuffer) {
-            fAAMiterStrokeRectIndexBuffer =
-                gpu->createIndexBuffer(sizeof(gMiterStrokeAARectIdx), false);
-            if (NULL != fAAMiterStrokeRectIndexBuffer) {
+GrIndexBuffer* GrAARectRenderer::aaStrokeRectIndexBuffer(GrGpu* gpu) {
+    if (NULL == fAAStrokeRectIndexBuffer) {
+        fAAStrokeRectIndexBuffer =
+                  gpu->createIndexBuffer(sizeof(gStrokeAARectIdx), false);
+        if (NULL != fAAStrokeRectIndexBuffer) {
 #ifdef SK_DEBUG
-                bool updated =
+            bool updated =
 #endif
-                fAAMiterStrokeRectIndexBuffer->updateData(gMiterStrokeAARectIdx,
-                                                          sizeof(gMiterStrokeAARectIdx));
-                GR_DEBUGASSERT(updated);
-            }
+            fAAStrokeRectIndexBuffer->updateData(gStrokeAARectIdx,
+                                                 sizeof(gStrokeAARectIdx));
+            GR_DEBUGASSERT(updated);
         }
-        return fAAMiterStrokeRectIndexBuffer;
-    } else {
-        if (NULL == fAABevelStrokeRectIndexBuffer) {
-            fAABevelStrokeRectIndexBuffer =
-                gpu->createIndexBuffer(sizeof(gBevelStrokeAARectIdx), false);
-            if (NULL != fAABevelStrokeRectIndexBuffer) {
-#ifdef SK_DEBUG
-                bool updated =
-#endif
-                fAABevelStrokeRectIndexBuffer->updateData(gBevelStrokeAARectIdx,
-                                                          sizeof(gBevelStrokeAARectIdx));
-                GR_DEBUGASSERT(updated);
-            }
-        }
-        return fAABevelStrokeRectIndexBuffer;
     }
+    return fAAStrokeRectIndexBuffer;
 }
 
 void GrAARectRenderer::geometryFillAARect(GrGpu* gpu,
@@ -728,10 +653,9 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu,
                                     const SkRect& rect,
                                     const SkMatrix& combinedMatrix,
                                     const SkRect& devRect,
-                                    const SkStrokeRec* stroke,
+                                    SkScalar width,
                                     bool useVertexCoverage) {
     GrVec devStrokeSize;
-    SkScalar width = stroke->getWidth();
     if (width > 0) {
         devStrokeSize.set(width, width);
         combinedMatrix.mapVectors(&devStrokeSize, 1);
@@ -772,47 +696,24 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu,
     SkRect devInside(devRect);
     devInside.inset(rx, ry);
 
-    SkRect devOutsideAssist(devRect);
-
-    bool miterStroke = true;
-    // small miter limit means right angles show bevel...
-    if (stroke->getJoin() != SkPaint::kMiter_Join || stroke->getMiter() < SK_ScalarSqrt2) {
-        miterStroke = false;
-    }
-
-    // For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist)
-    // to draw the outer of the rect. Because there are 8 vertices on the outer
-    // edge, while vertex number of inner edge is 4, the same as miter-stroke. 
-    if (!miterStroke) {
-        devOutside.outset(0, rx);
-        devOutsideAssist.outset(0, ry);
-    }
-
-    this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist,
-                               devInside, useVertexCoverage, miterStroke);
+    this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCoverage);
 }
 
 void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
                                             GrDrawTarget* target,
                                             const SkRect& devOutside,
-                                            const SkRect& devOutsideAssist,
                                             const SkRect& devInside,
-                                            bool useVertexCoverage,
-                                            bool miterStroke) {
+                                            bool useVertexCoverage) {
     GrDrawState* drawState = target->drawState();
 
     set_aa_rect_vertex_attributes(drawState, useVertexCoverage);
 
-    int innerVertexNum = 4;
-    int outerVertexNum = miterStroke ? 4 : 8;
-    int totalVertexNum = (outerVertexNum + innerVertexNum) * 2;
-
-    GrDrawTarget::AutoReleaseGeometry geo(target, totalVertexNum, 0);
+    GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0);
     if (!geo.succeeded()) {
         GrPrintf("Failed to get space for vertices!\n");
         return;
     }
-    GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(gpu, miterStroke);
+    GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(gpu);
     if (NULL == indexBuffer) {
         GrPrintf("Failed to create index buffer!\n");
         return;
@@ -826,9 +727,9 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
     // coverage, one on the exterior of the stroke and the other on the interior.
     // The following pointers refer to the four rects, from outermost to innermost.
     GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts);
-    GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + outerVertexNum * vsize);
-    GrPoint* fan2Pos = reinterpret_cast<GrPoint*>(verts + 2 * outerVertexNum * vsize);
-    GrPoint* fan3Pos = reinterpret_cast<GrPoint*>(verts + (2 * outerVertexNum + innerVertexNum) * vsize);
+    GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize);
+    GrPoint* fan2Pos = reinterpret_cast<GrPoint*>(verts + 8 * vsize);
+    GrPoint* fan3Pos = reinterpret_cast<GrPoint*>(verts + 12 * vsize);
 
 #ifndef SK_IGNORE_THIN_STROKED_RECT_FIX
     // TODO: this only really works if the X & Y margins are the same all around
@@ -836,42 +737,23 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
     SkScalar inset = SkMinScalar(SK_Scalar1, devOutside.fRight - devInside.fRight);
     inset = SkMinScalar(inset, devInside.fLeft - devOutside.fLeft);
     inset = SkMinScalar(inset, devInside.fTop - devOutside.fTop);
-    if (miterStroke) {
-        inset = SK_ScalarHalf * SkMinScalar(inset, devOutside.fBottom - devInside.fBottom);
-    } else {
-        inset = SK_ScalarHalf * SkMinScalar(inset, devOutsideAssist.fBottom - devInside.fBottom);
-    }
+    inset = SK_ScalarHalf * SkMinScalar(inset, devOutside.fBottom - devInside.fBottom);
     SkASSERT(inset >= 0);
 #else
     SkScalar inset = SK_ScalarHalf;
 #endif
 
-    if (miterStroke) {
-        // outermost
-        set_inset_fan(fan0Pos, vsize, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
-        // inner two
-        set_inset_fan(fan1Pos, vsize, devOutside,  inset,  inset);
-        set_inset_fan(fan2Pos, vsize, devInside,  -inset, -inset);
-        // innermost
-        set_inset_fan(fan3Pos, vsize, devInside,   SK_ScalarHalf,  SK_ScalarHalf);
-    } else {
-        GrPoint* fan0AssistPos = reinterpret_cast<GrPoint*>(verts + 4 * vsize);
-        GrPoint* fan1AssistPos = reinterpret_cast<GrPoint*>(verts + (outerVertexNum + 4) * vsize);
-        // outermost
-        set_inset_fan(fan0Pos, vsize, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
-        set_inset_fan(fan0AssistPos, vsize, devOutsideAssist, -SK_ScalarHalf, -SK_ScalarHalf);
-        // outer one of the inner two
-        set_inset_fan(fan1Pos, vsize, devOutside,  inset,  inset);
-        set_inset_fan(fan1AssistPos, vsize, devOutsideAssist,  inset,  inset);
-        // inner one of the inner two
-        set_inset_fan(fan2Pos, vsize, devInside,  -inset, -inset);
-        // innermost
-        set_inset_fan(fan3Pos, vsize, devInside,   SK_ScalarHalf,  SK_ScalarHalf);
-    }
+    // outermost
+    set_inset_fan(fan0Pos, vsize, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
+    // inner two
+    set_inset_fan(fan1Pos, vsize, devOutside,  inset,  inset);
+    set_inset_fan(fan2Pos, vsize, devInside,  -inset, -inset);
+    // innermost
+    set_inset_fan(fan3Pos, vsize, devInside,   SK_ScalarHalf,  SK_ScalarHalf);
 
     // The outermost rect has 0 coverage
     verts += sizeof(GrPoint);
-    for (int i = 0; i < outerVertexNum; ++i) {
+    for (int i = 0; i < 4; ++i) {
         *reinterpret_cast<GrColor*>(verts + i * vsize) = 0;
     }
 
@@ -895,20 +777,20 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
         }
     }
 
-    verts += outerVertexNum * vsize;
-    for (int i = 0; i < outerVertexNum + innerVertexNum; ++i) {
+    verts += 4 * vsize;
+    for (int i = 0; i < 8; ++i) {
         *reinterpret_cast<GrColor*>(verts + i * vsize) = innerColor;
     }
 
     // The innermost rect has 0 coverage
-    verts += (2 * outerVertexNum + innerVertexNum) * vsize;
-    for (int i = 0; i < innerVertexNum; ++i) {
+    verts += 8 * vsize;
+    for (int i = 0; i < 4; ++i) {
         *reinterpret_cast<GrColor*>(verts + i * vsize) = 0;
     }
 
     target->setIndexSourceToBuffer(indexBuffer);
-    target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0,
-                        totalVertexNum, aaStrokeRectIndexCount(miterStroke));
+    target->drawIndexed(kTriangles_GrPrimitiveType,
+                        0, 0, 16, aaStrokeRectIndexCount());
 }
 
 void GrAARectRenderer::fillAANestedRects(GrGpu* gpu,
@@ -919,7 +801,7 @@ void GrAARectRenderer::fillAANestedRects(GrGpu* gpu,
     SkASSERT(combinedMatrix.rectStaysRect());
     SkASSERT(!rects[1].isEmpty());
 
-    SkRect devOutside, devOutsideAssist, devInside;
+    SkRect devOutside, devInside;
     combinedMatrix.mapRect(&devOutside, rects[0]);
     // can't call mapRect for devInside since it calls sort
     combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2);
@@ -929,6 +811,5 @@ void GrAARectRenderer::fillAANestedRects(GrGpu* gpu,
         return;
     }
 
-    this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist,
-                               devInside, useVertexCoverage, true);
+    this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCoverage);
 }
index 3e7e980e59371c6e3fa2043f6ee0ae33e79cb5c5..2e705ca80191e958c4fa139e8745aea7c35bdd9a 100644 (file)
@@ -11,7 +11,6 @@
 #include "SkMatrix.h"
 #include "SkRect.h"
 #include "SkRefCnt.h"
-#include "SkStrokeRec.h"
 
 class GrGpu;
 class GrDrawTarget;
@@ -26,8 +25,7 @@ public:
 
     GrAARectRenderer()
     : fAAFillRectIndexBuffer(NULL)
-    , fAAMiterStrokeRectIndexBuffer(NULL)
-    , fAABevelStrokeRectIndexBuffer(NULL) {
+    , fAAStrokeRectIndexBuffer(NULL) {
     }
 
     void reset();
@@ -37,7 +35,7 @@ public:
     }
 
     // TODO: potentialy fuse the fill & stroke methods and differentiate
-    // between them by passing in stroke (==NULL means fill).
+    // between them by passing in strokeWidth (<0 means fill).
 
     void fillAARect(GrGpu* gpu,
                     GrDrawTarget* target,
@@ -65,7 +63,7 @@ public:
                       const SkRect& rect,
                       const SkMatrix& combinedMatrix,
                       const SkRect& devRect,
-                      const SkStrokeRec* stroke,
+                      SkScalar width,
                       bool useVertexCoverage);
 
     // First rect is outer; second rect is inner
@@ -77,13 +75,12 @@ public:
 
 private:
     GrIndexBuffer*              fAAFillRectIndexBuffer;
-    GrIndexBuffer*              fAAMiterStrokeRectIndexBuffer;
-    GrIndexBuffer*              fAABevelStrokeRectIndexBuffer;
+    GrIndexBuffer*              fAAStrokeRectIndexBuffer;
 
     GrIndexBuffer* aaFillRectIndexBuffer(GrGpu* gpu);
 
-    static int aaStrokeRectIndexCount(bool miterStroke);
-    GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterStroke);
+    static int aaStrokeRectIndexCount();
+    GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu);
 
     // TODO: Remove the useVertexCoverage boolean. Just use it all the time
     // since we now have a coverage vertex attribute
@@ -107,10 +104,8 @@ private:
     void geometryStrokeAARect(GrGpu* gpu,
                               GrDrawTarget* target,
                               const SkRect& devOutside,
-                              const SkRect& devOutsideAssist,
                               const SkRect& devInside,
-                              bool useVertexCoverage,
-                              bool miterStroke);
+                              bool useVertexCoverage);
 
     typedef SkRefCnt INHERITED;
 };
index b0d34fd03933af6e531ca3b4ae78fbd723477cc7..65d1fe9de64b4b1a51c94276e4c0a21ab15fd264 100644 (file)
@@ -795,7 +795,7 @@ static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
 
 void GrContext::drawRect(const GrPaint& paint,
                          const SkRect& rect,
-                         const SkStrokeRec* stroke,
+                         SkScalar width,
                          const SkMatrix* matrix) {
     SK_TRACE_EVENT0("GrContext::drawRect");
 
@@ -803,7 +803,6 @@ void GrContext::drawRect(const GrPaint& paint,
     AutoCheckFlush acf(this);
     GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
 
-    SkScalar width = stroke == NULL ? -1 : stroke->getWidth();
     SkMatrix combinedMatrix = target->drawState()->getViewMatrix();
     if (NULL != matrix) {
         combinedMatrix.preConcat(*matrix);
@@ -856,9 +855,9 @@ void GrContext::drawRect(const GrPaint& paint,
             return;
         }
         if (width >= 0) {
-            fAARectRenderer->strokeAARect(this->getGpu(), target, rect,
-                                          combinedMatrix, devBoundRect,
-                                          stroke, useVertexCoverage);
+            fAARectRenderer->strokeAARect(this->getGpu(), target,
+                                          rect, combinedMatrix, devBoundRect,
+                                          width, useVertexCoverage);
         } else {
             // filled AA rect
             fAARectRenderer->fillAARect(this->getGpu(), target,
index 0f4b93140ef2ef902164595ba62074b2d62fd786..4041c411fc1391618b5238c3c85ddd83c13461c3 100644 (file)
@@ -613,11 +613,11 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
     SkScalar width = paint.getStrokeWidth();
 
     /*
-        We have special code for hairline strokes, miter-strokes, bevel-stroke
-        and fills. Anything else we just call our path code.
+        We have special code for hairline strokes, miter-strokes, and fills.
+        Anything else we just call our path code.
      */
     bool usePath = doStroke && width > 0 &&
-                    paint.getStrokeJoin() == SkPaint::kRound_Join;
+                    paint.getStrokeJoin() != SkPaint::kMiter_Join;
     // another two reasons we might need to call drawPath...
     if (paint.getMaskFilter() || paint.getPathEffect()) {
         usePath = true;
@@ -633,6 +633,12 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
         }
 #endif
     }
+    // small miter limit means right angles show bevel...
+    if (SkPaint::kMiter_Join == paint.getStrokeJoin() &&
+        paint.getStrokeMiter() < SK_ScalarSqrt2)
+    {
+        usePath = true;
+    }
     // until we can both stroke and fill rectangles
     if (paint.getStyle() == SkPaint::kStrokeAndFill_Style) {
         usePath = true;
@@ -649,13 +655,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
     if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
         return;
     }
-
-    if (!doStroke) {
-        fContext->drawRect(grPaint, rect);
-    } else {
-        SkStrokeRec stroke(paint);
-        fContext->drawRect(grPaint, rect, &stroke);
-    }
+    fContext->drawRect(grPaint, rect, doStroke ? width : -1);
 }
 
 ///////////////////////////////////////////////////////////////////////////////