Move GrPipelineBuilder out of gms & reduce use of GrPipelineBuilder.h
authorrobertphillips <robertphillips@google.com>
Thu, 23 Jun 2016 21:07:00 +0000 (14:07 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 23 Jun 2016 21:07:00 +0000 (14:07 -0700)
Just another step in reining in the GrPLB

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2086293006

Review-Url: https://codereview.chromium.org/2086293006

23 files changed:
gm/beziereffects.cpp
gm/bigrrectaaeffect.cpp
gm/constcolorprocessor.cpp
gm/convexpolyeffect.cpp
gm/dcshader.cpp
gm/rrects.cpp
gm/texturedomaineffect.cpp
gm/yuvtorgbeffect.cpp
src/gpu/GrClipMaskManager.h
src/gpu/GrDrawContextPriv.h
src/gpu/GrDrawTarget.h
src/gpu/GrGpu.h
src/gpu/GrGpuCommandBuffer.cpp
src/gpu/GrPipeline.h
src/gpu/GrResourceCache.cpp
src/gpu/GrSWMaskHelper.h
src/gpu/GrTextureParamsAdjuster.cpp
src/gpu/GrTextureProvider.cpp
src/gpu/GrXferProcessor.cpp
src/gpu/glsl/GrGLSLProgramBuilder.h
tests/GLProgramsTest.cpp
tests/PrimitiveProcessorTest.cpp
tools/gpu/GrTest.cpp

index ae1c37fdf6031ecd5a987c97c6b0bf2bd2be2e85..0c568d09f5b3ecf6201f2a6580bb689bb29a88c8 100644 (file)
@@ -188,14 +188,13 @@ protected:
                     boundsPaint.setStyle(SkPaint::kStroke_Style);
                     canvas->drawRect(bounds, boundsPaint);
 
-                    GrPipelineBuilder pipelineBuilder;
-                    pipelineBuilder.setXPFactory(
-                        GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+                    GrPaint grPaint;
+                    grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
 
                     SkAutoTUnref<GrDrawBatch> batch(
                         new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, klmSigns[c]));
 
-                    drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                    drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
                 }
                 ++col;
                 if (numCols == col) {
@@ -320,14 +319,13 @@ protected:
                     boundsPaint.setStyle(SkPaint::kStroke_Style);
                     canvas->drawRect(bounds, boundsPaint);
 
-                    GrPipelineBuilder pipelineBuilder;
-                    pipelineBuilder.setXPFactory(
-                        GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+                    GrPaint grPaint;
+                    grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
 
                     SkAutoTUnref<GrDrawBatch> batch(
                         new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, 1.f));
 
-                    drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                    drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
                 }
                 ++col;
                 if (numCols == col) {
@@ -527,16 +525,15 @@ protected:
                     boundsPaint.setStyle(SkPaint::kStroke_Style);
                     canvas->drawRect(bounds, boundsPaint);
 
-                    GrPipelineBuilder pipelineBuilder;
-                    pipelineBuilder.setXPFactory(
-                        GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+                    GrPaint grPaint;
+                    grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
 
                     GrPathUtils::QuadUVMatrix DevToUV(pts);
 
                     SkAutoTUnref<GrDrawBatch> batch(
                         new BezierQuadTestBatch(gp, bounds, color, DevToUV));
 
-                    drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                    drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
                 }
                 ++col;
                 if (numCols == col) {
index 924704a5acec1dbfbf9bb78dae9d77e79b0faced..7f79a34c6bf62434de74d0d896440fd8fc6fa81e 100644 (file)
@@ -9,7 +9,6 @@
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
 #include "GrDrawContextPriv.h"
-#include "GrPipelineBuilder.h"
 #include "SkRRect.h"
 #include "batches/GrDrawBatch.h"
 #include "batches/GrRectBatchFactory.h"
@@ -74,15 +73,15 @@ protected:
                 paint.setColor(SK_ColorWHITE);
                 canvas->drawRect(testBounds, paint);
 
-                GrPipelineBuilder pipelineBuilder;
-                pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+                GrPaint grPaint;
+                grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
 
                 SkRRect rrect = fRRect;
                 rrect.offset(SkIntToScalar(x + kGap), SkIntToScalar(y + kGap));
                 sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrect));
                 SkASSERT(fp);
                 if (fp) {
-                    pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
+                    grPaint.addCoverageFragmentProcessor(std::move(fp));
 
                     SkRect bounds = testBounds;
                     bounds.offset(SkIntToScalar(x), SkIntToScalar(y));
@@ -90,7 +89,7 @@ protected:
                     SkAutoTUnref<GrDrawBatch> batch(
                             GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(), bounds,
                                                                 nullptr, nullptr));
