aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--expectations/gm/ignored-tests.txt5
-rw-r--r--gm/beziereffects.cpp9
-rw-r--r--gm/convexpolyeffect.cpp12
-rw-r--r--include/gpu/GrFragmentProcessor.h15
-rw-r--r--include/gpu/GrInvariantOutput.h70
-rw-r--r--include/gpu/GrProcessor.h15
-rw-r--r--include/gpu/GrXferProcessor.h5
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp6
-rw-r--r--src/effects/SkBlurMaskFilter.cpp4
-rw-r--r--src/effects/SkLightingImageFilter.cpp2
-rw-r--r--src/effects/gradients/SkGradientShader.cpp4
-rw-r--r--src/gpu/GrAAConvexPathRenderer.cpp8
-rwxr-xr-xsrc/gpu/GrAADistanceFieldPathRenderer.cpp6
-rw-r--r--src/gpu/GrAAHairLinePathRenderer.cpp27
-rw-r--r--src/gpu/GrAAHairLinePathRenderer.h1
-rw-r--r--src/gpu/GrAARectRenderer.cpp98
-rwxr-xr-xsrc/gpu/GrBitmapTextContext.cpp7
-rwxr-xr-xsrc/gpu/GrContext.cpp34
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.cpp7
-rw-r--r--src/gpu/GrDefaultPathRenderer.cpp7
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp8
-rw-r--r--src/gpu/GrDrawState.cpp108
-rw-r--r--src/gpu/GrDrawState.h70
-rw-r--r--src/gpu/GrDrawTarget.cpp52
-rw-r--r--src/gpu/GrDrawTarget.h19
-rw-r--r--src/gpu/GrGeometryProcessor.h57
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp39
-rw-r--r--src/gpu/GrInOrderDrawBuffer.h19
-rw-r--r--src/gpu/GrOptDrawState.cpp45
-rw-r--r--src/gpu/GrOptDrawState.h10
-rw-r--r--src/gpu/GrOvalRenderer.cpp43
-rw-r--r--src/gpu/GrProcOptInfo.cpp49
-rw-r--r--src/gpu/GrProcOptInfo.h11
-rw-r--r--src/gpu/GrProcessor.cpp30
-rw-r--r--src/gpu/GrStencilAndCoverPathRenderer.cpp9
-rw-r--r--src/gpu/GrStencilAndCoverTextContext.cpp3
-rw-r--r--src/gpu/effects/GrBezierEffect.h12
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp2
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp12
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.h2
-rw-r--r--src/gpu/effects/GrConvexPolyEffect.cpp6
-rw-r--r--src/gpu/effects/GrConvolutionEffect.h2
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp22
-rwxr-xr-xsrc/gpu/effects/GrDistanceFieldTextureEffect.cpp14
-rw-r--r--src/gpu/effects/GrDistanceFieldTextureEffect.h6
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.h2
-rw-r--r--src/gpu/effects/GrOvalEffect.cpp4
-rw-r--r--src/gpu/effects/GrRRectEffect.cpp4
-rw-r--r--src/gpu/effects/GrSingleTextureEffect.h6
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp4
-rw-r--r--tests/GLProgramsTest.cpp42
51 files changed, 471 insertions, 583 deletions
diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt
index bdce6d9467..6c93e7af88 100644
--- a/expectations/gm/ignored-tests.txt
+++ b/expectations/gm/ignored-tests.txt
@@ -72,8 +72,3 @@ pictureimagefilter
clipped-bitmap-shaders-clamp
clipped-bitmap-shaders-clamp-hq
-# joshualitt
-path_primitive
-xfermodes3
-multipicturedraw_sierpinski_tiled
-multipicturedraw_sierpinski_simple
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index e7e63eaded..6f19ac93e7 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -164,10 +164,11 @@ protected:
verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs + 6, 1.f);
}
+ ds.setGeometryProcessor(gp);
ds.setRenderTarget(rt);
tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer());
- tt.target()->drawIndexed(&ds, gp, kTriangleFan_GrPrimitiveType, 0, 0,4,6);
+ tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
}
++col;
if (numCols == col) {
@@ -319,10 +320,11 @@ protected:
verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs + 6, 1.f);
}
+ ds.setGeometryProcessor(gp);
ds.setRenderTarget(rt);
tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer());
- tt.target()->drawIndexed(&ds, gp, kTriangleFan_GrPrimitiveType, 0, 0,4,6);
+ tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
}
++col;
if (numCols == col) {
@@ -503,10 +505,11 @@ protected:
GrPathUtils::QuadUVMatrix DevToUV(pts);
DevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
+ ds.setGeometryProcessor(gp);
ds.setRenderTarget(rt);
tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer());
- tt.target()->drawIndexed(&ds, gp, kTriangles_GrPrimitiveType, 0, 0, 4, 6);
+ tt.target()->drawIndexed(&ds, kTriangles_GrPrimitiveType, 0, 0, 4, 6);
}
++col;
if (numCols == col) {
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 03b9ad25a7..365660d517 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -133,8 +133,8 @@ protected:
}
GrDrawState ds;
- SkAutoTUnref<const GrGeometryProcessor> gp(
- GrDefaultGeoProcFactory::Create(0xff000000));
+ const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(0xff000000);
+ ds.setGeometryProcessor(gp)->unref();
ds.addCoverageProcessor(fp);
ds.setIdentityViewMatrix();
ds.setRenderTarget(rt);
@@ -150,7 +150,7 @@ protected:
bounds.toQuad(verts);
tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer());
- tt.target()->drawIndexed(&ds, gp, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
+ tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
x += SkScalarCeilToScalar(path->getBounds().width() + 10.f);
}
@@ -190,8 +190,8 @@ protected:
}
GrDrawState ds;
- SkAutoTUnref<const GrGeometryProcessor> gp(
- GrDefaultGeoProcFactory::Create(0xff000000));
+ const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(0xff000000);
+ ds.setGeometryProcessor(gp)->unref();
ds.addCoverageProcessor(fp);
ds.setIdentityViewMatrix();
ds.setRenderTarget(rt);
@@ -205,7 +205,7 @@ protected:
bounds.toQuad(verts);
tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer());
- tt.target()->drawIndexed(&ds, gp, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
+ tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
x += SkScalarCeilToScalar(rect.width() + 10.f);
}
diff --git a/include/gpu/GrFragmentProcessor.h b/include/gpu/GrFragmentProcessor.h
index 0c155996d5..3f308d7e75 100644
--- a/include/gpu/GrFragmentProcessor.h
+++ b/include/gpu/GrFragmentProcessor.h
@@ -67,16 +67,6 @@ public:
return this->onIsEqual(that);
}
- /**
- * This function is used to perform optimizations. When called the invarientOuput param
- * indicate whether the input components to this processor in the FS will have known values.
- * In inout the validFlags member is a bitfield of GrColorComponentFlags. The isSingleComponent
- * member indicates whether the input will be 1 or 4 bytes. The function updates the members of
- * inout to indicate known values of its output. A component of the color member only has
- * meaning if the corresponding bit in validFlags is set.
- */
- void computeInvariantOutput(GrInvariantOutput* inout) const;
-
protected:
/**
* Fragment Processor subclasses call this from their constructor to register coordinate
@@ -111,11 +101,6 @@ protected:
*/
void setWillNotUseInputColor() { fWillUseInputColor = false; }
- /**
- * Subclass implements this to support getConstantColorComponents(...).
- */
- virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
-
private:
/**
* Subclass implements this to support isEqual(). It will only be called if it is known that
diff --git a/include/gpu/GrInvariantOutput.h b/include/gpu/GrInvariantOutput.h
index 269748a026..1d3eda1b2c 100644
--- a/include/gpu/GrInvariantOutput.h
+++ b/include/gpu/GrInvariantOutput.h
@@ -10,49 +10,6 @@
#include "GrColor.h"
-struct GrInitInvariantOutput {
- GrInitInvariantOutput()
- : fValidFlags(0)
- , fColor(0)
- , fIsSingleComponent(false)
- , fIsLCDCoverage(false) {}
-
- void setKnownFourComponents(GrColor color) {
- fColor = color;
- fValidFlags = kRGBA_GrColorComponentFlags;
- fIsSingleComponent = false;
- }
-
- void setUnknownFourComponents() {
- fValidFlags = 0;
- fIsSingleComponent = false;
- }
-
- void setUnknownOpaqueFourComponents() {
- fColor = 0xff << GrColor_SHIFT_A;
- fValidFlags = kA_GrColorComponentFlag;
- fIsSingleComponent = false;
- }
-
- void setKnownSingleComponent(uint8_t alpha) {
- fColor = GrColorPackRGBA(alpha, alpha, alpha, alpha);
- fValidFlags = kRGBA_GrColorComponentFlags;
- fIsSingleComponent = true;
- }
-
- void setUnknownSingleComponent() {
- fValidFlags = 0;
- fIsSingleComponent = true;
- }
-
- void setUsingLCDCoverage() { fIsLCDCoverage = true; }
-
- uint32_t fValidFlags;
- GrColor fColor;
- bool fIsSingleComponent;
- bool fIsLCDCoverage; // Temorary data member until texture pixel configs are updated
-};
-
class GrInvariantOutput {
public:
GrInvariantOutput(GrColor color, GrColorComponentFlags flags, bool isSingleComponent)
@@ -63,14 +20,6 @@ public:
, fWillUseInputColor(true)
, fIsLCDCoverage(false) {}
- GrInvariantOutput(const GrInitInvariantOutput& io)
- : fColor(io.fColor)
- , fValidFlags(io.fValidFlags)
- , fIsSingleComponent(io.fIsSingleComponent)
- , fNonMulStageFound(false)
- , fWillUseInputColor(false)
- , fIsLCDCoverage(io.fIsLCDCoverage) {}
-
virtual ~GrInvariantOutput() {}
enum ReadInput {
@@ -78,18 +27,18 @@ public:
kWillNot_ReadInput,
};
- void mulByUnknownOpaqueFourComponents() {
+ void mulByUnknownOpaqueColor() {
if (this->isOpaque()) {
fValidFlags = kA_GrColorComponentFlag;
fIsSingleComponent = false;
} else {
// Since the current state is not opaque we no longer care if the color being
// multiplied is opaque.
- this->mulByUnknownFourComponents();
+ this->mulByUnknownColor();
}
}
- void mulByUnknownFourComponents() {
+ void mulByUnknownColor() {
if (this->hasZeroAlpha()) {
this->internalSetToTransparentBlack();
} else {
@@ -97,7 +46,7 @@ public:
}
}
- void mulByUnknownSingleComponent() {
+ void mulByUnknownAlpha() {
if (this->hasZeroAlpha()) {
this->internalSetToTransparentBlack();
} else {
@@ -106,7 +55,7 @@ public:
}
}
- void mulByKnownSingleComponent(uint8_t alpha) {
+ void mulByKnownAlpha(uint8_t alpha) {
if (this->hasZeroAlpha() || 0 == alpha) {
this->internalSetToTransparentBlack();
} else {
@@ -173,15 +122,6 @@ private:
fWillUseInputColor = true;
}
- void reset(const GrInitInvariantOutput& io) {
- fColor = io.fColor;
- fValidFlags = io.fValidFlags;
- fIsSingleComponent = io.fIsSingleComponent;
- fNonMulStageFound = false;
- fWillUseInputColor = true;
- fIsLCDCoverage = io.fIsLCDCoverage;
- }
-
void internalSetToTransparentBlack() {
fValidFlags = kRGBA_GrColorComponentFlags;
fColor = 0;
diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h
index 8a8d685e51..6a497e7514 100644
--- a/include/gpu/GrProcessor.h
+++ b/include/gpu/GrProcessor.h
@@ -61,6 +61,16 @@ public:
virtual ~GrProcessor();
+ /**
+ * This function is used to perform optimizations. When called the invarientOuput param
+ * indicate whether the input components to this processor in the FS will have known values.
+ * In inout the validFlags member is a bitfield of GrColorComponentFlags. The isSingleComponent
+ * member indicates whether the input will be 1 or 4 bytes. The function updates the members of
+ * inout to indicate known values of its output. A component of the color member only has
+ * meaning if the corresponding bit in validFlags is set.
+ */
+ void computeInvariantOutput(GrInvariantOutput* inout) const;
+
/** Human-meaningful string to identify this prcoessor; may be embedded
in generated shader code. */
virtual const char* name() const = 0;
@@ -122,6 +132,11 @@ protected:
uint32_t fClassID;
private:
+ /**
+ * Subclass implements this to support getConstantColorComponents(...).
+ */
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
+
static uint32_t GenClassID() {
// fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The
// atomic inc returns the old value not the incremented value. So we add
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h
index db0d6e8656..696359b8b3 100644
--- a/include/gpu/GrXferProcessor.h
+++ b/include/gpu/GrXferProcessor.h
@@ -134,11 +134,6 @@ protected:
*/
void setWillReadDstColor() { fWillReadDstColor = true; }
- /**
- * Subclass implements this to support getConstantColorComponents(...).
- */
- virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
-
private:
virtual bool onIsEqual(const GrXferProcessor&) const = 0;
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index 317f6f09ec..2703a245e0 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -230,11 +230,11 @@ bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
void AlphaThresholdEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
} else if (GrPixelConfigIsOpaque(this->texture(0)->config()) && fOuterThreshold >= 1.f) {
- inout->mulByUnknownOpaqueFourComponents();
+ inout->mulByUnknownOpaqueColor();
} else {
- inout->mulByUnknownFourComponents();
+ inout->mulByUnknownColor();
}
}
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 7c0bbb851d..feb321ad77 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -817,7 +817,7 @@ bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
}
void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
@@ -979,7 +979,7 @@ GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma,
}
void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
}
GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTexture *ninePatchTexture)
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index e53cb02569..adac45bdc9 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -349,7 +349,7 @@ protected:
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
// lighting shaders are complicated. We just throw up our hands.
- inout->mulByUnknownFourComponents();
+ inout->mulByUnknownColor();
}
private:
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 3b73eae6aa..0c147946f3 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -1158,9 +1158,9 @@ bool GrGradientEffect::onIsEqual(const GrFragmentProcessor& processor) const {
void GrGradientEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
if (fIsOpaque) {
- inout->mulByUnknownOpaqueFourComponents();
+ inout->mulByUnknownOpaqueColor();
} else {
- inout->mulByUnknownFourComponents();
+ inout->mulByUnknownColor();
}
}
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 0007e33b7f..44782dd279 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -596,8 +596,8 @@ private:
return true;
}
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
- out->setUnknownSingleComponent();
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
+ inout->mulByUnknownAlpha();
}
const GrAttribute* fInPosition;
@@ -679,7 +679,8 @@ bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target,
// Our computed verts should all be within one pixel of the segment control points.
devBounds.outset(SK_Scalar1, SK_Scalar1);
- SkAutoTUnref<GrGeometryProcessor> quadProcessor(QuadEdgeEffect::Create(color));
+ GrGeometryProcessor* quadProcessor = QuadEdgeEffect::Create(color);
+ drawState->setGeometryProcessor(quadProcessor)->unref();
GrDrawTarget::AutoReleaseGeometry arg(target, vCount, quadProcessor->getVertexStride(), iCount);
SkASSERT(quadProcessor->getVertexStride() == sizeof(QuadVertex));
@@ -708,7 +709,6 @@ bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target,
for (int i = 0; i < draws.count(); ++i) {
const Draw& draw = draws[i];
target->drawIndexed(drawState,
- quadProcessor,
kTriangles_GrPrimitiveType,
vOffset, // start vertex
0, // start index
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index f79d96b6a9..7a7c1e4379 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -323,13 +323,14 @@ bool GrAADistanceFieldPathRenderer::internalDrawPath(GrDrawTarget* target,
flags |= vm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode);
- if (flags != fEffectFlags || fCachedGeometryProcessor->color() != color) {
+ if (flags != fEffectFlags || fCachedGeometryProcessor->getColor() != color) {
fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Create(color,
texture,
params,
flags));
fEffectFlags = flags;
}
+ drawState->setGeometryProcessor(fCachedGeometryProcessor.get());
void* vertices = NULL;
bool success = target->reserveVertexAndIndexSpace(4,
@@ -371,8 +372,7 @@ bool GrAADistanceFieldPathRenderer::internalDrawPath(GrDrawTarget* target,
vm.mapRect(&r);
target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, fCachedGeometryProcessor.get(),
- kTriangles_GrPrimitiveType, 1, 4, 6, &r);
+ target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &r);
target->resetVertexSource();
return true;
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index a95f900366..37150bd9a5 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -644,7 +644,6 @@ void add_line(const SkPoint p[2],
bool GrAAHairLinePathRenderer::createLineGeom(GrDrawTarget* target,
GrDrawState* drawState,
uint8_t coverage,
- size_t vertexStride,
GrDrawTarget::AutoReleaseGeometry* arg,
SkRect* devBounds,
const SkPath& path,
@@ -654,8 +653,9 @@ bool GrAAHairLinePathRenderer::createLineGeom(GrDrawTarget* target,
int vertCnt = kLineSegNumVertices * lineCnt;
- SkASSERT(vertexStride == sizeof(LineVertex));
- if (!arg->set(target, vertCnt, vertexStride, 0)) {
+ size_t vstride = drawState->getGeometryProcessor()->getVertexStride();
+ SkASSERT(vstride == sizeof(LineVertex));
+ if (!arg->set(target, vertCnt, vstride, 0)) {
return false;
}
@@ -839,14 +839,13 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
uint32_t gpFlags = GrDefaultGeoProcFactory::kPosition_GPType |
GrDefaultGeoProcFactory::kCoverage_GPType;
GrDrawState::AutoRestoreEffects are(drawState);
- SkAutoTUnref<const GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Create(color,
- gpFlags,
- newCoverage));
+ drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(color,
+ gpFlags,
+ newCoverage))->unref();
if (!this->createLineGeom(target,
drawState,
newCoverage,
- gp->getVertexStride(),
&arg,
&devBounds,
path,
@@ -872,7 +871,6 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
while (lines < lineCnt) {
int n = SkTMin(lineCnt - lines, kLineSegsNumInIdxBuffer);
target->drawIndexed(drawState,
- gp,
kTriangles_GrPrimitiveType,
kLineSegNumVertices*lines, // startV
0, // startI
@@ -917,20 +915,20 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
kQuadNumVertices * quadCnt + kQuadNumVertices * conicCnt));
if (quadCnt > 0) {
- SkAutoTUnref<GrGeometryProcessor> hairQuadProcessor(
+ GrGeometryProcessor* hairQuadProcessor =
GrQuadEffect::Create(color,
kHairlineAA_GrProcessorEdgeType,
*target->caps(),
- newCoverage));
+ newCoverage);
SkASSERT(hairQuadProcessor);
GrDrawState::AutoRestoreEffects are(drawState);
target->setIndexSourceToBuffer(fQuadsIndexBuffer);
+ drawState->setGeometryProcessor(hairQuadProcessor)->unref();
int quads = 0;
while (quads < quadCnt) {
int n = SkTMin(quadCnt - quads, kQuadsNumInIdxBuffer);
target->drawIndexed(drawState,
- hairQuadProcessor,
kTriangles_GrPrimitiveType,
kQuadNumVertices*quads, // startV
0, // startI
@@ -943,16 +941,15 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
if (conicCnt > 0) {
GrDrawState::AutoRestoreEffects are(drawState);
- SkAutoTUnref<GrGeometryProcessor> hairConicProcessor(
- GrConicEffect::Create(color, kHairlineAA_GrProcessorEdgeType, *target->caps(),
- newCoverage));
+ GrGeometryProcessor* hairConicProcessor = GrConicEffect::Create(
+ color, kHairlineAA_GrProcessorEdgeType, *target->caps(), newCoverage);
SkASSERT(hairConicProcessor);
+ drawState->setGeometryProcessor(hairConicProcessor)->unref();
int conics = 0;
while (conics < conicCnt) {
int n = SkTMin(conicCnt - conics, kQuadsNumInIdxBuffer);
target->drawIndexed(drawState,
- hairConicProcessor,
kTriangles_GrPrimitiveType,
kQuadNumVertices*(quadCnt + conics), // startV
0, // startI
diff --git a/src/gpu/GrAAHairLinePathRenderer.h b/src/gpu/GrAAHairLinePathRenderer.h
index 5b7b785bc7..5d00e7e9f1 100644
--- a/src/gpu/GrAAHairLinePathRenderer.h
+++ b/src/gpu/GrAAHairLinePathRenderer.h
@@ -43,7 +43,6 @@ private:
bool createLineGeom(GrDrawTarget* target,
GrDrawState*,
uint8_t coverage,
- size_t vertexStride,
GrDrawTarget::AutoReleaseGeometry* arg,
SkRect* devBounds,
const SkPath& path,
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 23757ce8c5..0cf757502e 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -25,21 +25,20 @@ enum CoverageAttribType {
};
}
-static const GrGeometryProcessor* create_rect_gp(const GrDrawState& drawState, GrColor color,
- CoverageAttribType* type) {
+static CoverageAttribType set_rect_attribs(GrDrawState* drawState, GrColor color) {
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
- const GrGeometryProcessor* gp;
- if (drawState.canTweakAlphaForCoverage()) {
- gp = GrDefaultGeoProcFactory::Create(color, flags);
- SkASSERT(gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
- *type = kUseColor_CoverageAttribType;
+ if (drawState->canTweakAlphaForCoverage()) {
+ drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(color, flags))->unref();
+ SkASSERT(drawState->getGeometryProcessor()->getVertexStride() ==
+ sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
+ return kUseColor_CoverageAttribType;
} else {
flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
- gp = GrDefaultGeoProcFactory::Create(color, flags);
- SkASSERT(gp->getVertexStride()==sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr));
- *type = kUseCoverage_CoverageAttribType;
+ drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(color, flags))->unref();
+ SkASSERT(drawState->getGeometryProcessor()->getVertexStride() ==
+ sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr));
+ return kUseCoverage_CoverageAttribType;
}
- return gp;
}
static void set_inset_fan(SkPoint* pts, size_t stride,
@@ -183,14 +182,13 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
const SkRect& devRect) {
GrDrawState::AutoRestoreEffects are(drawState);
- CoverageAttribType type;
- SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(*drawState, color, &type));
- if (kUseCoverage_CoverageAttribType == type && GrColorIsOpaque(color)) {
+ CoverageAttribType covAttribType = set_rect_attribs(drawState, color);
+ if (kUseCoverage_CoverageAttribType == covAttribType && GrColorIsOpaque(color)) {
drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true);
}
- size_t vertexStride = gp->getVertexStride();
- GrDrawTarget::AutoReleaseGeometry geo(target, 8, vertexStride, 0);
+ size_t vstride = drawState->getGeometryProcessor()->getVertexStride();
+ GrDrawTarget::AutoReleaseGeometry geo(target, 8, vstride, 0);
if (!geo.succeeded()) {
SkDebugf("Failed to get space for vertices!\n");
return;
@@ -211,7 +209,7 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
- SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride);
+ SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vstride);
SkScalar inset = SkMinScalar(devRect.width(), SK_Scalar1);
inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height());
@@ -225,8 +223,8 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
combinedMatrix.mapRect(&devRect, rect);
#endif
- set_inset_fan(fan0Pos, vertexStride, devRect, -SK_ScalarHalf, -SK_ScalarHalf);
- set_inset_fan(fan1Pos, vertexStride, devRect, inset, inset);
+ set_inset_fan(fan0Pos, vstride, devRect, -SK_ScalarHalf, -SK_ScalarHalf);
+ set_inset_fan(fan1Pos, vstride, devRect, inset, inset);
} else {
// compute transformed (1, 0) and (0, 1) vectors
SkVector vec[2] = {
@@ -241,38 +239,38 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
// create the rotated rect
fan0Pos->setRectFan(rect.fLeft, rect.fTop,
- rect.fRight, rect.fBottom, vertexStride);
- combinedMatrix.mapPointsWithStride(fan0Pos, vertexStride, 4);
+ rect.fRight, rect.fBottom, vstride);
+ combinedMatrix.mapPointsWithStride(fan0Pos, vstride, 4);
// Now create the inset points and then outset the original
// rotated points
// TL
- *((SkPoint*)((intptr_t)fan1Pos + 0 * vertexStride)) =
- *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) + vec[0] + vec[1];
- *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) -= vec[0] + vec[1];
+ *((SkPoint*)((intptr_t)fan1Pos + 0 * vstride)) =
+ *((SkPoint*)((intptr_t)fan0Pos + 0 * vstride)) + vec[0] + vec[1];
+ *((SkPoint*)((intptr_t)fan0Pos + 0 * vstride)) -= vec[0] + vec[1];
// BL
- *((SkPoint*)((intptr_t)fan1Pos + 1 * vertexStride)) =
- *((SkPoint*)((intptr_t)fan0Pos + 1 * vertexStride)) + vec[0] - vec[1];
- *((SkPoint*)((intptr_t)fan0Pos + 1 * vertexStride)) -= vec[0] - vec[1];
+ *((SkPoint*)((intptr_t)fan1Pos + 1 * vstride)) =
+ *((SkPoint*)((intptr_t)fan0Pos + 1 * vstride)) + vec[0] - vec[1];
+ *((SkPoint*)((intptr_t)fan0Pos + 1 * vstride)) -= vec[0] - vec[1];
// BR
- *((SkPoint*)((intptr_t)fan1Pos + 2 * vertexStride)) =
- *((SkPoint*)((intptr_t)fan0Pos + 2 * vertexStride)) - vec[0] - vec[1];
- *((SkPoint*)((intptr_t)fan0Pos + 2 * vertexStride)) += vec[0] + vec[1];
+ *((SkPoint*)((intptr_t)fan1Pos + 2 * vstride)) =
+ *((SkPoint*)((intptr_t)fan0Pos + 2 * vstride)) - vec[0] - vec[1];
+ *((SkPoint*)((intptr_t)fan0Pos + 2 * vstride)) += vec[0] + vec[1];
// TR
- *((SkPoint*)((intptr_t)fan1Pos + 3 * vertexStride)) =
- *((SkPoint*)((intptr_t)fan0Pos + 3 * vertexStride)) - vec[0] + vec[1];
- *((SkPoint*)((intptr_t)fan0Pos + 3 * vertexStride)) += vec[0] - vec[1];
+ *((SkPoint*)((intptr_t)fan1Pos + 3 * vstride)) =
+ *((SkPoint*)((intptr_t)fan0Pos + 3 * vstride)) - vec[0] + vec[1];
+ *((SkPoint*)((intptr_t)fan0Pos + 3 * vstride)) += vec[0] - vec[1];
}
// Make verts point to vertex color and then set all the color and coverage vertex attrs values.
verts += sizeof(SkPoint);
for (int i = 0; i < 4; ++i) {
- if (kUseCoverage_CoverageAttribType == type) {
- *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
- *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) = 0;
+ if (kUseCoverage_CoverageAttribType == covAttribType) {
+ *reinterpret_cast<GrColor*>(verts + i * vstride) = color;
+ *reinterpret_cast<float*>(verts + i * vstride + sizeof(GrColor)) = 0;
} else {
- *reinterpret_cast<GrColor*>(verts + i * vertexStride) = 0;
+ *reinterpret_cast<GrColor*>(verts + i * vstride) = 0;
}
}
@@ -284,23 +282,22 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
scale = 0xff;
}
- verts += 4 * vertexStride;
+ verts += 4 * vstride;
float innerCoverage = GrNormalizeByteToFloat(scale);
GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale);
for (int i = 0; i < 4; ++i) {
- if (kUseCoverage_CoverageAttribType == type) {
- *reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
- *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) = innerCoverage;
+ if (kUseCoverage_CoverageAttribType == covAttribType) {
+ *reinterpret_cast<GrColor*>(verts + i * vstride) = color;
+ *reinterpret_cast<float*>(verts + i * vstride + sizeof(GrColor)) = innerCoverage;
} else {
- *reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor;
+ *reinterpret_cast<GrColor*>(verts + i * vstride) = scaledColor;
}
}
target->setIndexSourceToBuffer(indexBuffer);
target->drawIndexedInstances(drawState,
- gp,
kTriangles_GrPrimitiveType,
1,
kVertsPerAAFillRect,
@@ -386,11 +383,9 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
const SkRect& devInside,
bool miterStroke) {
GrDrawState::AutoRestoreEffects are(drawState);
+ CoverageAttribType covAttribType = set_rect_attribs(drawState, color);
- CoverageAttribType type;
- SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(*drawState, color, &type));
-
- if (kUseCoverage_CoverageAttribType == type && GrColorIsOpaque(color)) {
+ if (kUseCoverage_CoverageAttribType == covAttribType && GrColorIsOpaque(color)) {
drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true);
}
@@ -398,7 +393,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
int outerVertexNum = miterStroke ? 4 : 8;
int totalVertexNum = (outerVertexNum + innerVertexNum) * 2;
- size_t vstride = gp->getVertexStride();
+ size_t vstride = drawState->getGeometryProcessor()->getVertexStride();
GrDrawTarget::AutoReleaseGeometry geo(target, totalVertexNum, vstride, 0);
if (!geo.succeeded()) {
SkDebugf("Failed to get space for vertices!\n");
@@ -463,7 +458,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
// The outermost rect has 0 coverage
verts += sizeof(SkPoint);
for (int i = 0; i < outerVertexNum; ++i) {
- if (kUseCoverage_CoverageAttribType == type) {
+ if (kUseCoverage_CoverageAttribType == covAttribType) {
*reinterpret_cast<GrColor*>(verts + i * vstride) = color;
*reinterpret_cast<float*>(verts + i * vstride + sizeof(GrColor)) = 0;
} else {
@@ -485,7 +480,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
verts += outerVertexNum * vstride;
for (int i = 0; i < outerVertexNum + innerVertexNum; ++i) {
- if (kUseCoverage_CoverageAttribType == type) {
+ if (kUseCoverage_CoverageAttribType == covAttribType) {
*reinterpret_cast<GrColor*>(verts + i * vstride) = color;
*reinterpret_cast<float*>(verts + i * vstride + sizeof(GrColor)) = innerCoverage;
} else {
@@ -496,7 +491,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
// The innermost rect has 0 coverage
verts += (outerVertexNum + innerVertexNum) * vstride;
for (int i = 0; i < innerVertexNum; ++i) {
- if (kUseCoverage_CoverageAttribType == type) {
+ if (kUseCoverage_CoverageAttribType == covAttribType) {
*reinterpret_cast<GrColor*>(verts + i * vstride) = color;
*reinterpret_cast<GrColor*>(verts + i * vstride + sizeof(GrColor)) = 0;
} else {
@@ -506,7 +501,6 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
target->setIndexSourceToBuffer(indexBuffer);
target->drawIndexedInstances(drawState,
- gp,
kTriangles_GrPrimitiveType,
1,
totalVertexNum,
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
index 7ee5585722..6a624ae23e 100755
--- a/src/gpu/GrBitmapTextContext.cpp
+++ b/src/gpu/GrBitmapTextContext.cpp
@@ -561,18 +561,19 @@ void GrBitmapTextContext::flush() {
if (kARGB_GrMaskFormat == fCurrMaskFormat) {
uint32_t textureUniqueID = fCurrTexture->getUniqueID();
if (textureUniqueID != fEffectTextureUniqueID ||
- fCachedGeometryProcessor->color() != color) {
+ fCachedGeometryProcessor->getColor() != color) {
uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType;
fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(color, flags));
fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCurrTexture,
SkMatrix::I(),
params));
}
+ drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
drawState.addColorProcessor(fCachedTextureProcessor.get());
} else {
uint32_t textureUniqueID = fCurrTexture->getUniqueID();
if (textureUniqueID != fEffectTextureUniqueID ||
- fCachedGeometryProcessor->color() != color) {
+ fCachedGeometryProcessor->getColor() != color) {
bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat;
fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color,
fCurrTexture,
@@ -580,12 +581,12 @@ void GrBitmapTextContext::flush() {
hasColor));
fEffectTextureUniqueID = textureUniqueID;
}
+ drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
}
int nGlyphs = fCurrVertex / kVerticesPerGlyph;
fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
fDrawTarget->drawIndexedInstances(&drawState,
- fCachedGeometryProcessor.get(),
kTriangles_GrPrimitiveType,
nGlyphs,
kVerticesPerGlyph,
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index bfbce359a4..9d07fdfd9c 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -315,8 +315,8 @@ GrTexture* GrContext::createResizedTexture(const GrSurfaceDesc& desc,
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
GrDefaultGeoProcFactory::kLocalCoord_GPType;
- SkAutoTUnref<const GrGeometryProcessor> gp(
- GrDefaultGeoProcFactory::Create(GrColor_WHITE, flags));
+ const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(GrColor_WHITE, flags);
+ drawState.setGeometryProcessor(gp)->unref();
GrDrawTarget::AutoReleaseGeometry arg(fDrawBuffer, 4, gp->getVertexStride(), 0);
SkASSERT(gp->getVertexStride() == 2 * sizeof(SkPoint));
@@ -325,7 +325,7 @@ GrTexture* GrContext::createResizedTexture(const GrSurfaceDesc& desc,
SkPoint* verts = (SkPoint*) arg.vertices();
verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint));
verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint));
- fDrawBuffer->drawNonIndexed(&drawState, gp, kTriangleFan_GrPrimitiveType, 0, 4);
+ fDrawBuffer->drawNonIndexed(&drawState, kTriangleFan_GrPrimitiveType, 0, 4);
}
} else {
// TODO: Our CPU stretch doesn't filter. But we create separate
@@ -758,7 +758,8 @@ void GrContext::drawRect(const GrPaint& paint,
// unitSquareVertexBuffer()
static const int worstCaseVertCount = 10;
- SkAutoTUnref<const GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Create(color));
+ const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(color);
+ drawState.setGeometryProcessor(gp)->unref();
GrDrawTarget::AutoReleaseGeometry geo(target,
worstCaseVertCount,
gp->getVertexStride(),
@@ -789,7 +790,7 @@ void GrContext::drawRect(const GrPaint& paint,
vertex[4].set(rect.fLeft, rect.fTop);
}
- target->drawNonIndexed(&drawState, gp, primType, 0, vertCount);
+ target->drawNonIndexed(&drawState, primType, 0, vertCount);
} else {
// filled BW rect
target->drawSimpleRect(&drawState, color, rect);
@@ -812,11 +813,12 @@ void GrContext::drawRectToRect(const GrPaint& paint,
target->drawRect(&drawState, paint.getColor(), dstRect, &localRect, localMatrix);
}
-static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords,
- const GrColor* colors,
- int* colorOffset,
- int* texOffset,
- GrColor color) {
+static void set_vertex_attributes(GrDrawState* drawState,
+ const SkPoint* texCoords,
+ const GrColor* colors,
+ int* colorOffset,
+ int* texOffset,
+ GrColor color) {
*texOffset = -1;
*colorOffset = -1;
@@ -833,7 +835,7 @@ static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords
*colorOffset = sizeof(SkPoint);
flags |= GrDefaultGeoProcFactory::kColor_GPType;
}
- return GrDefaultGeoProcFactory::Create(color, flags);
+ drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(color, flags))->unref();
}
void GrContext::drawVertices(const GrPaint& paint,
@@ -856,10 +858,10 @@ void GrContext::drawVertices(const GrPaint& paint,
GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target);
int colorOffset = -1, texOffset = -1;
- SkAutoTUnref<const GrGeometryProcessor> gp(
- set_vertex_attributes(texCoords, colors, &colorOffset, &texOffset, paint.getColor()));
+ set_vertex_attributes(&drawState, texCoords, colors, &colorOffset, &texOffset,
+ paint.getColor());
- size_t vertexStride = gp->getVertexStride();
+ size_t vertexStride = drawState.getGeometryProcessor()->getVertexStride();
SkASSERT(vertexStride == sizeof(SkPoint) + (SkToBool(texCoords) ? sizeof(SkPoint) : 0)
+ (SkToBool(colors) ? sizeof(GrColor) : 0));
if (!geo.set(target, vertexCount, vertexStride, indexCount)) {
@@ -887,9 +889,9 @@ void GrContext::drawVertices(const GrPaint& paint,
for (int i = 0; i < indexCount; ++i) {
curIndex[i] = indices[i];
}
- target->drawIndexed(&drawState, gp, primitiveType, 0, 0, vertexCount, indexCount);
+ target->drawIndexed(&drawState, primitiveType, 0, 0, vertexCount, indexCount);
} else {
- target->drawNonIndexed(&drawState, gp, primitiveType, 0, vertexCount);
+ target->drawNonIndexed(&drawState, primitiveType, 0, vertexCount);
}
}
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index a798ee86ef..dca6c1c017 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -128,12 +128,11 @@ private:
return gp.fFlags == this->fFlags;
}
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
if (fInCoverage) {
- out->setUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
} else {
- // uniform coverage
- out->setKnownSingleComponent(this->coverage());
+ inout->mulByKnownAlpha(255);
}
}
diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index 07f92086a2..24d3c456cb 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -498,13 +498,12 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
drawState->enableState(GrDrawState::kNoColorWrites_StateBit);
}
GrDrawState::AutoRestoreEffects are(drawState);
- SkAutoTUnref<const GrGeometryProcessor> gp(
+ drawState->setGeometryProcessor(
GrDefaultGeoProcFactory::Create(color,
GrDefaultGeoProcFactory::kPosition_GPType,
- newCoverage));
+ newCoverage))->unref();
if (indexCnt) {
target->drawIndexed(drawState,
- gp,
primType,
0,
0,
@@ -512,7 +511,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
indexCnt,
&devBounds);
} else {
- target->drawNonIndexed(drawState, gp, primType, 0, vertexCnt, &devBounds);
+ target->drawNonIndexed(drawState, primType, 0, vertexCnt, &devBounds);
}
}
}
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index ea72c290dd..d35ba233e7 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -637,6 +637,9 @@ void GrDistanceFieldTextContext::flush() {
}
this->setupCoverageEffect(filteredColor);
+ // Effects could be stored with one of the cache objects (atlas?)
+ drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
+
// Set draw state
if (fUseLCDText) {
// TODO: move supportsRGBCoverage check to setupCoverageEffect and only add LCD
@@ -645,18 +648,17 @@ void GrDistanceFieldTextContext::flush() {
if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorComponentFlags)) {
SkDebugf("LCD Text will not draw correctly.\n");
}
- SkASSERT(!fCachedGeometryProcessor->hasVertexColor());
+ SkASSERT(!drawState.hasColorVertexAttribute());
} else {
if (0xFF == GrColorUnpackA(fPaint.getColor())) {
drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true);
}
// We're using per-vertex color.
- SkASSERT(fCachedGeometryProcessor->hasVertexColor());
+ SkASSERT(drawState.hasColorVertexAttribute());
}
int nGlyphs = fCurrVertex / kVerticesPerGlyph;
fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
fDrawTarget->drawIndexedInstances(&drawState,
- fCachedGeometryProcessor.get(),
kTriangles_GrPrimitiveType,
nGlyphs,
kVerticesPerGlyph,
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 72ec7a32b5..465c10c99a 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -14,7 +14,7 @@
#include "GrXferProcessor.h"
#include "effects/GrPorterDuffXferProcessor.h"
-bool GrDrawState::isEqual(const GrDrawState& that, bool explicitLocalCoords) const {
+bool GrDrawState::isEqual(const GrDrawState& that) const {
if (this->getRenderTarget() != that.getRenderTarget() ||
this->fColorStages.count() != that.fColorStages.count() ||
this->fCoverageStages.count() != that.fCoverageStages.count() ||
@@ -25,6 +25,17 @@ bool GrDrawState::isEqual(const GrDrawState& that, bool explicitLocalCoords) con
return false;
}
+ bool explicitLocalCoords = this->hasLocalCoordAttribute();
+ if (this->hasGeometryProcessor()) {
+ if (!that.hasGeometryProcessor()) {
+ return false;
+ } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProcessor())) {
+ return false;
+ }
+ } else if (that.hasGeometryProcessor()) {
+ return false;
+ }
+
if (!this->getXPFactory()->isEqual(*that.getXPFactory())) {
return false;
}
@@ -66,6 +77,7 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
fFlagBits = that.fFlagBits;
fStencilSettings = that.fStencilSettings;
fDrawFace = that.fDrawFace;
+ fGeometryProcessor.reset(SkSafeRef(that.fGeometryProcessor.get()));
fXPFactory.reset(SkRef(that.getXPFactory()));
fColorStages = that.fColorStages;
fCoverageStages = that.fCoverageStages;
@@ -84,9 +96,10 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
}
void GrDrawState::onReset(const SkMatrix* initialViewMatrix) {
- SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages());
+ SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages());
fRenderTarget.reset(NULL);
+ fGeometryProcessor.reset(NULL);
fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode));
fColorStages.reset();
fCoverageStages.reset();
@@ -107,10 +120,6 @@ void GrDrawState::onReset(const SkMatrix* initialViewMatrix) {
fColorCache = GrColor_ILLEGAL;
fCoverageCache = GrColor_ILLEGAL;
-
- fColorPrimProc = NULL;
- fCoveragePrimProc = NULL;
-
}
bool GrDrawState::setIdentityViewMatrix() {
@@ -132,8 +141,9 @@ bool GrDrawState::setIdentityViewMatrix() {
}
void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRenderTarget* rt) {
- SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages());
+ SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages());
+ fGeometryProcessor.reset(NULL);
fColorStages.reset();
fCoverageStages.reset();
@@ -187,7 +197,7 @@ bool GrDrawState::canUseFracCoveragePrimProc(GrColor color, const GrDrawTargetCa
this->isCoverageDrawing(), this->isColorWriteDisabled());
}
-bool GrDrawState::hasSolidCoverage(const GrPrimitiveProcessor* pp) const {
+bool GrDrawState::hasSolidCoverage(GrColor coverage) const {
// If we're drawing coverage directly then coverage is effectively treated as color.
if (this->isCoverageDrawing()) {
return true;
@@ -197,15 +207,15 @@ bool GrDrawState::hasSolidCoverage(const GrPrimitiveProcessor* pp) const {
return false;
}
- this->calcCoverageInvariantOutput(pp);
+ this->calcCoverageInvariantOutput(coverage);
return fCoverageProcInfo.isSolidWhite();
}
//////////////////////////////////////////////////////////////////////////////s
-bool GrDrawState::willEffectReadDstColor(const GrPrimitiveProcessor* pp) const {
- this->calcColorInvariantOutput(pp);
- this->calcCoverageInvariantOutput(pp);
+bool GrDrawState::willEffectReadDstColor(GrColor color, GrColor coverage) const {
+ this->calcColorInvariantOutput(color);
+ this->calcCoverageInvariantOutput(coverage);
// TODO: Remove need to create the XP here.
// Also once all custom blends are turned into XPs we can remove the need
// to check other stages since only xp's will be able to read dst
@@ -225,6 +235,15 @@ bool GrDrawState::willEffectReadDstColor(const GrPrimitiveProcessor* pp) const {
void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
if (fDrawState) {
+ // See the big comment on the class definition about GPs.
+ if (SK_InvalidUniqueID == fOriginalGPID) {
+ fDrawState->fGeometryProcessor.reset(NULL);
+ } else {
+ SkASSERT(fDrawState->getGeometryProcessor()->getUniqueID() ==
+ fOriginalGPID);
+ fOriginalGPID = SK_InvalidUniqueID;
+ }
+
int m = fDrawState->numColorStages() - fColorEffectCnt;
SkASSERT(m >= 0);
fDrawState->fColorStages.pop_back_n(m);
@@ -240,6 +259,10 @@ void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
}
fDrawState = ds;
if (NULL != ds) {
+ SkASSERT(SK_InvalidUniqueID == fOriginalGPID);
+ if (NULL != ds->getGeometryProcessor()) {
+ fOriginalGPID = ds->getGeometryProcessor()->getUniqueID();
+ }
fColorEffectCnt = ds->numColorStages();
fCoverageEffectCnt = ds->numCoverageStages();
SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;)
@@ -349,35 +372,38 @@ GrDrawState::~GrDrawState() {
////////////////////////////////////////////////////////////////////////////////
-bool GrDrawState::willBlendWithDst(const GrPrimitiveProcessor* pp) const {
- this->calcColorInvariantOutput(pp);
- this->calcCoverageInvariantOutput(pp);
- return fXPFactory->willBlendWithDst(fColorProcInfo, fCoverageProcInfo,
- this->isCoverageDrawing(), this->isColorWriteDisabled());
-}
-
-void GrDrawState::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const {
- if (!fColorProcInfoValid || fColorPrimProc != pp) {
- fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->numColorStages());
- fColorProcInfoValid = true;
- fColorPrimProc = pp;
+bool GrDrawState::srcAlphaWillBeOne(GrColor color, GrColor coverage) const {
+ this->calcColorInvariantOutput(color);
+ if (this->isCoverageDrawing()) {
+ this->calcCoverageInvariantOutput(coverage);
+ return (fColorProcInfo.isOpaque() && fCoverageProcInfo.isOpaque());
}
+ return fColorProcInfo.isOpaque();
}
-void GrDrawState::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp) const {
- if (!fCoverageProcInfoValid || fCoveragePrimProc != pp) {
- fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(),
- this->numCoverageStages());
- fCoverageProcInfoValid = true;
- fCoveragePrimProc = pp;
- }
+bool GrDrawState::willBlendWithDst(GrColor color, GrColor coverage) const {
+ this->calcColorInvariantOutput(color);
+ this->calcCoverageInvariantOutput(coverage);
+ return fXPFactory->willBlendWithDst(fColorProcInfo, fCoverageProcInfo,
+ this->isCoverageDrawing(), this->isColorWriteDisabled());
}
void GrDrawState::calcColorInvariantOutput(GrColor color) const {
if (!fColorProcInfoValid || color != fColorCache) {
- GrColorComponentFlags flags = kRGBA_GrColorComponentFlags;
- fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(), color,
- flags, false);
+ GrColorComponentFlags flags;
+ if (this->hasColorVertexAttribute()) {
+ if (fHints & kVertexColorsAreOpaque_Hint) {
+ flags = kA_GrColorComponentFlag;
+ color = 0xFF << GrColor_SHIFT_A;
+ } else {
+ flags = static_cast<GrColorComponentFlags>(0);
+ color = 0;
+ }
+ } else {
+ flags = kRGBA_GrColorComponentFlags;
+ }
+ fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(),
+ color, flags, false);
fColorProcInfoValid = true;
fColorCache = color;
}
@@ -385,10 +411,16 @@ void GrDrawState::calcColorInvariantOutput(GrColor color) const {
void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const {
if (!fCoverageProcInfoValid || coverage != fCoverageCache) {
- GrColorComponentFlags flags = kRGBA_GrColorComponentFlags;
- fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(),
- this->numCoverageStages(), coverage, flags,
- true);
+ GrColorComponentFlags flags;
+ // Check if per-vertex or constant color may have partial alpha
+ if (this->hasCoverageVertexAttribute()) {
+ flags = static_cast<GrColorComponentFlags>(0);
+ coverage = 0;
+ } else {
+ flags = kRGBA_GrColorComponentFlags;
+ }
+ fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCoverageStages(),
+ coverage, flags, true, fGeometryProcessor.get());
fCoverageProcInfoValid = true;
fCoverageCache = coverage;
}
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index dff3c73f6c..17bd0f43df 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -68,6 +68,21 @@ public:
*/
void setFromPaint(const GrPaint& , const SkMatrix& viewMatrix, GrRenderTarget*);
+ ///////////////////////////////////////////////////////////////////////////
+ /// @name Vertex Attributes
+ ////
+
+ // TODO when we move this info off of GrGeometryProcessor, delete these
+ bool hasLocalCoordAttribute() const {
+ return this->hasGeometryProcessor() && this->getGeometryProcessor()->hasLocalCoords();
+ }
+ bool hasColorVertexAttribute() const {
+ return this->hasGeometryProcessor() && this->getGeometryProcessor()->hasVertexColor();
+ }
+ bool hasCoverageVertexAttribute() const {
+ return this->hasGeometryProcessor() && this->getGeometryProcessor()->hasVertexCoverage();
+ }
+
/// @}
/**
@@ -85,13 +100,29 @@ public:
/**
* Determines whether the output coverage is guaranteed to be one for all pixels hit by a draw.
*/
- bool hasSolidCoverage(const GrPrimitiveProcessor*) const;
+ bool hasSolidCoverage(GrColor coverage) const;
/**
* This function returns true if the render target destination pixel values will be read for
* blending during draw.
*/
- bool willBlendWithDst(const GrPrimitiveProcessor*) const;
+ bool willBlendWithDst(GrColor color, GrColor coverage) const;
+
+ /// @}
+
+ /**
+ * The geometry processor is the sole element of the skia pipeline which can use the vertex,
+ * geometry, and tesselation shaders. The GP may also compute a coverage in its fragment shader
+ * but is never put in the color processing pipeline.
+ */
+
+ const GrGeometryProcessor* setGeometryProcessor(const GrGeometryProcessor* geometryProcessor) {
+ SkASSERT(geometryProcessor);
+ SkASSERT(!this->hasGeometryProcessor());
+ fGeometryProcessor.reset(SkRef(geometryProcessor));
+ fCoverageProcInfoValid = false;
+ return geometryProcessor;
+ }
///////////////////////////////////////////////////////////////////////////
/// @name Effect Stages
@@ -116,6 +147,12 @@ public:
int numColorStages() const { return fColorStages.count(); }
int numCoverageStages() const { return fCoverageStages.count(); }
int numFragmentStages() const { return this->numColorStages() + this->numCoverageStages(); }
+ int numTotalStages() const {
+ return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 : 0);
+ }
+
+ bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()); }
+ const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryProcessor.get(); }
const GrXPFactory* getXPFactory() const { return fXPFactory.get(); }
@@ -126,7 +163,7 @@ public:
* Checks whether any of the effects will read the dst pixel color.
* TODO remove when we have an XP
*/
- bool willEffectReadDstColor(const GrPrimitiveProcessor*) const;
+ bool willEffectReadDstColor(GrColor color, GrColor coverage) const;
/**
* The xfer processor factory.
@@ -201,11 +238,13 @@ public:
public:
AutoRestoreEffects()
: fDrawState(NULL)
+ , fOriginalGPID(SK_InvalidUniqueID)
, fColorEffectCnt(0)
, fCoverageEffectCnt(0) {}
AutoRestoreEffects(GrDrawState* ds)
: fDrawState(NULL)
+ , fOriginalGPID(SK_InvalidUniqueID)
, fColorEffectCnt(0)
, fCoverageEffectCnt(0) {
this->set(ds);
@@ -219,6 +258,7 @@ public:
private:
GrDrawState* fDrawState;
+ uint32_t fOriginalGPID;
int fColorEffectCnt;
int fCoverageEffectCnt;
};
@@ -515,29 +555,22 @@ public:
GrDrawState& operator= (const GrDrawState& that);
private:
- bool isEqual(const GrDrawState& that, bool explicitLocalCoords) const;
+ bool isEqual(const GrDrawState& that) const;
- const GrProcOptInfo& colorProcInfo(const GrPrimitiveProcessor* pp) const {
- this->calcColorInvariantOutput(pp);
+ const GrProcOptInfo& colorProcInfo(GrColor color) const {
+ this->calcColorInvariantOutput(color);
return fColorProcInfo;
}
- const GrProcOptInfo& coverageProcInfo(const GrPrimitiveProcessor* pp) const {
- this->calcCoverageInvariantOutput(pp);
+ const GrProcOptInfo& coverageProcInfo(GrColor coverage) const {
+ this->calcCoverageInvariantOutput(coverage);
return fCoverageProcInfo;
}
/**
- * If fColorProcInfoValid is false, function calculates the invariant output for the color
- * stages and results are stored in fColorProcInfo.
- */
- void calcColorInvariantOutput(const GrPrimitiveProcessor*) const;
-
- /**
- * If fCoverageProcInfoValid is false, function calculates the invariant output for the coverage
- * stages and results are stored in fCoverageProcInfo.
+ * Determines whether src alpha is guaranteed to be one for all src pixels
*/
- void calcCoverageInvariantOutput(const GrPrimitiveProcessor*) const;
+ bool srcAlphaWillBeOne(GrColor color, GrColor coverage) const;
/**
* If fColorProcInfoValid is false, function calculates the invariant output for the color
@@ -564,6 +597,7 @@ private:
uint32_t fFlagBits;
GrStencilSettings fStencilSettings;
DrawFace fDrawFace;
+ SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
SkAutoTUnref<const GrXPFactory> fXPFactory;
FragmentStageArray fColorStages;
FragmentStageArray fCoverageStages;
@@ -575,8 +609,6 @@ private:
mutable bool fCoverageProcInfoValid;
mutable GrColor fColorCache;
mutable GrColor fCoverageCache;
- mutable const GrPrimitiveProcessor* fColorPrimProc;
- mutable const GrPrimitiveProcessor* fCoveragePrimProc;
friend class GrOptDrawState;
};
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 96594b1d63..adb7128e1c 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -307,7 +307,6 @@ void GrDrawTarget::popGeometrySource() {
////////////////////////////////////////////////////////////////////////////////
bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
- const GrGeometryProcessor* gp,
GrPrimitiveType type,
int startVertex,
int startIndex,
@@ -350,7 +349,8 @@ bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
SkASSERT(drawState.getRenderTarget());
- if (gp) {
+ if (drawState.hasGeometryProcessor()) {
+ const GrGeometryProcessor* gp = drawState.getGeometryProcessor();
int numTextures = gp->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = gp->texture(t);
@@ -383,10 +383,12 @@ bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
}
bool GrDrawTarget::setupDstReadIfNecessary(GrDrawState* ds,
- const GrPrimitiveProcessor* primProc,
+ GrColor color,
+ uint8_t coverage,
GrDeviceCoordTexture* dstCopy,
const SkRect* drawBounds) {
- if (this->caps()->dstReadInShaderSupport() || !ds->willEffectReadDstColor(primProc)) {
+ GrColor c = GrColorPackRGBA(coverage, coverage, coverage, coverage);
+ if (this->caps()->dstReadInShaderSupport() || !ds->willEffectReadDstColor(color, c)) {
return true;
}
SkIRect copyRect;
@@ -434,7 +436,6 @@ bool GrDrawTarget::setupDstReadIfNecessary(GrDrawState* ds,
}
void GrDrawTarget::drawIndexed(GrDrawState* ds,
- const GrGeometryProcessor* gp,
GrPrimitiveType type,
int startVertex,
int startIndex,
@@ -443,7 +444,7 @@ void GrDrawTarget::drawIndexed(GrDrawState* ds,
const SkRect* devBounds) {
SkASSERT(ds);
if (indexCount > 0 &&
- this->checkDraw(*ds, gp, type, startVertex, startIndex, vertexCount, indexCount)) {
+ this->checkDraw(*ds, type, startVertex, startIndex, vertexCount, indexCount)) {
// Setup clip
GrClipMaskManager::ScissorState scissorState;
@@ -470,23 +471,24 @@ void GrDrawTarget::drawIndexed(GrDrawState* ds,
// TODO: We should continue with incorrect blending.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy, devBounds)) {
+ const GrGeometryProcessor* gp = ds->getGeometryProcessor();
+ if (!this->setupDstReadIfNecessary(ds, gp->getColor(), gp->getCoverage(), &dstCopy,
+ devBounds)) {
return;
}
this->setDrawBuffers(&info, gp->getVertexStride());
- this->onDraw(*ds, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
+ this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
}
}
void GrDrawTarget::drawNonIndexed(GrDrawState* ds,
- const GrGeometryProcessor* gp,
GrPrimitiveType type,
int startVertex,
int vertexCount,
const SkRect* devBounds) {
SkASSERT(ds);
- if (vertexCount > 0 && this->checkDraw(*ds, gp, type, startVertex, -1, vertexCount, -1)) {
+ if (vertexCount > 0 && this->checkDraw(*ds, type, startVertex, -1, vertexCount, -1)) {
// Setup clip
GrClipMaskManager::ScissorState scissorState;
@@ -513,13 +515,15 @@ void GrDrawTarget::drawNonIndexed(GrDrawState* ds,
// TODO: We should continue with incorrect blending.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy, devBounds)) {
+ const GrGeometryProcessor* gp = ds->getGeometryProcessor();
+ if (!this->setupDstReadIfNecessary(ds, gp->getColor(), gp->getCoverage(), &dstCopy,
+ devBounds)) {
return;
}
this->setDrawBuffers(&info, gp->getVertexStride());
- this->onDraw(*ds, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
+ this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
}
}
@@ -559,7 +563,6 @@ void GrDrawTarget::getPathStencilSettingsForFilltype(GrPathRendering::FillType f
}
void GrDrawTarget::stencilPath(GrDrawState* ds,
- const GrPathProcessor* pathProc,
const GrPath* path,
GrPathRendering::FillType fill) {
// TODO: extract portions of checkDraw that are relevant to path stenciling.
@@ -581,11 +584,11 @@ void GrDrawTarget::stencilPath(GrDrawState* ds,
ds->getRenderTarget()->getStencilBuffer(),
&stencilSettings);
- this->onStencilPath(*ds, pathProc, path, scissorState, stencilSettings);
+ this->onStencilPath(*ds, path, scissorState, stencilSettings);
}
void GrDrawTarget::drawPath(GrDrawState* ds,
- const GrPathProcessor* pathProc,
+ GrColor color,
const GrPath* path,
GrPathRendering::FillType fill) {
// TODO: extract portions of checkDraw that are relevant to path rendering.
@@ -612,16 +615,16 @@ void GrDrawTarget::drawPath(GrDrawState* ds,
&stencilSettings);
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, pathProc, &dstCopy, &devBounds)) {
+ if (!this->setupDstReadIfNecessary(ds, color, 0xff, &dstCopy, &devBounds)) {
return;
}
- this->onDrawPath(*ds, pathProc, path, scissorState, stencilSettings, dstCopy.texture() ? &dstCopy :
- NULL);
+ this->onDrawPath(*ds, color, path, scissorState, stencilSettings, dstCopy.texture() ? &dstCopy :
+ NULL);
}
void GrDrawTarget::drawPaths(GrDrawState* ds,
- const GrPathProcessor* pathProc,
+ GrColor color,
const GrPathRange* pathRange,
const void* indices,
PathIndexType indexType,
@@ -656,11 +659,11 @@ void GrDrawTarget::drawPaths(GrDrawState* ds,
// point, because any context that supports NV_path_rendering will also
// support NV_blend_equation_advanced.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, pathProc, &dstCopy, NULL)) {
+ if (!this->setupDstReadIfNecessary(ds, color, 0xff, &dstCopy, NULL)) {
return;
}
- this->onDrawPaths(*ds, pathProc, pathRange, indices, indexType, transformValues, transformType,
+ this->onDrawPaths(*ds, color, pathRange, indices, indexType, transformValues, transformType,
count, scissorState, stencilSettings, dstCopy.texture() ? &dstCopy : NULL);
}
@@ -730,7 +733,6 @@ void GrDrawTarget::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
////////////////////////////////////////////////////////////////////////////////
void GrDrawTarget::drawIndexedInstances(GrDrawState* ds,
- const GrGeometryProcessor* gp,
GrPrimitiveType type,
int instanceCount,
int verticesPerInstance,
@@ -769,7 +771,8 @@ void GrDrawTarget::drawIndexedInstances(GrDrawState* ds,
// TODO: We should continue with incorrect blending.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy,devBounds)) {
+ const GrGeometryProcessor* gp = ds->getGeometryProcessor();
+ if (!this->setupDstReadIfNecessary(ds, gp->getColor(), gp->getCoverage(), &dstCopy,devBounds)) {
return;
}
@@ -779,14 +782,13 @@ void GrDrawTarget::drawIndexedInstances(GrDrawState* ds,
info.fIndexCount = info.fInstanceCount * indicesPerInstance;
if (this->checkDraw(*ds,
- gp,
type,
info.fStartVertex,
info.fStartIndex,
info.fVertexCount,
info.fIndexCount)) {
this->setDrawBuffers(&info, gp->getVertexStride());
- this->onDraw(*ds, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
+ this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
}
info.fStartVertex += info.fVertexCount;
instanceCount -= info.fInstanceCount;
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 770e8852b2..fc2ee76231 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -233,7 +233,6 @@ public:
* not a request for clipping.
*/
void drawIndexed(GrDrawState*,
- const GrGeometryProcessor*,
GrPrimitiveType type,
int startVertex,
int startIndex,
@@ -253,7 +252,6 @@ public:
* not a request for clipping.
*/
void drawNonIndexed(GrDrawState*,
- const GrGeometryProcessor*,
GrPrimitiveType type,
int startVertex,
int vertexCount,
@@ -265,13 +263,13 @@ public:
* on the draw state (if possible in the 3D API). Note, we will never have an inverse fill
* with stencil path
*/
- void stencilPath(GrDrawState*, const GrPathProcessor*, const GrPath*,GrPathRendering::FillType);
+ void stencilPath(GrDrawState*, const GrPath*, GrPathRendering::FillType fill);
/**
* Draws a path. Fill must not be a hairline. It will respect the HW
* antialias flag on the draw state (if possible in the 3D API).
*/
- void drawPath(GrDrawState*, const GrPathProcessor*, const GrPath*, GrPathRendering::FillType);
+ void drawPath(GrDrawState*, GrColor, const GrPath*, GrPathRendering::FillType fill);
/**
* Draws the aggregate path from combining multiple. Note that this will not
@@ -287,7 +285,7 @@ public:
* @param fill Fill type for drawing all the paths
*/
void drawPaths(GrDrawState*,
- const GrPathProcessor*,
+ GrColor,
const GrPathRange* pathRange,
const void* indices,
PathIndexType indexType,
@@ -359,7 +357,6 @@ public:
* not a request for clipping.
*/
void drawIndexedInstances(GrDrawState*,
- const GrGeometryProcessor*,
GrPrimitiveType type,
int instanceCount,
int verticesPerInstance,
@@ -659,7 +656,8 @@ protected:
// but couldn't be made. Otherwise, returns true. This method needs to be protected because it
// needs to be accessed by GLPrograms to setup a correct drawstate
bool setupDstReadIfNecessary(GrDrawState*,
- const GrPrimitiveProcessor*,
+ GrColor,
+ uint8_t,
GrDeviceCoordTexture* dstCopy,
const SkRect* drawBounds);
@@ -700,7 +698,6 @@ private:
virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0;
// subclass called to perform drawing
virtual void onDraw(const GrDrawState&,
- const GrGeometryProcessor*,
const DrawInfo&,
const GrClipMaskManager::ScissorState&,
const GrDeviceCoordTexture* dstCopy) = 0;
@@ -712,18 +709,17 @@ private:
const SkMatrix* localMatrix) = 0;
virtual void onStencilPath(const GrDrawState&,
- const GrPathProcessor*,
const GrPath*,
const GrClipMaskManager::ScissorState&,
const GrStencilSettings&) = 0;
virtual void onDrawPath(const GrDrawState&,
- const GrPathProcessor*,
+ GrColor,
const GrPath*,
const GrClipMaskManager::ScissorState&,
const GrStencilSettings&,
const GrDeviceCoordTexture* dstCopy) = 0;
virtual void onDrawPaths(const GrDrawState&,
- const GrPathProcessor*,
+ GrColor,
const GrPathRange*,
const void* indices,
PathIndexType,
@@ -770,7 +766,6 @@ private:
// called by drawIndexed and drawNonIndexed. Use a negative indexCount to
// indicate non-indexed drawing.
bool checkDraw(const GrDrawState&,
- const GrGeometryProcessor*,
GrPrimitiveType type,
int startVertex,
int startIndex,
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index 4411049c90..a0cfc09d45 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -39,23 +39,6 @@ class GrGLCaps;
class GrGLGeometryProcessor;
class GrOptDrawState;
-struct GrInitInvariantOutput;
-
-/*
- * GrGeometryProcessors and GrPathProcessors may effect invariantColor
- */
-class GrPrimitiveProcessor : public GrProcessor {
-public:
- // TODO GPs and PPs have to provide an initial coverage because the coverage invariant code is
- // broken right now
- virtual uint8_t coverage() const = 0;
- virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
- virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
-
-private:
- typedef GrProcessor INHERITED;
-};
-
/**
* A GrGeometryProcessor is used to perform computation in the vertex shader and
* add support for custom vertex attributes. A GrGemeotryProcessor is typically
@@ -66,7 +49,7 @@ private:
* added to the vertex attribute array specified on the GrDrawState.
* GrGeometryProcessor subclasses should be immutable after construction.
*/
-class GrGeometryProcessor : public GrPrimitiveProcessor {
+class GrGeometryProcessor : public GrProcessor {
public:
GrGeometryProcessor(GrColor color, uint8_t coverage = 0xff)
: fVertexStride(0)
@@ -131,13 +114,11 @@ public:
return false;
}
- if (!fHasVertexColor && this->color() != that.color()) {
+ if (!fHasVertexColor && this->getColor() != that.getColor()) {
return false;
}
- // TODO this is fragile, most gps set their coverage to 0xff so this is okay. In the long
- // term this should move to subclasses which set explicit coverage
- if (!fHasVertexCoverage && this->coverage() != that.coverage()) {
+ if (!fHasVertexCoverage && this->getCoverage() != that.getCoverage()) {
return false;
}
return this->onIsEqual(that);
@@ -152,8 +133,8 @@ public:
virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {}
- GrColor color() const { return fColor; }
- uint8_t coverage() const { return fCoverage; }
+ GrColor getColor() const { return fColor; }
+ uint8_t getCoverage() const { return fCoverage; }
// TODO this is a total hack until the gp can own whether or not it uses uniform
// color / coverage
@@ -161,8 +142,7 @@ public:
bool hasVertexCoverage() const { return fHasVertexCoverage; }
bool hasLocalCoords() const { return fHasLocalCoords; }
- void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE;
- void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE;
+ void computeInvariantColor(GrInvariantOutput* inout) const;
protected:
/**
@@ -183,9 +163,6 @@ protected:
void setHasVertexCoverage() { fHasVertexCoverage = true; }
void setHasLocalCoords() { fHasLocalCoords = true; }
- virtual void onGetInvariantOutputColor(GrInitInvariantOutput*) const {}
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const = 0;
-
private:
virtual bool onIsEqual(const GrGeometryProcessor&) const = 0;
@@ -200,26 +177,4 @@ private:
typedef GrProcessor INHERITED;
};
-
-/*
- * The path equivalent of the GP. For now this just manages color. In the long term we plan on
- * extending this class to handle all nvpr uniform / varying / program work.
- */
-class GrPathProcessor : public GrPrimitiveProcessor {
-public:
- static GrPathProcessor* Create(GrColor color) {
- return SkNEW_ARGS(GrPathProcessor, (color));
- }
-
- const char* name() const SK_OVERRIDE { return "PathProcessor"; }
- uint8_t coverage() const SK_OVERRIDE { return 0xff; }
- void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE;
- void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE;
-
-private:
- GrPathProcessor(GrColor color) : fColor(color) {}
- GrColor fColor;
-
- typedef GrProcessor INHERITED;
-};
#endif
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 0b5c96889b..493420db0b 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -62,17 +62,14 @@ void get_vertex_bounds(const void* vertices,
The vertex attrib order is always pos, color, [local coords].
*/
-static const GrGeometryProcessor* create_rect_gp(GrDrawState* drawState,
- bool hasLocalCoords,
- GrColor color) {
+static void set_vertex_attributes(GrDrawState* drawState, bool hasLocalCoords, GrColor color) {
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
GrDefaultGeoProcFactory::kColor_GPType;
flags |= hasLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
- const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(color, flags);
+ drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(color, flags))->unref();
if (0xFF == GrColorUnpackA(color)) {
drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true);
}
- return gp;
}
static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettings) {
@@ -119,10 +116,9 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
const SkMatrix* localMatrix) {
GrDrawState::AutoRestoreEffects are(ds);
- SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(ds, SkToBool(localRect),
- color));
+ set_vertex_attributes(ds, SkToBool(localRect), color);
- size_t vstride = gp->getVertexStride();
+ size_t vstride = ds->getGeometryProcessor()->getVertexStride();
SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) :
0));
AutoReleaseGeometry geo(this, 4, vstride, 0);
@@ -169,7 +165,7 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
}
this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer());
- this->drawIndexedInstances(ds, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds);
+ this->drawIndexedInstances(ds, kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds);
}
int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, const DrawInfo& info) {
@@ -225,13 +221,13 @@ int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, const DrawIn
}
void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds,
- const GrGeometryProcessor* gp,
const DrawInfo& info,
const ScissorState& scissorState,
const GrDeviceCoordTexture* dstCopy) {
SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
- if (!this->recordStateAndShouldDraw(ds, gp, NULL,
+ const GrGeometryProcessor* gp = ds.getGeometryProcessor();
+ if (!this->recordStateAndShouldDraw(ds, gp->getColor(), gp->getCoverage(),
GrGpu::PrimTypeToDrawType(info.primitiveType()),
scissorState, dstCopy)) {
return;
@@ -253,12 +249,11 @@ void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds,
}
void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds,
- const GrPathProcessor* pathProc,
const GrPath* path,
const GrClipMaskManager::ScissorState& scissorState,
const GrStencilSettings& stencilSettings) {
// Only compare the subset of GrDrawState relevant to path stenciling?
- if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kStencilPath_DrawType,
+ if (!this->recordStateAndShouldDraw(ds, GrColor_WHITE, 0xff, GrGpu::kStencilPath_DrawType,
scissorState, NULL)) {
return;
}
@@ -268,14 +263,14 @@ void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds,
}
void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds,
- const GrPathProcessor* pathProc,
+ GrColor color,
const GrPath* path,
const GrClipMaskManager::ScissorState& scissorState,
const GrStencilSettings& stencilSettings,
const GrDeviceCoordTexture* dstCopy) {
// TODO: Only compare the subset of GrDrawState relevant to path covering?
- if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kDrawPath_DrawType,
- scissorState, dstCopy)) {
+ if (!this->recordStateAndShouldDraw(ds, color, 0xff, GrGpu::kDrawPath_DrawType, scissorState,
+ dstCopy)) {
return;
}
DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
@@ -284,7 +279,7 @@ void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds,
}
void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
- const GrPathProcessor* pathProc,
+ GrColor color,
const GrPathRange* pathRange,
const void* indices,
PathIndexType indexType,
@@ -298,7 +293,7 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
SkASSERT(indices);
SkASSERT(transformValues);
- if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kDrawPath_DrawType, scissorState,
+ if (!this->recordStateAndShouldDraw(ds, color, 0xff, GrGpu::kDrawPath_DrawType, scissorState,
dstCopy)) {
return;
}
@@ -329,7 +324,7 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
transformType == previous->fTransformType &&
stencilSettings == previous->fStencilSettings &&
path_fill_type_is_winding(stencilSettings) &&
- !ds.willBlendWithDst(pathProc)) {
+ !ds.willBlendWithDst(color, GrColor_WHITE)) {
// Fold this DrawPaths call into the one previous.
previous->fCount += count;
return;
@@ -495,13 +490,13 @@ bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst,
}
bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
- const GrGeometryProcessor* gp,
- const GrPathProcessor* pathProc,
+ GrColor color,
+ uint8_t coverage,
GrGpu::DrawType drawType,
const GrClipMaskManager::ScissorState& scissor,
const GrDeviceCoordTexture* dstCopy) {
SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
- (ds, gp, pathProc, *this->getGpu()->caps(), scissor,
+ (ds, color, coverage, *this->getGpu()->caps(), scissor,
dstCopy, drawType));
if (ss->fState.mustSkip()) {
fCmdBuffer.pop_back();
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index 9b850a7849..6771fccd66 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -171,12 +171,11 @@ private:
};
struct SetState : public Cmd {
- SetState(const GrDrawState& drawState, const GrGeometryProcessor* gp,
- const GrPathProcessor* pp, const GrDrawTargetCaps& caps,
- const ScissorState& scissor, const GrDeviceCoordTexture* dstCopy,
- GrGpu::DrawType drawType)
+ SetState(const GrDrawState& drawState, GrColor color, uint8_t coverage,
+ const GrDrawTargetCaps& caps, const ScissorState& scissor,
+ const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType drawType)
: Cmd(kSetState_Cmd)
- , fState(drawState, gp, pp, caps, scissor, dstCopy, drawType) {}
+ , fState(drawState, color, coverage, caps, scissor, dstCopy, drawType) {}
void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE;
@@ -191,7 +190,6 @@ private:
// overrides from GrDrawTarget
void onDraw(const GrDrawState&,
- const GrGeometryProcessor*,
const DrawInfo&,
const ScissorState&,
const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
@@ -202,18 +200,17 @@ private:
const SkMatrix* localMatrix) SK_OVERRIDE;
void onStencilPath(const GrDrawState&,
- const GrPathProcessor*,
const GrPath*,
const ScissorState&,
const GrStencilSettings&) SK_OVERRIDE;
void onDrawPath(const GrDrawState&,
- const GrPathProcessor*,
+ GrColor,
const GrPath*,
const ScissorState&,
const GrStencilSettings&,
const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
void onDrawPaths(const GrDrawState&,
- const GrPathProcessor*,
+ GrColor,
const GrPathRange*,
const void* indices,
PathIndexType,
@@ -240,8 +237,8 @@ private:
// records it. If the draw can be skipped false is returned and no new GrOptDrawState is
// recorded.
bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&,
- const GrGeometryProcessor*,
- const GrPathProcessor*,
+ GrColor,
+ uint8_t coverage,
GrGpu::DrawType,
const GrClipMaskManager::ScissorState&,
const GrDeviceCoordTexture*);
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 010fe4b739..9ebe551d6b 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -14,36 +14,21 @@
#include "GrXferProcessor.h"
GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
- const GrGeometryProcessor* gp,
- const GrPathProcessor* pathProc,
+ GrColor color,
+ uint8_t coverage,
const GrDrawTargetCaps& caps,
const ScissorState& scissorState,
const GrDeviceCoordTexture* dstCopy,
GrGpu::DrawType drawType)
: fFinalized(false) {
+ GrColor coverageColor = GrColorPackRGBA(coverage, coverage, coverage, coverage);
fDrawType = drawType;
- // Copy GeometryProcesssor from DS or ODS
- if (gp) {
- SkASSERT(!pathProc);
- SkASSERT(!(GrGpu::IsPathRenderingDrawType(drawType) ||
- GrGpu::kStencilPath_DrawType == drawType));
- fGeometryProcessor.reset(gp);
- fPrimitiveProcessor.reset(gp);
- } else {
- SkASSERT(!gp && pathProc && (GrGpu::IsPathRenderingDrawType(drawType) ||
- GrGpu::kStencilPath_DrawType == drawType));
- fPrimitiveProcessor.reset(pathProc);
- }
-
-
- const GrProcOptInfo& colorPOI = drawState.colorProcInfo(fPrimitiveProcessor);
- const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(fPrimitiveProcessor);
+ const GrProcOptInfo& colorPOI = drawState.colorProcInfo(color);
+ const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(coverageColor);
fColor = colorPOI.inputColorToEffectiveStage();
- // TODO fix this when coverage stages work correctly
- // fCoverage = coveragePOI.inputColorToEffectiveStage();
- fCoverage = fPrimitiveProcessor->coverage();
+ fCoverage = coverage;
// Create XferProcessor from DS's XPFactory
SkAutoTUnref<GrXferProcessor> xferProcessor(
@@ -101,11 +86,14 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
fFlags |= kDither_Flag;
}
- fDescInfo.fHasVertexColor = gp && gp->hasVertexColor();
+ fDescInfo.fHasVertexColor = drawState.hasGeometryProcessor() &&
+ drawState.getGeometryProcessor()->hasVertexColor();
- fDescInfo.fHasVertexCoverage = gp && gp->hasVertexCoverage();
+ fDescInfo.fHasVertexCoverage = drawState.hasGeometryProcessor() &&
+ drawState.getGeometryProcessor()->hasVertexCoverage();
- bool hasLocalCoords = gp && gp->hasLocalCoords();
+ bool hasLocalCoords = drawState.hasGeometryProcessor() &&
+ drawState.getGeometryProcessor()->hasLocalCoords();
int firstColorStageIdx = colorPOI.firstEffectiveStageIndex();
fDescInfo.fInputColorIsUsed = colorPOI.inputColorIsUsed();
@@ -118,6 +106,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
int firstCoverageStageIdx = 0;
fDescInfo.fInputCoverageIsUsed = true;
+
GrXferProcessor::BlendInfo blendInfo;
fXferProcessor->getBlendInfo(&blendInfo);
fSrcBlend = blendInfo.fSrcBlend;
@@ -129,6 +118,12 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
fDescInfo.fRequiresLocalCoordAttrib = hasLocalCoords;
+ // Copy GeometryProcesssor from DS or ODS
+ SkASSERT(GrGpu::IsPathRenderingDrawType(drawType) ||
+ GrGpu::kStencilPath_DrawType ||
+ drawState.hasGeometryProcessor());
+ fGeometryProcessor.reset(drawState.getGeometryProcessor());
+
// Copy Stages from DS to ODS
for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) {
SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
@@ -144,7 +139,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
}
// let the GP init the batch tracker
- if (gp) {
+ if (drawState.hasGeometryProcessor()) {
GrGeometryProcessor::InitBT init;
init.fOutputColor = fDescInfo.fInputColorIsUsed;
init.fOutputCoverage = fDescInfo.fInputCoverageIsUsed;
diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h
index 1e7b5e5ad1..55a5071d41 100644
--- a/src/gpu/GrOptDrawState.h
+++ b/src/gpu/GrOptDrawState.h
@@ -19,7 +19,6 @@
class GrDeviceCoordTexture;
class GrDrawState;
-class GrPathProcessor;
/**
* Class that holds an optimized version of a GrDrawState. It is meant to be an immutable class,
@@ -31,9 +30,8 @@ public:
typedef GrClipMaskManager::ScissorState ScissorState;
- GrOptDrawState(const GrDrawState& drawState, const GrGeometryProcessor*, const GrPathProcessor*,
- const GrDrawTargetCaps&, const ScissorState&,
- const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType);
+ GrOptDrawState(const GrDrawState& drawState, GrColor, uint8_t coverage, const GrDrawTargetCaps&,
+ const ScissorState&, const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType);
bool operator== (const GrOptDrawState& that) const;
bool operator!= (const GrOptDrawState& that) const { return !(*this == that); }
@@ -209,7 +207,7 @@ private:
* the function may adjust the blend coefficients. After this function is called the src and dst
* blend coeffs will represent those used by backend API.
*/
- void setOutputStateInfo(const GrDrawState& ds, GrXferProcessor::OptFlags,
+ void setOutputStateInfo(const GrDrawState& ds, GrColor coverage, GrXferProcessor::OptFlags,
const GrDrawTargetCaps&);
enum Flags {
@@ -221,7 +219,6 @@ private:
typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget;
typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray;
typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryProcessor;
- typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitiveProcessor;
typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor;
RenderTarget fRenderTarget;
ScissorState fScissorState;
@@ -236,7 +233,6 @@ private:
GrBlendCoeff fDstBlend;
uint32_t fFlags;
ProgramGeometryProcessor fGeometryProcessor;
- ProgramPrimitiveProcessor fPrimitiveProcessor;
GrBatchTracker fBatchTracker;
ProgramXferProcessor fXferProcessor;
FragmentStageArray fFragmentStages;
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 22a18d2d10..eac6fb4a3a 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -144,8 +144,8 @@ private:
return cee.fStroke == fStroke;
}
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
- out->setUnknownSingleComponent();
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
+ inout->mulByUnknownAlpha();
}
const GrAttribute* fInPosition;
@@ -290,8 +290,8 @@ private:
return eee.fStroke == fStroke;
}
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
- out->setUnknownSingleComponent();
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
+ inout->mulByUnknownAlpha();
}
const GrAttribute* fInPosition;
@@ -455,8 +455,8 @@ private:
return eee.fMode == fMode;
}
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
- out->setUnknownSingleComponent();
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
+ inout->mulByUnknownAlpha();
}
const GrAttribute* fInPosition;
@@ -562,8 +562,8 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target,
}
}
- SkAutoTUnref<GrGeometryProcessor> gp(
- CircleEdgeEffect::Create(color, isStrokeOnly && innerRadius > 0));
+ GrGeometryProcessor* gp = CircleEdgeEffect::Create(color, isStrokeOnly && innerRadius > 0);
+ drawState->setGeometryProcessor(gp)->unref();
GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0);
SkASSERT(gp->getVertexStride() == sizeof(CircleVertex));
@@ -609,7 +609,7 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target,
verts[3].fInnerRadius = innerRadius;
target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
+ target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
target->resetIndexSource();
}
@@ -689,8 +689,11 @@ bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
return false;
}
- SkAutoTUnref<GrGeometryProcessor> gp(
- EllipseEdgeEffect::Create(color, isStrokeOnly && innerXRadius > 0 && innerYRadius > 0));
+ GrGeometryProcessor* gp = EllipseEdgeEffect::Create(color,
+ isStrokeOnly &&
+ innerXRadius > 0 && innerYRadius > 0);
+
+ drawState->setGeometryProcessor(gp)->unref();
GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0);
SkASSERT(gp->getVertexStride() == sizeof(EllipseVertex));
@@ -741,7 +744,7 @@ bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
+ target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
target->resetIndexSource();
return true;
@@ -806,7 +809,9 @@ bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
SkScalar innerRatioX = SkScalarDiv(xRadius, innerXRadius);
SkScalar innerRatioY = SkScalarDiv(yRadius, innerYRadius);
- SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(color, mode));
+ GrGeometryProcessor* gp = DIEllipseEdgeEffect::Create(color, mode);
+
+ drawState->setGeometryProcessor(gp)->unref();
GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0);
SkASSERT(gp->getVertexStride() == sizeof(DIEllipseVertex));
@@ -852,7 +857,7 @@ bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY - offsetDy);
target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
+ target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
target->resetIndexSource();
return true;
@@ -1072,7 +1077,8 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target,
isStrokeOnly = (isStrokeOnly && innerRadius >= 0);
- SkAutoTUnref<GrGeometryProcessor> effect(CircleEdgeEffect::Create(color, isStrokeOnly));
+ GrGeometryProcessor* effect = CircleEdgeEffect::Create(color, isStrokeOnly);
+ drawState->setGeometryProcessor(effect)->unref();
GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStride(), 0);
SkASSERT(effect->getVertexStride() == sizeof(CircleVertex));
@@ -1134,7 +1140,7 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target,
int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
SK_ARRAY_COUNT(gRRectIndices);
target->setIndexSourceToBuffer(indexBuffer);
- target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveType, 1, 16, indexCnt,
+ target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 16, indexCnt,
&bounds);
// otherwise we use the ellipse renderer
@@ -1173,7 +1179,8 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target,
isStrokeOnly = (isStrokeOnly && innerXRadius >= 0 && innerYRadius >= 0);
- SkAutoTUnref<GrGeometryProcessor> effect(EllipseEdgeEffect::Create(color, isStrokeOnly));
+ GrGeometryProcessor* effect = EllipseEdgeEffect::Create(color, isStrokeOnly);
+ drawState->setGeometryProcessor(effect)->unref();
GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStride(), 0);
SkASSERT(effect->getVertexStride() == sizeof(EllipseVertex));
@@ -1240,7 +1247,7 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target,
int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
SK_ARRAY_COUNT(gRRectIndices);
target->setIndexSourceToBuffer(indexBuffer);
- target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveType, 1, 16, indexCnt,
+ target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 16, indexCnt,
&bounds);
}
diff --git a/src/gpu/GrProcOptInfo.cpp b/src/gpu/GrProcOptInfo.cpp
index ebcf016075..a84ac2e17f 100644
--- a/src/gpu/GrProcOptInfo.cpp
+++ b/src/gpu/GrProcOptInfo.cpp
@@ -11,57 +11,37 @@
#include "GrFragmentStage.h"
#include "GrGeometryProcessor.h"
-void GrProcOptInfo::calcColorWithPrimProc(const GrPrimitiveProcessor* primProc,
- const GrFragmentStage* stages,
- int stageCount) {
- GrInitInvariantOutput out;
- primProc->getInvariantOutputColor(&out);
- fInOut.reset(out);
- this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition());
-}
-
-void GrProcOptInfo::calcCoverageWithPrimProc(const GrPrimitiveProcessor* primProc,
- const GrFragmentStage* stages,
- int stageCount) {
- GrInitInvariantOutput out;
- primProc->getInvariantOutputCoverage(&out);
- fInOut.reset(out);
- this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition());
-}
-
void GrProcOptInfo::calcWithInitialValues(const GrFragmentStage* stages,
int stageCount,
GrColor startColor,
GrColorComponentFlags flags,
- bool areCoverageStages) {
- GrInitInvariantOutput out;
- out.fIsSingleComponent = areCoverageStages;
- out.fColor = startColor;
- out.fValidFlags = flags;
- this->internalCalc(stages, stageCount, false);
-}
-
-void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
- int stageCount,
- bool initWillReadFragmentPosition) {
+ bool areCoverageStages,
+ const GrGeometryProcessor* gp) {
+ fInOut.reset(startColor, flags, areCoverageStages);
fFirstEffectStageIndex = 0;
fInputColorIsUsed = true;
- fInputColor = fInOut.color();
+ fInputColor = startColor;
fRemoveVertexAttrib = false;
fReadsDst = false;
- fReadsFragPosition = initWillReadFragmentPosition;
+ fReadsFragPosition = false;
+
+ if (areCoverageStages && gp) {
+ gp->computeInvariantOutput(&fInOut);
+ }
for (int i = 0; i < stageCount; ++i) {
const GrFragmentProcessor* processor = stages[i].getProcessor();
fInOut.resetWillUseInputColor();
processor->computeInvariantOutput(&fInOut);
- SkDEBUGCODE(fInOut.validate());
+#ifdef SK_DEBUG
+ fInOut.validate();
+#endif
if (!fInOut.willUseInputColor()) {
fFirstEffectStageIndex = i;
fInputColorIsUsed = false;
// Reset these since we don't care if previous stages read these values
fReadsDst = false;
- fReadsFragPosition = initWillReadFragmentPosition;
+ fReadsFragPosition = false;
}
if (processor->willReadDstColor()) {
fReadsDst = true;
@@ -79,7 +59,8 @@ void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
fInOut.resetNonMulStageFound();
// Reset these since we don't care if previous stages read these values
fReadsDst = false;
- fReadsFragPosition = initWillReadFragmentPosition;
+ fReadsFragPosition = false;
}
}
}
+
diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h
index 30b286f3ae..91ff5f9eb5 100644
--- a/src/gpu/GrProcOptInfo.h
+++ b/src/gpu/GrProcOptInfo.h
@@ -13,7 +13,7 @@
class GrFragmentStage;
class GrFragmentProcessor;
-class GrPrimitiveProcessor;
+class GrGeometryProcessor;
class GrProcessor;
/**
@@ -33,11 +33,8 @@ public:
, fReadsFragPosition(false) {}
void calcWithInitialValues(const GrFragmentStage*, int stageCount, GrColor startColor,
- GrColorComponentFlags flags, bool areCoverageStages);
-
- void calcColorWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentStage*, int stagecount);
- void calcCoverageWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentStage*,
- int stagecount);
+ GrColorComponentFlags flags, bool areCoverageStages,
+ const GrGeometryProcessor* gp = NULL);
bool isSolidWhite() const { return fInOut.isSolidWhite(); }
bool isOpaque() const { return fInOut.isOpaque(); }
@@ -92,8 +89,6 @@ public:
bool readsFragPosition() const { return fReadsFragPosition; }
private:
- void internalCalc(const GrFragmentStage*, int stagecount, bool initWillReadFragPosition);
-
GrInvariantOutput fInOut;
int fFirstEffectStageIndex;
bool fInputColorIsUsed;
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index c937c2ec1a..2bcd9b46a2 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -145,6 +145,10 @@ bool GrProcessor::hasSameTextureAccesses(const GrProcessor& that) const {
return true;
}
+void GrProcessor::computeInvariantOutput(GrInvariantOutput* inout) const {
+ this->onComputeInvariantOutput(inout);
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) {
@@ -165,33 +169,10 @@ bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con
return true;
}
-void GrFragmentProcessor::computeInvariantOutput(GrInvariantOutput* inout) const {
- this->onComputeInvariantOutput(inout);
-}
-
///////////////////////////////////////////////////////////////////////////////////////////////////
-void GrGeometryProcessor::getInvariantOutputColor(GrInitInvariantOutput* out) const {
- if (fHasVertexColor) {
- out->setUnknownFourComponents();
- } else {
- out->setKnownFourComponents(fColor);
- }
- this->onGetInvariantOutputColor(out);
-}
+void GrGeometryProcessor::computeInvariantColor(GrInvariantOutput* intout) const {
-void GrGeometryProcessor::getInvariantOutputCoverage(GrInitInvariantOutput* out) const {
- this->onGetInvariantOutputCoverage(out);
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-void GrPathProcessor::getInvariantOutputColor(GrInitInvariantOutput* out) const {
- out->setKnownFourComponents(fColor);
-}
-
-void GrPathProcessor::getInvariantOutputCoverage(GrInitInvariantOutput* out) const {
- out->setKnownSingleComponent(0xff);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -212,3 +193,4 @@ void GrGeometryData::operator delete(void* target) {
// Initial static variable from GrXPFactory
int32_t GrXPFactory::gCurrXPFClassID =
GrXPFactory::kIllegalXPFClassID;
+
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp
index d8470f3c8c..e7c4fc8899 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -85,9 +85,8 @@ void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target,
const SkPath& path,
const SkStrokeRec& stroke) {
SkASSERT(!path.isInverseFillType());
- SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE));
SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
- target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFillType()));
+ target->stencilPath(drawState, p, convert_skpath_filltype(path.getFillType()));
}
bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
@@ -118,8 +117,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
drawState->setStencil(kInvertedStencilPass);
// fake inverse with a stencil and cover
- SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE));
- target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFillType()));
+ target->stencilPath(drawState, p, convert_skpath_filltype(path.getFillType()));
GrDrawState::AutoViewMatrixRestore avmr;
SkRect bounds = SkRect::MakeLTRB(0, 0,
@@ -147,8 +145,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
0xffff);
drawState->setStencil(kStencilPass);
- SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color));
- target->drawPath(drawState, pp, p, convert_skpath_filltype(path.getFillType()));
+ target->drawPath(drawState, color, p, convert_skpath_filltype(path.getFillType()));
}
drawState->stencil()->setDisabled();
diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp
index 42f74ea0f5..bf1e58dae8 100644
--- a/src/gpu/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/GrStencilAndCoverTextContext.cpp
@@ -399,8 +399,7 @@ static const SkScalar* get_xy_scalar_array(const SkPoint* pointArray) {
void GrStencilAndCoverTextContext::flush() {
if (fQueuedGlyphCount > 0) {
- SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(fPaint.getColor()));
- fDrawTarget->drawPaths(&fDrawState, pp, fGlyphs,
+ fDrawTarget->drawPaths(&fDrawState, fPaint.getColor(), fGlyphs,
fGlyphIndices, GrPathRange::kU16_PathIndexType,
get_xy_scalar_array(fGlyphPositions),
GrPathRendering::kTranslate_PathTransformType,
diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h
index 53b1053b0c..a9cbeb0dcb 100644
--- a/src/gpu/effects/GrBezierEffect.h
+++ b/src/gpu/effects/GrBezierEffect.h
@@ -102,8 +102,8 @@ private:
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
- out->setUnknownSingleComponent();
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
+ inout->mulByUnknownAlpha();
}
GrPrimitiveEdgeType fEdgeType;
@@ -171,8 +171,8 @@ private:
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
- out->setUnknownSingleComponent();
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
+ inout->mulByUnknownAlpha();
}
GrPrimitiveEdgeType fEdgeType;
@@ -241,8 +241,8 @@ private:
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
- out->setUnknownSingleComponent();
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
+ inout->mulByUnknownAlpha();
}
GrPrimitiveEdgeType fEdgeType;
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 76edff0dc6..8ada70eaa9 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -175,7 +175,7 @@ bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
// FIXME: Perhaps we can do better.
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect);
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 9c5e82e8ff..1578fd8fe4 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -84,15 +84,15 @@ bool GrBitmapTextGeoProc::onIsEqual(const GrGeometryProcessor& other) const {
return SkToBool(this->inColor()) == SkToBool(gp.inColor());
}
-void GrBitmapTextGeoProc::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
+void GrBitmapTextGeoProc::onComputeInvariantOutput(GrInvariantOutput* inout) const {
if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
- out->setUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
} else if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
- out->setUnknownOpaqueFourComponents();
- out->setUsingLCDCoverage();
+ inout->mulByUnknownOpaqueColor();
+ inout->setUsingLCDCoverage();
} else {
- out->setUnknownFourComponents();
- out->setUsingLCDCoverage();
+ inout->mulByUnknownColor();
+ inout->setUsingLCDCoverage();
}
}
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.h b/src/gpu/effects/GrBitmapTextGeoProc.h
index ef86704845..ce235ae154 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.h
+++ b/src/gpu/effects/GrBitmapTextGeoProc.h
@@ -45,7 +45,7 @@ private:
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
const GrAttribute* fInPosition;
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 14307165e3..248cd17353 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -44,9 +44,9 @@ private:
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
if (fRect.isEmpty()) {
// An empty rect will have no coverage anywhere.
- inout->mulByKnownSingleComponent(0);
+ inout->mulByKnownAlpha(0);
} else {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
}
}
@@ -323,7 +323,7 @@ GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, co
GrConvexPolyEffect::~GrConvexPolyEffect() {}
void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
}
void GrConvexPolyEffect::getGLProcessorKey(const GrGLCaps& caps,
diff --git a/src/gpu/effects/GrConvolutionEffect.h b/src/gpu/effects/GrConvolutionEffect.h
index 1d0950bfa5..7fda3699c3 100644
--- a/src/gpu/effects/GrConvolutionEffect.h
+++ b/src/gpu/effects/GrConvolutionEffect.h
@@ -99,7 +99,7 @@ private:
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const {
// If the texture was opaque we could know that the output color if we knew the sum of the
// kernel values.
- inout->mulByUnknownFourComponents();
+ inout->mulByUnknownColor();
}
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 1641d272fc..b59b2a6e5c 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -335,7 +335,7 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState
devIntervals[0] = lineLength;
}
- SkAutoTUnref<const GrGeometryProcessor> gp;
+ const GrGeometryProcessor* gp;
bool fullDash = devIntervals[1] > 0.f || useAA;
if (fullDash) {
SkPathEffect::DashInfo devInfo;
@@ -347,12 +347,14 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState
bool isRoundCap = SkPaint::kRound_Cap == cap;
GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_DashCap :
GrDashingEffect::kNonRound_DashCap;
- gp.reset(GrDashingEffect::Create(color, edgeType, devInfo, strokeWidth, capType));
+ gp = GrDashingEffect::Create(color, edgeType, devInfo, strokeWidth, capType);
} else {
// Set up the vertex data for the line and start/end dashes
- gp.reset(GrDefaultGeoProcFactory::Create(color, GrDefaultGeoProcFactory::kPosition_GPType));
+ gp = GrDefaultGeoProcFactory::Create(color, GrDefaultGeoProcFactory::kPosition_GPType);
}
+ drawState->setGeometryProcessor(gp)->unref();
+
int totalRectCnt = 0;
totalRectCnt += !lineDone ? 1 : 0;
@@ -433,7 +435,7 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState
}
target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, totalRectCnt, 4, 6);
+ target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, totalRectCnt, 4, 6);
target->resetIndexSource();
return true;
}
@@ -487,7 +489,7 @@ private:
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrPrimitiveEdgeType fEdgeType;
const GrAttribute* fInPosition;
@@ -612,8 +614,8 @@ GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
DashingCircleEffect::~DashingCircleEffect() {}
-void DashingCircleEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
- out->setUnknownSingleComponent();
+void DashingCircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
+ inout->mulByUnknownAlpha();
}
void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
@@ -717,7 +719,7 @@ private:
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrPrimitiveEdgeType fEdgeType;
const GrAttribute* fInPosition;
@@ -855,8 +857,8 @@ GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
DashingLineEffect::~DashingLineEffect() {}
-void DashingLineEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
- out->setUnknownSingleComponent();
+void DashingLineEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
+ inout->mulByUnknownAlpha();
}
void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
index be06c1dbc4..f408d2dfec 100755
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
@@ -206,8 +206,8 @@ bool GrDistanceFieldTextureEffect::onIsEqual(const GrGeometryProcessor& other) c
fFlags == cte.fFlags;
}
-void GrDistanceFieldTextureEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
- out->setUnknownSingleComponent();
+void GrDistanceFieldTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
+ inout->mulByUnknownAlpha();
}
void GrDistanceFieldTextureEffect::getGLProcessorKey(const GrBatchTracker& bt,
@@ -407,8 +407,8 @@ bool GrDistanceFieldNoGammaTextureEffect::onIsEqual(const GrGeometryProcessor& o
return fFlags == cte.fFlags;
}
-void GrDistanceFieldNoGammaTextureEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const{
- out->setUnknownSingleComponent();
+void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
+ inout->mulByUnknownAlpha();
}
void GrDistanceFieldNoGammaTextureEffect::getGLProcessorKey(const GrBatchTracker& bt,
@@ -665,9 +665,9 @@ bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrGeometryProcessor& other
fFlags == cte.fFlags);
}
-void GrDistanceFieldLCDTextureEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
- out->setUnknownFourComponents();
- out->setUsingLCDCoverage();
+void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
+ inout->mulByUnknownColor();
+ inout->setUsingLCDCoverage();
}
void GrDistanceFieldLCDTextureEffect::getGLProcessorKey(const GrBatchTracker& bt,
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.h b/src/gpu/effects/GrDistanceFieldTextureEffect.h
index a290d5785d..f0f7e3b8c9 100644
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.h
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.h
@@ -87,7 +87,7 @@ private:
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
#ifdef SK_GAMMA_APPLY_TO_A8
@@ -139,7 +139,7 @@ private:
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
uint32_t fFlags;
@@ -190,7 +190,7 @@ private:
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
GrTextureAccess fGammaTextureAccess;
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h
index 8d6bb7cc10..6d60609e31 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.h
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.h
@@ -81,7 +81,7 @@ private:
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
// TODO: Try to do better?
- inout->mulByUnknownFourComponents();
+ inout->mulByUnknownColor();
}
SkIRect fBounds;
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index f1d1e68f29..b750599aec 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -56,7 +56,7 @@ GrFragmentProcessor* CircleEffect::Create(GrPrimitiveEdgeType edgeType, const Sk
}
void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
}
CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar r)
@@ -233,7 +233,7 @@ GrFragmentProcessor* EllipseEffect::Create(GrPrimitiveEdgeType edgeType,
}
void EllipseEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
}
EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar rx, SkScalar ry)
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index 1c1bd18791..64a9d413ce 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -86,7 +86,7 @@ GrFragmentProcessor* CircularRRectEffect::Create(GrPrimitiveEdgeType edgeType,
}
void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
}
CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t circularCornerFlags,
@@ -426,7 +426,7 @@ EllipticalRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect
}
void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
}
EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const SkRRect& rrect)
diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h
index 9df0cffa5a..6fd6819e92 100644
--- a/src/gpu/effects/GrSingleTextureEffect.h
+++ b/src/gpu/effects/GrSingleTextureEffect.h
@@ -41,11 +41,11 @@ protected:
*/
void updateInvariantOutputForModulation(GrInvariantOutput* inout) const {
if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
} else if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
- inout->mulByUnknownOpaqueFourComponents();
+ inout->mulByUnknownOpaqueColor();
} else {
- inout->mulByUnknownFourComponents();
+ inout->mulByUnknownColor();
}
}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index f1ef61832c..b5b9ae46d9 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -273,9 +273,9 @@ bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper
if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
- inout->mulByUnknownSingleComponent();
+ inout->mulByUnknownAlpha();
} else {
- inout->mulByUnknownFourComponents();
+ inout->mulByUnknownColor();
}
} else {
this->updateInvariantOutputForModulation(inout);
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index c0de2a594d..953b5e07cb 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -129,14 +129,19 @@ static void set_random_xpf(GrContext* context, const GrDrawTargetCaps& caps, GrD
ds->setXPFactory(xpf.get());
}
-static const GrGeometryProcessor* get_random_gp(GrContext* context,
- const GrDrawTargetCaps& caps,
- SkRandom* random,
- GrTexture* dummyTextures[]) {
- return GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random,
- context,
- caps,
- dummyTextures);
+static void set_random_gp(GrContext* context,
+ const GrDrawTargetCaps& caps,
+ GrDrawState* ds,
+ SkRandom* random,
+ GrTexture* dummyTextures[]) {
+ SkAutoTUnref<const GrGeometryProcessor> gp(
+ GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random,
+ context,
+ caps,
+ dummyTextures));
+ SkASSERT(gp);
+
+ ds->setGeometryProcessor(gp);
}
static void set_random_color_coverage_stages(GrGpuGL* gpu,
@@ -288,12 +293,8 @@ bool GrDrawTarget::programUnitTest(int maxStages) {
// twiddle drawstate knobs randomly
bool hasGeometryProcessor = !usePathRendering;
- const GrGeometryProcessor* gp = NULL;
- const GrPathProcessor* pathProc = NULL;
if (hasGeometryProcessor) {
- gp = get_random_gp(fContext, gpu->glCaps(), &random, dummyTextures);
- } else {
- pathProc = GrPathProcessor::Create(GrColor_WHITE);
+ set_random_gp(fContext, gpu->glCaps(), &ds, &random, dummyTextures);
}
set_random_color_coverage_stages(gpu,
&ds,
@@ -311,20 +312,19 @@ bool GrDrawTarget::programUnitTest(int maxStages) {
GrDeviceCoordTexture dstCopy;
- const GrPrimitiveProcessor* primProc;
- if (hasGeometryProcessor) {
- primProc = gp;
- } else {
- primProc = pathProc;
- }
- if (!this->setupDstReadIfNecessary(&ds, primProc, &dstCopy, NULL)) {
+ // TODO take color off the PP when its installed
+ GrColor color = ds.hasGeometryProcessor() ? ds.getGeometryProcessor()->getColor() :
+ GrColor_WHITE;
+ uint8_t coverage = ds.hasGeometryProcessor() ? ds.getGeometryProcessor()->getCoverage() :
+ 0xff;
+ if (!this->setupDstReadIfNecessary(&ds, color, coverage, &dstCopy, NULL)) {
SkDebugf("Couldn't setup dst read texture");
return false;
}
// create optimized draw state, setup readDst texture if required, and build a descriptor
// and program. ODS creation can fail, so we have to check
- GrOptDrawState ods(ds, gp, pathProc, *gpu->caps(), scissor, &dstCopy, drawType);
+ GrOptDrawState ods(ds, color, coverage, *gpu->caps(), scissor, &dstCopy, drawType);
if (ods.mustSkip()) {
continue;
}