aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-01-11 13:42:54 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-11 19:56:48 +0000
commit82f44319159bb98dcacdbbec7ea643dde5ed024b (patch)
treedcd8c8a5caaac2675fcfdf48c5af67f946200c24 /gm
parentab273facbfe496a3d5dd798e6b4b57c41eed7f16 (diff)
Make GrPaints move their GrProcessor ownership into GrPipelineBuilder.
This makes GrPaints usable only once. In some places we must make copies in order to issue draws with the same paint state. Change-Id: Ie816e5185ce93a064111cad64c6880e1e21184c2 Reviewed-on: https://skia-review.googlesource.com/6844 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/beziereffects.cpp12
-rw-r--r--gm/bigrrectaaeffect.cpp9
-rw-r--r--gm/constcolorprocessor.cpp4
-rw-r--r--gm/convexpolyeffect.cpp8
-rw-r--r--gm/rrects.cpp10
-rw-r--r--gm/texdata.cpp6
-rw-r--r--gm/texturedomaineffect.cpp4
-rw-r--r--gm/windowrectangles.cpp21
-rw-r--r--gm/yuvtorgbeffect.cpp14
9 files changed, 42 insertions, 46 deletions
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index bcce9dbafb..cc28538dd0 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -198,8 +198,8 @@ protected:
std::unique_ptr<GrDrawOp> op =
BezierCubicOrConicTestOp::Make(gp, bounds, color, klmEqs, klmSigns[c]);
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(
+ std::move(grPaint), GrAAType::kNone, std::move(op));
}
++col;
if (numCols == col) {
@@ -331,8 +331,8 @@ protected:
std::unique_ptr<GrDrawOp> op =
BezierCubicOrConicTestOp::Make(gp, bounds, color, klmEqs, 1.f);
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(
+ std::move(grPaint), GrAAType::kNone, std::move(op));
}
++col;
if (numCols == col) {
@@ -547,8 +547,8 @@ protected:
std::unique_ptr<GrDrawOp> op =
BezierQuadTestOp::Make(gp, bounds, color, DevToUV);
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(
+ std::move(grPaint), GrAAType::kNone, std::move(op));
}
++col;
if (numCols == col) {
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index d8034a4384..f4e00fbba2 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -74,14 +74,13 @@ protected:
paint.setColor(SK_ColorWHITE);
canvas->drawRect(testBounds, paint);
- GrPaint grPaint;
- grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
-
SkRRect rrect = fRRect;
rrect.offset(SkIntToScalar(x + kGap), SkIntToScalar(y + kGap));
sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrect));
SkASSERT(fp);
if (fp) {
+ GrPaint grPaint;
+ grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
grPaint.addCoverageFragmentProcessor(std::move(fp));
SkRect bounds = testBounds;
@@ -89,8 +88,8 @@ protected:
std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
0xff000000, SkMatrix::I(), bounds, nullptr, nullptr));
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(
+ std::move(grPaint), GrAAType::kNone, std::move(op));
}
canvas->restore();
x = x + fTestOffsetX;
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index 0fe476ff56..17a1bc5820 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -111,8 +111,8 @@ protected:
std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
grPaint.getColor(), viewMatrix, renderRect, nullptr, nullptr));
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(
+ std::move(grPaint), GrAAType::kNone, std::move(op));
// 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.
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 5927d5d0c7..1be92dafab 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -185,8 +185,8 @@ protected:
std::unique_ptr<GrDrawOp> op = PolyBoundsOp::Make(p.getBounds(), 0xff000000);
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(std::move(grPaint),
+ GrAAType::kNone, std::move(op));
x += SkScalarCeilToScalar(path->getBounds().width() + kDX);
}
@@ -225,8 +225,8 @@ protected:
std::unique_ptr<GrDrawOp> op = PolyBoundsOp::Make(rect, 0xff000000);
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(std::move(grPaint),
+ GrAAType::kNone, std::move(op));
x += SkScalarCeilToScalar(rect.width() + kDX);
}
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index 33de77f11d..d4f5bdfa6e 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -102,14 +102,13 @@ protected:
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
if (kEffect_Type == fType) {
#if SK_SUPPORT_GPU
- GrPaint grPaint;
- grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
-
SkRRect rrect = fRRects[curRRect];
rrect.offset(SkIntToScalar(x), SkIntToScalar(y));
GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrect));
if (fp) {
+ GrPaint grPaint;
+ grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
grPaint.addCoverageFragmentProcessor(std::move(fp));
SkRect bounds = rrect.getBounds();
@@ -117,9 +116,8 @@ protected:
std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
0xff000000, SkMatrix::I(), bounds, nullptr, nullptr));
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint,
- GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(
+ std::move(grPaint), GrAAType::kNone, std::move(op));
} else {
drew = false;
}
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index 574dfad2be..8520d28b12 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -102,7 +102,8 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
tm.postIDiv(2*S, 2*S);
paint.addColorTextureProcessor(texture, nullptr, tm);
- renderTargetContext->drawRect(clip, paint, GrAA::kNo, vm, SkRect::MakeWH(2*S, 2*S));
+ renderTargetContext->drawRect(clip, GrPaint(paint), GrAA::kNo, vm,
+ SkRect::MakeWH(2 * S, 2 * S));
// now update the lower right of the texture in first pass
// or upper right in second pass
@@ -116,7 +117,8 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
texture->writePixels(S, (i ? 0 : S), S, S,
texture->config(), gTextureData.get(),
4 * stride);
- renderTargetContext->drawRect(clip, paint, GrAA::kNo, vm, SkRect::MakeWH(2*S, 2*S));
+ renderTargetContext->drawRect(clip, std::move(paint), GrAA::kNo, vm,
+ SkRect::MakeWH(2 * S, 2 * S));
}
}
#endif
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 7313f89a3b..32042aab84 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -128,8 +128,8 @@ protected:
std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr));
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(
+ std::move(grPaint), GrAAType::kNone, std::move(op));
x += renderRect.width() + kTestPad;
}
y += renderRect.height() + kTestPad;
diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp
index 156da58bf2..29356fc72a 100644
--- a/gm/windowrectangles.cpp
+++ b/gm/windowrectangles.cpp
@@ -127,10 +127,8 @@ private:
constexpr static int kMaskCheckerSize = 5;
SkString onShortName() final { return SkString("windowrectangles_mask"); }
void onCoverClipStack(const SkClipStack&, SkCanvas*) final;
- void visualizeAlphaMask(GrContext*, GrRenderTargetContext*, const GrReducedClip&,
- const GrPaint&);
- void visualizeStencilMask(GrContext*, GrRenderTargetContext*, const GrReducedClip&,
- const GrPaint&);
+ void visualizeAlphaMask(GrContext*, GrRenderTargetContext*, const GrReducedClip&, GrPaint&&);
+ void visualizeStencilMask(GrContext*, GrRenderTargetContext*, const GrReducedClip&, GrPaint&&);
void stencilCheckerboard(GrRenderTargetContext*, bool flip);
void fail(SkCanvas*);
};
@@ -192,16 +190,15 @@ void WindowRectanglesMaskGM::onCoverClipStack(const SkClipStack& stack, SkCanvas
GrPaint paint;
if (!rtc->isStencilBufferMultisampled()) {
paint.setColor4f(GrColor4f(0, 0.25f, 1, 1));
- this->visualizeAlphaMask(ctx, rtc, reducedClip, paint);
+ this->visualizeAlphaMask(ctx, rtc, reducedClip, std::move(paint));
} else {
paint.setColor4f(GrColor4f(1, 0.25f, 0.25f, 1));
- this->visualizeStencilMask(ctx, rtc, reducedClip, paint);
+ this->visualizeStencilMask(ctx, rtc, reducedClip, std::move(paint));
}
}
void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetContext* rtc,
- const GrReducedClip& reducedClip,
- const GrPaint& paint) {
+ const GrReducedClip& reducedClip, GrPaint&& paint) {
sk_sp<GrRenderTargetContext> maskRTC(
ctx->makeRenderTargetContextWithFallback(SkBackingFit::kExact, kLayerRect.width(),
kLayerRect.height(), kAlpha_8_GrPixelConfig,
@@ -228,13 +225,13 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo
// inside window rectangles or outside the scissor should still have the initial checkerboard
// intact. (This verifies we didn't spend any time modifying those pixels in the mask.)
AlphaOnlyClip clip(mask.get(), x, y);
- rtc->drawRect(clip, paint, GrAA::kYes, SkMatrix::I(),
- SkRect::Make(SkIRect::MakeXYWH(x, y, mask->width(), mask->height())));
+ rtc->drawRect(clip, std::move(paint), GrAA::kYes, SkMatrix::I(),
+ SkRect::Make(SkIRect::MakeXYWH(x, y, mask->width(), mask->height())));
}
void WindowRectanglesMaskGM::visualizeStencilMask(GrContext* ctx, GrRenderTargetContext* rtc,
const GrReducedClip& reducedClip,
- const GrPaint& paint) {
+ GrPaint&& paint) {
if (!ctx->resourceProvider()->attachStencilAttachment(rtc->accessRenderTarget())) {
return;
}
@@ -247,7 +244,7 @@ void WindowRectanglesMaskGM::visualizeStencilMask(GrContext* ctx, GrRenderTarget
// Now visualize the stencil mask by covering the entire render target. The regions inside
// window rectangless or outside the scissor should still have the initial checkerboard intact.
// (This verifies we didn't spend any time modifying those pixels in the mask.)
- rtc->drawPaint(StencilOnlyClip(), paint, SkMatrix::I());
+ rtc->drawPaint(StencilOnlyClip(), std::move(paint), SkMatrix::I());
}
void WindowRectanglesMaskGM::stencilCheckerboard(GrRenderTargetContext* rtc, bool flip) {
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 103c2e41ff..8d78f132cf 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -110,8 +110,6 @@ protected:
{1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
for (int i = 0; i < 6; ++i) {
- GrPaint grPaint;
- grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
sk_sp<GrFragmentProcessor> fp(
GrYUVEffect::MakeYUVToRGB(texture[indices[i][0]].get(),
texture[indices[i][1]].get(),
@@ -120,13 +118,15 @@ protected:
static_cast<SkYUVColorSpace>(space),
false));
if (fp) {
+ GrPaint grPaint;
+ grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
+ grPaint.addColorFragmentProcessor(std::move(fp));
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
- grPaint.addColorFragmentProcessor(std::move(fp));
std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr));
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(
+ std::move(grPaint), GrAAType::kNone, std::move(op));
}
x += renderRect.width() + kTestPad;
}
@@ -238,8 +238,8 @@ protected:
grPaint.addColorFragmentProcessor(fp);
std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr));
- renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
- std::move(op));
+ renderTargetContext->priv().testingOnly_addDrawOp(std::move(grPaint),
+ GrAAType::kNone, std::move(op));
}
}
}