-                    drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                    drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
                 }
             canvas->restore();
             x = x + fTestOffsetX;
index 8ae93a4ae929f62f8b8eab90f58371c5244bf950..32d03a0c02563ba2fed9d5cf56db9e4e9a4f1f8b 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "GrContext.h"
 #include "GrDrawContextPriv.h"
-#include "GrPipelineBuilder.h"
 #include "SkGrPriv.h"
 #include "SkGradientShader.h"
 #include "batches/GrDrawBatch.h"
@@ -107,13 +106,12 @@ protected:
                     GrColor color = kColors[procColor];
                     sk_sp<GrFragmentProcessor> fp(GrConstColorProcessor::Make(color, mode));
 
-                    GrPipelineBuilder pipelineBuilder(grPaint, drawContext->mustUseHWAA(grPaint));
-                    pipelineBuilder.addColorFragmentProcessor(std::move(fp));
+                    grPaint.addColorFragmentProcessor(std::move(fp));
 
                     SkAutoTUnref<GrDrawBatch> batch(
                             GrRectBatchFactory::CreateNonAAFill(grPaint.getColor(), viewMatrix,
                                                                 renderRect, nullptr, nullptr));
-                    drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                    drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
 
                     // Draw labels for the input to the processor and the processor to the right of
                     // the test rect. The input label appears above the processor label.
index 3f8ae09a1afeceb0e29bceffc6e7bef4b286ed09..a5c290456658f0294008616d42fafb88eee5a95a 100644 (file)
@@ -178,13 +178,13 @@ protected:
                     continue;
                 }
 
-                GrPipelineBuilder pipelineBuilder;
-                pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
-                pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
+                GrPaint grPaint;
+                grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+                grPaint.addCoverageFragmentProcessor(std::move(fp));
 
                 SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(p.getBounds(), 0xff000000));
 
-                drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
 
                 x += SkScalarCeilToScalar(path->getBounds().width() + kDX);
             }
@@ -217,13 +217,13 @@ protected:
                     continue;
                 }
 
-                GrPipelineBuilder pipelineBuilder;
-                pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
-                pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
+                GrPaint grPaint;
+                grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+                grPaint.addCoverageFragmentProcessor(std::move(fp));
 
                 SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(rect, 0xff000000));
 
-                drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
 
                 x += SkScalarCeilToScalar(rect.width() + kDX);
             }
index 2b179a0a1fc639680b4a2eea6d5115a848cb2fd3..3ed6dc1296657197b642671e4ad6674cff09b0d3 100644 (file)
@@ -9,6 +9,7 @@
 #if SK_SUPPORT_GPU
 #include "GrFragmentProcessor.h"
 #include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
 #include "effects/GrXfermodeFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
