aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2015-01-22 10:16:09 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-22 10:16:09 -0800
commit8dd688b7569df569a672a8a67b2db86a9d376cfc (patch)
treee173468f68becd63d0796010c6ddf15215912d3b /src/gpu
parente44acc9617b875e2ffc84cdf938a5e359e8e8edb (diff)
Rename GrOptDrawState to GrPipeline and GrDrawState to GrPipelineBuilder
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrAAConvexPathRenderer.cpp10
-rw-r--r--src/gpu/GrAAConvexPathRenderer.h4
-rwxr-xr-xsrc/gpu/GrAADistanceFieldPathRenderer.cpp16
-rwxr-xr-xsrc/gpu/GrAADistanceFieldPathRenderer.h8
-rw-r--r--src/gpu/GrAAHairLinePathRenderer.cpp28
-rw-r--r--src/gpu/GrAAHairLinePathRenderer.h8
-rw-r--r--src/gpu/GrAARectRenderer.cpp34
-rw-r--r--src/gpu/GrAARectRenderer.h14
-rwxr-xr-xsrc/gpu/GrBitmapTextContext.cpp11
-rw-r--r--src/gpu/GrClipMaskManager.cpp177
-rw-r--r--src/gpu/GrClipMaskManager.h22
-rwxr-xr-xsrc/gpu/GrContext.cpp166
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.cpp1
-rw-r--r--src/gpu/GrDefaultPathRenderer.cpp62
-rw-r--r--src/gpu/GrDefaultPathRenderer.h12
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp9
-rw-r--r--src/gpu/GrDrawTarget.cpp156
-rw-r--r--src/gpu/GrDrawTarget.h69
-rw-r--r--src/gpu/GrGpu.h12
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp56
-rw-r--r--src/gpu/GrInOrderDrawBuffer.h27
-rw-r--r--src/gpu/GrOvalRenderer.cpp63
-rw-r--r--src/gpu/GrOvalRenderer.h12
-rw-r--r--src/gpu/GrPathRenderer.h42
-rw-r--r--src/gpu/GrPathRendererChain.cpp10
-rw-r--r--src/gpu/GrPipeline.cpp (renamed from src/gpu/GrOptDrawState.cpp)70
-rw-r--r--src/gpu/GrPipeline.h (renamed from src/gpu/GrOptDrawState.h)34
-rw-r--r--src/gpu/GrPipelineBuilder.cpp (renamed from src/gpu/GrDrawState.cpp)65
-rw-r--r--src/gpu/GrPipelineBuilder.h (renamed from src/gpu/GrDrawState.h)83
-rw-r--r--src/gpu/GrSWMaskHelper.cpp10
-rw-r--r--src/gpu/GrSWMaskHelper.h4
-rw-r--r--src/gpu/GrSoftwarePathRenderer.cpp30
-rw-r--r--src/gpu/GrSoftwarePathRenderer.h6
-rw-r--r--src/gpu/GrStencilAndCoverPathRenderer.cpp34
-rw-r--r--src/gpu/GrStencilAndCoverPathRenderer.h8
-rw-r--r--src/gpu/GrStencilAndCoverTextContext.cpp10
-rw-r--r--src/gpu/GrStencilAndCoverTextContext.h4
-rw-r--r--src/gpu/GrTest.cpp4
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp14
-rw-r--r--src/gpu/effects/GrDashingEffect.h7
-rw-r--r--src/gpu/gl/GrGLGpu.cpp36
-rw-r--r--src/gpu/gl/GrGLGpu.h13
-rw-r--r--src/gpu/gl/GrGLGpuProgramCache.cpp1
-rw-r--r--src/gpu/gl/GrGLProgram.cpp32
-rw-r--r--src/gpu/gl/GrGLProgram.h12
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp18
-rw-r--r--src/gpu/gl/GrGLProgramDesc.h4
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp14
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.h4
49 files changed, 783 insertions, 763 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 27cc8aa3be..031dac3c48 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -9,12 +9,12 @@
#include "GrAAConvexPathRenderer.h"
#include "GrContext.h"
-#include "GrDrawState.h"
#include "GrDrawTargetCaps.h"
#include "GrGeometryProcessor.h"
#include "GrInvariantOutput.h"
-#include "GrProcessor.h"
#include "GrPathUtils.h"
+#include "GrProcessor.h"
+#include "GrPipelineBuilder.h"
#include "SkGeometry.h"
#include "SkString.h"
#include "SkStrokeRec.h"
@@ -694,7 +694,7 @@ GrGeometryProcessor* QuadEdgeEffect::TestCreate(SkRandom* random,
///////////////////////////////////////////////////////////////////////////////
bool GrAAConvexPathRenderer::canDrawPath(const GrDrawTarget* target,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
@@ -704,7 +704,7 @@ bool GrAAConvexPathRenderer::canDrawPath(const GrDrawTarget* target,
}
bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& vm,
const SkPath& origPath,
@@ -782,7 +782,7 @@ bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target,
int vOffset = 0;
for (int i = 0; i < draws.count(); ++i) {
const Draw& draw = draws[i];
- target->drawIndexed(drawState,
+ target->drawIndexed(pipelineBuilder,
quadProcessor,
kTriangles_GrPrimitiveType,
vOffset, // start vertex
diff --git a/src/gpu/GrAAConvexPathRenderer.h b/src/gpu/GrAAConvexPathRenderer.h
index b07781f2f3..bb2d3f0a1e 100644
--- a/src/gpu/GrAAConvexPathRenderer.h
+++ b/src/gpu/GrAAConvexPathRenderer.h
@@ -16,7 +16,7 @@ public:
GrAAConvexPathRenderer();
virtual bool canDrawPath(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath&,
const SkStrokeRec&,
@@ -24,7 +24,7 @@ public:
protected:
virtual bool onDrawPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkPath&,
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index 99093faed7..b11769c7c7 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -10,7 +10,7 @@
#include "GrAtlas.h"
#include "GrContext.h"
-#include "GrDrawState.h"
+#include "GrPipelineBuilder.h"
#include "GrSurfacePriv.h"
#include "GrSWMaskHelper.h"
#include "GrTexturePriv.h"
@@ -66,7 +66,7 @@ GrAADistanceFieldPathRenderer::~GrAADistanceFieldPathRenderer() {
////////////////////////////////////////////////////////////////////////////////
bool GrAADistanceFieldPathRenderer::canDrawPath(const GrDrawTarget* target,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
@@ -95,7 +95,7 @@ bool GrAADistanceFieldPathRenderer::canDrawPath(const GrDrawTarget* target,
GrPathRenderer::StencilSupport
GrAADistanceFieldPathRenderer::onGetStencilSupport(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkPath&,
const SkStrokeRec&) const {
return GrPathRenderer::kNoSupport_StencilSupport;
@@ -104,7 +104,7 @@ GrAADistanceFieldPathRenderer::onGetStencilSupport(const GrDrawTarget*,
////////////////////////////////////////////////////////////////////////////////
bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
@@ -144,7 +144,7 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target,
}
// use signed distance field to render
- return this->internalDrawPath(target, drawState, color, viewMatrix, path, pathData);
+ return this->internalDrawPath(target, pipelineBuilder, color, viewMatrix, path, pathData);
}
// padding around path bounds to allow for antialiased pixels
@@ -306,13 +306,13 @@ bool GrAADistanceFieldPathRenderer::freeUnusedPlot() {
}
bool GrAADistanceFieldPathRenderer::internalDrawPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
const PathData* pathData) {
GrTexture* texture = fAtlas->getTexture();
- GrDrawState::AutoRestoreEffects are(drawState);
+ GrPipelineBuilder::AutoRestoreEffects are(pipelineBuilder);
SkASSERT(pathData->fPlot);
GrDrawTarget::DrawToken drawToken = target->getCurrentDrawToken();
@@ -374,7 +374,7 @@ bool GrAADistanceFieldPathRenderer::internalDrawPath(GrDrawTarget* target,
viewMatrix.mapRect(&r);
target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, fCachedGeometryProcessor.get(),
+ target->drawIndexedInstances(pipelineBuilder, fCachedGeometryProcessor.get(),
kTriangles_GrPrimitiveType, 1, 4, 6, &r);
target->resetVertexSource();
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.h b/src/gpu/GrAADistanceFieldPathRenderer.h
index b17b3050c2..994c1ebfb8 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.h
+++ b/src/gpu/GrAADistanceFieldPathRenderer.h
@@ -25,7 +25,7 @@ public:
virtual ~GrAADistanceFieldPathRenderer();
virtual bool canDrawPath(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath&,
const SkStrokeRec&,
@@ -33,12 +33,12 @@ public:
protected:
virtual StencilSupport onGetStencilSupport(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkPath&,
const SkStrokeRec&) const SK_OVERRIDE;
virtual bool onDrawPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkPath&,
@@ -81,7 +81,7 @@ private:
SkTDynamicHash<PathData, PathData::Key> fPathCache;
PathDataList fPathList;
- bool internalDrawPath(GrDrawTarget*, GrDrawState*, GrColor, const SkMatrix& viewMatrix,
+ bool internalDrawPath(GrDrawTarget*, GrPipelineBuilder*, GrColor, const SkMatrix& viewMatrix,
const SkPath& path, const PathData* pathData);
PathData* addPathToAtlas(const SkPath& path, const SkStrokeRec& stroke, bool antiAlias,
uint32_t dimension, SkScalar scale);
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index eea6463702..ce24cf8c26 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -9,11 +9,11 @@
#include "GrContext.h"
#include "GrDefaultGeoProcFactory.h"
-#include "GrDrawState.h"
#include "GrDrawTargetCaps.h"
#include "GrGpu.h"
#include "GrIndexBuffer.h"
#include "GrPathUtils.h"
+#include "GrPipelineBuilder.h"
#include "GrProcessor.h"
#include "SkGeometry.h"
#include "SkStroke.h"
@@ -643,7 +643,7 @@ void add_line(const SkPoint p[2],
///////////////////////////////////////////////////////////////////////////////
bool GrAAHairLinePathRenderer::createLineGeom(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
uint8_t coverage,
size_t vertexStride,
@@ -683,7 +683,7 @@ bool GrAAHairLinePathRenderer::createLineGeom(GrDrawTarget* target,
}
bool GrAAHairLinePathRenderer::createBezierGeom(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
GrDrawTarget::AutoReleaseGeometry* arg,
SkRect* devBounds,
@@ -743,7 +743,7 @@ bool GrAAHairLinePathRenderer::createBezierGeom(GrDrawTarget* target,
}
bool GrAAHairLinePathRenderer::canDrawPath(const GrDrawTarget* target,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
@@ -801,7 +801,7 @@ bool check_bounds(const SkMatrix& viewMatrix, const SkRect& devBounds, void* ver
}
bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
@@ -814,7 +814,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
}
SkIRect devClipBounds;
- target->getClip()->getConservativeBounds(drawState->getRenderTarget(), &devClipBounds);
+ target->getClip()->getConservativeBounds(pipelineBuilder->getRenderTarget(), &devClipBounds);
int lineCnt;
int quadCnt;
@@ -845,7 +845,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
GrDrawTarget::AutoReleaseGeometry arg;
SkRect devBounds;
- GrDrawState::AutoRestoreEffects are(drawState);
+ GrPipelineBuilder::AutoRestoreEffects are(pipelineBuilder);
uint32_t gpFlags = GrDefaultGeoProcFactory::kPosition_GPType |
GrDefaultGeoProcFactory::kCoverage_GPType;
SkAutoTUnref<const GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Create(gpFlags,
@@ -856,7 +856,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
newCoverage));
if (!this->createLineGeom(target,
- drawState,
+ pipelineBuilder,
viewMatrix,
newCoverage,
gp->getVertexStride(),
@@ -879,7 +879,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
int lines = 0;
while (lines < lineCnt) {
int n = SkTMin(lineCnt - lines, kLineSegsNumInIdxBuffer);
- target->drawIndexed(drawState,
+ target->drawIndexed(pipelineBuilder,
gp,
kTriangles_GrPrimitiveType,
kLineSegNumVertices*lines, // startV
@@ -898,7 +898,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
SkRect devBounds;
if (!this->createBezierGeom(target,
- drawState,
+ pipelineBuilder,
viewMatrix,
&arg,
&devBounds,
@@ -930,13 +930,13 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
invert,
newCoverage));
SkASSERT(hairQuadProcessor);
- GrDrawState::AutoRestoreEffects are(drawState);
+ GrPipelineBuilder::AutoRestoreEffects are(pipelineBuilder);
target->setIndexSourceToBuffer(fQuadsIndexBuffer);
int quads = 0;
while (quads < quadCnt) {
int n = SkTMin(quadCnt - quads, kQuadsNumInIdxBuffer);
- target->drawIndexed(drawState,
+ target->drawIndexed(pipelineBuilder,
hairQuadProcessor,
kTriangles_GrPrimitiveType,
kQuadNumVertices*quads, // startV
@@ -953,13 +953,13 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
GrConicEffect::Create(color, vm, kHairlineAA_GrProcessorEdgeType,
*target->caps(), invert, newCoverage));
SkASSERT(hairConicProcessor);
- GrDrawState::AutoRestoreEffects are(drawState);
+ GrPipelineBuilder::AutoRestoreEffects are(pipelineBuilder);
target->setIndexSourceToBuffer(fQuadsIndexBuffer);
int conics = 0;
while (conics < conicCnt) {
int n = SkTMin(conicCnt - conics, kQuadsNumInIdxBuffer);
- target->drawIndexed(drawState,
+ target->drawIndexed(pipelineBuilder,
hairConicProcessor,
kTriangles_GrPrimitiveType,
kQuadNumVertices*(quadCnt + conics), // startV
diff --git a/src/gpu/GrAAHairLinePathRenderer.h b/src/gpu/GrAAHairLinePathRenderer.h
index 8bc3e3e804..91c00d78c3 100644
--- a/src/gpu/GrAAHairLinePathRenderer.h
+++ b/src/gpu/GrAAHairLinePathRenderer.h
@@ -18,7 +18,7 @@ public:
static GrPathRenderer* Create(GrContext* context);
virtual bool canDrawPath(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath&,
const SkStrokeRec&,
@@ -30,7 +30,7 @@ public:
protected:
virtual bool onDrawPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkPath&,
@@ -43,7 +43,7 @@ private:
const GrIndexBuffer* fQuadsIndexBuffer);
bool createLineGeom(GrDrawTarget* target,
- GrDrawState*,
+ GrPipelineBuilder*,
const SkMatrix& viewMatrix,
uint8_t coverage,
size_t vertexStride,
@@ -54,7 +54,7 @@ private:
int lineCnt);
bool createBezierGeom(GrDrawTarget* target,
- GrDrawState*,
+ GrPipelineBuilder*,
const SkMatrix& viewMatrix,
GrDrawTarget::AutoReleaseGeometry* arg,
SkRect* devBounds,
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 444bb519ac..0ffdd4d9f9 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -25,13 +25,13 @@ enum CoverageAttribType {
};
}
-static const GrGeometryProcessor* create_rect_gp(const GrDrawState& drawState,
+static const GrGeometryProcessor* create_rect_gp(const GrPipelineBuilder& pipelineBuilder,
GrColor color,
CoverageAttribType* type,
const SkMatrix& localMatrix) {
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
const GrGeometryProcessor* gp;
- if (drawState.canTweakAlphaForCoverage()) {
+ if (pipelineBuilder.canTweakAlphaForCoverage()) {
gp = GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), localMatrix);
SkASSERT(gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
*type = kUseColor_CoverageAttribType;
@@ -179,12 +179,12 @@ GrIndexBuffer* GrAARectRenderer::aaStrokeRectIndexBuffer(bool miterStroke) {
}
void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& devRect) {
- GrDrawState::AutoRestoreEffects are(drawState);
+ GrPipelineBuilder::AutoRestoreEffects are(pipelineBuilder);
SkMatrix localMatrix;
if (!viewMatrix.invert(&localMatrix)) {
@@ -193,7 +193,7 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
}
CoverageAttribType type;
- SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(*drawState, color, &type,
+ SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(*pipelineBuilder, color, &type,
localMatrix));
size_t vertexStride = gp->getVertexStride();
@@ -306,7 +306,7 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
}
target->setIndexSourceToBuffer(indexBuffer);
- target->drawIndexedInstances(drawState,
+ target->drawIndexedInstances(pipelineBuilder,
gp,
kTriangles_GrPrimitiveType,
1,
@@ -316,7 +316,7 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
}
void GrAARectRenderer::strokeAARect(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
@@ -364,7 +364,7 @@ void GrAARectRenderer::strokeAARect(GrDrawTarget* target,
}
if (spare <= 0 && miterStroke) {
- this->fillAARect(target, drawState, color, viewMatrix, devOutside,
+ this->fillAARect(target, pipelineBuilder, color, viewMatrix, devOutside,
devOutside);
return;
}
@@ -382,19 +382,19 @@ void GrAARectRenderer::strokeAARect(GrDrawTarget* target,
devOutsideAssist.outset(0, ry);
}
- this->geometryStrokeAARect(target, drawState, color, viewMatrix, devOutside, devOutsideAssist,
+ this->geometryStrokeAARect(target, pipelineBuilder, color, viewMatrix, devOutside, devOutsideAssist,
devInside, miterStroke);
}
void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& devOutside,
const SkRect& devOutsideAssist,
const SkRect& devInside,
bool miterStroke) {
- GrDrawState::AutoRestoreEffects are(drawState);
+ GrPipelineBuilder::AutoRestoreEffects are(pipelineBuilder);
SkMatrix localMatrix;
if (!viewMatrix.invert(&localMatrix)) {
@@ -403,7 +403,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
}
CoverageAttribType type;
- SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(*drawState, color, &type,
+ SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(*pipelineBuilder, color, &type,
localMatrix));
int innerVertexNum = 4;
@@ -517,7 +517,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
}
target->setIndexSourceToBuffer(indexBuffer);
- target->drawIndexedInstances(drawState,
+ target->drawIndexedInstances(pipelineBuilder,
gp,
kTriangles_GrPrimitiveType,
1,
@@ -527,7 +527,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
}
void GrAARectRenderer::fillAANestedRects(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect rects[2]) {
@@ -540,11 +540,11 @@ void GrAARectRenderer::fillAANestedRects(GrDrawTarget* target,
viewMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2);
if (devInside.isEmpty()) {
- this->fillAARect(target, drawState, color, viewMatrix, devOutside,
+ this->fillAARect(target, pipelineBuilder, color, viewMatrix, devOutside,
devOutside);
return;
}
- this->geometryStrokeAARect(target, drawState, color, viewMatrix, devOutside, devOutsideAssist,
- devInside, true);
+ this->geometryStrokeAARect(target, pipelineBuilder, color, viewMatrix, devOutside,
+ devOutsideAssist, devInside, true);
}
diff --git a/src/gpu/GrAARectRenderer.h b/src/gpu/GrAARectRenderer.h
index d6d07dde12..5a96f2cbca 100644
--- a/src/gpu/GrAARectRenderer.h
+++ b/src/gpu/GrAARectRenderer.h
@@ -15,7 +15,7 @@
#include "SkStrokeRec.h"
class GrGpu;
-class GrDrawState;
+class GrPipelineBuilder;
class GrDrawTarget;
class GrIndexBuffer;
@@ -43,16 +43,16 @@ public:
// between them by passing in stroke (==NULL means fill).
void fillAARect(GrDrawTarget* target,
- GrDrawState* ds,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& devRect) {
- this->geometryFillAARect(target, ds, color, viewMatrix, rect, devRect);
+ this->geometryFillAARect(target, pipelineBuilder, color, viewMatrix, rect, devRect);
}
void strokeAARect(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkRect& rect,
@@ -61,7 +61,7 @@ public:
// First rect is outer; second rect is inner
void fillAANestedRects(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkRect rects[2]);
@@ -70,14 +70,14 @@ private:
GrIndexBuffer* aaStrokeRectIndexBuffer(bool miterStroke);
void geometryFillAARect(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& devRect);
void geometryStrokeAARect(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkRect& devOutside,
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
index 2df3a710d2..f39e7a1bb0 100755
--- a/src/gpu/GrBitmapTextContext.cpp
+++ b/src/gpu/GrBitmapTextContext.cpp
@@ -529,8 +529,8 @@ void GrBitmapTextContext::flush() {
}
if (fCurrVertex > 0) {
- GrDrawState drawState;
- drawState.setFromPaint(fPaint, fContext->getRenderTarget());
+ GrPipelineBuilder pipelineBuilder;
+ pipelineBuilder.setFromPaint(fPaint, fContext->getRenderTarget());
// setup our sampler state for our text texture/atlas
SkASSERT(SkIsAlign4(fCurrVertex));
@@ -550,7 +550,8 @@ void GrBitmapTextContext::flush() {
// TODO: move supportsRGBCoverage check to setupCoverageEffect and only add LCD
// processor if the xp can support it. For now we will simply assume that if
// fUseLCDText is true, then we have a known color output.
- if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorComponentFlags)) {
+ const GrXPFactory* xpFactory = pipelineBuilder.getXPFactory();
+ if (!xpFactory->supportsRGBCoverage(0, kRGBA_GrColorComponentFlags)) {
SkDebugf("LCD Text will not draw correctly.\n");
}
break;
@@ -574,7 +575,7 @@ void GrBitmapTextContext::flush() {
params));
fEffectTextureUniqueID = textureUniqueID;
}
- drawState.addColorProcessor(fCachedTextureProcessor.get());
+ pipelineBuilder.addColorProcessor(fCachedTextureProcessor.get());
} else {
uint32_t textureUniqueID = fCurrTexture->getUniqueID();
if (textureUniqueID != fEffectTextureUniqueID ||
@@ -594,7 +595,7 @@ void GrBitmapTextContext::flush() {
int nGlyphs = fCurrVertex / kVerticesPerGlyph;
fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
- fDrawTarget->drawIndexedInstances(&drawState,
+ fDrawTarget->drawIndexedInstances(&pipelineBuilder,
fCachedGeometryProcessor.get(),
kTriangles_GrPrimitiveType,
nGlyphs,
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index c2dc4fb223..6bfdba6cce 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -31,9 +31,9 @@ namespace {
// set up the draw state to enable the aa clipping mask. Besides setting up the
// stage matrix this also alters the vertex layout
void setup_drawstate_aaclip(const SkIRect &devBound,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrTexture* result) {
- SkASSERT(drawState);
+ SkASSERT(pipelineBuilder);
SkMatrix mat;
// We use device coords to compute the texture coordinates. We set our matrix to be a
@@ -44,7 +44,7 @@ void setup_drawstate_aaclip(const SkIRect &devBound,
SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
// This could be a long-lived effect that is cached with the alpha-mask.
- drawState->addCoverageProcessor(
+ pipelineBuilder->addCoverageProcessor(
GrTextureDomainEffect::Create(result,
mat,
GrTextureDomain::MakeTexelDomain(result, domainTexels),
@@ -55,7 +55,7 @@ void setup_drawstate_aaclip(const SkIRect &devBound,
bool path_needs_SW_renderer(GrContext* context,
const GrDrawTarget* gpu,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& origPath,
const SkStrokeRec& stroke,
@@ -70,7 +70,8 @@ bool path_needs_SW_renderer(GrContext* context,
GrPathRendererChain::kColorAntiAlias_DrawType :
GrPathRendererChain::kColor_DrawType;
- return NULL == context->getPathRenderer(gpu, drawState, viewMatrix, *path, stroke, false, type);
+ return NULL == context->getPathRenderer(gpu, pipelineBuilder, viewMatrix, *path, stroke,
+ false, type);
}
}
@@ -79,7 +80,7 @@ bool path_needs_SW_renderer(GrContext* context,
* will be used on any element. If so, it returns true to indicate that the
* entire clip should be rendered in SW and then uploaded en masse to the gpu.
*/
-bool GrClipMaskManager::useSWOnlyPath(const GrDrawState* drawState,
+bool GrClipMaskManager::useSWOnlyPath(const GrPipelineBuilder* pipelineBuilder,
const SkVector& clipToMaskOffset,
const GrReducedClip::ElementList& elements) {
// TODO: generalize this function so that when
@@ -99,7 +100,7 @@ bool GrClipMaskManager::useSWOnlyPath(const GrDrawState* drawState,
if (Element::kRect_Type != element->getType()) {
SkPath path;
element->asPath(&path);
- if (path_needs_SW_renderer(this->getContext(), fClipTarget, drawState, translate,
+ if (path_needs_SW_renderer(this->getContext(), fClipTarget, pipelineBuilder, translate,
path, stroke, element->isAA())) {
return true;
}
@@ -108,8 +109,8 @@ bool GrClipMaskManager::useSWOnlyPath(const GrDrawState* drawState,
return false;
}
-bool GrClipMaskManager::installClipEffects(GrDrawState* drawState,
- GrDrawState::AutoRestoreEffects* are,
+bool GrClipMaskManager::installClipEffects(GrPipelineBuilder* pipelineBuilder,
+ GrPipelineBuilder::AutoRestoreEffects* are,
const GrReducedClip::ElementList& elements,
const SkVector& clipToRTOffset,
const SkRect* drawBounds) {
@@ -119,8 +120,8 @@ bool GrClipMaskManager::installClipEffects(GrDrawState* drawState,
boundsInClipSpace.offset(-clipToRTOffset.fX, -clipToRTOffset.fY);
}
- are->set(drawState);
- GrRenderTarget* rt = drawState->getRenderTarget();
+ are->set(pipelineBuilder);
+ GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
GrReducedClip::ElementList::Iter iter(elements);
bool failed = false;
while (iter.get()) {
@@ -186,7 +187,7 @@ bool GrClipMaskManager::installClipEffects(GrDrawState* drawState,
break;
}
if (fp) {
- drawState->addCoverageProcessor(fp);
+ pipelineBuilder->addCoverageProcessor(fp);
} else {
failed = true;
break;
@@ -204,9 +205,9 @@ bool GrClipMaskManager::installClipEffects(GrDrawState* drawState,
////////////////////////////////////////////////////////////////////////////////
// sort out what kind of clip mask needs to be created: alpha, stencil,
// scissor, or entirely software
-bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
- GrDrawState::AutoRestoreEffects* are,
- GrDrawState::AutoRestoreStencil* ars,
+bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder,
+ GrPipelineBuilder::AutoRestoreEffects* are,
+ GrPipelineBuilder::AutoRestoreStencil* ars,
GrScissorState* scissorState,
const GrClipData* clipDataIn,
const SkRect* devBounds) {
@@ -220,12 +221,12 @@ bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
GrReducedClip::InitialState initialState;
SkIRect clipSpaceIBounds;
bool requiresAA;
- GrRenderTarget* rt = drawState->getRenderTarget();
+ GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
// GrDrawTarget should have filtered this for us
SkASSERT(rt);
- bool ignoreClip = !drawState->isClipState() || clipDataIn->fClipStack->isWideOpen();
+ bool ignoreClip = !pipelineBuilder->isClipState() || clipDataIn->fClipStack->isWideOpen();
if (!ignoreClip) {
SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height());
clipSpaceRTIBounds.offset(clipDataIn->fOrigin);
@@ -246,7 +247,7 @@ bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
}
if (ignoreClip) {
- this->setDrawStateStencil(drawState, ars);
+ this->setPipelineBuilderStencil(pipelineBuilder, ars);
return true;
}
@@ -262,7 +263,7 @@ bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
SkVector clipToRTOffset = { SkIntToScalar(-clipDataIn->fOrigin.fX),
SkIntToScalar(-clipDataIn->fOrigin.fY) };
if (elements.isEmpty() ||
- (requiresAA && this->installClipEffects(drawState, are, elements, clipToRTOffset,
+ (requiresAA && this->installClipEffects(pipelineBuilder, are, elements, clipToRTOffset,
devBounds))) {
SkIRect scissorSpaceIBounds(clipSpaceIBounds);
scissorSpaceIBounds.offset(-clipDataIn->fOrigin);
@@ -270,7 +271,7 @@ bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
!SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) {
scissorState->set(scissorSpaceIBounds);
}
- this->setDrawStateStencil(drawState, ars);
+ this->setPipelineBuilderStencil(pipelineBuilder, ars);
return true;
}
}
@@ -286,7 +287,7 @@ bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
SkIntToScalar(-clipSpaceIBounds.fTop)
};
- if (this->useSWOnlyPath(drawState, clipToMaskOffset, elements)) {
+ if (this->useSWOnlyPath(pipelineBuilder, clipToMaskOffset, elements)) {
// The clip geometry is complex enough that it will be more efficient to create it
// entirely in software
result = this->createSoftwareClipMask(genID,
@@ -307,8 +308,8 @@ bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
// clipSpace bounds. We determine the mask's position WRT to the render target here.
SkIRect rtSpaceMaskBounds = clipSpaceIBounds;
rtSpaceMaskBounds.offset(-clipDataIn->fOrigin);
- setup_drawstate_aaclip(rtSpaceMaskBounds, drawState, result);
- this->setDrawStateStencil(drawState, ars);
+ setup_drawstate_aaclip(rtSpaceMaskBounds, pipelineBuilder, result);
+ this->setPipelineBuilderStencil(pipelineBuilder, ars);
return true;
}
// if alpha clip mask creation fails fall through to the non-AA code paths
@@ -337,28 +338,29 @@ bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
SkIRect scissorSpaceIBounds(clipSpaceIBounds);
scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset);
scissorState->set(scissorSpaceIBounds);
- this->setDrawStateStencil(drawState, ars);
+ this->setPipelineBuilderStencil(pipelineBuilder, ars);
return true;
}
namespace {
////////////////////////////////////////////////////////////////////////////////
-// Set a coverage drawing XPF on the drawState for the given op and invertCoverage mode
-void set_coverage_drawing_xpf(SkRegion::Op op, bool invertCoverage, GrDrawState* drawState) {
+// Set a coverage drawing XPF on the pipelineBuilder for the given op and invertCoverage mode
+void set_coverage_drawing_xpf(SkRegion::Op op, bool invertCoverage,
+ GrPipelineBuilder* pipelineBuilder) {
SkASSERT(op <= SkRegion::kLastOp);
- drawState->setCoverageSetOpXPFactory(op, invertCoverage);
+ pipelineBuilder->setCoverageSetOpXPFactory(op, invertCoverage);
}
}
////////////////////////////////////////////////////////////////////////////////
-bool GrClipMaskManager::drawElement(GrDrawState* drawState,
+bool GrClipMaskManager::drawElement(GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
GrTexture* target,
const SkClipStack::Element* element,
GrPathRenderer* pr) {
GrDrawTarget::AutoGeometryPush agp(fClipTarget);
- drawState->setRenderTarget(target->asRenderTarget());
+ pipelineBuilder->setRenderTarget(target->asRenderTarget());
// The color we use to draw does not matter since we will always be using a GrCoverageSetOpXP
// which ignores color.
@@ -376,13 +378,13 @@ bool GrClipMaskManager::drawElement(GrDrawState* drawState,
SkRect devRect = element->getRect();
viewMatrix.mapRect(&devRect);
this->getContext()->getAARectRenderer()->fillAARect(fClipTarget,
- drawState,
+ pipelineBuilder,
color,
viewMatrix,
element->getRect(),
devRect);
} else {
- fClipTarget->drawSimpleRect(drawState, color, viewMatrix, element->getRect());
+ fClipTarget->drawSimpleRect(pipelineBuilder, color, viewMatrix, element->getRect());
}
return true;
default: {
@@ -397,25 +399,26 @@ bool GrClipMaskManager::drawElement(GrDrawState* drawState,
GrPathRendererChain::DrawType type;
type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_DrawType :
GrPathRendererChain::kColor_DrawType;
- pr = this->getContext()->getPathRenderer(fClipTarget, drawState, viewMatrix, path,
- stroke, false, type);
+ pr = this->getContext()->getPathRenderer(fClipTarget, pipelineBuilder, viewMatrix,
+ path, stroke, false, type);
}
if (NULL == pr) {
return false;
}
- pr->drawPath(fClipTarget, drawState, color, viewMatrix, path, stroke, element->isAA());
+ pr->drawPath(fClipTarget, pipelineBuilder, color, viewMatrix, path, stroke,
+ element->isAA());
break;
}
}
return true;
}
-bool GrClipMaskManager::canStencilAndDrawElement(GrDrawState* drawState,
+bool GrClipMaskManager::canStencilAndDrawElement(GrPipelineBuilder* pipelineBuilder,
GrTexture* target,
GrPathRenderer** pr,
const SkClipStack::Element* element) {
- drawState->setRenderTarget(target->asRenderTarget());
+ pipelineBuilder->setRenderTarget(target->asRenderTarget());
if (Element::kRect_Type == element->getType()) {
return true;
@@ -431,34 +434,35 @@ bool GrClipMaskManager::canStencilAndDrawElement(GrDrawState* drawState,
GrPathRendererChain::DrawType type = element->isAA() ?
GrPathRendererChain::kStencilAndColorAntiAlias_DrawType :
GrPathRendererChain::kStencilAndColor_DrawType;
- *pr = this->getContext()->getPathRenderer(fClipTarget, drawState, SkMatrix::I(), path,
+ *pr = this->getContext()->getPathRenderer(fClipTarget, pipelineBuilder, SkMatrix::I(), path,
stroke, false, type);
return SkToBool(*pr);
}
}
-void GrClipMaskManager::mergeMask(GrDrawState* drawState,
+void GrClipMaskManager::mergeMask(GrPipelineBuilder* pipelineBuilder,
GrTexture* dstMask,
GrTexture* srcMask,
SkRegion::Op op,
const SkIRect& dstBound,
const SkIRect& srcBound) {
- drawState->setRenderTarget(dstMask->asRenderTarget());
+ pipelineBuilder->setRenderTarget(dstMask->asRenderTarget());
// We want to invert the coverage here
- set_coverage_drawing_xpf(op, false, drawState);
+ set_coverage_drawing_xpf(op, false, pipelineBuilder);
SkMatrix sampleM;
sampleM.setIDiv(srcMask->width(), srcMask->height());
- drawState->addCoverageProcessor(
+ pipelineBuilder->addCoverageProcessor(
GrTextureDomainEffect::Create(srcMask,
sampleM,
GrTextureDomain::MakeTexelDomain(srcMask, srcBound),
GrTextureDomain::kDecal_Mode,
GrTextureParams::kNone_FilterMode))->unref();
// The color passed in here does not matter since the coverageSetOpXP won't read it.
- fClipTarget->drawSimpleRect(drawState, GrColor_WHITE, SkMatrix::I(), SkRect::Make(dstBound));
+ fClipTarget->drawSimpleRect(pipelineBuilder, GrColor_WHITE, SkMatrix::I(),
+ SkRect::Make(dstBound));
}
GrTexture* GrClipMaskManager::createTempMask(int width, int height) {
@@ -563,11 +567,11 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
SkRegion::Op op = element->getOp();
bool invert = element->isInverseFilled();
if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) {
- GrDrawState drawState;
- drawState.enableState(GrDrawState::kClip_StateBit);
+ GrPipelineBuilder pipelineBuilder;
+ pipelineBuilder.enableState(GrPipelineBuilder::kClip_StateBit);
GrPathRenderer* pr = NULL;
- bool useTemp = !this->canStencilAndDrawElement(&drawState, result, &pr, element);
+ bool useTemp = !this->canStencilAndDrawElement(&pipelineBuilder, result, &pr, element);
GrTexture* dst;
// This is the bounds of the clip element in the space of the alpha-mask. The temporary
// mask buffer can be substantially larger than the actually clip stack element. We
@@ -598,7 +602,7 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
invert ? 0xffffffff : 0x00000000,
true,
dst->asRenderTarget());
- set_coverage_drawing_xpf(SkRegion::kReplace_Op, invert, &drawState);
+ set_coverage_drawing_xpf(SkRegion::kReplace_Op, invert, &pipelineBuilder);
} else {
// draw directly into the result with the stencil set to make the pixels affected
// by the clip shape be non-zero.
@@ -610,34 +614,34 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
0xffff,
0xffff,
0xffff);
- drawState.setStencil(kStencilInElement);
- set_coverage_drawing_xpf(op, invert, &drawState);
+ pipelineBuilder.setStencil(kStencilInElement);
+ set_coverage_drawing_xpf(op, invert, &pipelineBuilder);
}
- if (!this->drawElement(&drawState, translate, dst, element, pr)) {
+ if (!this->drawElement(&pipelineBuilder, translate, dst, element, pr)) {
fAACache.reset();
return NULL;
}
if (useTemp) {
- GrDrawState backgroundDrawState;
- backgroundDrawState.enableState(GrDrawState::kClip_StateBit);
- backgroundDrawState.setRenderTarget(result->asRenderTarget());
+ GrPipelineBuilder backgroundPipelineBuilder;
+ backgroundPipelineBuilder.enableState(GrPipelineBuilder::kClip_StateBit);
+ backgroundPipelineBuilder.setRenderTarget(result->asRenderTarget());
// Now draw into the accumulator using the real operation and the temp buffer as a
// texture
- this->mergeMask(&backgroundDrawState,
+ this->mergeMask(&backgroundPipelineBuilder,
result,
temp,
op,
maskSpaceIBounds,
maskSpaceElementIBounds);
} else {
- GrDrawState backgroundDrawState;
- backgroundDrawState.enableState(GrDrawState::kClip_StateBit);
- backgroundDrawState.setRenderTarget(result->asRenderTarget());
+ GrPipelineBuilder backgroundPipelineBuilder;
+ backgroundPipelineBuilder.enableState(GrPipelineBuilder::kClip_StateBit);
+ backgroundPipelineBuilder.setRenderTarget(result->asRenderTarget());
- set_coverage_drawing_xpf(op, !invert, &backgroundDrawState);
+ set_coverage_drawing_xpf(op, !invert, &backgroundPipelineBuilder);
// Draw to the exterior pixels (those with a zero stencil value).
GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement,
kZero_StencilOp,
@@ -646,19 +650,19 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
0xffff,
0x0000,
0xffff);
- backgroundDrawState.setStencil(kDrawOutsideElement);
+ backgroundPipelineBuilder.setStencil(kDrawOutsideElement);
// The color passed in here does not matter since the coverageSetOpXP won't read it.
- fClipTarget->drawSimpleRect(&backgroundDrawState, GrColor_WHITE, translate,
+ fClipTarget->drawSimpleRect(&backgroundPipelineBuilder, GrColor_WHITE, translate,
clipSpaceIBounds);
}
} else {
- GrDrawState drawState;
- drawState.enableState(GrDrawState::kClip_StateBit);
+ GrPipelineBuilder pipelineBuilder;
+ pipelineBuilder.enableState(GrPipelineBuilder::kClip_StateBit);
// all the remaining ops can just be directly draw into the accumulation buffer
- set_coverage_drawing_xpf(op, false, &drawState);
+ set_coverage_drawing_xpf(op, false, &pipelineBuilder);
// The color passed in here does not matter since the coverageSetOpXP won't read it.
- this->drawElement(&drawState, translate, result, element);
+ this->drawElement(&pipelineBuilder, translate, result, element);
}
}
@@ -712,15 +716,15 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) {
const Element* element = iter.get();
- GrDrawState drawState;
- drawState.setRenderTarget(rt);
- drawState.enableState(GrDrawState::kClip_StateBit);
+ GrPipelineBuilder pipelineBuilder;
+ pipelineBuilder.setRenderTarget(rt);
+ pipelineBuilder.enableState(GrPipelineBuilder::kClip_StateBit);
- drawState.setDisableColorXPFactory();
+ pipelineBuilder.setDisableColorXPFactory();
// if the target is MSAA then we want MSAA enabled when the clip is soft
if (rt->isMultisampled()) {
- drawState.setState(GrDrawState::kHWAntialias_StateBit, element->isAA());
+ pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_StateBit, element->isAA());
}
bool fillInverted = false;
@@ -746,7 +750,7 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
clipPath.toggleInverseFillType();
}
pr = this->getContext()->getPathRenderer(fClipTarget,
- &drawState,
+ &pipelineBuilder,
viewMatrix,
clipPath,
stroke,
@@ -784,18 +788,19 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
0x0000,
0xffff);
if (Element::kRect_Type == element->getType()) {
- *drawState.stencil() = gDrawToStencil;
- fClipTarget->drawSimpleRect(&drawState, GrColor_WHITE, viewMatrix,
+ *pipelineBuilder.stencil() = gDrawToStencil;
+ fClipTarget->drawSimpleRect(&pipelineBuilder, GrColor_WHITE, viewMatrix,
element->getRect());
} else {
if (!clipPath.isEmpty()) {
GrDrawTarget::AutoGeometryPush agp(fClipTarget);
if (canRenderDirectToStencil) {
- *drawState.stencil() = gDrawToStencil;
- pr->drawPath(fClipTarget, &drawState, GrColor_WHITE, viewMatrix,
+ *pipelineBuilder.stencil() = gDrawToStencil;
+ pr->drawPath(fClipTarget, &pipelineBuilder, GrColor_WHITE, viewMatrix,
clipPath, stroke, false);
} else {
- pr->stencilPath(fClipTarget, &drawState, viewMatrix, clipPath, stroke);
+ pr->stencilPath(fClipTarget, &pipelineBuilder, viewMatrix, clipPath,
+ stroke);
}
}
}
@@ -805,22 +810,22 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
// element directly or a bounding rect of the entire clip.
fClipMode = kModifyClip_StencilClipMode;
for (int p = 0; p < passes; ++p) {
- GrDrawState drawStateCopy(drawState);
- *drawStateCopy.stencil() = stencilSettings[p];
+ GrPipelineBuilder pipelineBuilderCopy(pipelineBuilder);
+ *pipelineBuilderCopy.stencil() = stencilSettings[p];
if (canDrawDirectToClip) {
if (Element::kRect_Type == element->getType()) {
- fClipTarget->drawSimpleRect(&drawStateCopy, GrColor_WHITE, viewMatrix,
+ fClipTarget->drawSimpleRect(&pipelineBuilderCopy, GrColor_WHITE, viewMatrix,
element->getRect());
} else {
GrDrawTarget::AutoGeometryPush agp(fClipTarget);
- pr->drawPath(fClipTarget, &drawStateCopy, GrColor_WHITE, viewMatrix,
+ pr->drawPath(fClipTarget, &pipelineBuilderCopy, GrColor_WHITE, viewMatrix,
clipPath, stroke, false);
}
} else {
// The view matrix is setup to do clip space -> stencil space translation, so
// draw rect in clip space.
- fClipTarget->drawSimpleRect(&drawStateCopy, GrColor_WHITE, viewMatrix,
+ fClipTarget->drawSimpleRect(&pipelineBuilderCopy, GrColor_WHITE, viewMatrix,
SkRect::Make(clipSpaceIBounds));
}
}
@@ -885,8 +890,8 @@ const GrStencilSettings& basic_apply_stencil_clip_settings() {
}
}
-void GrClipMaskManager::setDrawStateStencil(GrDrawState* drawState,
- GrDrawState::AutoRestoreStencil* ars) {
+void GrClipMaskManager::setPipelineBuilderStencil(GrPipelineBuilder* pipelineBuilder,
+ GrPipelineBuilder::AutoRestoreStencil* ars) {
// We make two copies of the StencilSettings here (except in the early
// exit scenario. One copy from draw state to the stack var. Then another
// from the stack var to the gpu. We could make this class hold a ptr to
@@ -898,19 +903,19 @@ void GrClipMaskManager::setDrawStateStencil(GrDrawState* drawState,
// The GrGpu client may not be using the stencil buffer but we may need to
// enable it in order to respect a stencil clip.
- if (drawState->getStencil().isDisabled()) {
+ if (pipelineBuilder->getStencil().isDisabled()) {
if (GrClipMaskManager::kRespectClip_StencilClipMode == fClipMode) {
settings = basic_apply_stencil_clip_settings();
} else {
return;
}
} else {
- settings = drawState->getStencil();
+ settings = pipelineBuilder->getStencil();
}
// TODO: dynamically attach a stencil buffer
int stencilBits = 0;
- GrStencilBuffer* stencilBuffer = drawState->getRenderTarget()->getStencilBuffer();
+ GrStencilBuffer* stencilBuffer = pipelineBuilder->getRenderTarget()->getStencilBuffer();
if (stencilBuffer) {
stencilBits = stencilBuffer->bits();
}
@@ -918,8 +923,8 @@ void GrClipMaskManager::setDrawStateStencil(GrDrawState* drawState,
SkASSERT(fClipTarget->caps()->stencilWrapOpsSupport() || !settings.usesWrapOp());
SkASSERT(fClipTarget->caps()->twoSidedStencilSupport() || !settings.isTwoSided());
this->adjustStencilParams(&settings, fClipMode, stencilBits);
- ars->set(drawState);
- drawState->setStencil(settings);
+ ars->set(pipelineBuilder);
+ pipelineBuilder->setStencil(settings);
}
void GrClipMaskManager::adjustStencilParams(GrStencilSettings* settings,
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h
index fef47e4c3c..ed3d431268 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -9,7 +9,7 @@
#include "GrClipMaskCache.h"
#include "GrContext.h"
-#include "GrDrawState.h"
+#include "GrPipelineBuilder.h"
#include "GrReducedClip.h"
#include "GrStencil.h"
#include "GrTexture.h"
@@ -48,9 +48,9 @@ public:
* the manager when it must install additional effects to implement the
* clip. devBounds is optional but can help optimize clipping.
*/
- bool setupClipping(GrDrawState*,
- GrDrawState::AutoRestoreEffects*,
- GrDrawState::AutoRestoreStencil*,
+ bool setupClipping(GrPipelineBuilder*,
+ GrPipelineBuilder::AutoRestoreEffects*,
+ GrPipelineBuilder::AutoRestoreStencil*,
GrScissorState*,
const GrClipData* clipDataIn,
const SkRect* devBounds);
@@ -94,8 +94,8 @@ private:
// Attempts to install a series of coverage effects to implement the clip. Return indicates
// whether the element list was successfully converted to effects.
- bool installClipEffects(GrDrawState*,
- GrDrawState::AutoRestoreEffects*,
+ bool installClipEffects(GrPipelineBuilder*,
+ GrPipelineBuilder::AutoRestoreEffects*,
const GrReducedClip::ElementList&,
const SkVector& clipOffset,
const SkRect* devBounds);
@@ -133,14 +133,14 @@ private:
const SkIRect& clipSpaceIBounds,
bool willUpload);
- bool useSWOnlyPath(const GrDrawState*,
+ bool useSWOnlyPath(const GrPipelineBuilder*,
const SkVector& clipToMaskOffset,
const GrReducedClip::ElementList& elements);
// Draws a clip element into the target alpha mask. The caller should have already setup the
// desired blend operation. Optionally if the caller already selected a path renderer it can
// be passed. Otherwise the function will select one if the element is a path.
- bool drawElement(GrDrawState*,
+ bool drawElement(GrPipelineBuilder*,
const SkMatrix& viewMatrix,
GrTexture* target,
const SkClipStack::Element*,
@@ -149,12 +149,12 @@ private:
// Determines whether it is possible to draw the element to both the stencil buffer and the
// alpha mask simultaneously. If so and the element is a path a compatible path renderer is
// also returned.
- bool canStencilAndDrawElement(GrDrawState*,
+ bool canStencilAndDrawElement(GrPipelineBuilder*,
GrTexture* target,
GrPathRenderer**,
const SkClipStack::Element*);
- void mergeMask(GrDrawState*,
+ void mergeMask(GrPipelineBuilder*,
GrTexture* dstMask,
GrTexture* srcMask,
SkRegion::Op op,
@@ -170,7 +170,7 @@ private:
* updates the GrGpu with stencil settings that account stencil-based
* clipping.
*/
- void setDrawStateStencil(GrDrawState*, GrDrawState::AutoRestoreStencil*);
+ void setPipelineBuilderStencil(GrPipelineBuilder*, GrPipelineBuilder::AutoRestoreStencil*);
/**
* Adjusts the stencil settings to account for interaction with stencil
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index a0fc678a40..b798ef0478 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -294,8 +294,8 @@ GrTexture* GrContext::createResizedTexture(const GrSurfaceDesc& desc,
GrTexture* texture = fGpu->createTexture(rtDesc, true, NULL, 0);
if (texture) {
- GrDrawState drawState;
- drawState.setRenderTarget(texture->asRenderTarget());
+ GrPipelineBuilder pipelineBuilder;
+ pipelineBuilder.setRenderTarget(texture->asRenderTarget());
// if filtering is not desired then we want to ensure all
// texels in the resampled image are copies of texels from
@@ -303,7 +303,7 @@ GrTexture* GrContext::createResizedTexture(const GrSurfaceDesc& desc,
GrTextureParams params(SkShader::kClamp_TileMode,
filter ? GrTextureParams::kBilerp_FilterMode :
GrTextureParams::kNone_FilterMode);
- drawState.addColorTextureProcessor(clampedTexture, SkMatrix::I(), params);
+ pipelineBuilder.addColorTextureProcessor(clampedTexture, SkMatrix::I(), params);
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
GrDefaultGeoProcFactory::kLocalCoord_GPType;
@@ -317,7 +317,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(&pipelineBuilder, gp, kTriangleFan_GrPrimitiveType, 0, 4);
}
} else {
// TODO: Our CPU stretch doesn't filter. But we create separate
@@ -571,14 +571,14 @@ void GrContext::drawPaint(const GrPaint& origPaint, const SkMatrix& viewMatrix)
}
AutoCheckFlush acf(this);
- GrDrawState drawState;
- GrDrawTarget* target = this->prepareToDraw(&drawState, paint, &acf);
+ GrPipelineBuilder pipelineBuilder;
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, paint, &acf);
if (NULL == target) {
return;
}
GR_CREATE_TRACE_MARKER("GrContext::drawPaintWithPerspective", target);
- target->drawRect(&drawState, paint->getColor(), SkMatrix::I(), r, NULL, &localMatrix);
+ target->drawRect(&pipelineBuilder, paint->getColor(), SkMatrix::I(), r, NULL, &localMatrix);
}
}
@@ -618,21 +618,21 @@ static inline bool is_irect(const SkRect& r) {
}
static bool apply_aa_to_rect(GrDrawTarget* target,
- GrDrawState* ds,
+ GrPipelineBuilder* pipelineBuilder,
SkRect* devBoundRect,
const SkRect& rect,
SkScalar strokeWidth,
const SkMatrix& combinedMatrix,
GrColor color) {
- if (!ds->canTweakAlphaForCoverage() && !ds->canUseFracCoveragePrimProc(color,
- *target->caps())) {
+ if (!pipelineBuilder->canTweakAlphaForCoverage() &&
+ !pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps())) {
#ifdef SK_DEBUG
//SkDebugf("Turning off AA to correctly apply blend.\n");
#endif
return false;
}
- if (ds->getRenderTarget()->isMultisampled()) {
+ if (pipelineBuilder->getRenderTarget()->isMultisampled()) {
return false;
}
@@ -680,8 +680,8 @@ void GrContext::drawRect(const GrPaint& paint,
}
AutoCheckFlush acf(this);
- GrDrawState drawState;
- GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
+ GrPipelineBuilder pipelineBuilder;
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
if (NULL == target) {
return;
}
@@ -693,7 +693,7 @@ void GrContext::drawRect(const GrPaint& paint,
// cases where the RT is fully inside a stroke.
if (width < 0) {
SkRect rtRect;
- drawState.getRenderTarget()->getBoundsRect(&rtRect);
+ pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect);
SkRect clipSpaceRTRect = rtRect;
bool checkClip = false;
if (this->getClip()) {
@@ -726,15 +726,15 @@ void GrContext::drawRect(const GrPaint& paint,
GrColor color = paint.getColor();
SkRect devBoundRect;
- bool needAA = paint.isAntiAlias() && !drawState.getRenderTarget()->isMultisampled();
- bool doAA = needAA && apply_aa_to_rect(target, &drawState, &devBoundRect, rect, width,
+ bool needAA = paint.isAntiAlias() && !pipelineBuilder.getRenderTarget()->isMultisampled();
+ bool doAA = needAA && apply_aa_to_rect(target, &pipelineBuilder, &devBoundRect, rect, width,
viewMatrix, color);
if (doAA) {
if (width >= 0) {
const SkStrokeRec& strokeRec = strokeInfo->getStrokeRec();
fAARectRenderer->strokeAARect(target,
- &drawState,
+ &pipelineBuilder,
color,
viewMatrix,
rect,
@@ -743,7 +743,7 @@ void GrContext::drawRect(const GrPaint& paint,
} else {
// filled AA rect
fAARectRenderer->fillAARect(target,
- &drawState,
+ &pipelineBuilder,
color,
viewMatrix,
rect,
@@ -793,10 +793,10 @@ void GrContext::drawRect(const GrPaint& paint,
vertex[4].set(rect.fLeft, rect.fTop);
}
- target->drawNonIndexed(&drawState, gp, primType, 0, vertCount);
+ target->drawNonIndexed(&pipelineBuilder, gp, primType, 0, vertCount);
} else {
// filled BW rect
- target->drawSimpleRect(&drawState, color, viewMatrix, rect);
+ target->drawSimpleRect(&pipelineBuilder, color, viewMatrix, rect);
}
}
@@ -806,15 +806,16 @@ void GrContext::drawNonAARectToRect(const GrPaint& paint,
const SkRect& localRect,
const SkMatrix* localMatrix) {
AutoCheckFlush acf(this);
- GrDrawState drawState;
- GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
+ GrPipelineBuilder pipelineBuilder;
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
if (NULL == target) {
return;
}
GR_CREATE_TRACE_MARKER("GrContext::drawRectToRect", target);
- target->drawRect(&drawState, paint.getColor(), viewMatrix, rectToDraw, &localRect, localMatrix);
+ target->drawRect(&pipelineBuilder, paint.getColor(), viewMatrix, rectToDraw, &localRect,
+ localMatrix);
}
static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords,
@@ -851,10 +852,10 @@ void GrContext::drawVertices(const GrPaint& paint,
const uint16_t indices[],
int indexCount) {
AutoCheckFlush acf(this);
- GrDrawState drawState;
+ GrPipelineBuilder pipelineBuilder;
GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scope
- GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
if (NULL == target) {
return;
}
@@ -894,9 +895,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(&pipelineBuilder, gp, primitiveType, 0, 0, vertexCount, indexCount);
} else {
- target->drawNonIndexed(&drawState, gp, primitiveType, 0, vertexCount);
+ target->drawNonIndexed(&pipelineBuilder, gp, primitiveType, 0, vertexCount);
}
}
@@ -918,8 +919,8 @@ void GrContext::drawRRect(const GrPaint& paint,
}
AutoCheckFlush acf(this);
- GrDrawState drawState;
- GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
+ GrPipelineBuilder pipelineBuilder;
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
if (NULL == target) {
return;
}
@@ -929,12 +930,12 @@ void GrContext::drawRRect(const GrPaint& paint,
const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec();
GrColor color = paint.getColor();
- if (!fOvalRenderer->drawRRect(target, &drawState, color, viewMatrix, paint.isAntiAlias(), rrect,
- strokeRec)) {
+ if (!fOvalRenderer->drawRRect(target, &pipelineBuilder, color, viewMatrix, paint.isAntiAlias(),
+ rrect, strokeRec)) {
SkPath path;
path.addRRect(rrect);
- this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAntiAlias(), path,
- strokeInfo);
+ this->internalDrawPath(target, &pipelineBuilder, viewMatrix, color, paint.isAntiAlias(),
+ path, strokeInfo);
}
}
@@ -949,21 +950,22 @@ void GrContext::drawDRRect(const GrPaint& paint,
}
AutoCheckFlush acf(this);
- GrDrawState drawState;
- GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
+ GrPipelineBuilder pipelineBuilder;
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target);
GrColor color = paint.getColor();
- if (!fOvalRenderer->drawDRRect(target, &drawState, color, viewMatrix, paint.isAntiAlias(), outer, inner)) {
+ if (!fOvalRenderer->drawDRRect(target, &pipelineBuilder, color, viewMatrix, paint.isAntiAlias(),
+ outer, inner)) {
SkPath path;
path.addRRect(inner);
path.addRRect(outer);
path.setFillType(SkPath::kEvenOdd_FillType);
GrStrokeInfo fillRec(SkStrokeRec::kFill_InitStyle);
- this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAntiAlias(), path,
- fillRec);
+ this->internalDrawPath(target, &pipelineBuilder, viewMatrix, color, paint.isAntiAlias(),
+ path, fillRec);
}
}
@@ -985,8 +987,8 @@ void GrContext::drawOval(const GrPaint& paint,
}
AutoCheckFlush acf(this);
- GrDrawState drawState;
- GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
+ GrPipelineBuilder pipelineBuilder;
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
if (NULL == target) {
return;
}
@@ -996,18 +998,18 @@ void GrContext::drawOval(const GrPaint& paint,
const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec();
GrColor color = paint.getColor();
- if (!fOvalRenderer->drawOval(target, &drawState, color, viewMatrix, paint.isAntiAlias(), oval,
- strokeRec)) {
+ if (!fOvalRenderer->drawOval(target, &pipelineBuilder, color, viewMatrix, paint.isAntiAlias(),
+ oval, strokeRec)) {
SkPath path;
path.addOval(oval);
- this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAntiAlias(), path,
- strokeInfo);
+ this->internalDrawPath(target, &pipelineBuilder, viewMatrix, color, paint.isAntiAlias(),
+ path, strokeInfo);
}
}
// Can 'path' be drawn as a pair of filled nested rectangles?
static bool is_nested_rects(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
@@ -1025,8 +1027,8 @@ static bool is_nested_rects(GrDrawTarget* target,
return false;
}
- if (!drawState->canTweakAlphaForCoverage() &&
- !drawState->canUseFracCoveragePrimProc(color, *target->caps())) {
+ if (!pipelineBuilder->canTweakAlphaForCoverage() &&
+ !pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps())) {
return false;
}
@@ -1080,14 +1082,14 @@ void GrContext::drawPath(const GrPaint& paint,
SkPoint pts[2];
if (path.isLine(pts)) {
AutoCheckFlush acf(this);
- GrDrawState drawState;
- GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
+ GrPipelineBuilder pipelineBuilder;
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
if (NULL == target) {
return;
}
- if (GrDashingEffect::DrawDashLine(fGpu, target, &drawState, color, viewMatrix, pts,
- paint, strokeInfo)) {
+ if (GrDashingEffect::DrawDashLine(fGpu, target, &pipelineBuilder, color, viewMatrix,
+ pts, paint, strokeInfo)) {
return;
}
}
@@ -1112,8 +1114,8 @@ void GrContext::drawPath(const GrPaint& paint,
// the writePixels that uploads to the scratch will perform a flush so we're
// OK.
AutoCheckFlush acf(this);
- GrDrawState drawState;
- GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
+ GrPipelineBuilder pipelineBuilder;
+ GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
if (NULL == target) {
return;
}
@@ -1122,14 +1124,15 @@ void GrContext::drawPath(const GrPaint& paint,
const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec();
- bool useCoverageAA = paint.isAntiAlias() && !drawState.getRenderTarget()->isMultisampled();
+ bool useCoverageAA = paint.isAntiAlias() &&
+ !pipelineBuilder.getRenderTarget()->isMultisampled();
if (useCoverageAA && strokeRec.getWidth() < 0 && !path.isConvex()) {
// Concave AA paths are expensive - try to avoid them for special cases
SkRect rects[2];
- if (is_nested_rects(target, &drawState, color, viewMatrix, path, strokeRec, rects)) {
- fAARectRenderer->fillAANestedRects(target, &drawState, color, viewMatrix,rects);
+ if (is_nested_rects(target, &pipelineBuilder, color, viewMatrix, path, strokeRec, rects)) {
+ fAARectRenderer->fillAANestedRects(target, &pipelineBuilder, color, viewMatrix,rects);
return;
}
}
@@ -1138,15 +1141,15 @@ void GrContext::drawPath(const GrPaint& paint,
bool isOval = path.isOval(&ovalRect);
if (!isOval || path.isInverseFillType() ||
- !fOvalRenderer->drawOval(target, &drawState, color, viewMatrix, paint.isAntiAlias(),
+ !fOvalRenderer->drawOval(target, &pipelineBuilder, color, viewMatrix, paint.isAntiAlias(),
ovalRect, strokeRec)) {
- this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAntiAlias(), path,
- strokeInfo);
+ this->internalDrawPath(target, &pipelineBuilder, viewMatrix, color, paint.isAntiAlias(),
+ path, strokeInfo);
}
}
void GrContext::internalDrawPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
GrColor color,
bool useAA,
@@ -1162,8 +1165,8 @@ void GrContext::internalDrawPath(GrDrawTarget* target,
// aa. If we have some future driver-mojo path AA that can do the right
// thing WRT to the blend then we'll need some query on the PR.
bool useCoverageAA = useAA &&
- !drawState->getRenderTarget()->isMultisampled() &&
- drawState->canUseFracCoveragePrimProc(color, *target->caps());
+ !pipelineBuilder->getRenderTarget()->isMultisampled() &&
+ pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps());
GrPathRendererChain::DrawType type =
@@ -1175,8 +1178,8 @@ void GrContext::internalDrawPath(GrDrawTarget* target,
SkTCopyOnFirstWrite<SkStrokeRec> stroke(strokeInfo.getStrokeRec());
// Try a 1st time without stroking the path and without allowing the SW renderer
- GrPathRenderer* pr = this->getPathRenderer(target, drawState, viewMatrix, *pathPtr, *stroke,
- false, type);
+ GrPathRenderer* pr = this->getPathRenderer(target, pipelineBuilder, viewMatrix, *pathPtr,
+ *stroke, false, type);
if (NULL == pr) {
if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, NULL)) {
@@ -1191,7 +1194,8 @@ void GrContext::internalDrawPath(GrDrawTarget* target,
}
// This time, allow SW renderer
- pr = this->getPathRenderer(target, drawState, viewMatrix, *pathPtr, *stroke, true, type);
+ pr = this->getPathRenderer(target, pipelineBuilder, viewMatrix, *pathPtr, *stroke, true,
+ type);
}
if (NULL == pr) {
@@ -1201,7 +1205,7 @@ void GrContext::internalDrawPath(GrDrawTarget* target,
return;
}
- pr->drawPath(target, drawState, color, viewMatrix, *pathPtr, *stroke, useCoverageAA);
+ pr->drawPath(target, pipelineBuilder, color, viewMatrix, *pathPtr, *stroke, useCoverageAA);
}
////////////////////////////////////////////////////////////////////////////////
@@ -1339,10 +1343,10 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
GrDrawTarget* drawTarget = this->prepareToDraw(NULL, NULL, NULL);
GrDrawTarget::AutoGeometryPush agp(drawTarget);
- GrDrawState drawState;
- drawState.addColorProcessor(fp);
- drawState.setRenderTarget(renderTarget);
- drawTarget->drawSimpleRect(&drawState, GrColor_WHITE, matrix,
+ GrPipelineBuilder pipelineBuilder;
+ pipelineBuilder.addColorProcessor(fp);
+ pipelineBuilder.setRenderTarget(renderTarget);
+ drawTarget->drawSimpleRect(&pipelineBuilder, GrColor_WHITE, matrix,
SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)));
}
@@ -1458,13 +1462,14 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
// can be invoked in this method
{
GrDrawTarget::AutoGeometryPush agp(fDrawBuffer);
- GrDrawState drawState;
+ GrPipelineBuilder pipelineBuilder;
SkASSERT(fp);
- drawState.addColorProcessor(fp);
+ pipelineBuilder.addColorProcessor(fp);
- drawState.setRenderTarget(tempTexture->asRenderTarget());
+ pipelineBuilder.setRenderTarget(tempTexture->asRenderTarget());
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
- fDrawBuffer->drawSimpleRect(&drawState, GrColor_WHITE, SkMatrix::I(), rect);
+ fDrawBuffer->drawSimpleRect(&pipelineBuilder, GrColor_WHITE, SkMatrix::I(),
+ rect);
// we want to read back from the scratch's origin
left = 0;
top = 0;
@@ -1552,7 +1557,7 @@ void GrContext::flushSurfaceWrites(GrSurface* surface) {
}
}
-GrDrawTarget* GrContext::prepareToDraw(GrDrawState* ds,
+GrDrawTarget* GrContext::prepareToDraw(GrPipelineBuilder* pipelineBuilder,
const GrPaint* paint,
const AutoCheckFlush* acf) {
if (NULL == fGpu) {
@@ -1560,10 +1565,11 @@ GrDrawTarget* GrContext::prepareToDraw(GrDrawState* ds,
}
ASSERT_OWNED_RESOURCE(fRenderTarget.get());
- if (ds) {
+ if (pipelineBuilder) {
SkASSERT(paint && acf);
- ds->setFromPaint(*paint, fRenderTarget.get());
- ds->setState(GrDrawState::kClip_StateBit, fClip && !fClip->fClipStack->isWideOpen());
+ pipelineBuilder->setFromPaint(*paint, fRenderTarget.get());
+ pipelineBuilder->setState(GrPipelineBuilder::kClip_StateBit,
+ fClip && !fClip->fClipStack->isWideOpen());
}
fDrawBuffer->setClip(fClip);
return fDrawBuffer;
@@ -1576,7 +1582,7 @@ GrDrawTarget* GrContext::prepareToDraw(GrDrawState* ds,
* can be individually allowed/disallowed via the "allowSW" boolean.
*/
GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
@@ -1589,7 +1595,7 @@ GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target,
}
GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target,
- drawState,
+ pipelineBuilder,
viewMatrix,
path,
stroke,
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index 3e32e65c62..20ec66553c 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -7,7 +7,6 @@
#include "GrDefaultGeoProcFactory.h"
-#include "GrDrawState.h"
#include "GrInvariantOutput.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index af0404ae0e..7b9817484f 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -9,8 +9,8 @@
#include "GrContext.h"
#include "GrDefaultGeoProcFactory.h"
-#include "GrDrawState.h"
#include "GrPathUtils.h"
+#include "GrPipelineBuilder.h"
#include "SkGeometry.h"
#include "SkString.h"
#include "SkStrokeRec.h"
@@ -165,7 +165,7 @@ static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok
GrPathRenderer::StencilSupport
GrDefaultPathRenderer::onGetStencilSupport(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkPath& path,
const SkStrokeRec& stroke) const {
if (single_pass_path(path, stroke)) {
@@ -208,7 +208,7 @@ static inline void add_quad(SkPoint** vert, const SkPoint* base, const SkPoint p
}
bool GrDefaultPathRenderer::createGeom(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrPrimitiveType* primType,
int* vertexCnt,
int* indexCnt,
@@ -342,7 +342,7 @@ FINISHED:
}
bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
@@ -368,7 +368,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
GrPrimitiveType primType;
GrDrawTarget::AutoReleaseGeometry arg;
if (!this->createGeom(target,
- drawState,
+ pipelineBuilder,
&primType,
&vertexCnt,
&indexCnt,
@@ -379,13 +379,13 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
return false;
}
// Save the current xp on the draw state so we can reset it if needed
- SkAutoTUnref<const GrXPFactory> backupXPFactory(SkRef(drawState->getXPFactory()));
+ SkAutoTUnref<const GrXPFactory> backupXPFactory(SkRef(pipelineBuilder->getXPFactory()));
// face culling doesn't make sense here
- SkASSERT(GrDrawState::kBoth_DrawFace == drawState->getDrawFace());
+ SkASSERT(GrPipelineBuilder::kBoth_DrawFace == pipelineBuilder->getDrawFace());
int passCount = 0;
const GrStencilSettings* passes[3];
- GrDrawState::DrawFace drawFace[3];
+ GrPipelineBuilder::DrawFace drawFace[3];
bool reverse = false;
bool lastPassIsBounds;
@@ -397,7 +397,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
passes[0] = NULL;
}
lastPassIsBounds = false;
- drawFace[0] = GrDrawState::kBoth_DrawFace;
+ drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
} else {
if (single_pass_path(path, *stroke)) {
passCount = 1;
@@ -406,7 +406,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
} else {
passes[0] = NULL;
}
- drawFace[0] = GrDrawState::kBoth_DrawFace;
+ drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
lastPassIsBounds = false;
} else {
switch (path.getFillType()) {
@@ -427,7 +427,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
passes[1] = &gEOColorPass;
}
}
- drawFace[0] = drawFace[1] = GrDrawState::kBoth_DrawFace;
+ drawFace[0] = drawFace[1] = GrPipelineBuilder::kBoth_DrawFace;
break;
case SkPath::kInverseWinding_FillType:
@@ -441,7 +441,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
passes[0] = &gWindStencilSeparateNoWrap;
}
passCount = 2;
- drawFace[0] = GrDrawState::kBoth_DrawFace;
+ drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
} else {
if (fStencilWrapOps) {
passes[0] = &gWindSingleStencilWithWrapInc;
@@ -451,8 +451,8 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
passes[1] = &gWindSingleStencilNoWrapDec;
}
// which is cw and which is ccw is arbitrary.
- drawFace[0] = GrDrawState::kCW_DrawFace;
- drawFace[1] = GrDrawState::kCCW_DrawFace;
+ drawFace[0] = GrPipelineBuilder::kCW_DrawFace;
+ drawFace[1] = GrPipelineBuilder::kCCW_DrawFace;
passCount = 3;
}
if (stencilOnly) {
@@ -460,7 +460,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
--passCount;
} else {
lastPassIsBounds = true;
- drawFace[passCount-1] = GrDrawState::kBoth_DrawFace;
+ drawFace[passCount-1] = GrPipelineBuilder::kBoth_DrawFace;
if (reverse) {
passes[passCount-1] = &gInvWindColorPass;
} else {
@@ -476,21 +476,21 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
}
SkRect devBounds;
- GetPathDevBounds(path, drawState->getRenderTarget(), viewMatrix, &devBounds);
+ GetPathDevBounds(path, pipelineBuilder->getRenderTarget(), viewMatrix, &devBounds);
for (int p = 0; p < passCount; ++p) {
- drawState->setDrawFace(drawFace[p]);
+ pipelineBuilder->setDrawFace(drawFace[p]);
if (passes[p]) {
- *drawState->stencil() = *passes[p];
+ *pipelineBuilder->stencil() = *passes[p];
}
if (lastPassIsBounds && (p == passCount-1)) {
- // Reset the XP Factory on drawState
- drawState->setXPFactory(backupXPFactory);
+ // Reset the XP Factory on pipelineBuilder
+ pipelineBuilder->setXPFactory(backupXPFactory);
SkRect bounds;
SkMatrix localMatrix = SkMatrix::I();
if (reverse) {
- SkASSERT(drawState->getRenderTarget());
+ SkASSERT(pipelineBuilder->getRenderTarget());
// draw over the dev bounds (which will be the whole dst surface for inv fill).
bounds = devBounds;
SkMatrix vmi;
@@ -508,12 +508,12 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
GrDrawTarget::AutoGeometryPush agp(target);
const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() :
viewMatrix;
- target->drawRect(drawState, color, viewM, bounds, NULL, &localMatrix);
+ target->drawRect(pipelineBuilder, color, viewM, bounds, NULL, &localMatrix);
} else {
if (passCount > 1) {
- drawState->setDisableColorXPFactory();
+ pipelineBuilder->setDisableColorXPFactory();
}
- GrDrawState::AutoRestoreEffects are(drawState);
+ GrPipelineBuilder::AutoRestoreEffects are(pipelineBuilder);
SkAutoTUnref<const GrGeometryProcessor> gp(
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
color,
@@ -522,7 +522,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
false,
newCoverage));
if (indexCnt) {
- target->drawIndexed(drawState,
+ target->drawIndexed(pipelineBuilder,
gp,
primType,
0,
@@ -531,7 +531,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
indexCnt,
&devBounds);
} else {
- target->drawNonIndexed(drawState, gp, primType, 0, vertexCnt, &devBounds);
+ target->drawNonIndexed(pipelineBuilder, gp, primType, 0, vertexCnt, &devBounds);
}
}
}
@@ -539,7 +539,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
}
bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
@@ -551,14 +551,14 @@ bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target,
}
bool GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
bool antiAlias) {
return this->internalDrawPath(target,
- drawState,
+ pipelineBuilder,
color,
viewMatrix,
path,
@@ -567,11 +567,11 @@ bool GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target,
}
void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke) {
SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType());
SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType());
- this->internalDrawPath(target, drawState, GrColor_WHITE, viewMatrix, path, stroke, true);
+ this->internalDrawPath(target, pipelineBuilder, GrColor_WHITE, viewMatrix, path, stroke, true);
}
diff --git a/src/gpu/GrDefaultPathRenderer.h b/src/gpu/GrDefaultPathRenderer.h
index e1eea88414..5a805e5f7b 100644
--- a/src/gpu/GrDefaultPathRenderer.h
+++ b/src/gpu/GrDefaultPathRenderer.h
@@ -20,7 +20,7 @@ public:
GrDefaultPathRenderer(bool separateStencilSupport, bool stencilWrapOpsSupport);
virtual bool canDrawPath(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath&,
const SkStrokeRec&,
@@ -29,12 +29,12 @@ public:
private:
virtual StencilSupport onGetStencilSupport(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkPath&,
const SkStrokeRec&) const SK_OVERRIDE;
virtual bool onDrawPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkPath&,
@@ -42,13 +42,13 @@ private:
bool antiAlias) SK_OVERRIDE;
virtual void onStencilPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath&,
const SkStrokeRec&) SK_OVERRIDE;
bool internalDrawPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkPath&,
@@ -56,7 +56,7 @@ private:
bool stencilOnly);
bool createGeom(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrPrimitiveType*,
int* vertexCnt,
int* indexCnt,
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 14809756c8..425c56c892 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -636,8 +636,8 @@ void GrDistanceFieldTextContext::flush() {
}
if (fCurrVertex > 0) {
- GrDrawState drawState;
- drawState.setFromPaint(fPaint, fContext->getRenderTarget());
+ GrPipelineBuilder pipelineBuilder;
+ pipelineBuilder.setFromPaint(fPaint, fContext->getRenderTarget());
// setup our sampler state for our text texture/atlas
SkASSERT(SkIsAlign4(fCurrVertex));
@@ -657,7 +657,8 @@ void GrDistanceFieldTextContext::flush() {
// TODO: move supportsRGBCoverage check to setupCoverageEffect and only add LCD
// processor if the xp can support it. For now we will simply assume that if
// fUseLCDText is true, then we have a known color output.
- if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorComponentFlags)) {
+ const GrXPFactory* xpFactory = pipelineBuilder.getXPFactory();
+ if (!xpFactory->supportsRGBCoverage(0, kRGBA_GrColorComponentFlags)) {
SkDebugf("LCD Text will not draw correctly.\n");
}
SkASSERT(!fCachedGeometryProcessor->hasVertexColor());
@@ -667,7 +668,7 @@ void GrDistanceFieldTextContext::flush() {
}
int nGlyphs = fCurrVertex / kVerticesPerGlyph;
fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
- fDrawTarget->drawIndexedInstances(&drawState,
+ fDrawTarget->drawIndexedInstances(&pipelineBuilder,
fCachedGeometryProcessor.get(),
kTriangles_GrPrimitiveType,
nGlyphs,
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index f14515462a..e8a758d25f 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -306,7 +306,7 @@ void GrDrawTarget::popGeometrySource() {
////////////////////////////////////////////////////////////////////////////////
-bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
+bool GrDrawTarget::checkDraw(const GrPipelineBuilder& pipelineBuilder,
const GrGeometryProcessor* gp,
GrPrimitiveType type,
int startVertex,
@@ -324,7 +324,8 @@ bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
maxValidVertex = geoSrc.fVertexCount;
break;
case kBuffer_GeometrySrcType:
- maxValidVertex = static_cast<int>(geoSrc.fVertexBuffer->gpuMemorySize() / geoSrc.fVertexSize);
+ maxValidVertex = static_cast<int>(geoSrc.fVertexBuffer->gpuMemorySize() /
+ geoSrc.fVertexSize);
break;
}
if (maxVertex > maxValidVertex) {
@@ -340,7 +341,8 @@ bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
maxValidIndex = geoSrc.fIndexCount;
break;
case kBuffer_GeometrySrcType:
- maxValidIndex = static_cast<int>(geoSrc.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t));
+ maxValidIndex = static_cast<int>(geoSrc.fIndexBuffer->gpuMemorySize() /
+ sizeof(uint16_t));
break;
}
if (maxIndex > maxValidIndex) {
@@ -348,49 +350,49 @@ bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
}
}
- SkASSERT(drawState.getRenderTarget());
+ SkASSERT(pipelineBuilder.getRenderTarget());
if (gp) {
int numTextures = gp->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = gp->texture(t);
- SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget());
+ SkASSERT(texture->asRenderTarget() != pipelineBuilder.getRenderTarget());
}
}
- for (int s = 0; s < drawState.numColorStages(); ++s) {
- const GrProcessor* effect = drawState.getColorStage(s).processor();
+ for (int s = 0; s < pipelineBuilder.numColorStages(); ++s) {
+ const GrProcessor* effect = pipelineBuilder.getColorStage(s).processor();
int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = effect->texture(t);
- SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget());
+ SkASSERT(texture->asRenderTarget() != pipelineBuilder.getRenderTarget());
}
}
- for (int s = 0; s < drawState.numCoverageStages(); ++s) {
- const GrProcessor* effect = drawState.getCoverageStage(s).processor();
+ for (int s = 0; s < pipelineBuilder.numCoverageStages(); ++s) {
+ const GrProcessor* effect = pipelineBuilder.getCoverageStage(s).processor();
int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = effect->texture(t);
- SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget());
+ SkASSERT(texture->asRenderTarget() != pipelineBuilder.getRenderTarget());
}
}
#endif
- if (NULL == drawState.getRenderTarget()) {
+ if (NULL == pipelineBuilder.getRenderTarget()) {
return false;
}
return true;
}
-bool GrDrawTarget::setupDstReadIfNecessary(GrDrawState* ds,
+bool GrDrawTarget::setupDstReadIfNecessary(GrPipelineBuilder* pipelineBuilder,
GrDeviceCoordTexture* dstCopy,
const SkRect* drawBounds) {
- if (this->caps()->dstReadInShaderSupport() || !ds->willEffectReadDstColor()) {
+ if (this->caps()->dstReadInShaderSupport() || !pipelineBuilder->willEffectReadDstColor()) {
return true;
}
SkIRect copyRect;
const GrClipData* clip = this->getClip();
- GrRenderTarget* rt = ds->getRenderTarget();
+ GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
clip->getConservativeBounds(rt, &copyRect);
if (drawBounds) {
@@ -432,7 +434,7 @@ bool GrDrawTarget::setupDstReadIfNecessary(GrDrawState* ds,
}
}
-void GrDrawTarget::drawIndexed(GrDrawState* ds,
+void GrDrawTarget::drawIndexed(GrPipelineBuilder* pipelineBuilder,
const GrGeometryProcessor* gp,
GrPrimitiveType type,
int startVertex,
@@ -440,15 +442,16 @@ void GrDrawTarget::drawIndexed(GrDrawState* ds,
int vertexCount,
int indexCount,
const SkRect* devBounds) {
- SkASSERT(ds);
+ SkASSERT(pipelineBuilder);
if (indexCount > 0 &&
- this->checkDraw(*ds, gp, type, startVertex, startIndex, vertexCount, indexCount)) {
+ this->checkDraw(*pipelineBuilder, gp, type, startVertex, startIndex, vertexCount,
+ indexCount)) {
// Setup clip
GrScissorState scissorState;
- GrDrawState::AutoRestoreEffects are;
- GrDrawState::AutoRestoreStencil ars;
- if (!this->setupClip(ds, &are, &ars, &scissorState, devBounds)) {
+ GrPipelineBuilder::AutoRestoreEffects are;
+ GrPipelineBuilder::AutoRestoreStencil ars;
+ if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBounds)) {
return;
}
@@ -469,29 +472,30 @@ void GrDrawTarget::drawIndexed(GrDrawState* ds,
// TODO: We should continue with incorrect blending.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) {
+ if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) {
return;
}
this->setDrawBuffers(&info, gp->getVertexStride());
- this->onDraw(*ds, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
+ this->onDraw(*pipelineBuilder, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
}
}
-void GrDrawTarget::drawNonIndexed(GrDrawState* ds,
+void GrDrawTarget::drawNonIndexed(GrPipelineBuilder* pipelineBuilder,
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)) {
+ SkASSERT(pipelineBuilder);
+ if (vertexCount > 0 && this->checkDraw(*pipelineBuilder, gp, type, startVertex, -1, vertexCount,
+ -1)) {
// Setup clip
GrScissorState scissorState;
- GrDrawState::AutoRestoreEffects are;
- GrDrawState::AutoRestoreStencil ars;
- if (!this->setupClip(ds, &are, &ars, &scissorState, devBounds)) {
+ GrPipelineBuilder::AutoRestoreEffects are;
+ GrPipelineBuilder::AutoRestoreStencil ars;
+ if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBounds)) {
return;
}
@@ -512,13 +516,13 @@ void GrDrawTarget::drawNonIndexed(GrDrawState* ds,
// TODO: We should continue with incorrect blending.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) {
+ if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) {
return;
}
this->setDrawBuffers(&info, gp->getVertexStride());
- this->onDraw(*ds, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
+ this->onDraw(*pipelineBuilder, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
}
}
@@ -557,68 +561,68 @@ void GrDrawTarget::getPathStencilSettingsForFilltype(GrPathRendering::FillType f
this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings);
}
-void GrDrawTarget::stencilPath(GrDrawState* ds,
+void GrDrawTarget::stencilPath(GrPipelineBuilder* pipelineBuilder,
const GrPathProcessor* pathProc,
const GrPath* path,
GrPathRendering::FillType fill) {
// TODO: extract portions of checkDraw that are relevant to path stenciling.
SkASSERT(path);
SkASSERT(this->caps()->pathRenderingSupport());
- SkASSERT(ds);
+ SkASSERT(pipelineBuilder);
// Setup clip
GrScissorState scissorState;
- GrDrawState::AutoRestoreEffects are;
- GrDrawState::AutoRestoreStencil ars;
- if (!this->setupClip(ds, &are, &ars, &scissorState, NULL)) {
+ GrPipelineBuilder::AutoRestoreEffects are;
+ GrPipelineBuilder::AutoRestoreStencil ars;
+ if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, NULL)) {
return;
}
// set stencil settings for path
GrStencilSettings stencilSettings;
this->getPathStencilSettingsForFilltype(fill,
- ds->getRenderTarget()->getStencilBuffer(),
+ pipelineBuilder->getRenderTarget()->getStencilBuffer(),
&stencilSettings);
- this->onStencilPath(*ds, pathProc, path, scissorState, stencilSettings);
+ this->onStencilPath(*pipelineBuilder, pathProc, path, scissorState, stencilSettings);
}
-void GrDrawTarget::drawPath(GrDrawState* ds,
+void GrDrawTarget::drawPath(GrPipelineBuilder* pipelineBuilder,
const GrPathProcessor* pathProc,
const GrPath* path,
GrPathRendering::FillType fill) {
// TODO: extract portions of checkDraw that are relevant to path rendering.
SkASSERT(path);
SkASSERT(this->caps()->pathRenderingSupport());
- SkASSERT(ds);
+ SkASSERT(pipelineBuilder);
SkRect devBounds = path->getBounds();
pathProc->viewMatrix().mapRect(&devBounds);
// Setup clip
GrScissorState scissorState;
- GrDrawState::AutoRestoreEffects are;
- GrDrawState::AutoRestoreStencil ars;
- if (!this->setupClip(ds, &are, &ars, &scissorState, &devBounds)) {
+ GrPipelineBuilder::AutoRestoreEffects are;
+ GrPipelineBuilder::AutoRestoreStencil ars;
+ if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, &devBounds)) {
return;
}
// set stencil settings for path
GrStencilSettings stencilSettings;
this->getPathStencilSettingsForFilltype(fill,
- ds->getRenderTarget()->getStencilBuffer(),
+ pipelineBuilder->getRenderTarget()->getStencilBuffer(),
&stencilSettings);
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, &dstCopy, &devBounds)) {
+ if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, &devBounds)) {
return;
}
- this->onDrawPath(*ds, pathProc, path, scissorState, stencilSettings, dstCopy.texture() ? &dstCopy :
- NULL);
+ this->onDrawPath(*pipelineBuilder, pathProc, path, scissorState, stencilSettings,
+ dstCopy.texture() ? &dstCopy : NULL);
}
-void GrDrawTarget::drawPaths(GrDrawState* ds,
+void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder,
const GrPathProcessor* pathProc,
const GrPathRange* pathRange,
const void* indices,
@@ -632,21 +636,21 @@ void GrDrawTarget::drawPaths(GrDrawState* ds,
SkASSERT(indices);
SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeInBytes(indexType));
SkASSERT(transformValues);
- SkASSERT(ds);
+ SkASSERT(pipelineBuilder);
// Setup clip
GrScissorState scissorState;
- GrDrawState::AutoRestoreEffects are;
- GrDrawState::AutoRestoreStencil ars;
+ GrPipelineBuilder::AutoRestoreEffects are;
+ GrPipelineBuilder::AutoRestoreStencil ars;
- if (!this->setupClip(ds, &are, &ars, &scissorState, NULL)) {
+ if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, NULL)) {
return;
}
// set stencil settings for path
GrStencilSettings stencilSettings;
this->getPathStencilSettingsForFilltype(fill,
- ds->getRenderTarget()->getStencilBuffer(),
+ pipelineBuilder->getRenderTarget()->getStencilBuffer(),
&stencilSettings);
// Don't compute a bounding box for setupDstReadIfNecessary(), we'll opt
@@ -654,12 +658,13 @@ 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, &dstCopy, NULL)) {
+ if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, NULL)) {
return;
}
- this->onDrawPaths(*ds, pathProc, pathRange, indices, indexType, transformValues, transformType,
- count, scissorState, stencilSettings, dstCopy.texture() ? &dstCopy : NULL);
+ this->onDrawPaths(*pipelineBuilder, pathProc, pathRange, indices, indexType, transformValues,
+ transformType, count, scissorState, stencilSettings,
+ dstCopy.texture() ? &dstCopy : NULL);
}
void GrDrawTarget::clear(const SkIRect* rect,
@@ -677,10 +682,10 @@ void GrDrawTarget::clear(const SkIRect* rect,
this->discard(renderTarget);
}
- GrDrawState drawState;
- drawState.setRenderTarget(renderTarget);
+ GrPipelineBuilder pipelineBuilder;
+ pipelineBuilder.setRenderTarget(renderTarget);
- this->drawSimpleRect(&drawState, color, SkMatrix::I(), *rect);
+ this->drawSimpleRect(&pipelineBuilder, color, SkMatrix::I(), *rect);
} else {
this->onClear(rect, color, canIgnoreRect, renderTarget);
}
@@ -727,14 +732,14 @@ void GrDrawTarget::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
////////////////////////////////////////////////////////////////////////////////
-void GrDrawTarget::drawIndexedInstances(GrDrawState* ds,
+void GrDrawTarget::drawIndexedInstances(GrPipelineBuilder* pipelineBuilder,
const GrGeometryProcessor* gp,
GrPrimitiveType type,
int instanceCount,
int verticesPerInstance,
int indicesPerInstance,
const SkRect* devBounds) {
- SkASSERT(ds);
+ SkASSERT(pipelineBuilder);
if (!verticesPerInstance || !indicesPerInstance) {
return;
@@ -747,9 +752,9 @@ void GrDrawTarget::drawIndexedInstances(GrDrawState* ds,
// Setup clip
GrScissorState scissorState;
- GrDrawState::AutoRestoreEffects are;
- GrDrawState::AutoRestoreStencil ars;
- if (!this->setupClip(ds, &are, &ars, &scissorState, devBounds)) {
+ GrPipelineBuilder::AutoRestoreEffects are;
+ GrPipelineBuilder::AutoRestoreStencil ars;
+ if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBounds)) {
return;
}
@@ -767,7 +772,7 @@ void GrDrawTarget::drawIndexedInstances(GrDrawState* ds,
// TODO: We should continue with incorrect blending.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) {
+ if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) {
return;
}
@@ -776,7 +781,7 @@ void GrDrawTarget::drawIndexedInstances(GrDrawState* ds,
info.fVertexCount = info.fInstanceCount * verticesPerInstance;
info.fIndexCount = info.fInstanceCount * indicesPerInstance;
- if (this->checkDraw(*ds,
+ if (this->checkDraw(*pipelineBuilder,
gp,
type,
info.fStartVertex,
@@ -784,7 +789,8 @@ void GrDrawTarget::drawIndexedInstances(GrDrawState* ds,
info.fVertexCount,
info.fIndexCount)) {
this->setDrawBuffers(&info, gp->getVertexStride());
- this->onDraw(*ds, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
+ this->onDraw(*pipelineBuilder, gp, info, scissorState,
+ dstCopy.texture() ? &dstCopy : NULL);
}
info.fStartVertex += info.fVertexCount;
instanceCount -= info.fInstanceCount;
@@ -938,18 +944,18 @@ bool GrDrawTarget::copySurface(GrSurface* dst,
return false;
}
- GrDrawState drawState;
- drawState.setRenderTarget(rt);
+ GrPipelineBuilder pipelineBuilder;
+ pipelineBuilder.setRenderTarget(rt);
SkMatrix matrix;
matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX),
SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY));
matrix.postIDiv(tex->width(), tex->height());
- drawState.addColorTextureProcessor(tex, matrix);
+ pipelineBuilder.addColorTextureProcessor(tex, matrix);
SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX,
clippedDstPoint.fY,
clippedSrcRect.width(),
clippedSrcRect.height());
- this->drawSimpleRect(&drawState, GrColor_WHITE, SkMatrix::I(), dstRect);
+ this->drawSimpleRect(&pipelineBuilder, GrColor_WHITE, SkMatrix::I(), dstRect);
return true;
}
@@ -1210,12 +1216,12 @@ uint32_t GrDrawTargetCaps::CreateUniqueID() {
///////////////////////////////////////////////////////////////////////////////////////////////////
-bool GrClipTarget::setupClip(GrDrawState* ds,
- GrDrawState::AutoRestoreEffects* are,
- GrDrawState::AutoRestoreStencil* ars,
+bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder,
+ GrPipelineBuilder::AutoRestoreEffects* are,
+ GrPipelineBuilder::AutoRestoreStencil* ars,
GrScissorState* scissorState,
const SkRect* devBounds) {
- return fClipMaskManager.setupClipping(ds,
+ return fClipMaskManager.setupClipping(pipelineBuilder,
are,
ars,
scissorState,
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 6628e37228..b66f1c6bd3 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -11,9 +11,9 @@
#include "GrClipData.h"
#include "GrClipMaskManager.h"
#include "GrContext.h"
-#include "GrDrawState.h"
#include "GrIndexBuffer.h"
#include "GrPathRendering.h"
+#include "GrPipelineBuilder.h"
#include "GrTraceMarker.h"
#include "GrVertexBuffer.h"
@@ -125,7 +125,7 @@ public:
* snapshot of the data is made and the pointers are invalid.
*
* @param vertexCount the number of vertices to reserve space for. Can be
- * 0. Vertex size is queried from the current GrDrawState.
+ * 0. Vertex size is queried from the current GrPipelineBuilder.
* @param indexCount the number of indices to reserve space for. Can be 0.
* @param vertices will point to reserved vertex space if vertexCount is
* non-zero. Illegal to pass NULL if vertexCount > 0.
@@ -148,7 +148,7 @@ public:
*
* @param vertexCount in: hint about how many vertices the caller would
* like to allocate. Vertex size is queried from the
- * current GrDrawState.
+ * current GrPipelineBuilder.
* out: a hint about the number of vertices that can be
* allocated cheaply. Negative means no hint.
* Ignored if NULL.
@@ -168,7 +168,7 @@ public:
*
* @param buffer vertex buffer containing vertex data. Must be
* unlocked before draw call. Vertex size is queried
- * from current GrDrawState.
+ * from current GrPipelineBuilder.
*/
void setVertexSourceToBuffer(const GrVertexBuffer* buffer, size_t vertexStride);
@@ -232,7 +232,7 @@ public:
* @param devBounds optional bounds hint. This is a promise from the caller,
* not a request for clipping.
*/
- void drawIndexed(GrDrawState*,
+ void drawIndexed(GrPipelineBuilder*,
const GrGeometryProcessor*,
GrPrimitiveType type,
int startVertex,
@@ -252,7 +252,7 @@ public:
* @param devBounds optional bounds hint. This is a promise from the caller,
* not a request for clipping.
*/
- void drawNonIndexed(GrDrawState*,
+ void drawNonIndexed(GrPipelineBuilder*,
const GrGeometryProcessor*,
GrPrimitiveType type,
int startVertex,
@@ -262,21 +262,23 @@ public:
/**
* Draws path into the stencil buffer. The fill must be either even/odd or
* winding (not inverse or hairline). It will respect the HW antialias flag
- * on the draw state (if possible in the 3D API). Note, we will never have an inverse fill
- * with stencil path
+ * on the GrPipelineBuilder (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(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*,
+ GrPathRendering::FillType);
/**
* 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).
+ * antialias flag on the GrPipelineBuilder (if possible in the 3D API).
*/
- void drawPath(GrDrawState*, const GrPathProcessor*, const GrPath*, GrPathRendering::FillType);
+ void drawPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*,
+ GrPathRendering::FillType);
/**
* Draws the aggregate path from combining multiple. Note that this will not
* always be equivalent to back-to-back calls to drawPath(). It will respect
- * the HW antialias flag on the draw state (if possible in the 3D API).
+ * the HW antialias flag on the GrPipelineBuilder (if possible in the 3D API).
*
* @param pathRange Source paths to draw from
* @param indices Array of path indices to draw
@@ -286,7 +288,7 @@ public:
* @param count Number of paths to draw
* @param fill Fill type for drawing all the paths
*/
- void drawPaths(GrDrawState*,
+ void drawPaths(GrPipelineBuilder*,
const GrPathProcessor*,
const GrPathRange* pathRange,
const void* indices,
@@ -308,7 +310,7 @@ public:
* that rectangle before it is input to GrCoordTransforms that read local
* coordinates
*/
- void drawRect(GrDrawState* ds,
+ void drawRect(GrPipelineBuilder* ds,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
@@ -321,10 +323,11 @@ public:
/**
* Helper for drawRect when the caller doesn't need separate local rects or matrices.
*/
- void drawSimpleRect(GrDrawState* ds, GrColor color, const SkMatrix& viewM, const SkRect& rect) {
+ void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& viewM,
+ const SkRect& rect) {
this->drawRect(ds, color, viewM, rect, NULL, NULL);
}
- void drawSimpleRect(GrDrawState* ds, GrColor color, const SkMatrix& viewM,
+ void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& viewM,
const SkIRect& irect) {
SkRect rect = SkRect::Make(irect);
this->drawRect(ds, color, viewM, rect, NULL, NULL);
@@ -360,7 +363,7 @@ public:
* @param devBounds optional bounds hint. This is a promise from the caller,
* not a request for clipping.
*/
- void drawIndexedInstances(GrDrawState*,
+ void drawIndexedInstances(GrPipelineBuilder*,
const GrGeometryProcessor*,
GrPrimitiveType type,
int instanceCount,
@@ -369,9 +372,9 @@ public:
const SkRect* devBounds = NULL);
/**
- * Clear the passed in render target. Ignores the draw state and clip. Clears the whole thing if
- * rect is NULL, otherwise just the rect. If canIgnoreRect is set then the entire render target
- * can be optionally cleared.
+ * Clear the passed in render target. Ignores the GrPipelineBuilder and clip. Clears the whole
+ * thing if rect is NULL, otherwise just the rect. If canIgnoreRect is set then the entire
+ * render target can be optionally cleared.
*/
void clear(const SkIRect* rect,
GrColor color,
@@ -660,7 +663,7 @@ protected:
// Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required
// 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*,
+ bool setupDstReadIfNecessary(GrPipelineBuilder*,
GrDeviceCoordTexture* dstCopy,
const SkRect* drawBounds);
@@ -700,31 +703,31 @@ private:
virtual void geometrySourceWillPush() = 0;
virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0;
// subclass called to perform drawing
- virtual void onDraw(const GrDrawState&,
+ virtual void onDraw(const GrPipelineBuilder&,
const GrGeometryProcessor*,
const DrawInfo&,
const GrScissorState&,
const GrDeviceCoordTexture* dstCopy) = 0;
// TODO copy in order drawbuffer onDrawRect to here
- virtual void onDrawRect(GrDrawState*,
+ virtual void onDrawRect(GrPipelineBuilder*,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
const SkMatrix* localMatrix) = 0;
- virtual void onStencilPath(const GrDrawState&,
+ virtual void onStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
const GrScissorState&,
const GrStencilSettings&) = 0;
- virtual void onDrawPath(const GrDrawState&,
+ virtual void onDrawPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
const GrScissorState&,
const GrStencilSettings&,
const GrDeviceCoordTexture* dstCopy) = 0;
- virtual void onDrawPaths(const GrDrawState&,
+ virtual void onDrawPaths(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPathRange*,
const void* indices,
@@ -771,7 +774,7 @@ private:
// called by drawIndexed and drawNonIndexed. Use a negative indexCount to
// indicate non-indexed drawing.
- bool checkDraw(const GrDrawState&,
+ bool checkDraw(const GrPipelineBuilder&,
const GrGeometryProcessor*,
GrPrimitiveType type,
int startVertex,
@@ -788,9 +791,9 @@ private:
const GrStencilBuffer*,
GrStencilSettings*);
virtual GrClipMaskManager* clipMaskManager() = 0;
- virtual bool setupClip(GrDrawState*,
- GrDrawState::AutoRestoreEffects* are,
- GrDrawState::AutoRestoreStencil* ars,
+ virtual bool setupClip(GrPipelineBuilder*,
+ GrPipelineBuilder::AutoRestoreEffects* are,
+ GrPipelineBuilder::AutoRestoreStencil* ars,
GrScissorState* scissorState,
const SkRect* devBounds) = 0;
@@ -848,9 +851,9 @@ protected:
private:
GrClipMaskManager* clipMaskManager() SK_OVERRIDE { return &fClipMaskManager; }
- virtual bool setupClip(GrDrawState*,
- GrDrawState::AutoRestoreEffects* are,
- GrDrawState::AutoRestoreStencil* ars,
+ virtual bool setupClip(GrPipelineBuilder*,
+ GrPipelineBuilder::AutoRestoreEffects* are,
+ GrPipelineBuilder::AutoRestoreStencil* ars,
GrScissorState* scissorState,
const SkRect* devBounds) SK_OVERRIDE;
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 5bbc3dcb05..17bed8b9b1 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -15,11 +15,11 @@
class GrContext;
class GrIndexBufferAllocPool;
-class GrOptDrawState;
class GrPath;
class GrPathRange;
class GrPathRenderer;
class GrPathRendererChain;
+class GrPipeline;
class GrPrimitiveProcessor;
class GrStencilBuffer;
class GrVertexBufferAllocPool;
@@ -306,7 +306,7 @@ public:
virtual void buildProgramDesc(GrProgramDesc*,
const GrPrimitiveProcessor&,
- const GrOptDrawState&,
+ const GrPipeline&,
const GrProgramDesc::DescInfo&,
const GrBatchTracker&) const = 0;
@@ -351,17 +351,17 @@ public:
struct DrawArgs {
typedef GrDrawTarget::DrawInfo DrawInfo;
DrawArgs(const GrPrimitiveProcessor* primProc,
- const GrOptDrawState* optState,
+ const GrPipeline* pipeline,
const GrProgramDesc* desc,
const GrBatchTracker* batchTracker)
: fPrimitiveProcessor(primProc)
- , fOptState(optState)
+ , fPipeline(pipeline)
, fDesc(desc)
, fBatchTracker(batchTracker) {
- SkASSERT(primProc && optState && desc && batchTracker);
+ SkASSERT(primProc && pipeline && desc && batchTracker);
}
const GrPrimitiveProcessor* fPrimitiveProcessor;
- const GrOptDrawState* fOptState;
+ const GrPipeline* fPipeline;
const GrProgramDesc* fDesc;
const GrBatchTracker* fBatchTracker;
};
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 5b1f00891e..70d61ecfff 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -114,13 +114,13 @@ static inline uint8_t strip_trace_bit(uint8_t cmd) { return cmd & kCmdMask; }
static inline bool cmd_has_trace_marker(uint8_t cmd) { return SkToBool(cmd & kTraceCmdBit); }
-void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
+void GrInOrderDrawBuffer::onDrawRect(GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
const SkMatrix* localMatrix) {
- GrDrawState::AutoRestoreEffects are(ds);
+ GrPipelineBuilder::AutoRestoreEffects are(pipelineBuilder);
// Go to device coords to allow batching across matrix changes
SkMatrix invert = SkMatrix::I();
@@ -183,10 +183,12 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
}
this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer());
- this->drawIndexedInstances(ds, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds);
+ this->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType, 1, 4, 6,
+ &devBounds);
}
-int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, const DrawInfo& info) {
+int GrInOrderDrawBuffer::concatInstancedDraw(const GrPipelineBuilder& pipelineBuilder,
+ const DrawInfo& info) {
SkASSERT(!fCmdBuffer.empty());
SkASSERT(info.isInstanced());
@@ -238,20 +240,20 @@ int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, const DrawIn
return instancesToConcat;
}
-void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds,
+void GrInOrderDrawBuffer::onDraw(const GrPipelineBuilder& pipelineBuilder,
const GrGeometryProcessor* gp,
const DrawInfo& info,
const GrScissorState& scissorState,
const GrDeviceCoordTexture* dstCopy) {
SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
- if (!this->recordStateAndShouldDraw(ds, gp, scissorState, dstCopy)) {
+ if (!this->recordStateAndShouldDraw(pipelineBuilder, gp, scissorState, dstCopy)) {
return;
}
Draw* draw;
if (info.isInstanced()) {
- int instancesConcated = this->concatInstancedDraw(ds, info);
+ int instancesConcated = this->concatInstancedDraw(pipelineBuilder, info);
if (info.instanceCount() > instancesConcated) {
draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info));
draw->fInfo.adjustInstanceCount(-instancesConcated);
@@ -264,28 +266,28 @@ void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds,
this->recordTraceMarkersIfNecessary();
}
-void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds,
+void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder,
const GrPathProcessor* pathProc,
const GrPath* path,
const GrScissorState& scissorState,
const GrStencilSettings& stencilSettings) {
StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath,
- (path, ds.getRenderTarget()));
+ (path, pipelineBuilder.getRenderTarget()));
sp->fScissor = scissorState;
- sp->fUseHWAA = ds.isHWAntialias();
+ sp->fUseHWAA = pipelineBuilder.isHWAntialias();
sp->fViewMatrix = pathProc->viewMatrix();
sp->fStencil = stencilSettings;
this->recordTraceMarkersIfNecessary();
}
-void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds,
+void GrInOrderDrawBuffer::onDrawPath(const GrPipelineBuilder& pipelineBuilder,
const GrPathProcessor* pathProc,
const GrPath* path,
const GrScissorState& scissorState,
const GrStencilSettings& stencilSettings,
const GrDeviceCoordTexture* dstCopy) {
- // TODO: Only compare the subset of GrDrawState relevant to path covering?
- if (!this->recordStateAndShouldDraw(ds, pathProc, scissorState, dstCopy)) {
+ // TODO: Only compare the subset of GrPipelineBuilder relevant to path covering?
+ if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, dstCopy)) {
return;
}
DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
@@ -293,7 +295,7 @@ void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds,
this->recordTraceMarkersIfNecessary();
}
-void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
+void GrInOrderDrawBuffer::onDrawPaths(const GrPipelineBuilder& pipelineBuilder,
const GrPathProcessor* pathProc,
const GrPathRange* pathRange,
const void* indices,
@@ -308,7 +310,7 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
SkASSERT(indices);
SkASSERT(transformValues);
- if (!this->recordStateAndShouldDraw(ds, pathProc, scissorState, dstCopy)) {
+ if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, dstCopy)) {
return;
}
@@ -338,7 +340,7 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
transformType == previous->fTransformType &&
stencilSettings == previous->fStencilSettings &&
path_fill_type_is_winding(stencilSettings) &&
- !ds.willBlendWithDst(pathProc)) {
+ !pipelineBuilder.willBlendWithDst(pathProc)) {
// Fold this DrawPaths call into the one previous.
previous->fCount += count;
return;
@@ -430,8 +432,8 @@ void GrInOrderDrawBuffer::onFlush() {
if (kSetState_Cmd == strip_trace_bit(iter->fType)) {
SetState* ss = reinterpret_cast<SetState*>(iter.get());
- this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProcessor, ss->fState,
- ss->fState.descInfo(), ss->fBatchTracker);
+ this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProcessor, ss->fPipeline,
+ ss->fPipeline.descInfo(), ss->fBatchTracker);
currentState = ss;
} else {
@@ -449,7 +451,7 @@ void GrInOrderDrawBuffer::onFlush() {
void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
SkASSERT(state);
- DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
+ DrawArgs args(state->fPrimitiveProcessor.get(), &state->fPipeline, &state->fDesc,
&state->fBatchTracker);
buf->getGpu()->draw(args, fInfo);
}
@@ -467,14 +469,14 @@ void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, const S
void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
SkASSERT(state);
- DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
+ DrawArgs args(state->fPrimitiveProcessor.get(), &state->fPipeline, &state->fDesc,
&state->fBatchTracker);
buf->getGpu()->drawPath(args, this->path(), fStencilSettings);
}
void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
SkASSERT(state);
- DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
+ DrawArgs args(state->fPrimitiveProcessor.get(), &state->fPipeline, &state->fDesc,
&state->fBatchTracker);
buf->getGpu()->drawPaths(args, this->pathRange(),
&buf->fPathIndexBuffer[fIndicesLocation], fIndexType,
@@ -514,26 +516,26 @@ bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst,
return false;
}
-bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
+bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrPipelineBuilder& pipelineBuilder,
const GrPrimitiveProcessor* primProc,
const GrScissorState& scissor,
const GrDeviceCoordTexture* dstCopy) {
SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
- (ds, primProc, *this->getGpu()->caps(), scissor,
- dstCopy));
- if (ss->fState.mustSkip()) {
+ (pipelineBuilder, primProc, *this->getGpu()->caps(),
+ scissor, dstCopy));
+ if (ss->fPipeline.mustSkip()) {
fCmdBuffer.pop_back();
return false;
}
ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker,
- ss->fState.getInitBatchTracker());
+ ss->fPipeline.getInitBatchTracker());
if (fPrevState &&
fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
*ss->fPrimitiveProcessor,
ss->fBatchTracker) &&
- fPrevState->fState.isEqual(ss->fState)) {
+ fPrevState->fPipeline.isEqual(ss->fPipeline)) {
fCmdBuffer.pop_back();
} else {
fPrevState = ss;
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index ea1279bc57..afa7d27394 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -9,7 +9,7 @@
#define GrInOrderDrawBuffer_DEFINED
#include "GrFlushToGpuDrawTarget.h"
-#include "GrOptDrawState.h"
+#include "GrPipeline.h"
#include "GrPath.h"
#include "GrTRecorder.h"
@@ -178,19 +178,20 @@ private:
GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
};
+ // TODO: rename to SetPipeline once pp, batch tracker, and desc are removed
struct SetState : public Cmd {
- SetState(const GrDrawState& drawState, const GrPrimitiveProcessor* primProc,
+ SetState(const GrPipelineBuilder& pipelineBuilder, const GrPrimitiveProcessor* primProc,
const GrDrawTargetCaps& caps,
const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy)
: Cmd(kSetState_Cmd)
, fPrimitiveProcessor(primProc)
- , fState(drawState, primProc, caps, scissor, dstCopy) {}
+ , fPipeline(pipelineBuilder, primProc, caps, scissor, dstCopy) {}
void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE;
typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitiveProcessor;
ProgramPrimitiveProcessor fPrimitiveProcessor;
- const GrOptDrawState fState;
+ const GrPipeline fPipeline;
GrProgramDesc fDesc;
GrBatchTracker fBatchTracker;
};
@@ -202,30 +203,30 @@ private:
void onFlush() SK_OVERRIDE;
// overrides from GrDrawTarget
- void onDraw(const GrDrawState&,
+ void onDraw(const GrPipelineBuilder&,
const GrGeometryProcessor*,
const DrawInfo&,
const GrScissorState&,
const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
- void onDrawRect(GrDrawState*,
+ void onDrawRect(GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
const SkMatrix* localMatrix) SK_OVERRIDE;
- void onStencilPath(const GrDrawState&,
+ void onStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
const GrScissorState&,
const GrStencilSettings&) SK_OVERRIDE;
- void onDrawPath(const GrDrawState&,
+ void onDrawPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
const GrScissorState&,
const GrStencilSettings&,
const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
- void onDrawPaths(const GrDrawState&,
+ void onDrawPaths(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPathRange*,
const void* indices,
@@ -247,12 +248,12 @@ private:
// Attempts to concat instances from info onto the previous draw. info must represent an
// instanced draw. The caller must have already recorded a new draw state and clip if necessary.
- int concatInstancedDraw(const GrDrawState&, const DrawInfo&);
+ int concatInstancedDraw(const GrPipelineBuilder&, const DrawInfo&);
- // Determines whether the current draw operation requires a new GrOptDrawState and if so
- // records it. If the draw can be skipped false is returned and no new GrOptDrawState is
+ // Determines whether the current draw operation requires a new GrPipeline and if so
+ // records it. If the draw can be skipped false is returned and no new GrPipeline is
// recorded.
- bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&,
+ bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrPipelineBuilder&,
const GrPrimitiveProcessor*,
const GrScissorState&,
const GrDeviceCoordTexture*);
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index a35d70859a..4b24e4542b 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -8,11 +8,11 @@
#include "GrOvalRenderer.h"
#include "GrProcessor.h"
-#include "GrDrawState.h"
#include "GrDrawTarget.h"
#include "GrGeometryProcessor.h"
#include "GrGpu.h"
#include "GrInvariantOutput.h"
+#include "GrPipelineBuilder.h"
#include "SkRRect.h"
#include "SkStrokeRec.h"
#include "SkTLazy.h"
@@ -657,7 +657,7 @@ void GrOvalRenderer::reset() {
}
bool GrOvalRenderer::drawOval(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
bool useAA,
@@ -665,8 +665,8 @@ bool GrOvalRenderer::drawOval(GrDrawTarget* target,
const SkStrokeRec& stroke)
{
bool useCoverageAA = useAA &&
- !drawState->getRenderTarget()->isMultisampled() &&
- drawState->canUseFracCoveragePrimProc(color, *target->caps());
+ !pipelineBuilder->getRenderTarget()->isMultisampled() &&
+ pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps());
if (!useCoverageAA) {
return false;
@@ -674,14 +674,15 @@ bool GrOvalRenderer::drawOval(GrDrawTarget* target,
// we can draw circles
if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(viewMatrix)) {
- this->drawCircle(target, drawState, color, viewMatrix, useCoverageAA, oval, stroke);
+ this->drawCircle(target, pipelineBuilder, color, viewMatrix, useCoverageAA, oval, stroke);
// if we have shader derivative support, render as device-independent
} else if (target->caps()->shaderDerivativeSupport()) {
- return this->drawDIEllipse(target, drawState, color, viewMatrix, useCoverageAA, oval,
+ return this->drawDIEllipse(target, pipelineBuilder, color, viewMatrix, useCoverageAA, oval,
stroke);
// otherwise axis-aligned ellipses only
} else if (viewMatrix.rectStaysRect()) {
- return this->drawEllipse(target, drawState, color, viewMatrix, useCoverageAA, oval, stroke);
+ return this->drawEllipse(target, pipelineBuilder, color, viewMatrix, useCoverageAA, oval,
+ stroke);
} else {
return false;
}
@@ -692,7 +693,7 @@ bool GrOvalRenderer::drawOval(GrDrawTarget* target,
///////////////////////////////////////////////////////////////////////////////
void GrOvalRenderer::drawCircle(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
bool useCoverageAA,
@@ -778,14 +779,14 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target,
verts[3].fInnerRadius = innerRadius;
target->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
+ target->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
target->resetIndexSource();
}
///////////////////////////////////////////////////////////////////////////////
bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
bool useCoverageAA,
@@ -912,14 +913,14 @@ bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
target->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
+ target->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
target->resetIndexSource();
return true;
}
bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
bool useCoverageAA,
@@ -1020,7 +1021,7 @@ bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY - offsetDy);
target->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
+ target->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
target->resetIndexSource();
return true;
@@ -1072,16 +1073,16 @@ GrIndexBuffer* GrOvalRenderer::rRectIndexBuffer(bool isStrokeOnly) {
}
bool GrOvalRenderer::drawDRRect(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
bool useAA,
const SkRRect& origOuter,
const SkRRect& origInner) {
bool applyAA = useAA &&
- !drawState->getRenderTarget()->isMultisampled() &&
- drawState->canUseFracCoveragePrimProc(color, *target->caps());
- GrDrawState::AutoRestoreEffects are;
+ !pipelineBuilder->getRenderTarget()->isMultisampled() &&
+ pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps());
+ GrPipelineBuilder::AutoRestoreEffects are;
if (!origInner.isEmpty()) {
SkTCopyOnFirstWrite<SkRRect> inner(origInner);
if (!viewMatrix.isIdentity()) {
@@ -1097,12 +1098,12 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target,
if (NULL == fp) {
return false;
}
- are.set(drawState);
- drawState->addCoverageProcessor(fp)->unref();
+ are.set(pipelineBuilder);
+ pipelineBuilder->addCoverageProcessor(fp)->unref();
}
SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle);
- if (this->drawRRect(target, drawState, color, viewMatrix, useAA, origOuter, fillRec)) {
+ if (this->drawRRect(target, pipelineBuilder, color, viewMatrix, useAA, origOuter, fillRec)) {
return true;
}
@@ -1120,7 +1121,7 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target,
return false;
}
if (!are.isSet()) {
- are.set(drawState);
+ are.set(pipelineBuilder);
}
SkMatrix invert;
@@ -1128,30 +1129,30 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target,
return false;
}
- drawState->addCoverageProcessor(effect)->unref();
+ pipelineBuilder->addCoverageProcessor(effect)->unref();
SkRect bounds = outer->getBounds();
if (applyAA) {
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
}
- target->drawRect(drawState, color, SkMatrix::I(), bounds, NULL, &invert);
+ target->drawRect(pipelineBuilder, color, SkMatrix::I(), bounds, NULL, &invert);
return true;
}
bool GrOvalRenderer::drawRRect(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
bool useAA,
const SkRRect& rrect,
const SkStrokeRec& stroke) {
if (rrect.isOval()) {
- return this->drawOval(target, drawState, color, viewMatrix, useAA, rrect.getBounds(),
+ return this->drawOval(target, pipelineBuilder, color, viewMatrix, useAA, rrect.getBounds(),
stroke);
}
bool useCoverageAA = useAA &&
- !drawState->getRenderTarget()->isMultisampled() &&
- drawState->canUseFracCoveragePrimProc(color, *target->caps());
+ !pipelineBuilder->getRenderTarget()->isMultisampled() &&
+ pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps());
// only anti-aliased rrects for now
if (!useCoverageAA) {
@@ -1304,8 +1305,8 @@ 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,
- &bounds);
+ target->drawIndexedInstances(pipelineBuilder, effect, kTriangles_GrPrimitiveType, 1, 16,
+ indexCnt, &bounds);
// otherwise we use the ellipse renderer
} else {
@@ -1412,8 +1413,8 @@ 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,
- &bounds);
+ target->drawIndexedInstances(pipelineBuilder, effect, kTriangles_GrPrimitiveType, 1, 16,
+ indexCnt, &bounds);
}
target->resetIndexSource();
diff --git a/src/gpu/GrOvalRenderer.h b/src/gpu/GrOvalRenderer.h
index 16c1248b3f..9d861c5b8d 100644
--- a/src/gpu/GrOvalRenderer.h
+++ b/src/gpu/GrOvalRenderer.h
@@ -35,21 +35,21 @@ public:
void reset();
bool drawOval(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
bool useAA,
const SkRect& oval,
const SkStrokeRec& stroke);
bool drawRRect(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
bool useAA,
const SkRRect& rrect,
const SkStrokeRec& stroke);
bool drawDRRect(GrDrawTarget* target,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
bool useAA,
@@ -58,21 +58,21 @@ public:
private:
bool drawEllipse(GrDrawTarget* target,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
bool useCoverageAA,
const SkRect& ellipse,
const SkStrokeRec& stroke);
bool drawDIEllipse(GrDrawTarget* target,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
bool useCoverageAA,
const SkRect& ellipse,
const SkStrokeRec& stroke);
void drawCircle(GrDrawTarget* target,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
bool useCoverageAA,
diff --git a/src/gpu/GrPathRenderer.h b/src/gpu/GrPathRenderer.h
index 6f087b4434..5144597ab5 100644
--- a/src/gpu/GrPathRenderer.h
+++ b/src/gpu/GrPathRenderer.h
@@ -24,8 +24,8 @@ struct GrPoint;
/**
* Base class for drawing paths into a GrDrawTarget.
*
- * Derived classes can use stages GrPaint::kTotalStages through GrDrawState::kNumStages-1. The
- * stages before GrPaint::kTotalStages are reserved for setting up the draw (i.e., textures and
+ * Derived classes can use stages GrPaint::kTotalStages through GrPipelineBuilder::kNumStages-1.
+ * The stages before GrPaint::kTotalStages are reserved for setting up the draw (i.e., textures and
* filter masks).
*/
class SK_API GrPathRenderer : public SkRefCnt {
@@ -54,7 +54,7 @@ public:
* rendered into the stencil.
*
* A GrPathRenderer can provide three levels of support for stenciling paths:
- * 1) kNoRestriction: This is the most general. The caller sets up the GrDrawState on the target
+ * 1) kNoRestriction: This is the most general. The caller sets up the GrPipelineBuilder on the target
* and calls drawPath(). The path is rendered exactly as the draw state
* indicates including support for simultaneous color and stenciling with
* arbitrary stenciling rules. Pixels partially covered by AA paths are
@@ -82,11 +82,11 @@ public:
* @param stroke the stroke information (width, join, cap).
*/
StencilSupport getStencilSupport(const GrDrawTarget* target,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkPath& path,
const SkStrokeRec& stroke) const {
SkASSERT(!path.isInverseFillType());
- return this->onGetStencilSupport(target, drawState, path, stroke);
+ return this->onGetStencilSupport(target, pipelineBuilder, path, stroke);
}
/**
@@ -94,17 +94,17 @@ public:
* caller to fallback to another path renderer This function is called when searching for a path
* renderer capable of rendering a path.
*
- * @param target The target that the path will be rendered to
- * @param drawState The drawState
- * @param viewMatrix The viewMatrix
- * @param path The path to draw
- * @param stroke The stroke information (width, join, cap)
- * @param antiAlias True if anti-aliasing is required.
+ * @param target The target that the path will be rendered to
+ * @param pipelineBuilder The pipelineBuilder
+ * @param viewMatrix The viewMatrix
+ * @param path The path to draw
+ * @param stroke The stroke information (width, join, cap)
+ * @param antiAlias True if anti-aliasing is required.
*
* @return true if the path can be drawn by this object, false otherwise.
*/
virtual bool canDrawPath(const GrDrawTarget* target,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& rec,
@@ -114,14 +114,14 @@ public:
* the subclass must respect the stencil settings of the target's draw state.
*
* @param target The target that the path will be rendered to
- * @param drawState The drawState
+ * @param pipelineBuilder The pipelineBuilder
* @param viewMatrix The viewMatrix
* @param path the path to draw.
* @param stroke the stroke information (width, join, cap)
* @param antiAlias true if anti-aliasing is required.
*/
bool drawPath(GrDrawTarget* target,
- GrDrawState* ds,
+ GrPipelineBuilder* ds,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
@@ -144,7 +144,7 @@ public:
* @param target target that the path will be rendered to
*/
void stencilPath(GrDrawTarget* target,
- GrDrawState* ds,
+ GrPipelineBuilder* ds,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke) {
@@ -172,7 +172,7 @@ protected:
* Subclass overrides if it has any limitations of stenciling support.
*/
virtual StencilSupport onGetStencilSupport(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkPath&,
const SkStrokeRec&) const {
return kNoRestriction_StencilSupport;
@@ -182,7 +182,7 @@ protected:
* Subclass implementation of drawPath()
*/
virtual bool onDrawPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkPath&,
@@ -194,7 +194,7 @@ protected:
* kStencilOnly in onGetStencilSupport().
*/
virtual void onStencilPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke) {
@@ -205,9 +205,9 @@ protected:
0xffff,
0xffff,
0xffff);
- drawState->setStencil(kIncrementStencil);
- drawState->setDisableColorXPFactory();
- this->drawPath(target, drawState, GrColor_WHITE, viewMatrix, path, stroke, false);
+ pipelineBuilder->setStencil(kIncrementStencil);
+ pipelineBuilder->setDisableColorXPFactory();
+ this->drawPath(target, pipelineBuilder, GrColor_WHITE, viewMatrix, path, stroke, false);
}
// Helper for getting the device bounds of a path. Inverse filled paths will have bounds set
diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp
index 0ba9364cd4..d11763bff1 100644
--- a/src/gpu/GrPathRendererChain.cpp
+++ b/src/gpu/GrPathRendererChain.cpp
@@ -32,7 +32,7 @@ GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) {
}
GrPathRenderer* GrPathRendererChain::getPathRenderer(const GrDrawTarget* target,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
@@ -60,12 +60,10 @@ GrPathRenderer* GrPathRendererChain::getPathRenderer(const GrDrawTarget* target,
for (int i = 0; i < fChain.count(); ++i) {
- if (fChain[i]->canDrawPath(target, drawState, viewMatrix, path, stroke, antiAlias)) {
+ if (fChain[i]->canDrawPath(target, pipelineBuilder, viewMatrix, path, stroke, antiAlias)) {
if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) {
- GrPathRenderer::StencilSupport support = fChain[i]->getStencilSupport(target,
- drawState,
- path,
- stroke);
+ GrPathRenderer::StencilSupport support =
+ fChain[i]->getStencilSupport(target, pipelineBuilder, path, stroke);
if (support < minStencilSupport) {
continue;
} else if (stencilSupport) {
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrPipeline.cpp
index a111007114..c35808e033 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -1,29 +1,29 @@
/*
- * Copyright 2014 Google Inc.
+ * Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "GrOptDrawState.h"
+#include "GrPipeline.h"
-#include "GrDrawState.h"
#include "GrDrawTargetCaps.h"
#include "GrGpu.h"
+#include "GrPipelineBuilder.h"
#include "GrProcOptInfo.h"
#include "GrXferProcessor.h"
-GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
+GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder,
const GrPrimitiveProcessor* primProc,
const GrDrawTargetCaps& caps,
const GrScissorState& scissorState,
const GrDeviceCoordTexture* dstCopy) {
- const GrProcOptInfo& colorPOI = drawState.colorProcInfo(primProc);
- const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(primProc);
+ const GrProcOptInfo& colorPOI = pipelineBuilder.colorProcInfo(primProc);
+ const GrProcOptInfo& coveragePOI = pipelineBuilder.coverageProcInfo(primProc);
// Create XferProcessor from DS's XPFactory
SkAutoTUnref<GrXferProcessor> xferProcessor(
- drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI));
+ pipelineBuilder.getXPFactory()->createXferProcessor(colorPOI, coveragePOI));
GrColor overrideColor = GrColor_ILLEGAL;
if (colorPOI.firstEffectiveStageIndex() != 0) {
@@ -36,72 +36,72 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
optFlags = xferProcessor->getOptimizations(colorPOI,
coveragePOI,
- drawState.getStencil().doesWrite(),
+ pipelineBuilder.getStencil().doesWrite(),
&overrideColor,
caps);
}
- // When path rendering the stencil settings are not always set on the draw state
+ // When path rendering the stencil settings are not always set on the GrPipelineBuilder
// so we must check the draw type. In cases where we will skip drawing we simply return a
- // null GrOptDrawState.
+ // null GrPipeline.
if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) {
// Set the fields that don't default init and return. The lack of a render target will
// indicate that this can be skipped.
fFlags = 0;
- fDrawFace = GrDrawState::kInvalid_DrawFace;
+ fDrawFace = GrPipelineBuilder::kInvalid_DrawFace;
return;
}
- fRenderTarget.reset(drawState.fRenderTarget.get());
+ fRenderTarget.reset(pipelineBuilder.fRenderTarget.get());
SkASSERT(fRenderTarget);
fScissorState = scissorState;
- fStencilSettings = drawState.getStencil();
- fDrawFace = drawState.getDrawFace();
- // TODO move this out of optDrawState
+ fStencilSettings = pipelineBuilder.getStencil();
+ fDrawFace = pipelineBuilder.getDrawFace();
+ // TODO move this out of GrPipeline
if (dstCopy) {
fDstCopy = *dstCopy;
}
fFlags = 0;
- if (drawState.isHWAntialias()) {
+ if (pipelineBuilder.isHWAntialias()) {
fFlags |= kHWAA_Flag;
}
- if (drawState.isDither()) {
+ if (pipelineBuilder.isDither()) {
fFlags |= kDither_Flag;
}
int firstColorStageIdx = colorPOI.firstEffectiveStageIndex();
// TODO: Once we can handle single or four channel input into coverage stages then we can use
- // drawState's coverageProcInfo (like color above) to set this initial information.
+ // GrPipelineBuilder's coverageProcInfo (like color above) to set this initial information.
int firstCoverageStageIdx = 0;
GrXferProcessor::BlendInfo blendInfo;
fXferProcessor->getBlendInfo(&blendInfo);
- this->adjustProgramFromOptimizations(drawState, optFlags, colorPOI, coveragePOI,
+ this->adjustProgramFromOptimizations(pipelineBuilder, optFlags, colorPOI, coveragePOI,
&firstColorStageIdx, &firstCoverageStageIdx);
fDescInfo.fReadsDst = fXferProcessor->willReadDstColor();
bool usesLocalCoords = false;
- // Copy Stages from DS to ODS
- for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) {
+ // Copy Stages from PipelineBuilder to Pipeline
+ for (int i = firstColorStageIdx; i < pipelineBuilder.numColorStages(); ++i) {
SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
GrPendingFragmentStage,
- (drawState.fColorStages[i]));
+ (pipelineBuilder.fColorStages[i]));
usesLocalCoords = usesLocalCoords ||
- drawState.fColorStages[i].processor()->usesLocalCoords();
+ pipelineBuilder.fColorStages[i].processor()->usesLocalCoords();
}
fNumColorStages = fFragmentStages.count();
- for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) {
+ for (int i = firstCoverageStageIdx; i < pipelineBuilder.numCoverageStages(); ++i) {
SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
GrPendingFragmentStage,
- (drawState.fCoverageStages[i]));
+ (pipelineBuilder.fCoverageStages[i]));
usesLocalCoords = usesLocalCoords ||
- drawState.fCoverageStages[i].processor()->usesLocalCoords();
+ pipelineBuilder.fCoverageStages[i].processor()->usesLocalCoords();
}
// let the GP init the batch tracker
@@ -111,23 +111,23 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
fInitBT.fUsesLocalCoords = usesLocalCoords;
}
-void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds,
- GrXferProcessor::OptFlags flags,
- const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI,
- int* firstColorStageIdx,
- int* firstCoverageStageIdx) {
+void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelineBuilder,
+ GrXferProcessor::OptFlags flags,
+ const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ int* firstColorStageIdx,
+ int* firstCoverageStageIdx) {
fDescInfo.fReadsFragPosition = false;
if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) ||
(flags & GrXferProcessor::kOverrideColor_OptFlag)) {
- *firstColorStageIdx = ds.numColorStages();
+ *firstColorStageIdx = pipelineBuilder.numColorStages();
} else {
fDescInfo.fReadsFragPosition = colorPOI.readsFragPosition();
}
if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) {
- *firstCoverageStageIdx = ds.numCoverageStages();
+ *firstCoverageStageIdx = pipelineBuilder.numCoverageStages();
} else {
if (coveragePOI.readsFragPosition()) {
fDescInfo.fReadsFragPosition = true;
@@ -137,7 +137,7 @@ void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds,
////////////////////////////////////////////////////////////////////////////////
-bool GrOptDrawState::isEqual(const GrOptDrawState& that) const {
+bool GrPipeline::isEqual(const GrPipeline& that) const {
if (this->getRenderTarget() != that.getRenderTarget() ||
this->fFragmentStages.count() != that.fFragmentStages.count() ||
this->fNumColorStages != that.fNumColorStages ||
diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrPipeline.h
index 626e6d7c61..df654ba407 100644
--- a/src/gpu/GrOptDrawState.h
+++ b/src/gpu/GrPipeline.h
@@ -1,12 +1,12 @@
/*
- * Copyright 2014 Google Inc.
+ * Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef GrOptDrawState_DEFINED
-#define GrOptDrawState_DEFINED
+#ifndef GrPipeline_DEFINED
+#define GrPipeline_DEFINED
#include "GrColor.h"
#include "GrGpu.h"
@@ -18,26 +18,26 @@
#include "SkRefCnt.h"
class GrDeviceCoordTexture;
-class GrDrawState;
class GrPathProcessor;
+class GrPipelineBuilder;
/**
- * Class that holds an optimized version of a GrDrawState. It is meant to be an immutable class,
- * and contains all data needed to set the state for a gpu draw.
+ * Class that holds an optimized version of a GrPipelineBuilder. It is meant to be an immutable
+ * class, and contains all data needed to set the state for a gpu draw.
*/
-class GrOptDrawState {
+class GrPipeline {
public:
- SK_DECLARE_INST_COUNT(GrOptDrawState)
+ SK_DECLARE_INST_COUNT(GrPipeline)
- GrOptDrawState(const GrDrawState& drawState, const GrPrimitiveProcessor*,
- const GrDrawTargetCaps&, const GrScissorState&,
- const GrDeviceCoordTexture* dstCopy);
+ GrPipeline(const GrPipelineBuilder& pipelineBuilder, const GrPrimitiveProcessor*,
+ const GrDrawTargetCaps&, const GrScissorState&,
+ const GrDeviceCoordTexture* dstCopy);
/*
- * Returns true if it is possible to combine the two GrOptDrawStates and it will update 'this'
+ * Returns true if it is possible to combine the two GrPipelines and it will update 'this'
* to subsume 'that''s draw.
*/
- bool isEqual(const GrOptDrawState& that) const;
+ bool isEqual(const GrPipeline& that) const;
/// @}
@@ -122,7 +122,7 @@ public:
* or both faces.
* @return the current draw face(s).
*/
- GrDrawState::DrawFace getDrawFace() const { return fDrawFace; }
+ GrPipelineBuilder::DrawFace getDrawFace() const { return fDrawFace; }
/// @}
@@ -138,7 +138,7 @@ private:
/**
* Alter the program desc and inputs (attribs and processors) based on the blend optimization.
*/
- void adjustProgramFromOptimizations(const GrDrawState& ds,
+ void adjustProgramFromOptimizations(const GrPipelineBuilder& ds,
GrXferProcessor::OptFlags,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
@@ -150,7 +150,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 GrPipelineBuilder& ds, GrXferProcessor::OptFlags,
const GrDrawTargetCaps&);
enum Flags {
@@ -164,7 +164,7 @@ private:
RenderTarget fRenderTarget;
GrScissorState fScissorState;
GrStencilSettings fStencilSettings;
- GrDrawState::DrawFace fDrawFace;
+ GrPipelineBuilder::DrawFace fDrawFace;
GrDeviceCoordTexture fDstCopy;
uint32_t fFlags;
ProgramXferProcessor fXferProcessor;
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrPipelineBuilder.cpp
index db703935ca..f329c05b91 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrPipelineBuilder.cpp
@@ -1,20 +1,20 @@
/*
- * Copyright 2012 Google Inc.
+ * Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "GrDrawState.h"
+#include "GrPipelineBuilder.h"
#include "GrBlend.h"
-#include "GrOptDrawState.h"
#include "GrPaint.h"
+#include "GrPipeline.h"
#include "GrProcOptInfo.h"
#include "GrXferProcessor.h"
#include "effects/GrPorterDuffXferProcessor.h"
-GrDrawState::GrDrawState()
+GrPipelineBuilder::GrPipelineBuilder()
: fFlagBits(0x0)
, fDrawFace(kBoth_DrawFace)
, fColorProcInfoValid(false)
@@ -26,7 +26,7 @@ GrDrawState::GrDrawState()
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
}
-GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
+GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) {
fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get()));
fFlagBits = that.fFlagBits;
fStencilSettings = that.fStencilSettings;
@@ -50,7 +50,7 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
return *this;
}
-void GrDrawState::setFromPaint(const GrPaint& paint, GrRenderTarget* rt) {
+void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt) {
SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages());
fColorStages.reset();
@@ -74,10 +74,10 @@ void GrDrawState::setFromPaint(const GrPaint& paint, GrRenderTarget* rt) {
fFlagBits = 0;
// Enable the clip bit
- this->enableState(GrDrawState::kClip_StateBit);
+ this->enableState(GrPipelineBuilder::kClip_StateBit);
- this->setState(GrDrawState::kDither_StateBit, paint.isDither());
- this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias());
+ this->setState(GrPipelineBuilder::kDither_StateBit, paint.isDither());
+ this->setState(GrPipelineBuilder::kHWAntialias_StateBit, paint.isAntiAlias());
fColorProcInfoValid = false;
fCoverageProcInfoValid = false;
@@ -91,7 +91,8 @@ void GrDrawState::setFromPaint(const GrPaint& paint, GrRenderTarget* rt) {
////////////////////////////////////////////////////////////////////////////////
-bool GrDrawState::canUseFracCoveragePrimProc(GrColor color, const GrDrawTargetCaps& caps) const {
+bool GrPipelineBuilder::canUseFracCoveragePrimProc(GrColor color,
+ const GrDrawTargetCaps& caps) const {
if (caps.dualSourceBlendingSupport()) {
return true;
}
@@ -107,30 +108,30 @@ bool GrDrawState::canUseFracCoveragePrimProc(GrColor color, const GrDrawTargetCa
//////////////////////////////////////////////////////////////////////////////s
-bool GrDrawState::willEffectReadDstColor() const {
+bool GrPipelineBuilder::willEffectReadDstColor() const {
return this->getXPFactory()->willReadDst();
}
-void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
- if (fDrawState) {
- int m = fDrawState->numColorStages() - fColorEffectCnt;
+void GrPipelineBuilder::AutoRestoreEffects::set(GrPipelineBuilder* pipelineBuilder) {
+ if (fPipelineBuilder) {
+ int m = fPipelineBuilder->numColorStages() - fColorEffectCnt;
SkASSERT(m >= 0);
- fDrawState->fColorStages.pop_back_n(m);
+ fPipelineBuilder->fColorStages.pop_back_n(m);
- int n = fDrawState->numCoverageStages() - fCoverageEffectCnt;
+ int n = fPipelineBuilder->numCoverageStages() - fCoverageEffectCnt;
SkASSERT(n >= 0);
- fDrawState->fCoverageStages.pop_back_n(n);
+ fPipelineBuilder->fCoverageStages.pop_back_n(n);
if (m + n > 0) {
- fDrawState->fColorProcInfoValid = false;
- fDrawState->fCoverageProcInfoValid = false;
+ fPipelineBuilder->fColorProcInfoValid = false;
+ fPipelineBuilder->fCoverageProcInfoValid = false;
}
- SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;)
+ SkDEBUGCODE(--fPipelineBuilder->fBlockEffectRemovalCnt;)
}
- fDrawState = ds;
- if (NULL != ds) {
- fColorEffectCnt = ds->numColorStages();
- fCoverageEffectCnt = ds->numCoverageStages();
- SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;)
+ fPipelineBuilder = pipelineBuilder;
+ if (NULL != pipelineBuilder) {
+ fColorEffectCnt = pipelineBuilder->numColorStages();
+ fCoverageEffectCnt = pipelineBuilder->numCoverageStages();
+ SkDEBUGCODE(++pipelineBuilder->fBlockEffectRemovalCnt;)
}
}
@@ -138,19 +139,19 @@ void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
// Some blend modes allow folding a fractional coverage value into the color's alpha channel, while
// others will blend incorrectly.
-bool GrDrawState::canTweakAlphaForCoverage() const {
+bool GrPipelineBuilder::canTweakAlphaForCoverage() const {
return this->getXPFactory()->canTweakAlphaForCoverage();
}
////////////////////////////////////////////////////////////////////////////////
-GrDrawState::~GrDrawState() {
+GrPipelineBuilder::~GrPipelineBuilder() {
SkASSERT(0 == fBlockEffectRemovalCnt);
}
////////////////////////////////////////////////////////////////////////////////
-bool GrDrawState::willBlendWithDst(const GrPrimitiveProcessor* pp) const {
+bool GrPipelineBuilder::willBlendWithDst(const GrPrimitiveProcessor* pp) const {
this->calcColorInvariantOutput(pp);
this->calcCoverageInvariantOutput(pp);
@@ -159,7 +160,7 @@ bool GrDrawState::willBlendWithDst(const GrPrimitiveProcessor* pp) const {
return output.fWillBlendWithDst;
}
-void GrDrawState::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const {
+void GrPipelineBuilder::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const {
if (!fColorProcInfoValid || fColorPrimProc != pp) {
fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->numColorStages());
fColorProcInfoValid = true;
@@ -167,7 +168,7 @@ void GrDrawState::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const
}
}
-void GrDrawState::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp) const {
+void GrPipelineBuilder::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp) const {
if (!fCoverageProcInfoValid || fCoveragePrimProc != pp) {
fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(),
this->numCoverageStages());
@@ -176,7 +177,7 @@ void GrDrawState::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp) co
}
}
-void GrDrawState::calcColorInvariantOutput(GrColor color) const {
+void GrPipelineBuilder::calcColorInvariantOutput(GrColor color) const {
if (!fColorProcInfoValid || color != fColorCache) {
GrColorComponentFlags flags = kRGBA_GrColorComponentFlags;
fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(), color,
@@ -186,7 +187,7 @@ void GrDrawState::calcColorInvariantOutput(GrColor color) const {
}
}
-void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const {
+void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const {
if (!fCoverageProcInfoValid || coverage != fCoverageCache) {
GrColorComponentFlags flags = kRGBA_GrColorComponentFlags;
fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(),
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrPipelineBuilder.h
index 45fc574bde..9579024d6a 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -1,12 +1,12 @@
/*
- * Copyright 2011 Google Inc.
+ * Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef GrDrawState_DEFINED
-#define GrDrawState_DEFINED
+#ifndef GrPipelineBuilder_DEFINED
+#define GrPipelineBuilder_DEFINED
#include "GrBlend.h"
@@ -28,24 +28,22 @@ class GrDrawTargetCaps;
class GrPaint;
class GrTexture;
-class GrDrawState {
+class GrPipelineBuilder {
public:
- GrDrawState();
- /**
- * Copies another draw state.
- **/
- GrDrawState(const GrDrawState& state) {
+ GrPipelineBuilder();
+
+ GrPipelineBuilder(const GrPipelineBuilder& pipelineBuilder) {
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
- *this = state;
+ *this = pipelineBuilder;
}
- virtual ~GrDrawState();
+ virtual ~GrPipelineBuilder();
/**
- * Initializes the GrDrawState based on a GrPaint, view matrix and render target. Note that
- * GrDrawState encompasses more than GrPaint. Aspects of GrDrawState that have no GrPaint
- * equivalents are set to default values with the exception of vertex attribute state which
- * is unmodified by this function and clipping which will be enabled.
+ * Initializes the GrPipelineBuilder based on a GrPaint, view matrix and render target. Note
+ * that GrPipelineBuilder encompasses more than GrPaint. Aspects of GrPipelineBuilder that have
+ * no GrPaint equivalents are set to default values with the exception of vertex attribute state
+ * which is unmodified by this function and clipping which will be enabled.
*/
void setFromPaint(const GrPaint&, GrRenderTarget*);
@@ -56,7 +54,7 @@ public:
* it may or may not be possible to correctly blend with fractional pixel coverage generated by
* the fragment shader.
*
- * This function considers the current draw state and the draw target's capabilities to
+ * This function considers the current GrPipelineBuilder and the draw target's capabilities to
* determine whether coverage can be handled correctly. This function assumes that the caller
* intends to specify fractional pixel coverage via a primitive processor but may not have
* specified it yet.
@@ -171,30 +169,23 @@ public:
}
/**
- * When this object is destroyed it will remove any color/coverage effects from the draw state
- * that were added after its constructor.
- *
- * This class has strange behavior around geometry processor. If there is a GP on the draw state
- * it will assert that the GP is not modified until after the destructor of the ARE. If the
- * draw state has a NULL GP when the ARE is constructed then it will reset it to null in the
- * destructor.
+ * When this object is destroyed it will remove any color/coverage effects from the pipeline
+ * builder that were added after its constructor.
*
- * TODO: We'd prefer for the ARE to just save and restore the GP. However, this would add
- * significant complexity to the multi-ref architecture for deferred drawing. Once GrDrawState
- * and GrOptDrawState are fully separated then GrDrawState will never be in the deferred
- * execution state and GrOptDrawState always will be (and will be immutable and therefore
- * unable to have an ARE). At this point we can restore sanity and have the ARE save and restore
- * the GP.
+ * This class has strange behavior around geometry processor. If there is a GP on the
+ * GrPipelineBuilder it will assert that the GP is not modified until after the destructor of
+ * the ARE. If the GrPipelineBuilder has a NULL GP when the ARE is constructed then it will reset
+ * it to null in the destructor.
*/
class AutoRestoreEffects : public ::SkNoncopyable {
public:
AutoRestoreEffects()
- : fDrawState(NULL)
+ : fPipelineBuilder(NULL)
, fColorEffectCnt(0)
, fCoverageEffectCnt(0) {}
- AutoRestoreEffects(GrDrawState* ds)
- : fDrawState(NULL)
+ AutoRestoreEffects(GrPipelineBuilder* ds)
+ : fPipelineBuilder(NULL)
, fColorEffectCnt(0)
, fCoverageEffectCnt(0) {
this->set(ds);
@@ -202,12 +193,12 @@ public:
~AutoRestoreEffects() { this->set(NULL); }
- void set(GrDrawState* ds);
+ void set(GrPipelineBuilder* ds);
- bool isSet() const { return SkToBool(fDrawState); }
+ bool isSet() const { return SkToBool(fPipelineBuilder); }
private:
- GrDrawState* fDrawState;
+ GrPipelineBuilder* fPipelineBuilder;
int fColorEffectCnt;
int fCoverageEffectCnt;
};
@@ -219,27 +210,27 @@ public:
*/
class AutoRestoreStencil : public ::SkNoncopyable {
public:
- AutoRestoreStencil() : fDrawState(NULL) {}
+ AutoRestoreStencil() : fPipelineBuilder(NULL) {}
- AutoRestoreStencil(GrDrawState* ds) : fDrawState(NULL) { this->set(ds); }
+ AutoRestoreStencil(GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { this->set(ds); }
~AutoRestoreStencil() { this->set(NULL); }
- void set(GrDrawState* ds) {
- if (fDrawState) {
- fDrawState->setStencil(fStencilSettings);
+ void set(GrPipelineBuilder* ds) {
+ if (fPipelineBuilder) {
+ fPipelineBuilder->setStencil(fStencilSettings);
}
- fDrawState = ds;
+ fPipelineBuilder = ds;
if (ds) {
fStencilSettings = ds->getStencil();
}
}
- bool isSet() const { return SkToBool(fDrawState); }
+ bool isSet() const { return SkToBool(fPipelineBuilder); }
private:
- GrDrawState* fDrawState;
- GrStencilSettings fStencilSettings;
+ GrPipelineBuilder* fPipelineBuilder;
+ GrStencilSettings fStencilSettings;
};
/// @}
@@ -397,7 +388,7 @@ public:
///////////////////////////////////////////////////////////////////////////
- GrDrawState& operator= (const GrDrawState& that);
+ GrPipelineBuilder& operator= (const GrPipelineBuilder& that);
private:
const GrProcOptInfo& colorProcInfo(const GrPrimitiveProcessor* pp) const {
@@ -457,7 +448,7 @@ private:
mutable const GrPrimitiveProcessor* fColorPrimProc;
mutable const GrPrimitiveProcessor* fCoveragePrimProc;
- friend class GrOptDrawState;
+ friend class GrPipeline;
};
#endif
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 21c935236d..2345eda077 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -7,7 +7,7 @@
#include "GrSWMaskHelper.h"
-#include "GrDrawState.h"
+#include "GrPipelineBuilder.h"
#include "GrDrawTargetCaps.h"
#include "GrGpu.h"
@@ -347,7 +347,7 @@ GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context,
void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkIRect& rect) {
@@ -355,7 +355,7 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
if (!viewMatrix.invert(&invert)) {
return;
}
- GrDrawState::AutoRestoreEffects are(drawState);
+ GrPipelineBuilder::AutoRestoreEffects are(pipelineBuilder);
SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft,
SK_Scalar1 * rect.fTop,
@@ -369,11 +369,11 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
maskMatrix.setIDiv(texture->width(), texture->height());
maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
- drawState->addCoverageProcessor(
+ pipelineBuilder->addCoverageProcessor(
GrSimpleTextureEffect::Create(texture,
maskMatrix,
GrTextureParams::kNone_FilterMode,
kDevice_GrCoordSet))->unref();
- target->drawRect(drawState, color, SkMatrix::I(), dstRect, NULL, &invert);
+ target->drawRect(pipelineBuilder, color, SkMatrix::I(), dstRect, NULL, &invert);
}
diff --git a/src/gpu/GrSWMaskHelper.h b/src/gpu/GrSWMaskHelper.h
index 71dec6357d..c18097122b 100644
--- a/src/gpu/GrSWMaskHelper.h
+++ b/src/gpu/GrSWMaskHelper.h
@@ -9,7 +9,7 @@
#define GrSWMaskHelper_DEFINED
#include "GrColor.h"
-#include "GrDrawState.h"
+#include "GrPipelineBuilder.h"
#include "SkBitmap.h"
#include "SkDraw.h"
#include "SkMatrix.h"
@@ -92,7 +92,7 @@ public:
// output of DrawPathMaskToTexture.
static void DrawToTargetWithPathMask(GrTexture* texture,
GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor,
const SkMatrix& viewMatrix,
const SkIRect& rect);
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 90b35f7431..4fb7538b03 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -12,7 +12,7 @@
////////////////////////////////////////////////////////////////////////////////
bool GrSoftwarePathRenderer::canDrawPath(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath&,
const SkStrokeRec&,
@@ -26,7 +26,7 @@ bool GrSoftwarePathRenderer::canDrawPath(const GrDrawTarget*,
GrPathRenderer::StencilSupport
GrSoftwarePathRenderer::onGetStencilSupport(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkPath&,
const SkStrokeRec&) const {
return GrPathRenderer::kNoSupport_StencilSupport;
@@ -39,13 +39,13 @@ namespace {
// path bounds will be a subset of the clip bounds. returns false if
// path bounds would be empty.
bool get_path_and_clip_bounds(const GrDrawTarget* target,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkPath& path,
const SkMatrix& matrix,
SkIRect* devPathBounds,
SkIRect* devClipBounds) {
// compute bounds as intersection of rt size, clip, and path
- const GrRenderTarget* rt = drawState->getRenderTarget();
+ const GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
if (NULL == rt) {
return false;
}
@@ -78,7 +78,7 @@ bool get_path_and_clip_bounds(const GrDrawTarget* target,
////////////////////////////////////////////////////////////////////////////////
void draw_around_inv_path(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkIRect& devClipBounds,
@@ -92,22 +92,22 @@ void draw_around_inv_path(GrDrawTarget* target,
if (devClipBounds.fTop < devPathBounds.fTop) {
rect.iset(devClipBounds.fLeft, devClipBounds.fTop,
devClipBounds.fRight, devPathBounds.fTop);
- target->drawRect(drawState, color, SkMatrix::I(), rect, NULL, &invert);
+ target->drawRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
}
if (devClipBounds.fLeft < devPathBounds.fLeft) {
rect.iset(devClipBounds.fLeft, devPathBounds.fTop,
devPathBounds.fLeft, devPathBounds.fBottom);
- target->drawRect(drawState, color, SkMatrix::I(), rect, NULL, &invert);
+ target->drawRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
}
if (devClipBounds.fRight > devPathBounds.fRight) {
rect.iset(devPathBounds.fRight, devPathBounds.fTop,
devClipBounds.fRight, devPathBounds.fBottom);
- target->drawRect(drawState, color, SkMatrix::I(), rect, NULL, &invert);
+ target->drawRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
}
if (devClipBounds.fBottom > devPathBounds.fBottom) {
rect.iset(devClipBounds.fLeft, devPathBounds.fBottom,
devClipBounds.fRight, devClipBounds.fBottom);
- target->drawRect(drawState, color, SkMatrix::I(), rect, NULL, &invert);
+ target->drawRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
}
}
@@ -116,7 +116,7 @@ void draw_around_inv_path(GrDrawTarget* target,
////////////////////////////////////////////////////////////////////////////////
// return true on success; false on failure
bool GrSoftwarePathRenderer::onDrawPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
@@ -128,10 +128,11 @@ bool GrSoftwarePathRenderer::onDrawPath(GrDrawTarget* target,
}
SkIRect devPathBounds, devClipBounds;
- if (!get_path_and_clip_bounds(target, drawState, path, viewMatrix,
+ if (!get_path_and_clip_bounds(target, pipelineBuilder, path, viewMatrix,
&devPathBounds, &devClipBounds)) {
if (path.isInverseFillType()) {
- draw_around_inv_path(target, drawState, color, viewMatrix, devClipBounds,devPathBounds);
+ draw_around_inv_path(target, pipelineBuilder, color, viewMatrix, devClipBounds,
+ devPathBounds);
}
return true;
}
@@ -144,12 +145,13 @@ bool GrSoftwarePathRenderer::onDrawPath(GrDrawTarget* target,
return false;
}
- GrDrawState copy = *drawState;
+ GrPipelineBuilder copy = *pipelineBuilder;
GrSWMaskHelper::DrawToTargetWithPathMask(texture, target, &copy, color, viewMatrix,
devPathBounds);
if (path.isInverseFillType()) {
- draw_around_inv_path(target, drawState, color, viewMatrix, devClipBounds, devPathBounds);
+ draw_around_inv_path(target, pipelineBuilder, color, viewMatrix, devClipBounds,
+ devPathBounds);
}
return true;
diff --git a/src/gpu/GrSoftwarePathRenderer.h b/src/gpu/GrSoftwarePathRenderer.h
index 43d5e55ce9..ed897cceaf 100644
--- a/src/gpu/GrSoftwarePathRenderer.h
+++ b/src/gpu/GrSoftwarePathRenderer.h
@@ -24,19 +24,19 @@ public:
}
virtual bool canDrawPath(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath&,
const SkStrokeRec&,
bool antiAlias) const SK_OVERRIDE;
protected:
virtual StencilSupport onGetStencilSupport(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkPath&,
const SkStrokeRec&) const SK_OVERRIDE;
virtual bool onDrawPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkPath&,
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp
index 207194dd79..1a3856c801 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -51,20 +51,20 @@ GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() {
}
bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target,
- const GrDrawState* drawState,
+ const GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke,
bool antiAlias) const {
return !stroke.isHairlineStyle() &&
!antiAlias && // doesn't do per-path AA, relies on the target having MSAA
- drawState->getRenderTarget()->getStencilBuffer() &&
- drawState->getStencil().isDisabled();
+ pipelineBuilder->getRenderTarget()->getStencilBuffer() &&
+ pipelineBuilder->getStencil().isDisabled();
}
GrPathRenderer::StencilSupport
GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkPath&,
const SkStrokeRec&) const {
return GrPathRenderer::kStencilOnly_StencilSupport;
@@ -82,18 +82,18 @@ static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec&
}
void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const SkStrokeRec& stroke) {
SkASSERT(!path.isInverseFillType());
SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, viewMatrix));
SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
- target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFillType()));
+ target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
}
bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
- GrDrawState* drawState,
+ GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkPath& path,
@@ -102,7 +102,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
SkASSERT(!antiAlias);
SkASSERT(!stroke.isHairlineStyle());
- SkASSERT(drawState->getStencil().isDisabled());
+ SkASSERT(pipelineBuilder->getStencil().isDisabled());
SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
@@ -118,16 +118,16 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
0x0000,
0xffff);
- drawState->setStencil(kInvertedStencilPass);
+ pipelineBuilder->setStencil(kInvertedStencilPass);
// fake inverse with a stencil and cover
SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, viewMatrix));
- target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFillType()));
+ target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
SkMatrix invert = SkMatrix::I();
- SkRect bounds = SkRect::MakeLTRB(0, 0,
- SkIntToScalar(drawState->getRenderTarget()->width()),
- SkIntToScalar(drawState->getRenderTarget()->height()));
+ SkRect bounds =
+ SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarget()->width()),
+ SkIntToScalar(pipelineBuilder->getRenderTarget()->height()));
SkMatrix vmi;
// mapRect through persp matrix may not be correct
if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) {
@@ -142,7 +142,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
}
}
const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix;
- target->drawRect(drawState, color, viewM, bounds, NULL, &invert);
+ target->drawRect(pipelineBuilder, color, viewM, bounds, NULL, &invert);
} else {
GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
kZero_StencilOp,
@@ -152,11 +152,11 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
0x0000,
0xffff);
- drawState->setStencil(kStencilPass);
+ pipelineBuilder->setStencil(kStencilPass);
SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatrix));
- target->drawPath(drawState, pp, p, convert_skpath_filltype(path.getFillType()));
+ target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
}
- drawState->stencil()->setDisabled();
+ pipelineBuilder->stencil()->setDisabled();
return true;
}
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.h b/src/gpu/GrStencilAndCoverPathRenderer.h
index 1ea26c4e8e..cb4012f3d1 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.h
+++ b/src/gpu/GrStencilAndCoverPathRenderer.h
@@ -26,7 +26,7 @@ public:
virtual ~GrStencilAndCoverPathRenderer();
virtual bool canDrawPath(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath&,
const SkStrokeRec&,
@@ -34,12 +34,12 @@ public:
protected:
virtual StencilSupport onGetStencilSupport(const GrDrawTarget*,
- const GrDrawState*,
+ const GrPipelineBuilder*,
const SkPath&,
const SkStrokeRec&) const SK_OVERRIDE;
virtual bool onDrawPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkPath&,
@@ -47,7 +47,7 @@ protected:
bool antiAlias) SK_OVERRIDE;
virtual void onStencilPath(GrDrawTarget*,
- GrDrawState*,
+ GrPipelineBuilder*,
const SkMatrix& viewMatrix,
const SkPath&,
const SkStrokeRec&) SK_OVERRIDE;
diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp
index 6447ca523a..c29dca6d0a 100644
--- a/src/gpu/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/GrStencilAndCoverTextContext.cpp
@@ -344,9 +344,9 @@ void GrStencilAndCoverTextContext::init(const GrPaint& paint,
&fGlyphCache->getDescriptor(), fStroke);
}
- fStateRestore.set(&fDrawState);
+ fStateRestore.set(&fPipelineBuilder);
- fDrawState.setFromPaint(fPaint, fContext->getRenderTarget());
+ fPipelineBuilder.setFromPaint(fPaint, fContext->getRenderTarget());
GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
kZero_StencilOp,
@@ -356,7 +356,7 @@ void GrStencilAndCoverTextContext::init(const GrPaint& paint,
0x0000,
0xffff);
- *fDrawState.stencil() = kStencilPass;
+ *fPipelineBuilder.stencil() = kStencilPass;
SkASSERT(0 == fQueuedGlyphCount);
SkASSERT(kGlyphBufferSize == fFallbackGlyphsIdx);
@@ -408,7 +408,7 @@ void GrStencilAndCoverTextContext::flush() {
SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(fPaint.getColor(),
fViewMatrix,
fLocalMatrix));
- fDrawTarget->drawPaths(&fDrawState, pp, fGlyphs,
+ fDrawTarget->drawPaths(&fPipelineBuilder, pp, fGlyphs,
fGlyphIndices, GrPathRange::kU16_PathIndexType,
get_xy_scalar_array(fGlyphPositions),
GrPathRendering::kTranslate_PathTransformType,
@@ -453,7 +453,7 @@ void GrStencilAndCoverTextContext::finish() {
SkGlyphCache::AttachCache(fGlyphCache);
fGlyphCache = NULL;
- fDrawState.stencil()->setDisabled();
+ fPipelineBuilder.stencil()->setDisabled();
fStateRestore.set(NULL);
fViewMatrix = fContextInitialMatrix;
GrTextContext::finish();
diff --git a/src/gpu/GrStencilAndCoverTextContext.h b/src/gpu/GrStencilAndCoverTextContext.h
index c7b06cc104..345b3a5d5a 100644
--- a/src/gpu/GrStencilAndCoverTextContext.h
+++ b/src/gpu/GrStencilAndCoverTextContext.h
@@ -51,8 +51,8 @@ private:
kMaxPerformance_RenderMode,
};
- GrDrawState fDrawState;
- GrDrawState::AutoRestoreEffects fStateRestore;
+ GrPipelineBuilder fPipelineBuilder;
+ GrPipelineBuilder::AutoRestoreEffects fStateRestore;
SkScalar fTextRatio;
float fTextInverseRatio;
SkGlyphCache* fGlyphCache;
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 5ec4dcfa4f..ef2517dcf0 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -48,7 +48,7 @@ void GrContext::purgeAllUnlockedResources() {
#include "GrInOrderDrawBuffer.h"
#include "GrGpu.h"
-class GrOptDrawState;
+class GrPipeline;
class MockGpu : public GrGpu {
public:
@@ -64,7 +64,7 @@ public:
GrPixelConfig config,
size_t rowBytes) const SK_OVERRIDE { return false; }
void buildProgramDesc(GrProgramDesc*,const GrPrimitiveProcessor&,
- const GrOptDrawState&,
+ const GrPipeline&,
const GrProgramDesc::DescInfo&,
const GrBatchTracker&) const SK_OVERRIDE {}
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 88ffad0c2e..4a034060de 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -28,9 +28,9 @@
// Returns whether or not the gpu can fast path the dash line effect.
static bool can_fast_path_dash(const SkPoint pts[2], const GrStrokeInfo& strokeInfo,
- const GrDrawTarget& target, const GrDrawState& ds,
+ const GrDrawTarget& target, const GrPipelineBuilder& pipelineBuilder,
const SkMatrix& viewMatrix) {
- if (ds.getRenderTarget()->isMultisampled()) {
+ if (pipelineBuilder.getRenderTarget()->isMultisampled()) {
return false;
}
@@ -164,10 +164,11 @@ static void setup_dashed_rect_pos(const SkRect& rect, int idx, const SkMatrix& m
matrix.mapPoints(&verts[idx], 4);
}
-bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState* drawState,
- GrColor color, const SkMatrix& viewMatrix, const SkPoint pts[2],
+bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target,
+ GrPipelineBuilder* pipelineBuilder, GrColor color,
+ const SkMatrix& viewMatrix, const SkPoint pts[2],
const GrPaint& paint, const GrStrokeInfo& strokeInfo) {
- if (!can_fast_path_dash(pts, strokeInfo, *target, *drawState, viewMatrix)) {
+ if (!can_fast_path_dash(pts, strokeInfo, *target, *pipelineBuilder, viewMatrix)) {
return false;
}
@@ -442,7 +443,8 @@ bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState
}
target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer());
- target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, totalRectCnt, 4, 6);
+ target->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType,
+ totalRectCnt, 4, 6);
target->resetIndexSource();
return true;
}
diff --git a/src/gpu/effects/GrDashingEffect.h b/src/gpu/effects/GrDashingEffect.h
index 651a240add..5552f1df1b 100644
--- a/src/gpu/effects/GrDashingEffect.h
+++ b/src/gpu/effects/GrDashingEffect.h
@@ -14,18 +14,19 @@
#include "SkPathEffect.h"
class GrGpu;
-class GrDrawState;
class GrDrawTarget;
class GrGeometryProcessor;
class GrPaint;
+class GrPipelineBuilder;
class GrStrokeInfo;
class GrGLDashingEffect;
class SkPath;
namespace GrDashingEffect {
- bool DrawDashLine(GrGpu*, GrDrawTarget*, GrDrawState*, GrColor, const SkMatrix& viewMatrix,
- const SkPoint pts[2], const GrPaint& paint, const GrStrokeInfo& strokeInfo);
+ bool DrawDashLine(GrGpu*, GrDrawTarget*, GrPipelineBuilder*, GrColor,
+ const SkMatrix& viewMatrix, const SkPoint pts[2], const GrPaint& paint,
+ const GrStrokeInfo& strokeInfo);
enum DashCap {
kRound_DashCap,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index b28c32e68c..f3aef13327 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -10,7 +10,7 @@
#include "GrGLStencilBuffer.h"
#include "GrGLTextureRenderTarget.h"
#include "GrGpuResourceCacheAccess.h"
-#include "GrOptDrawState.h"
+#include "GrPipeline.h"
#include "GrSurfacePriv.h"
#include "GrTemplates.h"
#include "GrTexturePriv.h"
@@ -242,7 +242,7 @@ void GrGLGpu::onResetContext(uint32_t resetBits) {
GL_CALL(Disable(GR_GL_DEPTH_TEST));
GL_CALL(DepthMask(GR_GL_FALSE));
- fHWDrawFace = GrDrawState::kInvalid_DrawFace;
+ fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace;
fHWDitherEnabled = kUnknown_TriState;
if (kGL_GrGLStandard == this->glStandard()) {
@@ -1338,12 +1338,12 @@ void GrGLGpu::flushScissor(const GrScissorState& scissorState,
bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) {
GrXferProcessor::BlendInfo blendInfo;
- const GrOptDrawState& optState = *args.fOptState;
- args.fOptState->getXferProcessor()->getBlendInfo(&blendInfo);
+ const GrPipeline& pipeline = *args.fPipeline;
+ args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo);
- this->flushDither(optState.isDitherState());
+ this->flushDither(pipeline.isDitherState());
this->flushColorWrite(blendInfo.fWriteColor);
- this->flushDrawFace(optState.getDrawFace());
+ this->flushDrawFace(pipeline.getDrawFace());
fCurrentProgram.reset(fProgramCache->getProgram(args));
if (NULL == fCurrentProgram.get()) {
@@ -1363,12 +1363,12 @@ bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) {
this->flushBlend(blendInfo);
}
- fCurrentProgram->setData(*args.fPrimitiveProcessor, optState, *args.fBatchTracker);
+ fCurrentProgram->setData(*args.fPrimitiveProcessor, pipeline, *args.fBatchTracker);
- GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTarget());
- this->flushStencil(optState.getStencil());
- this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->origin());
- this->flushHWAAState(glRT, optState.isHWAntialiasState(), isLineDraw);
+ GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget());
+ this->flushStencil(pipeline.getStencil());
+ this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin());
+ this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), isLineDraw);
// This must come after textures are flushed because a texture may need
// to be msaa-resolved (which will modify bound FBO state).
@@ -1432,10 +1432,10 @@ void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
void GrGLGpu::buildProgramDesc(GrProgramDesc* desc,
const GrPrimitiveProcessor& primProc,
- const GrOptDrawState& optState,
+ const GrPipeline& pipeline,
const GrProgramDesc::DescInfo& descInfo,
const GrBatchTracker& batchTracker) const {
- if (!GrGLProgramDescBuilder::Build(desc, primProc, optState, descInfo, this,
+ if (!GrGLProgramDescBuilder::Build(desc, primProc, pipeline, descInfo, this,
batchTracker)) {
SkDEBUGFAIL("Failed to generate GL program descriptor");
}
@@ -1864,7 +1864,7 @@ void GrGLGpu::onDraw(const DrawArgs& args, const GrDrawTarget::DrawInfo& info) {
void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) {
this->flushColorWrite(false);
- this->flushDrawFace(GrDrawState::kBoth_DrawFace);
+ this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget);
SkISize size = SkISize::Make(rt->width(), rt->height());
@@ -2234,18 +2234,18 @@ void GrGLGpu::flushColorWrite(bool writeColor) {
}
}
-void GrGLGpu::flushDrawFace(GrDrawState::DrawFace face) {
+void GrGLGpu::flushDrawFace(GrPipelineBuilder::DrawFace face) {
if (fHWDrawFace != face) {
switch (face) {
- case GrDrawState::kCCW_DrawFace:
+ case GrPipelineBuilder::kCCW_DrawFace:
GL_CALL(Enable(GR_GL_CULL_FACE));
GL_CALL(CullFace(GR_GL_BACK));
break;
- case GrDrawState::kCW_DrawFace:
+ case GrPipelineBuilder::kCW_DrawFace:
GL_CALL(Enable(GR_GL_CULL_FACE));
GL_CALL(CullFace(GR_GL_FRONT));
break;
- case GrDrawState::kBoth_DrawFace:
+ case GrPipelineBuilder::kBoth_DrawFace:
GL_CALL(Disable(GR_GL_CULL_FACE));
break;
default:
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 0173a23c48..9b4f0671b3 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -8,7 +8,6 @@
#ifndef GrGLGpu_DEFINED
#define GrGLGpu_DEFINED
-#include "GrDrawState.h"
#include "GrGLContext.h"
#include "GrGLIRect.h"
#include "GrGLIndexBuffer.h"
@@ -20,10 +19,12 @@
#include "GrGLVertexArray.h"
#include "GrGLVertexBuffer.h"
#include "GrGpu.h"
-#include "GrOptDrawState.h"
+#include "GrPipelineBuilder.h"
#include "GrXferProcessor.h"
#include "SkTypes.h"
+class GrPipeline;
+
#ifdef SK_DEVELOPER
#define PROGRAM_CACHE_STATS
#endif
@@ -106,7 +107,7 @@ public:
void buildProgramDesc(GrProgramDesc*,
const GrPrimitiveProcessor&,
- const GrOptDrawState&,
+ const GrPipeline&,
const GrProgramDesc::DescInfo&,
const GrBatchTracker&) const SK_OVERRIDE;
@@ -166,7 +167,7 @@ private:
// binds texture unit in GL
void setTextureUnit(int unitIdx);
- // Flushes state from GrOptDrawState to GL. Returns false if the state couldn't be set.
+ // Flushes state from GrPipeline to GL. Returns false if the state couldn't be set.
// TODO we only have need to know if this is a line draw for flushing AA state on some buggy
// hardware. Evaluate if this is really necessary anymore
bool flushGLState(const DrawArgs&, bool isLineDraw);
@@ -227,7 +228,7 @@ private:
void flushDither(bool dither);
void flushColorWrite(bool writeColor);
- void flushDrawFace(GrDrawState::DrawFace face);
+ void flushDrawFace(GrPipelineBuilder::DrawFace face);
// flushes the scissor. see the note on flushBoundTextureAndParams about
// flushing the scissor after that function is called.
@@ -443,7 +444,7 @@ private:
TriState fHWStencilTestEnabled;
- GrDrawState::DrawFace fHWDrawFace;
+ GrPipelineBuilder::DrawFace fHWDrawFace;
TriState fHWWriteToColor;
TriState fHWDitherEnabled;
uint32_t fHWBoundRenderTargetUniqueID;
diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp
index 3e20047be7..911fd936e8 100644
--- a/src/gpu/gl/GrGLGpuProgramCache.cpp
+++ b/src/gpu/gl/GrGLGpuProgramCache.cpp
@@ -11,7 +11,6 @@
#include "GrProcessor.h"
#include "GrGLProcessor.h"
#include "GrGLPathRendering.h"
-#include "GrOptDrawState.h"
#include "SkRTConf.h"
#include "SkTSearch.h"
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index c018cfe6c1..ad63dc4ea7 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -17,7 +17,7 @@
#include "GrGLPathRendering.h"
#include "GrGLShaderVar.h"
#include "GrGLSL.h"
-#include "GrOptDrawState.h"
+#include "GrPipeline.h"
#include "GrXferProcessor.h"
#include "SkXfermode.h"
@@ -103,11 +103,11 @@ void GrGLProgram::bindTextures(const Proc* ip, const GrProcessor& processor) {
///////////////////////////////////////////////////////////////////////////////
-void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrOptDrawState& optState,
+void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline,
const GrBatchTracker& batchTracker) {
- this->setRenderTargetState(primProc, optState);
+ this->setRenderTargetState(primProc, pipeline);
- const GrDeviceCoordTexture* dstCopy = optState.getDstCopy();
+ const GrDeviceCoordTexture* dstCopy = pipeline.getDstCopy();
if (dstCopy) {
if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) {
fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni,
@@ -135,21 +135,21 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrOptDrawS
this->bindTextures(fGeometryProcessor.get(), primProc);
if (fXferProcessor.get()) {
- const GrXferProcessor& xp = *optState.getXferProcessor();
+ const GrXferProcessor& xp = *pipeline.getXferProcessor();
fXferProcessor->fGLProc->setData(fProgramDataManager, xp);
this->bindTextures(fXferProcessor.get(), xp);
}
- this->setFragmentData(primProc, optState);
+ this->setFragmentData(primProc, pipeline);
// Some of GrGLProgram subclasses need to update state here
this->didSetData();
}
void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
- const GrOptDrawState& optState) {
+ const GrPipeline& pipeline) {
int numProcessors = fFragmentProcessors->fProcs.count();
for (int e = 0; e < numProcessors; ++e) {
- const GrPendingFragmentStage& stage = optState.getFragmentStage(e);
+ const GrPendingFragmentStage& stage = pipeline.getFragmentStage(e);
const GrProcessor& processor = *stage.processor();
fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, processor);
this->setTransformData(primProc,
@@ -170,21 +170,21 @@ void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
}
void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
- const GrOptDrawState& optState) {
+ const GrPipeline& pipeline) {
// Load the RT height uniform if it is needed to y-flip gl_FragCoord.
if (fBuiltinUniformHandles.fRTHeightUni.isValid() &&
- fRenderTargetState.fRenderTargetSize.fHeight != optState.getRenderTarget()->height()) {
+ fRenderTargetState.fRenderTargetSize.fHeight != pipeline.getRenderTarget()->height()) {
fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni,
- SkIntToScalar(optState.getRenderTarget()->height()));
+ SkIntToScalar(pipeline.getRenderTarget()->height()));
}
// call subclasses to set the actual view matrix
- this->onSetRenderTargetState(primProc, optState);
+ this->onSetRenderTargetState(primProc, pipeline);
}
void GrGLProgram::onSetRenderTargetState(const GrPrimitiveProcessor&,
- const GrOptDrawState& optState) {
- const GrRenderTarget* rt = optState.getRenderTarget();
+ const GrPipeline& pipeline) {
+ const GrRenderTarget* rt = pipeline.getRenderTarget();
SkISize size;
size.set(rt->width(), rt->height());
if (fRenderTargetState.fRenderTargetOrigin != rt->origin() ||
@@ -228,9 +228,9 @@ void GrGLNvprProgram::setTransformData(const GrPrimitiveProcessor& primProc,
}
void GrGLNvprProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primProc,
- const GrOptDrawState& optState) {
+ const GrPipeline& pipeline) {
SkASSERT(!primProc.willUseGeoShader() && primProc.numAttribs() == 0);
- const GrRenderTarget* rt = optState.getRenderTarget();
+ const GrRenderTarget* rt = pipeline.getRenderTarget();
SkISize size;
size.set(rt->width(), rt->height());
fGpu->glPathRendering()->setProjectionMatrix(primProc.viewMatrix(),
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index cce6c2a4d3..e49fbabf86 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -10,7 +10,6 @@
#define GrGLProgram_DEFINED
#include "builders/GrGLProgramBuilder.h"
-#include "GrDrawState.h"
#include "GrGLContext.h"
#include "GrGLProgramDesc.h"
#include "GrGLSL.h"
@@ -23,6 +22,7 @@
class GrGLProcessor;
class GrGLInstalledProcessors;
class GrGLProgramBuilder;
+class GrPipeline;
/**
* This class manages a GPU program and records per-program information.
@@ -95,7 +95,7 @@ public:
* GrGLGpu object to bind the textures required by the GrGLProcessors. The color and coverage
* stages come from GrGLProgramDesc::Build().
*/
- void setData(const GrPrimitiveProcessor&, const GrOptDrawState&, const GrBatchTracker&);
+ void setData(const GrPrimitiveProcessor&, const GrPipeline&, const GrBatchTracker&);
protected:
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
@@ -116,7 +116,7 @@ protected:
void initSamplers(Proc*, int* texUnitIdx);
// A templated helper to loop over effects, set the transforms(via subclass) and bind textures
- void setFragmentData(const GrPrimitiveProcessor&, const GrOptDrawState&);
+ void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&);
virtual void setTransformData(const GrPrimitiveProcessor&,
const GrPendingFragmentStage&,
int index,
@@ -131,8 +131,8 @@ protected:
virtual void didSetData() {}
// Helper for setData() that sets the view matrix and loads the render target height uniform
- void setRenderTargetState(const GrPrimitiveProcessor&, const GrOptDrawState&);
- virtual void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrOptDrawState&);
+ void setRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&);
+ virtual void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&);
// these reflect the current values of uniforms (GL uniform values travel with program)
RenderTargetState fRenderTargetState;
@@ -180,7 +180,7 @@ private:
const GrPendingFragmentStage&,
int index,
GrGLInstalledFragProc*) SK_OVERRIDE;
- virtual void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrOptDrawState&);
+ virtual void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&);
friend class GrGLNvprProgramBuilder;
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index a89941c884..32f831e84c 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -9,7 +9,7 @@
#include "GrGLProcessor.h"
#include "GrProcessor.h"
#include "GrGLGpu.h"
-#include "GrOptDrawState.h"
+#include "GrPipeline.h"
#include "SkChecksum.h"
#include "gl/builders/GrGLFragmentShaderBuilder.h"
@@ -88,7 +88,7 @@ static bool get_meta_key(const GrProcessor& proc,
bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
const GrPrimitiveProcessor& primProc,
- const GrOptDrawState& optState,
+ const GrPipeline& pipeline,
const GrProgramDesc::DescInfo& descInfo,
const GrGLGpu* gpu,
const GrBatchTracker& batchTracker) {
@@ -110,8 +110,8 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
return false;
}
- for (int s = 0; s < optState.numFragmentStages(); ++s) {
- const GrPendingFragmentStage& fps = optState.getFragmentStage(s);
+ for (int s = 0; s < pipeline.numFragmentStages(); ++s) {
+ const GrPendingFragmentStage& fps = pipeline.getFragmentStage(s);
const GrFragmentProcessor& fp = *fps.processor();
fp.getGLProcessorKey(gpu->glCaps(), &b);
if (!get_meta_key(fp, gpu->glCaps(), primProc.getTransformKey(fp.coordTransforms()), &b)) {
@@ -120,7 +120,7 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
}
}
- const GrXferProcessor& xp = *optState.getXferProcessor();
+ const GrXferProcessor& xp = *pipeline.getXferProcessor();
xp.getGLProcessorKey(gpu->glCaps(), &b);
if (!get_meta_key(xp, gpu->glCaps(), 0, &b)) {
desc->fKey.reset();
@@ -136,7 +136,7 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
memset(header, 0, kHeaderSize);
if (descInfo.fReadsDst) {
- const GrDeviceCoordTexture* dstCopy = optState.getDstCopy();
+ const GrDeviceCoordTexture* dstCopy = pipeline.getDstCopy();
SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport());
const GrTexture* dstCopyTexture = NULL;
if (dstCopy) {
@@ -151,14 +151,14 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
if (descInfo.fReadsFragPosition) {
header->fFragPosKey =
- GrGLFragmentShaderBuilder::KeyForFragmentPosition(optState.getRenderTarget(),
+ GrGLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRenderTarget(),
gpu->glCaps());
} else {
header->fFragPosKey = 0;
}
- header->fColorEffectCnt = optState.numColorStages();
- header->fCoverageEffectCnt = optState.numCoverageStages();
+ header->fColorEffectCnt = pipeline.numColorStages();
+ header->fCoverageEffectCnt = pipeline.numCoverageStages();
desc->finalize();
return true;
}
diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h
index 0584082a83..e4db4c3581 100644
--- a/src/gpu/gl/GrGLProgramDesc.h
+++ b/src/gpu/gl/GrGLProgramDesc.h
@@ -42,7 +42,7 @@ public:
* Builds a GL specific program descriptor
*
* @param GrPrimitiveProcessor The geometry
- * @param GrOptDrawState The optimized drawstate. The descriptor will represent a program
+ * @param GrPipeline The optimized drawstate. The descriptor will represent a program
* which this optstate can use to draw with. The optstate contains
* general draw information, as well as the specific color, geometry,
* and coverage stages which will be used to generate the GL Program for
@@ -57,7 +57,7 @@ public:
**/
static bool Build(GrProgramDesc*,
const GrPrimitiveProcessor&,
- const GrOptDrawState&,
+ const GrPipeline&,
const GrProgramDesc::DescInfo&,
const GrGLGpu*,
const GrBatchTracker&);
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 9fbb4c1953..088169622c 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -193,8 +193,8 @@ void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
// First we loop over all of the installed processors and collect coord transforms. These will
// be sent to the GrGLPrimitiveProcessor in its emitCode function
SkSTArray<8, GrGLProcessor::TransformedCoordsArray> outCoords;
- for (int i = 0; i < this->optState().numFragmentStages(); i++) {
- const GrFragmentProcessor* processor = this->optState().getFragmentStage(i).processor();
+ for (int i = 0; i < this->pipeline().numFragmentStages(); i++) {
+ const GrFragmentProcessor* processor = this->pipeline().getFragmentStage(i).processor();
SkSTArray<2, const GrCoordTransform*, true>& procCoords = fCoordTransforms.push_back();
for (int t = 0; t < processor->numTransforms(); t++) {
procCoords.push_back(&processor->coordTransform(t));
@@ -205,10 +205,10 @@ void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
this->emitAndInstallProc(primProc, inputColor, inputCoverage);
fFragmentProcessors.reset(SkNEW(GrGLInstalledFragProcs));
- int numProcs = this->optState().numFragmentStages();
- this->emitAndInstallFragProcs(0, this->optState().numColorStages(), inputColor);
- this->emitAndInstallFragProcs(this->optState().numColorStages(), numProcs, inputCoverage);
- this->emitAndInstallXferProc(*this->optState().getXferProcessor(), *inputColor, *inputCoverage);
+ int numProcs = this->pipeline().numFragmentStages();
+ this->emitAndInstallFragProcs(0, this->pipeline().numColorStages(), inputColor);
+ this->emitAndInstallFragProcs(this->pipeline().numColorStages(), numProcs, inputCoverage);
+ this->emitAndInstallXferProc(*this->pipeline().getXferProcessor(), *inputColor, *inputCoverage);
}
void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset,
@@ -216,7 +216,7 @@ void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset,
GrGLSLExpr4* inOut) {
for (int e = procOffset; e < numProcs; ++e) {
GrGLSLExpr4 output;
- const GrPendingFragmentStage& stage = this->optState().getFragmentStage(e);
+ const GrPendingFragmentStage& stage = this->pipeline().getFragmentStage(e);
this->emitAndInstallProc(stage, e, *inOut, &output);
*inOut = output;
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 612791e078..4b40cefad0 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -15,8 +15,8 @@
#include "../GrGLUniformHandle.h"
#include "../GrGLGeometryProcessor.h"
#include "../GrGLXferProcessor.h"
-#include "../../GrOptDrawState.h"
#include "../../GrPendingFragmentStage.h"
+#include "../../GrPipeline.h"
/*
* This is the base class for a series of interfaces. This base class *MUST* remain abstract with
@@ -283,7 +283,7 @@ protected:
GrGLProgramBuilder(GrGLGpu*, const DrawArgs&);
const GrPrimitiveProcessor& primitiveProcessor() const { return *fArgs.fPrimitiveProcessor; }
- const GrOptDrawState& optState() const { return *fArgs.fOptState; }
+ const GrPipeline& pipeline() const { return *fArgs.fPipeline; }
const GrProgramDesc& desc() const { return *fArgs.fDesc; }
const GrBatchTracker& batchTracker() const { return *fArgs.fBatchTracker; }
const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header(); }