Move GrStrokeRectBatch creation to behind factory
authorjoshualitt <joshualitt@chromium.org>
Mon, 10 Aug 2015 17:30:14 +0000 (10:30 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 10 Aug 2015 17:30:14 +0000 (10:30 -0700)
BUG=skia:

Review URL: https://codereview.chromium.org/1282283002

src/gpu/GrDrawContext.cpp
src/gpu/GrDrawTarget.cpp
src/gpu/batches/GrRectBatchFactory.cpp
src/gpu/batches/GrRectBatchFactory.h

index c67f6f48bff07d0057921eccf9dfbe51e6781253..f86e7834f0dc06bec6bda1ccfab5879fa71189dc 100644 (file)
@@ -20,7 +20,7 @@
 #include "batches/GrBatch.h"
 #include "batches/GrDrawAtlasBatch.h"
 #include "batches/GrDrawVerticesBatch.h"
-#include "batches/GrStrokeRectBatch.h"
+#include "batches/GrRectBatchFactory.h"
 
 #include "SkGr.h"
 #include "SkRSXform.h"
@@ -329,15 +329,10 @@ void GrDrawContext::drawRect(GrRenderTarget* rt,
     }
 
     if (width >= 0) {
-        GrStrokeRectBatch::Geometry geometry;
-        geometry.fViewMatrix = viewMatrix;
-        geometry.fColor = color;
-        geometry.fRect = rect;
-        geometry.fStrokeWidth = width;
-
         // Non-AA hairlines are snapped to pixel centers to make which pixels are hit deterministic
         bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled());
-        SkAutoTUnref<GrBatch> batch(GrStrokeRectBatch::Create(geometry, snapToPixelCenters));
+        SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateStrokeBW(color, viewMatrix, rect,
+                                                                       width, snapToPixelCenters));
 
         // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of
         // hairline rects. We jam all the vertices to pixel centers to avoid this, but not when MSAA
index c2a9eb0aa727ab992987e821424e11f70fd096cc..07dae0282495a5d2458241f47c1c716d9c7720cd 100644 (file)
@@ -294,8 +294,8 @@ void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
                               const SkRect& rect,
                               const SkRect* localRect,
                               const SkMatrix* localMatrix) {
-   SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::Create(color, viewMatrix, rect, localRect,
-                                                          localMatrix));
+   SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect, localRect,
+                                                                localMatrix));
    this->drawBatch(pipelineBuilder, batch);
 }
 
index b41561209e1c19239d4f35a37aa7df34dc6bba82..e2597d2a66e2bfcc16cdd4fba59e529168b34abf 100644 (file)
@@ -8,14 +8,15 @@
 #include "GrRectBatchFactory.h"
 
 #include "GrRectBatch.h"
+#include "GrStrokeRectBatch.h"
 
 namespace GrRectBatchFactory {
 
-GrBatch* Create(GrColor color,
-                const SkMatrix& viewMatrix,
-                const SkRect& rect,
-                const SkRect* localRect,
-                const SkMatrix* localMatrix) {
+GrBatch* CreateFillBW(GrColor color,
+                      const SkMatrix& viewMatrix,
+                      const SkRect& rect,
+                      const SkRect* localRect,
+                      const SkMatrix* localMatrix) {
     GrRectBatch::Geometry geometry;
     geometry.fColor = color;
     geometry.fViewMatrix = viewMatrix;
@@ -38,4 +39,17 @@ GrBatch* Create(GrColor color,
     return GrRectBatch::Create(geometry);
 }
 
+GrBatch* CreateStrokeBW(GrColor color,
+                        const SkMatrix& viewMatrix,
+                        const SkRect& rect,
+                        SkScalar strokeWidth,
+                        bool snapToPixelCenters) {
+    GrStrokeRectBatch::Geometry geometry;
+    geometry.fColor = color;
+    geometry.fViewMatrix = viewMatrix;
+    geometry.fRect = rect;
+    geometry.fStrokeWidth = strokeWidth;
+    return GrStrokeRectBatch::Create(geometry, snapToPixelCenters);
+}
+
 };
index 33ecf917d044aa23fbe4717ed25533b131feaa97..70ceac2c397b1a1e533308bbcf22fdbeaca1d9aa 100644 (file)
@@ -20,11 +20,17 @@ struct SkRect;
  */
 namespace GrRectBatchFactory {
 
-GrBatch* Create(GrColor color,
-                const SkMatrix& viewMatrix,
-                const SkRect& rect,
-                const SkRect* localRect,
-                const SkMatrix* localMatrix);
+GrBatch* CreateFillBW(GrColor color,
+                      const SkMatrix& viewMatrix,
+                      const SkRect& rect,
+                      const SkRect* localRect,
+                      const SkMatrix* localMatrix);
+
+GrBatch* CreateStrokeBW(GrColor color,
+                        const SkMatrix& viewMatrix,
+                        const SkRect& rect,
+                        SkScalar strokeWidth,
+                        bool snapToPixelCenters);
 
 };