index e104aea4335259769f08d5f90c871f91ba9f9443..0f3ac56fec59c2f38e36467f787190459935cb09 100644 (file)
@@ -101,16 +101,15 @@ protected:
                     canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
                     if (kEffect_Type == fType) {
 #if SK_SUPPORT_GPU
-                        GrPipelineBuilder pipelineBuilder;
-                        pipelineBuilder.setXPFactory(
-                            GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+                        GrPaint grPaint;
+                        grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
 
                         SkRRect rrect = fRRects[curRRect];
                         rrect.offset(SkIntToScalar(x), SkIntToScalar(y));
                         GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
                         sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrect));
                         if (fp) {
-                            pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
+                            grPaint.addCoverageFragmentProcessor(std::move(fp));
 
                             SkRect bounds = rrect.getBounds();
                             bounds.outset(2.f, 2.f);
@@ -118,8 +117,7 @@ protected:
                             SkAutoTUnref<GrDrawBatch> batch(
                                     GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(),
                                                                         bounds, nullptr, nullptr));
-                            drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder,
-                                                                                 batch);
+                            drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
                         } else {
                             drew = false;
                         }
index cac2b9c8d5c9448f6819d07e4ffca4ffb740ccca..3680006cc5fad3b4ab241f3303a4c7edebd9de72 100644 (file)
@@ -112,9 +112,8 @@ protected:
                 SkScalar x = kDrawPad + kTestPad;
                 for (int m = 0; m < GrTextureDomain::kModeCount; ++m) {
                     GrTextureDomain::Mode mode = (GrTextureDomain::Mode) m;
-                    GrPipelineBuilder pipelineBuilder;
-                    pipelineBuilder.setXPFactory(
-                        GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+                    GrPaint grPaint;
+                    grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
                     sk_sp<GrFragmentProcessor> fp(
                         GrTextureDomainEffect::Make(texture, textureMatrices[tm],
                                                 GrTextureDomain::MakeTexelDomain(texture,
@@ -125,12 +124,12 @@ protected:
                         continue;
                     }
                     const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
-                    pipelineBuilder.addColorFragmentProcessor(std::move(fp));
+                    grPaint.addColorFragmentProcessor(std::move(fp));
 
                     SkAutoTUnref<GrDrawBatch> batch(
                             GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
                                                                 renderRect, nullptr, nullptr));
-                    drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                    drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
                     x += renderRect.width() + kTestPad;
                 }
                 y += renderRect.height() + kTestPad;
index a153c991fc548c1ff298f17a6edf299ab833f9ad..0be30088c8fbb0452f4e91a869c27a946bac39c7 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "GrContext.h"
 #include "GrDrawContextPriv.h"
-#include "GrPipelineBuilder.h"
 #include "SkBitmap.h"
 #include "SkGr.h"
 #include "SkGradientShader.h"
@@ -113,19 +112,19 @@ protected:
                                        {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
 
             for (int i = 0; i < 6; ++i) {
-                GrPipelineBuilder pipelineBuilder;
-                pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+                GrPaint grPaint;
+                grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
                 sk_sp<GrFragmentProcessor> fp(GrYUVEffect::MakeYUVToRGB(
                     texture[indices[i][0]], texture[indices[i][1]], texture[indices[i][2]], sizes,
                     static_cast<SkYUVColorSpace>(space), false));
                 if (fp) {
                     SkMatrix viewMatrix;
                     viewMatrix.setTranslate(x, y);
-                    pipelineBuilder.addColorFragmentProcessor(std::move(fp));
+                    grPaint.addColorFragmentProcessor(std::move(fp));
                     SkAutoTUnref<GrDrawBatch> batch(
                             GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
                                                                 renderRect, nullptr, nullptr));
-                    drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                    drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
                 }
                 x += renderRect.width() + kTestPad;
             }
@@ -225,18 +224,18 @@ protected:
             SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset;
             SkScalar x = kDrawPad + kTestPad;
 
-            GrPipelineBuilder pipelineBuilder;
-            pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+            GrPaint grPaint;
+            grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
             sk_sp<GrFragmentProcessor> fp(
                 GrYUVEffect::MakeYUVToRGB(texture[0], texture[1], texture[2], sizes,
                                           static_cast<SkYUVColorSpace>(space), true));
             if (fp) {
                 SkMatrix viewMatrix;
                 viewMatrix.setTranslate(x, y);
-                pipelineBuilder.addColorFragmentProcessor(fp);
+                grPaint.addColorFragmentProcessor(fp);
                 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(
                     GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr));
-                drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+                drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
             }
         }
     }
index 0c71f7c384d0249dc10c5c420c346cb59e09810b..948ae62d776ea3fba86bbb285ffbffefac6a559a 100644 (file)
@@ -7,20 +7,24 @@
 #ifndef GrClipMaskManager_DEFINED
 #define GrClipMaskManager_DEFINED
 
-#include "GrPipelineBuilder.h"
 #include "GrReducedClip.h"
 #include "SkClipStack.h"
 #include "SkTypes.h"
 
 class GrAppliedClip;
 class GrClipStackClip;
+class GrContext;
 class GrDrawContext;
 class GrFixedClip;
 class GrPathRenderer;
 class GrPathRendererChain;
+class GrPipelineBuilder;
 class GrResourceProvider;
 class GrTexture;
 class GrTextureProvider;
+class GrUniqueKey;
+struct GrUserStencilSettings;
+
 
 /**
  * The clip mask creator handles the generation of the clip mask. If anti
index 0641e9f2b5032ee786f4dfdc5cc7137b09edee51..8087bcf58827ec91f2a7a6dc27f7974128209963 100644 (file)
@@ -50,9 +50,10 @@ public:
                             const SkMatrix& viewMatrix,
                             const SkPath&);
 
-    void testingOnly_drawBatch(const GrPipelineBuilder& pipelineBuilder,
+    void testingOnly_drawBatch(const GrPaint&,
                                GrDrawBatch* batch,
-                               const GrClip* = nullptr);
+                               const GrUserStencilSettings* = nullptr,
+                               bool snapToCenters = false);
 
 private:
     explicit GrDrawContextPriv(GrDrawContext* drawContext) : fDrawContext(drawContext) {}
index d43a930d1be36f953fdd375b5996f300928ad552..64c8a3345ce43c7033aa0f1e639641652f95fb56 100644 (file)
@@ -13,7 +13,6 @@
 #include "GrPathProcessor.h"
 #include "GrPrimitiveProcessor.h"
 #include "GrPathRendering.h"
-#include "GrPipelineBuilder.h"
 #include "GrXferProcessor.h"
 
 #include "batches/GrDrawBatch.h"
@@ -36,6 +35,7 @@ class GrClip;
 class GrCaps;
 class GrPath;
 class GrDrawPathBatchBase;
+class GrPipelineBuilder;
 
 class GrDrawTarget final : public SkRefCnt {
 public:
index f8528a1550ac60ed45599af95b4a3869fedad43b..5164b71f6918e51eaca0f822a74520c432a7f025 100644 (file)
@@ -9,7 +9,6 @@
 #define GrGpu_DEFINED
 
 #include "GrGpuCommandBuffer.h"
-#include "GrPipelineBuilder.h"
 #include "GrProgramDesc.h"
 #include "GrSwizzle.h"
 #include "GrAllocator.h"
@@ -22,6 +21,7 @@
 class GrBatchTracker;
 class GrBuffer;
 class GrContext;
+struct GrContextOptions;
 class GrGLContext;
 class GrMesh;
 class GrNonInstancedVertices;
index f79cb0f1e61506981c0306dd73342ae642505338..af0993e033133c4336b493e0b922d65ec36bcdeb 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "GrGpuCommandBuffer.h"
 
+#include "GrCaps.h"
 #include "GrGpu.h"
 #include "GrPrimitiveProcessor.h"
 #include "GrRenderTarget.h"
index 3fd70a38300a26e76e02037ff4c555a955066152..a17eb098cf4bc1edc046aaaf7c7ba775f84ef0fa 100644 (file)
@@ -13,7 +13,9 @@
 #include "GrGpu.h"
 #include "GrNonAtomicRef.h"
 #include "GrPendingProgramElement.h"
+#include "GrPipelineBuilder.h"
 #include "GrPrimitiveProcessor.h"
+#include "GrProcOptInfo.h"
 #include "GrProgramDesc.h"
 #include "GrStencilSettings.h"
 #include "GrTypesPriv.h"
index db97e35d7d938987351546b05b469c475e51e38c..71e40f1a5364fff5f31919231d527de982f1bb07 100644 (file)
@@ -7,6 +7,8 @@
 
 
 #include "GrResourceCache.h"
+
+#include "GrCaps.h"
 #include "GrGpuResourceCacheAccess.h"
 #include "GrTracing.h"
 #include "SkChecksum.h"
index fac4e6287eea5430fa49d8a13b49b2dc3a0a6a7f..107c77ef595b3fff585987d127733993b818e644 100644 (file)
@@ -10,7 +10,6 @@
 
 #include "SkAutoPixmapStorage.h"
 #include "GrColor.h"
-#include "GrPipelineBuilder.h"
 #include "SkBitmap.h"
 #include "SkDraw.h"
 #include "SkMatrix.h"
 #include "SkTypes.h"
 
 class GrClip;
+class GrPaint;
 class GrTextureProvider;
+class GrStyle;
 class GrTexture;
 class SkPath;
 class SkStrokeRec;
+struct GrUserStencilSettings;
 
 /**
  * The GrSWMaskHelper helps generate clip masks using the software rendering
index 1657fb9b95ca5474bae0c635bc1ad728669733a0..77743916c5918008402db921864dc1059c9db5ef 100644 (file)
@@ -20,6 +20,7 @@
 #include "SkGr.h"
 #include "SkGrPriv.h"
 #include "effects/GrBicubicEffect.h"
+#include "effects/GrSimpleTextureEffect.h"
 #include "effects/GrTextureDomain.h"
 
 typedef GrTextureProducer::CopyParams CopyParams;
index 69792ede81439aa17e0db153b608686b9d4bd248..00494da5a1194a088de10a5b44f66cd3e65b5b53 100644 (file)
@@ -6,6 +6,8 @@
  */
 
 #include "GrTextureProvider.h"
+
+#include "GrCaps.h"
 #include "GrTexturePriv.h"
 #include "GrResourceCache.h"
 #include "GrGpu.h"
index 910b873e861aa42a893da1cb2302ca03b2913a76..76e0ba0fc491198d4fd14776737849dd0f6f2051 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "GrXferProcessor.h"
 #include "GrPipeline.h"
-#include "GrPipelineBuilder.h"
 #include "GrProcOptInfo.h"
 #include "gl/GrGLCaps.h"
 
index c175fc6adf6e575db7de71e4cb6ac14c714f1ab8..27c84372c1aeaaddab852f5122f9d39a3be8b611 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "GrGeometryProcessor.h"
 #include "GrGpu.h"
+#include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "glsl/GrGLSLGeometryShaderBuilder.h"
 #include "glsl/GrGLSLPrimitiveProcessor.h"
index 7ce71c66377290a65f077a7a5a7debe8eddc13d8..171ed613163a2993a113cebc5dc3e2839e100f44 100644 (file)
@@ -184,10 +184,10 @@ static sk_sp<GrDrawContext> random_draw_context(GrContext* context,
     return drawContext;
 }
 
-static void set_random_xpf(GrPipelineBuilder* pipelineBuilder, GrProcessorTestData* d) {
+static void set_random_xpf(GrPaint* paint, GrProcessorTestData* d) {
     sk_sp<GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Make(d));
     SkASSERT(xpf);
-    pipelineBuilder->setXPFactory(std::move(xpf));
+    paint->setXPFactory(std::move(xpf));
 }
 
 static sk_sp<GrFragmentProcessor> create_random_proc_tree(GrProcessorTestData* d,
@@ -236,8 +236,9 @@ static sk_sp<GrFragmentProcessor> create_random_proc_tree(GrProcessorTestData* d
     return fp;
 }
 
-static void set_random_color_coverage_stages(GrPipelineBuilder* pipelineBuilder,
-                                             GrProcessorTestData* d, int maxStages) {
+static void set_random_color_coverage_stages(GrPaint* paint,
+                                             GrProcessorTestData* d,
+                                             int maxStages) {
     // Randomly choose to either create a linear pipeline of procs or create one proc tree
     const float procTreeProbability = 0.5f;
     if (d->fRandom->nextF() < procTreeProbability) {
@@ -245,7 +246,7 @@ static void set_random_color_coverage_stages(GrPipelineBuilder* pipelineBuilder,
         // processor key; maxTreeLevels should be a number from 1 to 4 inclusive.
         const int maxTreeLevels = 4;
         sk_sp<GrFragmentProcessor> fp(create_random_proc_tree(d, 2, maxTreeLevels));
-        pipelineBuilder->addColorFragmentProcessor(std::move(fp));
+        paint->addColorFragmentProcessor(std::move(fp));
     } else {
         int numProcs = d->fRandom->nextULessThan(maxStages + 1);
         int numColorProcs = d->fRandom->nextULessThan(numProcs + 1);
@@ -256,32 +257,30 @@ static void set_random_color_coverage_stages(GrPipelineBuilder* pipelineBuilder,
 
             // finally add the stage to the correct pipeline in the drawstate
             if (s < numColorProcs) {
-                pipelineBuilder->addColorFragmentProcessor(std::move(fp));
+                paint->addColorFragmentProcessor(std::move(fp));
             } else {
-                pipelineBuilder->addCoverageFragmentProcessor(std::move(fp));
+                paint->addCoverageFragmentProcessor(std::move(fp));
             }
             ++s;
         }
     }
 }
 
-static void set_random_state(GrPipelineBuilder* pipelineBuilder,
-                             GrDrawContext* drawContext,
-                             SkRandom* random) {
-    int state = 0;
-    for (int i = 1; i <= GrPipelineBuilder::kLast_Flag; i <<= 1) {
-        state |= random->nextBool() * i;
+static bool set_random_state(GrPaint* paint, SkRandom* random) {
+    if (random->nextBool()) {
+        paint->setDisableOutputConversionToSRGB(true);
     }
-
-    // If we don't have an MSAA rendertarget then we have to disable useHWAA
-    if ((state | GrPipelineBuilder::kHWAntialias_Flag) && !drawContext->isUnifiedMultisampled()) {
-        state &= ~GrPipelineBuilder::kHWAntialias_Flag;
+    if (random->nextBool()) {
+        paint->setAllowSRGBInputs(true);
+    }
+    if (random->nextBool()) {
+        paint->setAntiAlias(true);
     }
-    pipelineBuilder->enableState(state);
+    return random->nextBool();
 }
 
 // right now, the only thing we seem to care about in drawState's stencil is 'doesWrite()'
-static void set_random_stencil(GrPipelineBuilder* pipelineBuilder, SkRandom* random) {
+static const GrUserStencilSettings* get_random_stencil(SkRandom* random) {
     static constexpr GrUserStencilSettings kDoesWriteStencil(
         GrUserStencilSettings::StaticInit<
             0xffff,
@@ -302,9 +301,9 @@ static void set_random_stencil(GrPipelineBuilder* pipelineBuilder, SkRandom* ran
     );
 
     if (random->nextBool()) {
-        pipelineBuilder->setUserStencil(&kDoesWriteStencil);
+        return &kDoesWriteStencil;
     } else {
-        pipelineBuilder->setUserStencil(&kDoesNotWriteStencil);
+        return &kDoesNotWriteStencil;
     }
 }
 
@@ -346,19 +345,19 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
             return false;
         }
 
-        GrPipelineBuilder pipelineBuilder;
+        GrPaint grPaint;
 
         SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context));
         SkASSERT(batch);
 
         GrProcessorTestData ptd(&random, context, context->caps(),
                                 drawContext.get(), dummyTextures);
-        set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages);
-        set_random_xpf(&pipelineBuilder, &ptd);
-        set_random_state(&pipelineBuilder, drawContext.get(), &random);
-        set_random_stencil(&pipelineBuilder, &random);
+        set_random_color_coverage_stages(&grPaint, &ptd, maxStages);
+        set_random_xpf(&grPaint, &ptd);
+        bool snapToCenters = set_random_state(&grPaint, &random);
+        const GrUserStencilSettings* uss = get_random_stencil(&random);
 
-        drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, batch);
+        drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch, uss, snapToCenters);
     }
     // Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes)
     drawingManager->flush();
@@ -381,16 +380,16 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
             SkASSERT(batch);
             GrProcessorTestData ptd(&random, context, context->caps(),
                                     drawContext.get(), dummyTextures);
-            GrPipelineBuilder builder;
-            builder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
+            GrPaint grPaint;
+            grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
 
             sk_sp<GrFragmentProcessor> fp(
                 GrProcessorTestFactory<GrFragmentProcessor>::MakeIdx(i, &ptd));
             sk_sp<GrFragmentProcessor> blockFP(
                 BlockInputFragmentProcessor::Make(std::move(fp)));
-            builder.addColorFragmentProcessor(std::move(blockFP));
+            grPaint.addColorFragmentProcessor(std::move(blockFP));
 
-            drawContext->drawContextPriv().testingOnly_drawBatch(builder, batch);
+            drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
             drawingManager->flush();
         }
     }
index 5ef49942ba2263dec1235a3f12d42db2405818e0..6d5be09c243a44c6a26c054b3a8b40124ad4d54d 100644 (file)
@@ -122,10 +122,10 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
     REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0);
 #endif
     SkAutoTUnref<GrDrawBatch> batch;
-    GrPipelineBuilder pb;
+    GrPaint grPaint;
     // This one should succeed.
     batch.reset(new Batch(attribCnt));
-    drawContext->drawContextPriv().testingOnly_drawBatch(pb, batch);
+    drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
     context->flush();
 #if GR_GPU_STATS
     REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1);
@@ -134,7 +134,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
     context->resetGpuStats();
     // This one should fail.
     batch.reset(new Batch(attribCnt+1));
-    drawContext->drawContextPriv().testingOnly_drawBatch(pb, batch);
+    drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
     context->flush();
 #if GR_GPU_STATS
     REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0);
index dca47baea5750e8952443ffe9e8825ed9fa6a706..6a637efc61f4d1913752236cea1724956b6892e3 100644 (file)
@@ -234,19 +234,24 @@ void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT
     SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSingleOwner);)
 #define RETURN_IF_ABANDONED        if (fDrawContext->fDrawingManager->wasAbandoned()) { return; }
 
-void GrDrawContextPriv::testingOnly_drawBatch(const GrPipelineBuilder& pipelineBuilder,
+void GrDrawContextPriv::testingOnly_drawBatch(const GrPaint& paint,
                                               GrDrawBatch* batch,
-                                              const GrClip* clip) {
+                                              const GrUserStencilSettings* uss,
+                                              bool snapToCenters) {
     ASSERT_SINGLE_OWNER
     RETURN_IF_ABANDONED
     SkDEBUGCODE(fDrawContext->validate();)
     GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::testingOnly_drawBatch");
 
-    if (clip) {
-        fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, *clip, batch);
-    } else {
-        fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, GrNoClip(), batch);
+    GrPipelineBuilder pipelineBuilder(paint, fDrawContext->mustUseHWAA(paint));
+    if (uss) {
+        pipelineBuilder.setUserStencil(uss);
     }
+    if (snapToCenters) {
+        pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag, true);
+    }
+
+    fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, GrNoClip(), batch);
 }
 
 #undef ASSERT_SINGLE_OWNER