Preliminary attempt to remove batch tracker
BUG=skia: Review URL: https://codereview.chromium.org/1139723004
This commit is contained in:
parent
9b4b91f5c2
commit
cbfe91d825
@ -310,7 +310,7 @@ protected:
|
||||
}
|
||||
GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
|
||||
gp.reset(GrConicEffect::Create(color, SkMatrix::I(), et,
|
||||
*tt.target()->caps(), SkMatrix::I()));
|
||||
*tt.target()->caps(), SkMatrix::I(), false));
|
||||
if (!gp) {
|
||||
continue;
|
||||
}
|
||||
@ -550,7 +550,7 @@ protected:
|
||||
}
|
||||
GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
|
||||
gp.reset(GrQuadEffect::Create(color, SkMatrix::I(), et,
|
||||
*tt.target()->caps(), SkMatrix::I()));
|
||||
*tt.target()->caps(), SkMatrix::I(), false));
|
||||
if (!gp) {
|
||||
continue;
|
||||
}
|
||||
|
@ -158,7 +158,8 @@ protected:
|
||||
|
||||
static const GrColor color = 0xff000000;
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, color));
|
||||
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, color,
|
||||
false, false));
|
||||
|
||||
SkScalar y = 0;
|
||||
for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_IterStart);
|
||||
|
@ -525,8 +525,9 @@ static void create_vertices(const SegmentArray& segments,
|
||||
class QuadEdgeEffect : public GrGeometryProcessor {
|
||||
public:
|
||||
|
||||
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatrix) {
|
||||
return SkNEW_ARGS(QuadEdgeEffect, (color, localMatrix));
|
||||
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(QuadEdgeEffect, (color, localMatrix, usesLocalCoords));
|
||||
}
|
||||
|
||||
virtual ~QuadEdgeEffect() {}
|
||||
@ -536,7 +537,9 @@ public:
|
||||
const Attribute* inPosition() const { return fInPosition; }
|
||||
const Attribute* inQuadEdge() const { return fInQuadEdge; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
|
||||
class GLProcessor : public GrGLGeometryProcessor {
|
||||
public:
|
||||
@ -556,11 +559,10 @@ public:
|
||||
args.fPB->addVarying("QuadEdge", &v);
|
||||
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName);
|
||||
|
||||
const BatchTracker& local = args.fBT.cast<BatchTracker>();
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL,
|
||||
&fColorUniform);
|
||||
if (!qe.colorIgnored()) {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, qe.inPosition()->fName);
|
||||
@ -598,22 +600,22 @@ public:
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>();
|
||||
uint32_t key = local.fInputColorType << 16;
|
||||
key |= local.fUsesLocalCoords && qee.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
uint32_t key = 0;
|
||||
key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
key |= qee.colorIgnored() ? 0x2 : 0x0;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
const GrPrimitiveProcessor& gp,
|
||||
const GrBatchTracker& bt) override {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>();
|
||||
if (qe.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(qe.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = qe.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -642,31 +644,21 @@ public:
|
||||
return SkNEW_ARGS(GLProcessor, (*this, bt));
|
||||
}
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
|
||||
BatchTracker* local = bt->cast<BatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
private:
|
||||
QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix)
|
||||
QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix, bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fLocalMatrix(localMatrix) {
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords) {
|
||||
this->initClassID<QuadEdgeEffect>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVertexAttribType));
|
||||
}
|
||||
|
||||
struct BatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInQuadEdge;
|
||||
GrColor fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
|
||||
|
||||
@ -682,7 +674,8 @@ GrGeometryProcessor* QuadEdgeEffect::TestCreate(SkRandom* random,
|
||||
// Doesn't work without derivative instructions.
|
||||
return caps.shaderCaps()->shaderDerivativeSupport() ?
|
||||
QuadEdgeEffect::Create(GrRandomColor(random),
|
||||
GrTest::TestMatrix(random)) : NULL;
|
||||
GrTest::TestMatrix(random),
|
||||
random->nextBool()) : NULL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -732,13 +725,16 @@ static void extract_verts(const GrAAConvexTessellator& tess,
|
||||
}
|
||||
|
||||
static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
|
||||
const SkMatrix& localMatrix) {
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored) {
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
|
||||
if (!tweakAlphaForCoverage) {
|
||||
flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
|
||||
}
|
||||
|
||||
return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, SkMatrix::I(), localMatrix);
|
||||
return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
|
||||
SkMatrix::I(), localMatrix);
|
||||
}
|
||||
|
||||
class AAConvexPathBatch : public GrBatch {
|
||||
@ -791,18 +787,12 @@ public:
|
||||
|
||||
// Setup GrGeometryProcessor
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
create_fill_gp(canTweakAlphaForCoverage, invert));
|
||||
create_fill_gp(canTweakAlphaForCoverage, invert,
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO remove this when batch is everywhere
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
|
||||
SkASSERT(canTweakAlphaForCoverage ?
|
||||
@ -870,19 +860,11 @@ public:
|
||||
}
|
||||
|
||||
// Setup GrGeometryProcessor
|
||||
SkAutoTUnref<GrGeometryProcessor> quadProcessor(QuadEdgeEffect::Create(this->color(),
|
||||
invert));
|
||||
SkAutoTUnref<GrGeometryProcessor> quadProcessor(
|
||||
QuadEdgeEffect::Create(this->color(), invert, this->usesLocalCoords()));
|
||||
|
||||
batchTarget->initDraw(quadProcessor, pipeline);
|
||||
|
||||
// TODO remove this when batch is everywhere
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
quadProcessor->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
// TODO generate all segments for all paths and use one vertex buffer
|
||||
for (int i = 0; i < instanceCount; i++) {
|
||||
Geometry& args = fGeoData[i];
|
||||
@ -991,6 +973,7 @@ private:
|
||||
bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
|
||||
bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCoverage; }
|
||||
const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
struct BatchTracker {
|
||||
GrColor fColor;
|
||||
|
@ -197,9 +197,10 @@ public:
|
||||
this->viewMatrix(),
|
||||
atlas->getTexture(),
|
||||
params,
|
||||
flags));
|
||||
flags,
|
||||
this->usesLocalCoords()));
|
||||
|
||||
this->initDraw(batchTarget, dfProcessor, pipeline);
|
||||
batchTarget->initDraw(dfProcessor, pipeline);
|
||||
|
||||
FlushInfo flushInfo;
|
||||
|
||||
@ -414,7 +415,7 @@ private:
|
||||
&atlasLocation);
|
||||
if (!success) {
|
||||
this->flush(batchTarget, flushInfo);
|
||||
this->initDraw(batchTarget, dfProcessor, pipeline);
|
||||
batchTarget->initDraw(dfProcessor, pipeline);
|
||||
|
||||
SkDEBUGCODE(success =) atlas->addToAtlas(&id, batchTarget, width, height,
|
||||
dfStorage.get(), &atlasLocation);
|
||||
@ -491,20 +492,6 @@ private:
|
||||
vertexStride);
|
||||
}
|
||||
|
||||
void initDraw(GrBatchTarget* batchTarget,
|
||||
const GrGeometryProcessor* dfProcessor,
|
||||
const GrPipeline* pipeline) {
|
||||
batchTarget->initDraw(dfProcessor, pipeline);
|
||||
|
||||
// TODO remove this when batch is everywhere
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
dfProcessor->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
}
|
||||
|
||||
void flush(GrBatchTarget* batchTarget, FlushInfo* flushInfo) {
|
||||
GrVertices vertices;
|
||||
int maxInstancesPerDraw = flushInfo->fIndexBuffer->maxQuads();
|
||||
|
@ -774,6 +774,7 @@ private:
|
||||
uint8_t coverage() const { return fBatch.fCoverage; }
|
||||
bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
|
||||
const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
struct BatchTracker {
|
||||
GrColor fColor;
|
||||
@ -815,6 +816,8 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
|
||||
SkAutoTUnref<const GrGeometryProcessor> lineGP(
|
||||
GrDefaultGeoProcFactory::Create(gpFlags,
|
||||
this->color(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored(),
|
||||
*geometryProcessorViewM,
|
||||
*geometryProcessorLocalM,
|
||||
this->coverage()));
|
||||
@ -825,6 +828,7 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
|
||||
kHairlineAA_GrProcessorEdgeType,
|
||||
batchTarget->caps(),
|
||||
*geometryProcessorLocalM,
|
||||
this->usesLocalCoords(),
|
||||
this->coverage()));
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> conicGP(
|
||||
@ -833,6 +837,7 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
|
||||
kHairlineAA_GrProcessorEdgeType,
|
||||
batchTarget->caps(),
|
||||
*geometryProcessorLocalM,
|
||||
this->usesLocalCoords(),
|
||||
this->coverage()));
|
||||
|
||||
// This is hand inlined for maximum performance.
|
||||
@ -859,14 +864,6 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
|
||||
ref_lines_index_buffer(batchTarget->resourceProvider()));
|
||||
batchTarget->initDraw(lineGP, pipeline);
|
||||
|
||||
// TODO remove this when batch is everywhere
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
lineGP->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
const GrVertexBuffer* vertexBuffer;
|
||||
int firstVertex;
|
||||
|
||||
@ -929,14 +926,6 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
|
||||
if (quadCount > 0) {
|
||||
batchTarget->initDraw(quadGP, pipeline);
|
||||
|
||||
// TODO remove this when batch is everywhere
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
{
|
||||
GrVertices verts;
|
||||
verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
|
||||
@ -950,14 +939,6 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
|
||||
if (conicCount > 0) {
|
||||
batchTarget->initDraw(conicGP, pipeline);
|
||||
|
||||
// TODO remove this when batch is everywhere
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
{
|
||||
GrVertices verts;
|
||||
verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
|
||||
|
@ -31,14 +31,18 @@ static void set_inset_fan(SkPoint* pts, size_t stride,
|
||||
}
|
||||
|
||||
static const GrGeometryProcessor* create_fill_rect_gp(bool tweakAlphaForCoverage,
|
||||
const SkMatrix& localMatrix) {
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored) {
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
|
||||
const GrGeometryProcessor* gp;
|
||||
if (tweakAlphaForCoverage) {
|
||||
gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, SkMatrix::I(), localMatrix);
|
||||
gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
|
||||
SkMatrix::I(), localMatrix);
|
||||
} else {
|
||||
flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
|
||||
gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, SkMatrix::I(), localMatrix);
|
||||
gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
|
||||
SkMatrix::I(), localMatrix);
|
||||
}
|
||||
return gp;
|
||||
}
|
||||
@ -95,20 +99,12 @@ public:
|
||||
}
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
|
||||
localMatrix));
|
||||
localMatrix,
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
SkASSERT(canTweakAlphaForCoverage ?
|
||||
vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) :
|
||||
@ -176,6 +172,7 @@ private:
|
||||
bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCoverage; }
|
||||
bool colorIgnored() const { return fBatch.fColorIgnored; }
|
||||
const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
bool onCombineIfPossible(GrBatch* t) override {
|
||||
AAFillRectBatch* that = t->cast<AAFillRectBatch>();
|
||||
@ -453,20 +450,12 @@ public:
|
||||
}
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
|
||||
localMatrix));
|
||||
localMatrix,
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
|
||||
SkASSERT(canTweakAlphaForCoverage ?
|
||||
@ -626,6 +615,7 @@ private:
|
||||
bool colorIgnored() const { return fBatch.fColorIgnored; }
|
||||
const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; }
|
||||
bool miterStroke() const { return fBatch.fMiterStroke; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
bool onCombineIfPossible(GrBatch* t) override {
|
||||
AAStrokeRectBatch* that = t->cast<AAStrokeRectBatch>();
|
||||
|
@ -1537,7 +1537,8 @@ public:
|
||||
texture,
|
||||
params,
|
||||
fMaskFormat,
|
||||
localMatrix));
|
||||
localMatrix,
|
||||
this->usesLocalCoords()));
|
||||
}
|
||||
|
||||
FlushInfo flushInfo;
|
||||
@ -1547,7 +1548,7 @@ public:
|
||||
get_vertex_stride_df(fMaskFormat, fUseLCDText) :
|
||||
get_vertex_stride(fMaskFormat)));
|
||||
|
||||
this->initDraw(batchTarget, gp, pipeline);
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
int glyphCount = this->numGlyphs();
|
||||
int instanceCount = fInstanceCount;
|
||||
@ -1657,7 +1658,7 @@ public:
|
||||
if (!fFontCache->hasGlyph(glyph) &&
|
||||
!strike->addGlyphToAtlas(batchTarget, glyph, scaler)) {
|
||||
this->flush(batchTarget, &flushInfo);
|
||||
this->initDraw(batchTarget, gp, pipeline);
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
brokenRun = glyphIdx > 0;
|
||||
|
||||
SkDEBUGCODE(bool success =) strike->addGlyphToAtlas(batchTarget,
|
||||
@ -1849,20 +1850,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void initDraw(GrBatchTarget* batchTarget,
|
||||
const GrGeometryProcessor* gp,
|
||||
const GrPipeline* pipeline) {
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO remove this when batch is everywhere
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
}
|
||||
|
||||
void flush(GrBatchTarget* batchTarget, FlushInfo* flushInfo) {
|
||||
GrVertices vertices;
|
||||
int maxGlyphsPerDraw = flushInfo->fIndexBuffer->maxQuads();
|
||||
@ -1992,7 +1979,8 @@ private:
|
||||
texture,
|
||||
params,
|
||||
widthAdjust,
|
||||
flags);
|
||||
flags,
|
||||
this->usesLocalCoords());
|
||||
} else {
|
||||
flags |= kColorAttr_DistanceFieldEffectFlag;
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
@ -2003,13 +1991,15 @@ private:
|
||||
texture,
|
||||
params,
|
||||
correction,
|
||||
flags);
|
||||
flags,
|
||||
this->usesLocalCoords());
|
||||
#else
|
||||
return GrDistanceFieldA8TextGeoProc::Create(color,
|
||||
viewMatrix,
|
||||
texture,
|
||||
params,
|
||||
flags);
|
||||
flags,
|
||||
this->usesLocalCoords());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -104,12 +104,6 @@ public:
|
||||
fInlineUploads.reset();
|
||||
}
|
||||
|
||||
// TODO This goes away when everything uses batch
|
||||
GrBatchTracker* currentBatchTracker() {
|
||||
SkASSERT(!fFlushBuffer.empty());
|
||||
return &fFlushBuffer.back().fBatchTracker;
|
||||
}
|
||||
|
||||
const GrDrawTargetCaps& caps() const { return *fGpu->caps(); }
|
||||
|
||||
GrResourceProvider* resourceProvider() const { return fGpu->getContext()->resourceProvider(); }
|
||||
|
@ -438,21 +438,13 @@ public:
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
|
||||
this->color(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored(),
|
||||
this->viewMatrix(),
|
||||
SkMatrix::I()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
|
||||
SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr));
|
||||
@ -549,6 +541,7 @@ private:
|
||||
bool colorIgnored() const { return fBatch.fColorIgnored; }
|
||||
const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
|
||||
bool hairline() const { return fBatch.fHairline; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
bool onCombineIfPossible(GrBatch* t) override {
|
||||
// StrokeRectBatch* that = t->cast<StrokeRectBatch>();
|
||||
@ -711,7 +704,8 @@ static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords,
|
||||
int* colorOffset,
|
||||
int* texOffset,
|
||||
GrColor color,
|
||||
const SkMatrix& viewMatrix) {
|
||||
const SkMatrix& viewMatrix,
|
||||
bool coverageIgnored) {
|
||||
*texOffset = -1;
|
||||
*colorOffset = -1;
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType;
|
||||
@ -727,7 +721,8 @@ static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords,
|
||||
*colorOffset = sizeof(SkPoint);
|
||||
flags |= GrDefaultGeoProcFactory::kColor_GPType;
|
||||
}
|
||||
return GrDefaultGeoProcFactory::Create(flags, color, viewMatrix, SkMatrix::I());
|
||||
return GrDefaultGeoProcFactory::Create(flags, color, hasLocalCoords, coverageIgnored,
|
||||
viewMatrix, SkMatrix::I());
|
||||
}
|
||||
|
||||
class DrawVerticesBatch : public GrBatch {
|
||||
@ -785,20 +780,11 @@ public:
|
||||
int colorOffset = -1, texOffset = -1;
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
set_vertex_attributes(this->hasLocalCoords(), this->hasColors(), &colorOffset,
|
||||
&texOffset, this->color(), this->viewMatrix()));
|
||||
&texOffset, this->color(), this->viewMatrix(),
|
||||
this->coverageIgnored()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
|
||||
SkASSERT(vertexStride == sizeof(SkPoint) + (this->hasLocalCoords() ? sizeof(SkPoint) : 0)
|
||||
@ -923,6 +909,7 @@ private:
|
||||
bool hasLocalCoords() const { return fBatch.fHasLocalCoords; }
|
||||
int vertexCount() const { return fBatch.fVertexCount; }
|
||||
int indexCount() const { return fBatch.fIndexCount; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
bool onCombineIfPossible(GrBatch* t) override {
|
||||
DrawVerticesBatch* that = t->cast<DrawVerticesBatch>();
|
||||
|
@ -24,12 +24,16 @@ public:
|
||||
GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored,
|
||||
uint8_t coverage) {
|
||||
return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags,
|
||||
color,
|
||||
viewMatrix,
|
||||
localMatrix,
|
||||
coverage));
|
||||
coverage,
|
||||
usesLocalCoords,
|
||||
coverageIgnored));
|
||||
}
|
||||
|
||||
const char* name() const override { return "DefaultGeometryProcessor"; }
|
||||
@ -39,30 +43,14 @@ public:
|
||||
const Attribute* inLocalCoords() const { return fInLocalCoords; }
|
||||
const Attribute* inCoverage() const { return fInCoverage; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
bool hasVertexColor() const { return SkToBool(fInColor); }
|
||||
const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
uint8_t coverage() const { return fCoverage; }
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
|
||||
BatchTracker* local = bt->cast<BatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init,
|
||||
SkToBool(fInColor));
|
||||
|
||||
bool hasVertexCoverage = SkToBool(fInCoverage) && !init.fCoverageIgnored;
|
||||
bool covIsSolidWhite = !hasVertexCoverage && 0xff == this->coverage();
|
||||
if (init.fCoverageIgnored) {
|
||||
local->fInputCoverageType = kIgnored_GrGPInput;
|
||||
} else if (covIsSolidWhite) {
|
||||
local->fInputCoverageType = kAllOnes_GrGPInput;
|
||||
} else if (hasVertexCoverage) {
|
||||
SkASSERT(fInCoverage);
|
||||
local->fInputCoverageType = kAttribute_GrGPInput;
|
||||
} else {
|
||||
local->fInputCoverageType = kUniform_GrGPInput;
|
||||
local->fCoverage = this->coverage();
|
||||
}
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
bool coverageIgnored() const { return fCoverageIgnored; }
|
||||
bool hasVertexCoverage() const { return SkToBool(fInCoverage); }
|
||||
|
||||
class GLProcessor : public GrGLGeometryProcessor {
|
||||
public:
|
||||
@ -74,14 +62,19 @@ public:
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
|
||||
GrGLFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder();
|
||||
const BatchTracker& local = args.fBT.cast<BatchTracker>();
|
||||
|
||||
// emit attributes
|
||||
vsBuilder->emitAttributes(gp);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, gp.inColor(),
|
||||
&fColorUniform);
|
||||
if (!gp.colorIgnored()) {
|
||||
if (gp.hasVertexColor()) {
|
||||
pb->addPassThroughAttribute(gp.inColor(), args.fOutputColor);
|
||||
} else {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, gp.inPosition()->fName, gp.viewMatrix());
|
||||
|
||||
@ -96,21 +89,22 @@ public:
|
||||
}
|
||||
|
||||
// Setup coverage as pass through
|
||||
if (kUniform_GrGPInput == local.fInputCoverageType) {
|
||||
const char* fragCoverage;
|
||||
fCoverageUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Coverage",
|
||||
&fragCoverage);
|
||||
fs->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, fragCoverage);
|
||||
} else if (kAttribute_GrGPInput == local.fInputCoverageType) {
|
||||
SkASSERT(gp.inCoverage());
|
||||
fs->codeAppendf("float alpha = 1.0;");
|
||||
args.fPB->addPassThroughAttribute(gp.inCoverage(), "alpha");
|
||||
fs->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
|
||||
} else if (kAllOnes_GrGPInput == local.fInputCoverageType) {
|
||||
fs->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
|
||||
if (!gp.coverageIgnored()) {
|
||||
if (gp.hasVertexCoverage()) {
|
||||
fs->codeAppendf("float alpha = 1.0;");
|
||||
args.fPB->addPassThroughAttribute(gp.inCoverage(), "alpha");
|
||||
fs->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
|
||||
} else if (gp.coverage() == 0xff) {
|
||||
fs->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
|
||||
} else {
|
||||
const char* fragCoverage;
|
||||
fCoverageUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Coverage",
|
||||
&fragCoverage);
|
||||
fs->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, fragCoverage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,10 +113,13 @@ public:
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const DefaultGeoProc& def = gp.cast<DefaultGeoProc>();
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
uint32_t key = def.fFlags;
|
||||
key |= local.fInputColorType << 8 | local.fInputCoverageType << 16;
|
||||
key |= local.fUsesLocalCoords && def.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0;
|
||||
key |= def.colorIgnored() << 8;
|
||||
key |= def.coverageIgnored() << 9;
|
||||
key |= def.hasVertexColor() << 10;
|
||||
key |= def.hasVertexCoverage() << 11;
|
||||
key |= def.coverage() == 0xff ? 0x1 << 12 : 0;
|
||||
key |= def.usesLocalCoords() && def.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0;
|
||||
key |= ComputePosKey(def.viewMatrix()) << 25;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -133,16 +130,16 @@ public:
|
||||
const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>();
|
||||
this->setUniformViewMatrix(pdman, dgp.viewMatrix());
|
||||
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
if (dgp.color() != fColor && !dgp.hasVertexColor()) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(dgp.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = dgp.color();
|
||||
}
|
||||
if (kUniform_GrGPInput == local.fInputCoverageType && local.fCoverage != fCoverage) {
|
||||
pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(local.fCoverage));
|
||||
fCoverage = local.fCoverage;
|
||||
|
||||
if (dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) {
|
||||
pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverage()));
|
||||
fCoverage = dgp.coverage();
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +175,9 @@ private:
|
||||
GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
uint8_t coverage)
|
||||
uint8_t coverage,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored)
|
||||
: fInPosition(NULL)
|
||||
, fInColor(NULL)
|
||||
, fInLocalCoords(NULL)
|
||||
@ -187,7 +186,9 @@ private:
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fCoverage(coverage)
|
||||
, fFlags(gpTypeFlags) {
|
||||
, fFlags(gpTypeFlags)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fCoverageIgnored(coverageIgnored) {
|
||||
this->initClassID<DefaultGeoProc>();
|
||||
bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_GPType);
|
||||
bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLocalCoord_GPType);
|
||||
@ -198,7 +199,7 @@ private:
|
||||
}
|
||||
if (hasLocalCoord) {
|
||||
fInLocalCoords = &this->addVertexAttrib(Attribute("inLocalCoord",
|
||||
kVec2f_GrVertexAttribType));
|
||||
kVec2f_GrVertexAttribType));
|
||||
this->setHasLocalCoords();
|
||||
}
|
||||
if (hasCoverage) {
|
||||
@ -207,14 +208,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
struct BatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrGPInput fInputCoverageType;
|
||||
GrColor fColor;
|
||||
GrColor fCoverage;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInColor;
|
||||
const Attribute* fInLocalCoords;
|
||||
@ -224,6 +217,8 @@ private:
|
||||
SkMatrix fLocalMatrix;
|
||||
uint8_t fCoverage;
|
||||
uint32_t fFlags;
|
||||
bool fUsesLocalCoords;
|
||||
bool fCoverageIgnored;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
|
||||
|
||||
@ -251,11 +246,15 @@ GrGeometryProcessor* DefaultGeoProc::TestCreate(SkRandom* random,
|
||||
GrRandomColor(random),
|
||||
GrTest::TestMatrix(random),
|
||||
GrTest::TestMatrix(random),
|
||||
random->nextBool(),
|
||||
random->nextBool(),
|
||||
GrRandomCoverage(random));
|
||||
}
|
||||
|
||||
const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags,
|
||||
GrColor color,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
uint8_t coverage) {
|
||||
@ -263,5 +262,7 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags,
|
||||
color,
|
||||
viewMatrix,
|
||||
localMatrix,
|
||||
usesLocalCoords,
|
||||
coverageIgnored,
|
||||
coverage);
|
||||
}
|
||||
|
@ -83,6 +83,8 @@ public:
|
||||
// TODO clean this up
|
||||
static const GrGeometryProcessor* Create(uint32_t gpTypeFlags,
|
||||
GrColor,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored,
|
||||
const SkMatrix& viewMatrix = SkMatrix::I(),
|
||||
const SkMatrix& localMatrix = SkMatrix::I(),
|
||||
uint8_t coverage = 0xff);
|
||||
|
@ -254,6 +254,8 @@ public:
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
|
||||
this->color(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored(),
|
||||
this->viewMatrix(),
|
||||
SkMatrix::I(),
|
||||
this->coverage()));
|
||||
@ -263,16 +265,6 @@ public:
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
int instanceCount = fGeoData.count();
|
||||
|
||||
// compute number of vertices
|
||||
@ -518,6 +510,7 @@ private:
|
||||
bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
|
||||
const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; }
|
||||
bool isHairline() const { return fBatch.fIsHairline; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
struct BatchTracker {
|
||||
GrColor fColor;
|
||||
|
@ -26,6 +26,9 @@ public:
|
||||
|
||||
bool willUseGeoShader() const { return fWillUseGeoShader; }
|
||||
|
||||
// TODO delete when paths are in batch
|
||||
void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override {}
|
||||
|
||||
// TODO delete this when paths are in batch
|
||||
bool canMakeEqual(const GrBatchTracker& mine,
|
||||
const GrPrimitiveProcessor& that,
|
||||
@ -43,35 +46,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
/*
|
||||
* An optional simple helper function to determine by what means the GrGeometryProcessor should
|
||||
* use to provide color. If we are given an override color(ie the given overridecolor is NOT
|
||||
* GrColor_ILLEGAL) then we must always emit that color(currently overrides are only supported
|
||||
* via uniform, but with deferred Geometry we could use attributes). Otherwise, if our color is
|
||||
* ignored then we should not emit a color. Lastly, if we don't have vertex colors then we must
|
||||
* emit a color via uniform
|
||||
* TODO this function changes quite a bit with deferred geometry. There the GrGeometryProcessor
|
||||
* can upload a new color via attribute if needed.
|
||||
*/
|
||||
static GrGPInput GetColorInputType(GrColor* color, GrColor primitiveColor,
|
||||
const GrPipelineInfo& init,
|
||||
bool hasVertexColor) {
|
||||
if (init.fColorIgnored) {
|
||||
*color = GrColor_ILLEGAL;
|
||||
return kIgnored_GrGPInput;
|
||||
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
|
||||
*color = init.fOverrideColor;
|
||||
return kUniform_GrGPInput;
|
||||
}
|
||||
|
||||
*color = primitiveColor;
|
||||
if (hasVertexColor) {
|
||||
return kAttribute_GrGPInput;
|
||||
} else {
|
||||
return kUniform_GrGPInput;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses call this from their constructor to register vertex attributes. Attributes
|
||||
* will be padded to the nearest 4 bytes for performance reasons.
|
||||
|
@ -71,14 +71,17 @@ inline bool circle_stays_circle(const SkMatrix& m) {
|
||||
|
||||
class CircleEdgeEffect : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatrix& localMatrix) {
|
||||
return SkNEW_ARGS(CircleEdgeEffect, (color, stroke, localMatrix));
|
||||
static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(CircleEdgeEffect, (color, stroke, localMatrix, usesLocalCoords));
|
||||
}
|
||||
|
||||
const Attribute* inPosition() const { return fInPosition; }
|
||||
const Attribute* inCircleEdge() const { return fInCircleEdge; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
virtual ~CircleEdgeEffect() {}
|
||||
|
||||
const char* name() const override { return "CircleEdge"; }
|
||||
@ -94,7 +97,6 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
const BatchTracker& local = args.fBT.cast<BatchTracker>();
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
|
||||
// emit attributes
|
||||
@ -104,9 +106,10 @@ public:
|
||||
args.fPB->addVarying("CircleEdge", &v);
|
||||
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), ce.inCircleEdge()->fName);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL,
|
||||
&fColorUniform);
|
||||
// setup pass through color
|
||||
if (!ce.colorIgnored()) {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, ce.inPosition()->fName);
|
||||
@ -131,22 +134,22 @@ public:
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
const CircleEdgeEffect& ce = gp.cast<CircleEdgeEffect>();
|
||||
uint16_t key = ce.isStroked() ? 0x1 : 0x0;
|
||||
key |= local.fUsesLocalCoords && ce.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
key |= ce.colorIgnored() ? 0x4 : 0x0;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
const GrPrimitiveProcessor& gp,
|
||||
const GrBatchTracker& bt) override {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
const CircleEdgeEffect& ce = gp.cast<CircleEdgeEffect>();
|
||||
if (ce.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(ce.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = ce.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,16 +177,11 @@ public:
|
||||
return SkNEW_ARGS(GLProcessor, (*this, bt));
|
||||
}
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
|
||||
BatchTracker* local = bt->cast<BatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
private:
|
||||
CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix)
|
||||
CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fLocalMatrix(localMatrix) {
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords) {
|
||||
this->initClassID<CircleEdgeEffect>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge",
|
||||
@ -191,17 +189,12 @@ private:
|
||||
fStroke = stroke;
|
||||
}
|
||||
|
||||
struct BatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
GrColor fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInCircleEdge;
|
||||
bool fStroke;
|
||||
bool fUsesLocalCoords;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
|
||||
|
||||
@ -216,7 +209,8 @@ GrGeometryProcessor* CircleEdgeEffect::TestCreate(SkRandom* random,
|
||||
GrTexture* textures[]) {
|
||||
return CircleEdgeEffect::Create(GrRandomColor(random),
|
||||
random->nextBool(),
|
||||
GrTest::TestMatrix(random));
|
||||
GrTest::TestMatrix(random),
|
||||
random->nextBool());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -231,8 +225,9 @@ GrGeometryProcessor* CircleEdgeEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class EllipseEdgeEffect : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatrix& localMatrix) {
|
||||
return SkNEW_ARGS(EllipseEdgeEffect, (color, stroke, localMatrix));
|
||||
static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(EllipseEdgeEffect, (color, stroke, localMatrix, usesLocalCoords));
|
||||
}
|
||||
|
||||
virtual ~EllipseEdgeEffect() {}
|
||||
@ -243,7 +238,9 @@ public:
|
||||
const Attribute* inEllipseOffset() const { return fInEllipseOffset; }
|
||||
const Attribute* inEllipseRadii() const { return fInEllipseRadii; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
|
||||
inline bool isStroked() const { return fStroke; }
|
||||
|
||||
@ -256,7 +253,6 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
const BatchTracker& local = args.fBT.cast<BatchTracker>();
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
|
||||
// emit attributes
|
||||
@ -272,9 +268,10 @@ public:
|
||||
vsBuilder->codeAppendf("%s = %s;", ellipseRadii.vsOut(),
|
||||
ee.inEllipseRadii()->fName);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL,
|
||||
&fColorUniform);
|
||||
// setup pass through color
|
||||
if (!ee.colorIgnored()) {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, ee.inPosition()->fName);
|
||||
@ -314,23 +311,22 @@ public:
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
const EllipseEdgeEffect& ee = gp.cast<EllipseEdgeEffect>();
|
||||
uint16_t key = ee.isStroked() ? 0x1 : 0x0;
|
||||
key |= local.fUsesLocalCoords && ee.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
key |= ee.usesLocalCoords() && ee.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
key |= ee.colorIgnored() ? 0x4 : 0x0;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
const GrPrimitiveProcessor& gp,
|
||||
const GrBatchTracker& bt) override {
|
||||
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
const EllipseEdgeEffect& ee = gp.cast<EllipseEdgeEffect>();
|
||||
if (ee.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(ee.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = ee.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,16 +355,12 @@ public:
|
||||
return SkNEW_ARGS(GLProcessor, (*this, bt));
|
||||
}
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
|
||||
BatchTracker* local = bt->cast<BatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
private:
|
||||
EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix)
|
||||
EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fLocalMatrix(localMatrix) {
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords) {
|
||||
this->initClassID<EllipseEdgeEffect>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset",
|
||||
@ -378,18 +370,13 @@ private:
|
||||
fStroke = stroke;
|
||||
}
|
||||
|
||||
struct BatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInEllipseOffset;
|
||||
const Attribute* fInEllipseRadii;
|
||||
GrColor fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fStroke;
|
||||
bool fUsesLocalCoords;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
|
||||
|
||||
@ -404,7 +391,8 @@ GrGeometryProcessor* EllipseEdgeEffect::TestCreate(SkRandom* random,
|
||||
GrTexture* textures[]) {
|
||||
return EllipseEdgeEffect::Create(GrRandomColor(random),
|
||||
random->nextBool(),
|
||||
GrTest::TestMatrix(random));
|
||||
GrTest::TestMatrix(random),
|
||||
random->nextBool());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -422,8 +410,9 @@ class DIEllipseEdgeEffect : public GrGeometryProcessor {
|
||||
public:
|
||||
enum Mode { kStroke = 0, kHairline, kFill };
|
||||
|
||||
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix, Mode mode) {
|
||||
return SkNEW_ARGS(DIEllipseEdgeEffect, (color, viewMatrix, mode));
|
||||
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix, Mode mode,
|
||||
bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(DIEllipseEdgeEffect, (color, viewMatrix, mode, usesLocalCoords));
|
||||
}
|
||||
|
||||
virtual ~DIEllipseEdgeEffect() {}
|
||||
@ -434,7 +423,9 @@ public:
|
||||
const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; }
|
||||
const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
|
||||
inline Mode getMode() const { return fMode; }
|
||||
|
||||
@ -447,7 +438,6 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
const BatchTracker& local = args.fBT.cast<BatchTracker>();
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
|
||||
// emit attributes
|
||||
@ -463,9 +453,10 @@ public:
|
||||
vsBuilder->codeAppendf("%s = %s;", offsets1.vsOut(),
|
||||
ee.inEllipseOffsets1()->fName);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL,
|
||||
&fColorUniform);
|
||||
// setup pass through color
|
||||
if (!ee.colorIgnored()) {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, ee.inPosition()->fName, ee.viewMatrix());
|
||||
@ -519,11 +510,11 @@ public:
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
const DIEllipseEdgeEffect& ellipseEffect = gp.cast<DIEllipseEdgeEffect>();
|
||||
uint16_t key = ellipseEffect.getMode();
|
||||
key |= ComputePosKey(ellipseEffect.viewMatrix()) << 9;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
key |= ellipseEffect.colorIgnored() << 9;
|
||||
key |= ComputePosKey(ellipseEffect.viewMatrix()) << 10;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
@ -532,12 +523,11 @@ public:
|
||||
const DIEllipseEdgeEffect& dee = gp.cast<DIEllipseEdgeEffect>();
|
||||
this->setUniformViewMatrix(pdman, dee.viewMatrix());
|
||||
|
||||
const BatchTracker& local = bt.cast<BatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
if (dee.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(dee.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = dee.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -559,37 +549,28 @@ public:
|
||||
return SkNEW_ARGS(GLProcessor, (*this, bt));
|
||||
}
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
|
||||
BatchTracker* local = bt->cast<BatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
private:
|
||||
DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode)
|
||||
DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode,
|
||||
bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fViewMatrix(viewMatrix) {
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords) {
|
||||
this->initClassID<DIEllipseEdgeEffect>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0",
|
||||
kVec2f_GrVertexAttribType));
|
||||
kVec2f_GrVertexAttribType));
|
||||
fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1",
|
||||
kVec2f_GrVertexAttribType));
|
||||
kVec2f_GrVertexAttribType));
|
||||
fMode = mode;
|
||||
}
|
||||
|
||||
struct BatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInEllipseOffsets0;
|
||||
const Attribute* fInEllipseOffsets1;
|
||||
GrColor fColor;
|
||||
SkMatrix fViewMatrix;
|
||||
Mode fMode;
|
||||
bool fUsesLocalCoords;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
|
||||
|
||||
@ -604,7 +585,8 @@ GrGeometryProcessor* DIEllipseEdgeEffect::TestCreate(SkRandom* random,
|
||||
GrTexture* textures[]) {
|
||||
return DIEllipseEdgeEffect::Create(GrRandomColor(random),
|
||||
GrTest::TestMatrix(random),
|
||||
(Mode)(random->nextRangeU(0,2)));
|
||||
(Mode)(random->nextRangeU(0,2)),
|
||||
random->nextBool());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -692,20 +674,11 @@ public:
|
||||
// Setup geometry processor
|
||||
SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->color(),
|
||||
this->stroke(),
|
||||
invert));
|
||||
invert,
|
||||
this->usesLocalCoords()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
int instanceCount = fGeoData.count();
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
SkASSERT(vertexStride == sizeof(CircleVertex));
|
||||
@ -916,20 +889,11 @@ public:
|
||||
// Setup geometry processor
|
||||
SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->color(),
|
||||
this->stroke(),
|
||||
invert));
|
||||
invert,
|
||||
this->usesLocalCoords()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
int instanceCount = fGeoData.count();
|
||||
QuadHelper helper;
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
@ -1184,20 +1148,11 @@ public:
|
||||
// Setup geometry processor
|
||||
SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->color(),
|
||||
this->viewMatrix(),
|
||||
this->mode()));
|
||||
this->mode(),
|
||||
this->usesLocalCoords()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
int instanceCount = fGeoData.count();
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
SkASSERT(vertexStride == sizeof(DIEllipseVertex));
|
||||
@ -1549,20 +1504,11 @@ public:
|
||||
// Setup geometry processor
|
||||
SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->color(),
|
||||
this->stroke(),
|
||||
invert));
|
||||
invert,
|
||||
this->usesLocalCoords()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
int instanceCount = fGeoData.count();
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
SkASSERT(vertexStride == sizeof(CircleVertex));
|
||||
@ -1731,20 +1677,11 @@ public:
|
||||
// Setup geometry processor
|
||||
SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->color(),
|
||||
this->stroke(),
|
||||
invert));
|
||||
invert,
|
||||
this->usesLocalCoords()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
int instanceCount = fGeoData.count();
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
SkASSERT(vertexStride == sizeof(EllipseVertex));
|
||||
|
@ -57,12 +57,19 @@ bool GrPathProcessor::canMakeEqual(const GrBatchTracker& m,
|
||||
|
||||
const PathBatchTracker& mine = m.cast<PathBatchTracker>();
|
||||
const PathBatchTracker& theirs = t.cast<PathBatchTracker>();
|
||||
return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
|
||||
that, theirs.fUsesLocalCoords) &&
|
||||
CanCombineOutput(mine.fInputColorType, mine.fColor,
|
||||
theirs.fInputColorType, theirs.fColor) &&
|
||||
CanCombineOutput(mine.fInputCoverageType, 0xff,
|
||||
theirs.fInputCoverageType, 0xff);
|
||||
if (mine.fColor != theirs.fColor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mine.fUsesLocalCoords != theirs.fUsesLocalCoords) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mine.fUsesLocalCoords && !this->localMatrix().cheapEqualTo(other.localMatrix())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GrPathProcessor::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
|
@ -57,38 +57,6 @@ public:
|
||||
private:
|
||||
GrPathProcessor(GrColor color, const SkMatrix& viewMatrix, const SkMatrix& localMatrix);
|
||||
|
||||
/*
|
||||
* CanCombineOutput will return true if two draws are 'batchable' from a color perspective.
|
||||
* TODO is this really necessary?
|
||||
*/
|
||||
static bool CanCombineOutput(GrGPInput left, GrColor lColor, GrGPInput right, GrColor rColor) {
|
||||
if (left != right) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (kUniform_GrGPInput == left && lColor != rColor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool CanCombineLocalMatrices(const GrPrimitiveProcessor& l,
|
||||
bool leftUsesLocalCoords,
|
||||
const GrPrimitiveProcessor& r,
|
||||
bool rightUsesLocalCoords) {
|
||||
if (leftUsesLocalCoords != rightUsesLocalCoords) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const GrPathProcessor& left = l.cast<GrPathProcessor>();
|
||||
const GrPathProcessor& right = r.cast<GrPathProcessor>();
|
||||
if (leftUsesLocalCoords && !left.localMatrix().cheapEqualTo(right.localMatrix())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hasExplicitLocalCoords() const override { return false; }
|
||||
|
||||
GrColor fColor;
|
||||
|
@ -25,15 +25,19 @@
|
||||
The vertex attrib order is always pos, color, [local coords].
|
||||
*/
|
||||
static const GrGeometryProcessor* create_rect_gp(bool hasExplicitLocalCoords,
|
||||
GrColor color,
|
||||
const SkMatrix* localMatrix) {
|
||||
const SkMatrix* localMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored) {
|
||||
// TODO remove color when we have ignored color from the XP
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
|
||||
GrDefaultGeoProcFactory::kColor_GPType;
|
||||
flags |= hasExplicitLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
|
||||
if (localMatrix) {
|
||||
return GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), *localMatrix);
|
||||
return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords,
|
||||
coverageIgnored, SkMatrix::I(), *localMatrix);
|
||||
} else {
|
||||
return GrDefaultGeoProcFactory::Create(flags, color, SkMatrix::I(), SkMatrix::I());
|
||||
return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords,
|
||||
coverageIgnored, SkMatrix::I(), SkMatrix::I());
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,21 +102,12 @@ public:
|
||||
}
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(hasExplicitLocalCoords,
|
||||
this->color(),
|
||||
&invert));
|
||||
&invert,
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
int instanceCount = fGeoData.count();
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
SkASSERT(hasExplicitLocalCoords ?
|
||||
@ -176,6 +171,7 @@ private:
|
||||
const SkMatrix& localMatrix() const { return fGeoData[0].fLocalMatrix; }
|
||||
bool hasLocalRect() const { return fGeoData[0].fHasLocalRect; }
|
||||
bool hasLocalMatrix() const { return fGeoData[0].fHasLocalMatrix; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
bool onCombineIfPossible(GrBatch* t) override {
|
||||
RectBatch* that = t->cast<RectBatch>();
|
||||
|
@ -1412,9 +1412,10 @@ public:
|
||||
LOG("got %d pts, %d contours\n", maxPts, contourCnt);
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType;
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Create(flags, fColor, fViewMatrix, SkMatrix::I()));
|
||||
GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.fUsesLocalCoords,
|
||||
fPipelineInfo.fCoverageIgnored, fViewMatrix,
|
||||
SkMatrix::I()));
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), fPipelineInfo);
|
||||
|
||||
SkAutoTDeleteArray<Vertex*> contours(SkNEW_ARRAY(Vertex *, contourCnt));
|
||||
|
||||
|
@ -50,16 +50,6 @@ public:
|
||||
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
|
||||
batchTarget->initDraw(fGeometryProcessor, pipeline);
|
||||
|
||||
// TODO this is hacky, but the only way we have to initialize the GP is to use the
|
||||
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
|
||||
// everywhere we can remove this nastiness
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = fBatch.fUsesLocalCoords;
|
||||
fGeometryProcessor->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
this->onGenerateGeometry(batchTarget, pipeline);
|
||||
}
|
||||
|
||||
|
@ -12,13 +12,6 @@
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
struct ConicBatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
uint8_t fCoverageScale;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
class GrGLConicEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLConicEffect(const GrGeometryProcessor&,
|
||||
@ -37,16 +30,16 @@ public:
|
||||
const GrConicEffect& ce = primProc.cast<GrConicEffect>();
|
||||
this->setUniformViewMatrix(pdman, ce.viewMatrix());
|
||||
|
||||
const ConicBatchTracker& local = bt.cast<ConicBatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
if (ce.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(ce.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = ce.color();
|
||||
}
|
||||
if (0xff != local.fCoverageScale && fCoverageScale != local.fCoverageScale) {
|
||||
pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCoverageScale));
|
||||
fCoverageScale = local.fCoverageScale;
|
||||
|
||||
if (ce.coverageScale() != 0xff && ce.coverageScale() != fCoverageScale) {
|
||||
pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(ce.coverageScale()));
|
||||
fCoverageScale = ce.coverageScale();
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +71,6 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
const GrConicEffect& gp = args.fGP.cast<GrConicEffect>();
|
||||
const ConicBatchTracker& local = args.fBT.cast<ConicBatchTracker>();
|
||||
|
||||
// emit attributes
|
||||
vsBuilder->emitAttributes(gp);
|
||||
@ -88,8 +80,9 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputColor, NULL,
|
||||
&fColorUniform);
|
||||
if (!gp.colorIgnored()) {
|
||||
this->setupUniformColor(args.fPB, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, gp.inPosition()->fName, gp.viewMatrix());
|
||||
@ -155,7 +148,8 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
SkFAIL("Shouldn't get here");
|
||||
}
|
||||
|
||||
if (0xff != local.fCoverageScale) {
|
||||
// TODO should we really be doing this?
|
||||
if (gp.coverageScale() != 0xff) {
|
||||
const char* coverageScale;
|
||||
fCoverageScaleUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
@ -173,11 +167,10 @@ void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrConicEffect& ce = gp.cast<GrConicEffect>();
|
||||
const ConicBatchTracker& local = bt.cast<ConicBatchTracker>();
|
||||
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
||||
key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
|
||||
key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
|
||||
key |= local.fUsesLocalCoords && ce.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
||||
key |= GrColor_ILLEGAL != ce.color() ? 0x4 : 0x0;
|
||||
key |= 0xff != ce.coverageScale() ? 0x8 : 0x0;
|
||||
key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
||||
key |= ComputePosKey(ce.viewMatrix()) << 5;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -198,23 +191,18 @@ GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt
|
||||
}
|
||||
|
||||
GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage,
|
||||
GrPrimitiveEdgeType edgeType, const SkMatrix& localMatrix)
|
||||
GrPrimitiveEdgeType edgeType, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fLocalMatrix(viewMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fCoverageScale(coverage)
|
||||
, fEdgeType(edgeType) {
|
||||
this->initClassID<GrConicEffect>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs",
|
||||
kVec4f_GrVertexAttribType));
|
||||
}
|
||||
|
||||
void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
|
||||
ConicBatchTracker* local = bt->cast<ConicBatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fCoverageScale = fCoverageScale;
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
kVec4f_GrVertexAttribType));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -231,7 +219,7 @@ GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random,
|
||||
random->nextULessThan(kGrProcessorEdgeTypeCnt));
|
||||
gp = GrConicEffect::Create(GrRandomColor(random), GrTest::TestMatrix(random),
|
||||
edgeType, caps,
|
||||
GrTest::TestMatrix(random));
|
||||
GrTest::TestMatrix(random), random->nextBool());
|
||||
} while (NULL == gp);
|
||||
return gp;
|
||||
}
|
||||
@ -240,13 +228,6 @@ GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random,
|
||||
// Quad
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct QuadBatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
uint8_t fCoverageScale;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
class GrGLQuadEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLQuadEffect(const GrGeometryProcessor&,
|
||||
@ -265,16 +246,16 @@ public:
|
||||
const GrQuadEffect& qe = primProc.cast<GrQuadEffect>();
|
||||
this->setUniformViewMatrix(pdman, qe.viewMatrix());
|
||||
|
||||
const QuadBatchTracker& local = bt.cast<QuadBatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
if (qe.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(qe.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = qe.color();
|
||||
}
|
||||
if (0xff != local.fCoverageScale && local.fCoverageScale != fCoverageScale) {
|
||||
pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCoverageScale));
|
||||
fCoverageScale = local.fCoverageScale;
|
||||
|
||||
if (qe.coverageScale() != 0xff && qe.coverageScale() != fCoverageScale) {
|
||||
pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(qe.coverageScale()));
|
||||
fCoverageScale = qe.coverageScale();
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +287,6 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>();
|
||||
const QuadBatchTracker& local = args.fBT.cast<QuadBatchTracker>();
|
||||
|
||||
// emit attributes
|
||||
vsBuilder->emitAttributes(gp);
|
||||
@ -316,8 +296,9 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputColor, NULL,
|
||||
&fColorUniform);
|
||||
if (!gp.colorIgnored()) {
|
||||
this->setupUniformColor(args.fPB, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, gp.inPosition()->fName, gp.viewMatrix());
|
||||
@ -369,7 +350,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
SkFAIL("Shouldn't get here");
|
||||
}
|
||||
|
||||
if (0xff != local.fCoverageScale) {
|
||||
if (0xff != gp.coverageScale()) {
|
||||
const char* coverageScale;
|
||||
fCoverageScaleUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
@ -387,11 +368,10 @@ void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrQuadEffect& ce = gp.cast<GrQuadEffect>();
|
||||
const QuadBatchTracker& local = bt.cast<QuadBatchTracker>();
|
||||
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
||||
key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
|
||||
key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
|
||||
key |= local.fUsesLocalCoords && ce.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
||||
key |= ce.color() != GrColor_ILLEGAL ? 0x4 : 0x0;
|
||||
key |= ce.coverageScale() != 0xff ? 0x8 : 0x0;
|
||||
key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
||||
key |= ComputePosKey(ce.viewMatrix()) << 5;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -412,10 +392,12 @@ GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt,
|
||||
}
|
||||
|
||||
GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage,
|
||||
GrPrimitiveEdgeType edgeType, const SkMatrix& localMatrix)
|
||||
GrPrimitiveEdgeType edgeType, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fCoverageScale(coverage)
|
||||
, fEdgeType(edgeType) {
|
||||
this->initClassID<GrQuadEffect>();
|
||||
@ -424,13 +406,6 @@ GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
|
||||
kVec4f_GrVertexAttribType));
|
||||
}
|
||||
|
||||
void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
|
||||
QuadBatchTracker* local = bt->cast<QuadBatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fCoverageScale = fCoverageScale;
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect);
|
||||
@ -446,7 +421,8 @@ GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random,
|
||||
gp = GrQuadEffect::Create(GrRandomColor(random),
|
||||
GrTest::TestMatrix(random),
|
||||
edgeType, caps,
|
||||
GrTest::TestMatrix(random));
|
||||
GrTest::TestMatrix(random),
|
||||
random->nextBool());
|
||||
} while (NULL == gp);
|
||||
return gp;
|
||||
}
|
||||
@ -455,12 +431,6 @@ GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random,
|
||||
// Cubic
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct CubicBatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
class GrGLCubicEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLCubicEffect(const GrGeometryProcessor&,
|
||||
@ -479,12 +449,11 @@ public:
|
||||
const GrCubicEffect& ce = primProc.cast<GrCubicEffect>();
|
||||
this->setUniformViewMatrix(pdman, ce.viewMatrix());
|
||||
|
||||
const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
if (ce.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(ce.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = ce.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -506,7 +475,6 @@ GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor,
|
||||
void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>();
|
||||
const CubicBatchTracker& local = args.fBT.cast<CubicBatchTracker>();
|
||||
|
||||
// emit attributes
|
||||
vsBuilder->emitAttributes(gp);
|
||||
@ -516,8 +484,9 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputColor, NULL,
|
||||
&fColorUniform);
|
||||
if (!gp.colorIgnored()) {
|
||||
this->setupUniformColor(args.fPB, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(args.fPB, gpArgs, gp.inPosition()->fName, gp.viewMatrix());
|
||||
@ -618,9 +587,8 @@ void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrCubicEffect& ce = gp.cast<GrCubicEffect>();
|
||||
const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
|
||||
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
||||
key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x8;
|
||||
key |= ce.color() != GrColor_ILLEGAL ? 0x4 : 0x8;
|
||||
key |= ComputePosKey(ce.viewMatrix()) << 5;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -651,12 +619,6 @@ GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix,
|
||||
kVec4f_GrVertexAttribType));
|
||||
}
|
||||
|
||||
void GrCubicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
|
||||
CubicBatchTracker* local = bt->cast<CubicBatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect);
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
const GrPrimitiveEdgeType edgeType,
|
||||
const GrDrawTargetCaps& caps,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
uint8_t coverage = 0xff) {
|
||||
switch (edgeType) {
|
||||
case kFillAA_GrProcessorEdgeType:
|
||||
@ -71,18 +72,18 @@ public:
|
||||
}
|
||||
return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage,
|
||||
kFillAA_GrProcessorEdgeType,
|
||||
localMatrix));
|
||||
localMatrix, usesLocalCoords));
|
||||
case kHairlineAA_GrProcessorEdgeType:
|
||||
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage,
|
||||
kHairlineAA_GrProcessorEdgeType,
|
||||
localMatrix));
|
||||
localMatrix, usesLocalCoords));
|
||||
case kFillBW_GrProcessorEdgeType:
|
||||
return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage,
|
||||
kFillBW_GrProcessorEdgeType,
|
||||
localMatrix));
|
||||
localMatrix, usesLocalCoords));
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@ -98,8 +99,11 @@ public:
|
||||
inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); }
|
||||
inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
uint8_t coverageScale() const { return fCoverageScale; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps& caps,
|
||||
@ -108,15 +112,14 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&) const override;
|
||||
|
||||
void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override;
|
||||
|
||||
private:
|
||||
GrConicEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimitiveEdgeType,
|
||||
const SkMatrix& localMatrix);
|
||||
const SkMatrix& localMatrix, bool usesLocalCoords);
|
||||
|
||||
GrColor fColor;
|
||||
SkMatrix fViewMatrix;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
uint8_t fCoverageScale;
|
||||
GrPrimitiveEdgeType fEdgeType;
|
||||
const Attribute* fInPosition;
|
||||
@ -145,6 +148,7 @@ public:
|
||||
const GrPrimitiveEdgeType edgeType,
|
||||
const GrDrawTargetCaps& caps,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
uint8_t coverage = 0xff) {
|
||||
switch (edgeType) {
|
||||
case kFillAA_GrProcessorEdgeType:
|
||||
@ -153,18 +157,18 @@ public:
|
||||
}
|
||||
return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage,
|
||||
kFillAA_GrProcessorEdgeType,
|
||||
localMatrix));
|
||||
localMatrix, usesLocalCoords));
|
||||
case kHairlineAA_GrProcessorEdgeType:
|
||||
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage,
|
||||
kHairlineAA_GrProcessorEdgeType,
|
||||
localMatrix));
|
||||
localMatrix, usesLocalCoords));
|
||||
case kFillBW_GrProcessorEdgeType:
|
||||
return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage,
|
||||
kFillBW_GrProcessorEdgeType,
|
||||
localMatrix));
|
||||
localMatrix, usesLocalCoords));
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@ -180,8 +184,11 @@ public:
|
||||
inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); }
|
||||
inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
uint8_t coverageScale() const { return fCoverageScale; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps& caps,
|
||||
@ -190,15 +197,14 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&) const override;
|
||||
|
||||
void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override;
|
||||
|
||||
private:
|
||||
GrQuadEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimitiveEdgeType,
|
||||
const SkMatrix& localMatrix);
|
||||
const SkMatrix& localMatrix, bool usesLocalCoords);
|
||||
|
||||
GrColor fColor;
|
||||
SkMatrix fViewMatrix;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
uint8_t fCoverageScale;
|
||||
GrPrimitiveEdgeType fEdgeType;
|
||||
const Attribute* fInPosition;
|
||||
@ -258,6 +264,7 @@ public:
|
||||
inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); }
|
||||
inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
@ -267,8 +274,6 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&) const override;
|
||||
|
||||
void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override;
|
||||
|
||||
private:
|
||||
GrCubicEffect(GrColor, const SkMatrix& viewMatrix, GrPrimitiveEdgeType);
|
||||
|
||||
|
@ -15,12 +15,6 @@
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
struct BitmapTextBatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLBitmapTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&)
|
||||
@ -28,7 +22,6 @@ public:
|
||||
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
|
||||
const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTracker>();
|
||||
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
|
||||
@ -50,8 +43,13 @@ public:
|
||||
}
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, cte.inColor(),
|
||||
&fColorUniform);
|
||||
if (!cte.colorIgnored()) {
|
||||
if (cte.hasVertexColor()) {
|
||||
pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor);
|
||||
} else {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, cte.inPosition()->fName);
|
||||
@ -79,12 +77,12 @@ public:
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
const GrPrimitiveProcessor& gp,
|
||||
const GrBatchTracker& bt) override {
|
||||
const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>();
|
||||
if (btgp.color() != fColor && !btgp.hasVertexColor()) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(btgp.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = btgp.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,16 +97,12 @@ public:
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>();
|
||||
// We have to put the optional vertex attribute as part of the key. See the comment
|
||||
// on addVertexAttrib.
|
||||
// TODO When we have deferred geometry we can fix this
|
||||
const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
|
||||
uint32_t key = 0;
|
||||
key |= SkToBool(gp.inColor()) ? 0x1 : 0x0;
|
||||
key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
||||
key |= gp.maskFormat() == kARGB_GrMaskFormat ? 0x4 : 0x0;
|
||||
b->add32(local.fInputColorType << 16 | key);
|
||||
key |= gp.usesLocalCoords() && gp.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
key |= gp.colorIgnored() ? 0x2 : 0x0;
|
||||
key |= gp.maskFormat() << 3;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -122,15 +116,18 @@ private:
|
||||
|
||||
GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture,
|
||||
const GrTextureParams& params, GrMaskFormat format,
|
||||
const SkMatrix& localMatrix)
|
||||
const SkMatrix& localMatrix, bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fTextureAccess(texture, params)
|
||||
, fInColor(NULL)
|
||||
, fMaskFormat(format) {
|
||||
this->initClassID<GrBitmapTextGeoProc>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
|
||||
// TODO we could think about removing this attribute if color is ignored, but unfortunately
|
||||
// we don't do text positioning in batch, so we can't quite do that yet.
|
||||
bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat;
|
||||
if (hasVertexColor) {
|
||||
fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
|
||||
@ -152,13 +149,6 @@ GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt,
|
||||
return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt));
|
||||
}
|
||||
|
||||
void GrBitmapTextGeoProc::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
|
||||
BitmapTextBatchTracker* local = bt->cast<BitmapTextBatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init,
|
||||
SkToBool(fInColor));
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
|
||||
@ -197,5 +187,5 @@ GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random,
|
||||
}
|
||||
|
||||
return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params,
|
||||
format, GrTest::TestMatrix(random));
|
||||
format, GrTest::TestMatrix(random), random->nextBool());
|
||||
}
|
||||
|
@ -22,9 +22,10 @@ class GrInvariantOutput;
|
||||
class GrBitmapTextGeoProc : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Create(GrColor color, GrTexture* tex, const GrTextureParams& p,
|
||||
GrMaskFormat format,
|
||||
const SkMatrix& localMatrix) {
|
||||
return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, format, localMatrix));
|
||||
GrMaskFormat format, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, format, localMatrix,
|
||||
usesLocalCoords));
|
||||
}
|
||||
|
||||
virtual ~GrBitmapTextGeoProc() {}
|
||||
@ -36,7 +37,10 @@ public:
|
||||
const Attribute* inTextureCoords() const { return fInTextureCoords; }
|
||||
GrMaskFormat maskFormat() const { return fMaskFormat; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
bool hasVertexColor() const { return SkToBool(fInColor); }
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps& caps,
|
||||
@ -45,14 +49,13 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps& caps) const override;
|
||||
|
||||
void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override;
|
||||
|
||||
private:
|
||||
GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrTextureParams& params,
|
||||
GrMaskFormat format, const SkMatrix& localMatrix);
|
||||
GrMaskFormat format, const SkMatrix& localMatrix, bool usesLocalCoords);
|
||||
|
||||
GrColor fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
GrTextureAccess fTextureAccess;
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInColor;
|
||||
|
@ -241,7 +241,8 @@ static void setup_dashed_rect_pos(const SkRect& rect, int idx, const SkMatrix& m
|
||||
static GrGeometryProcessor* create_dash_gp(GrColor,
|
||||
DashAAMode aaMode,
|
||||
DashCap cap,
|
||||
const SkMatrix& localMatrix);
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
class DashBatch : public GrBatch {
|
||||
public:
|
||||
@ -315,25 +316,20 @@ public:
|
||||
bool isRoundCap = SkPaint::kRound_Cap == cap;
|
||||
DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
|
||||
if (this->fullDash()) {
|
||||
gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, invert));
|
||||
gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, invert,
|
||||
this->usesLocalCoords()));
|
||||
} else {
|
||||
// Set up the vertex data for the line and start/end dashes
|
||||
gp.reset(GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
|
||||
this->color(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored(),
|
||||
SkMatrix::I(),
|
||||
invert));
|
||||
}
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
// TODO remove this when batch is everywhere
|
||||
GrPipelineInfo init;
|
||||
init.fColorIgnored = fBatch.fColorIgnored;
|
||||
init.fOverrideColor = GrColor_ILLEGAL;
|
||||
init.fCoverageIgnored = fBatch.fCoverageIgnored;
|
||||
init.fUsesLocalCoords = this->usesLocalCoords();
|
||||
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
||||
|
||||
// useAA here means Edge AA or MSAA
|
||||
bool useAA = this->aaMode() != kBW_DashAAMode;
|
||||
bool fullDash = this->fullDash();
|
||||
@ -661,6 +657,7 @@ private:
|
||||
DashAAMode aaMode() const { return fBatch.fAAMode; }
|
||||
bool fullDash() const { return fBatch.fFullDash; }
|
||||
SkPaint::Cap cap() const { return fBatch.fCap; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
struct BatchTracker {
|
||||
GrColor fColor;
|
||||
@ -750,12 +747,6 @@ bool GrDashingEffect::DrawDashLine(GrDrawTarget* target,
|
||||
|
||||
class GLDashingCircleEffect;
|
||||
|
||||
struct DashingCircleBatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
/*
|
||||
* This effect will draw a dotted line (defined as a dashed lined with round caps and no on
|
||||
* interval). The radius of the dots is given by the strokeWidth and the spacing by the DashInfo.
|
||||
@ -771,7 +762,8 @@ public:
|
||||
|
||||
static GrGeometryProcessor* Create(GrColor,
|
||||
DashAAMode aaMode,
|
||||
const SkMatrix& localMatrix);
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
const char* name() const override { return "DashingCircleEffect"; }
|
||||
|
||||
@ -785,8 +777,12 @@ public:
|
||||
|
||||
GrColor color() const { return fColor; }
|
||||
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker&,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) const override;
|
||||
@ -794,13 +790,13 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker&,
|
||||
const GrGLSLCaps&) const override;
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
|
||||
|
||||
private:
|
||||
DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix);
|
||||
DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
GrColor fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
DashAAMode fAAMode;
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInDashParams;
|
||||
@ -855,7 +851,6 @@ GLDashingCircleEffect::GLDashingCircleEffect(const GrGeometryProcessor&,
|
||||
|
||||
void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
const DashingCircleEffect& dce = args.fGP.cast<DashingCircleEffect>();
|
||||
const DashingCircleBatchTracker local = args.fBT.cast<DashingCircleBatchTracker>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
|
||||
@ -873,7 +868,9 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
vsBuilder->codeAppendf("%s = %s;", circleParams.vsOut(), dce.inCircleParams()->fName);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL, &fColorUniform);
|
||||
if (!dce.colorIgnored()) {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, dce.inPosition()->fName);
|
||||
@ -904,12 +901,12 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrPrimitiveProcessor& processor,
|
||||
const GrBatchTracker& bt) {
|
||||
const DashingCircleBatchTracker& local = bt.cast<DashingCircleBatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
|
||||
if (dce.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(dce.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = dce.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -917,20 +914,21 @@ void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const DashingCircleBatchTracker& local = bt.cast<DashingCircleBatchTracker>();
|
||||
const DashingCircleEffect& dce = gp.cast<DashingCircleEffect>();
|
||||
uint32_t key = 0;
|
||||
key |= local.fUsesLocalCoords && dce.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
key |= dce.usesLocalCoords() && dce.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
key |= dce.colorIgnored() ? 0x2 : 0x0;
|
||||
key |= dce.aaMode() << 8;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
|
||||
DashAAMode aaMode,
|
||||
const SkMatrix& localMatrix) {
|
||||
return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix));
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix, usesLocalCoords));
|
||||
}
|
||||
|
||||
void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
@ -946,9 +944,11 @@ GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTrack
|
||||
|
||||
DashingCircleEffect::DashingCircleEffect(GrColor color,
|
||||
DashAAMode aaMode,
|
||||
const SkMatrix& localMatrix)
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fAAMode(aaMode) {
|
||||
this->initClassID<DashingCircleEffect>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
@ -957,12 +957,6 @@ DashingCircleEffect::DashingCircleEffect(GrColor color,
|
||||
kVec2f_GrVertexAttribType));
|
||||
}
|
||||
|
||||
void DashingCircleEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
|
||||
DashingCircleBatchTracker* local = bt->cast<DashingCircleBatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
|
||||
|
||||
GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random,
|
||||
@ -971,19 +965,14 @@ GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random,
|
||||
GrTexture*[]) {
|
||||
DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAModeCount));
|
||||
return DashingCircleEffect::Create(GrRandomColor(random),
|
||||
aaMode, GrTest::TestMatrix(random));
|
||||
aaMode, GrTest::TestMatrix(random),
|
||||
random->nextBool());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GLDashingLineEffect;
|
||||
|
||||
struct DashingLineBatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
/*
|
||||
* This effect will draw a dashed line. The width of the dash is given by the strokeWidth and the
|
||||
* length and spacing by the DashInfo. Both of the previous two parameters are in device space.
|
||||
@ -999,7 +988,8 @@ public:
|
||||
|
||||
static GrGeometryProcessor* Create(GrColor,
|
||||
DashAAMode aaMode,
|
||||
const SkMatrix& localMatrix);
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
const char* name() const override { return "DashingEffect"; }
|
||||
|
||||
@ -1013,8 +1003,12 @@ public:
|
||||
|
||||
GrColor color() const { return fColor; }
|
||||
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const override;
|
||||
@ -1022,13 +1016,13 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&) const override;
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
|
||||
|
||||
private:
|
||||
DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix);
|
||||
DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
GrColor fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
DashAAMode fAAMode;
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInDashParams;
|
||||
@ -1076,7 +1070,6 @@ GLDashingLineEffect::GLDashingLineEffect(const GrGeometryProcessor&,
|
||||
|
||||
void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
const DashingLineEffect& de = args.fGP.cast<DashingLineEffect>();
|
||||
const DashingLineBatchTracker& local = args.fBT.cast<DashingLineBatchTracker>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
@ -1096,7 +1089,10 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
vsBuilder->codeAppendf("%s = %s;", inRectParams.vsOut(), de.inRectParams()->fName);
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL, &fColorUniform);
|
||||
if (!de.colorIgnored()) {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, de.inPosition()->fName);
|
||||
@ -1144,12 +1140,12 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrPrimitiveProcessor& processor,
|
||||
const GrBatchTracker& bt) {
|
||||
const DashingLineBatchTracker& local = bt.cast<DashingLineBatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
const DashingLineEffect& de = processor.cast<DashingLineEffect>();
|
||||
if (de.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(de.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = de.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1157,20 +1153,21 @@ void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const DashingLineBatchTracker& local = bt.cast<DashingLineBatchTracker>();
|
||||
const DashingLineEffect& de = gp.cast<DashingLineEffect>();
|
||||
uint32_t key = 0;
|
||||
key |= local.fUsesLocalCoords && de.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
key |= de.usesLocalCoords() && de.localMatrix().hasPerspective() ? 0x1 : 0x0;
|
||||
key |= de.colorIgnored() ? 0x2 : 0x0;
|
||||
key |= de.aaMode() << 8;
|
||||
b->add32(key << 16 | local.fInputColorType);
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
|
||||
DashAAMode aaMode,
|
||||
const SkMatrix& localMatrix) {
|
||||
return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix));
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix, usesLocalCoords));
|
||||
}
|
||||
|
||||
void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
|
||||
@ -1186,9 +1183,11 @@ GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker
|
||||
|
||||
DashingLineEffect::DashingLineEffect(GrColor color,
|
||||
DashAAMode aaMode,
|
||||
const SkMatrix& localMatrix)
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fAAMode(aaMode) {
|
||||
this->initClassID<DashingLineEffect>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
@ -1196,12 +1195,6 @@ DashingLineEffect::DashingLineEffect(GrColor color,
|
||||
fInRectParams = &this->addVertexAttrib(Attribute("inRect", kVec4f_GrVertexAttribType));
|
||||
}
|
||||
|
||||
void DashingLineEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
|
||||
DashingLineBatchTracker* local = bt->cast<DashingLineBatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
|
||||
|
||||
GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random,
|
||||
@ -1210,7 +1203,7 @@ GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random,
|
||||
GrTexture*[]) {
|
||||
DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAModeCount));
|
||||
return DashingLineEffect::Create(GrRandomColor(random),
|
||||
aaMode, GrTest::TestMatrix(random));
|
||||
aaMode, GrTest::TestMatrix(random), random->nextBool());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -1218,12 +1211,13 @@ GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random,
|
||||
static GrGeometryProcessor* create_dash_gp(GrColor color,
|
||||
DashAAMode dashAAMode,
|
||||
DashCap cap,
|
||||
const SkMatrix& localMatrix) {
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
switch (cap) {
|
||||
case kRound_DashCap:
|
||||
return DashingCircleEffect::Create(color, dashAAMode, localMatrix);
|
||||
return DashingCircleEffect::Create(color, dashAAMode, localMatrix, usesLocalCoords);
|
||||
case kNonRound_DashCap:
|
||||
return DashingLineEffect::Create(color, dashAAMode, localMatrix);
|
||||
return DashingLineEffect::Create(color, dashAAMode, localMatrix, usesLocalCoords);
|
||||
default:
|
||||
SkFAIL("Unexpected dashed cap.");
|
||||
}
|
||||
|
@ -21,12 +21,6 @@
|
||||
// Assuming a radius of a little less than the diagonal of the fragment
|
||||
#define SK_DistanceFieldAAFactor "0.65"
|
||||
|
||||
struct DistanceFieldBatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
class GrGLDistanceFieldA8TextGeoProc : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLDistanceFieldA8TextGeoProc(const GrGeometryProcessor&,
|
||||
@ -40,7 +34,6 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const GrDistanceFieldA8TextGeoProc& dfTexEffect =
|
||||
args.fGP.cast<GrDistanceFieldA8TextGeoProc>();
|
||||
const DistanceFieldBatchTracker& local = args.fBT.cast<DistanceFieldBatchTracker>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
SkAssertResult(fsBuilder->enableFeature(
|
||||
@ -61,8 +54,13 @@ public:
|
||||
#endif
|
||||
|
||||
// Setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor,
|
||||
dfTexEffect.inColor(), &fColorUniform);
|
||||
if (!dfTexEffect.colorIgnored()) {
|
||||
if (dfTexEffect.hasVertexColor()) {
|
||||
pb->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
|
||||
} else {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEffect.viewMatrix());
|
||||
@ -154,12 +152,11 @@ public:
|
||||
const GrDistanceFieldA8TextGeoProc& dfa8gp = proc.cast<GrDistanceFieldA8TextGeoProc>();
|
||||
this->setUniformViewMatrix(pdman, dfa8gp.viewMatrix());
|
||||
|
||||
const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
if (dfa8gp.color() != fColor && !dfa8gp.hasVertexColor()) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(dfa8gp.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = dfa8gp.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,9 +165,9 @@ public:
|
||||
const GrGLSLCaps&,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrDistanceFieldA8TextGeoProc& dfTexEffect = gp.cast<GrDistanceFieldA8TextGeoProc>();
|
||||
const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTracker>();
|
||||
uint32_t key = dfTexEffect.getFlags();
|
||||
key |= local.fInputColorType << 16;
|
||||
key |= dfTexEffect.hasVertexColor() << 16;
|
||||
key |= dfTexEffect.colorIgnored() << 17;
|
||||
key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -195,7 +192,8 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrColor color,
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
float distanceAdjust,
|
||||
#endif
|
||||
uint32_t flags)
|
||||
uint32_t flags,
|
||||
bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fTextureAccess(texture, params)
|
||||
@ -203,7 +201,8 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrColor color,
|
||||
, fDistanceAdjust(distanceAdjust)
|
||||
#endif
|
||||
, fFlags(flags & kNonLCD_DistanceFieldEffectMask)
|
||||
, fInColor(NULL) {
|
||||
, fInColor(NULL)
|
||||
, fUsesLocalCoords(usesLocalCoords) {
|
||||
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
|
||||
this->initClassID<GrDistanceFieldA8TextGeoProc>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
@ -227,14 +226,6 @@ GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt,
|
||||
return SkNEW_ARGS(GrGLDistanceFieldA8TextGeoProc, (*this, bt));
|
||||
}
|
||||
|
||||
void GrDistanceFieldA8TextGeoProc::initBatchTracker(GrBatchTracker* bt,
|
||||
const GrPipelineInfo& init) const {
|
||||
DistanceFieldBatchTracker* local = bt->cast<DistanceFieldBatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init,
|
||||
SkToBool(fInColor));
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc);
|
||||
@ -264,17 +255,12 @@ GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(SkRandom* random,
|
||||
random->nextF(),
|
||||
#endif
|
||||
random->nextBool() ?
|
||||
kSimilarity_DistanceFieldEffectFlag : 0);
|
||||
kSimilarity_DistanceFieldEffectFlag : 0,
|
||||
random->nextBool());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct DistanceFieldPathBatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
class GrGLDistanceFieldPathGeoProc : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLDistanceFieldPathGeoProc(const GrGeometryProcessor&,
|
||||
@ -284,7 +270,6 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistanceFieldPathGeoProc>();
|
||||
|
||||
const DistanceFieldPathBatchTracker& local = args.fBT.cast<DistanceFieldPathBatchTracker>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
SkAssertResult(fsBuilder->enableFeature(
|
||||
@ -299,9 +284,13 @@ public:
|
||||
args.fPB->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
|
||||
|
||||
// setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor,
|
||||
dfTexEffect.inColor(), &fColorUniform);
|
||||
|
||||
if (!dfTexEffect.colorIgnored()) {
|
||||
if (dfTexEffect.hasVertexColor()) {
|
||||
pb->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
|
||||
} else {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
}
|
||||
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoords()->fName);
|
||||
|
||||
// Setup position
|
||||
@ -384,12 +373,11 @@ public:
|
||||
const GrDistanceFieldPathGeoProc& dfpgp = proc.cast<GrDistanceFieldPathGeoProc>();
|
||||
this->setUniformViewMatrix(pdman, dfpgp.viewMatrix());
|
||||
|
||||
const DistanceFieldPathBatchTracker& local = bt.cast<DistanceFieldPathBatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
if (dfpgp.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(dfpgp.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = dfpgp.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,9 +387,9 @@ public:
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrDistanceFieldPathGeoProc& dfTexEffect = gp.cast<GrDistanceFieldPathGeoProc>();
|
||||
|
||||
const DistanceFieldPathBatchTracker& local = bt.cast<DistanceFieldPathBatchTracker>();
|
||||
uint32_t key = dfTexEffect.getFlags();
|
||||
key |= local.fInputColorType << 16;
|
||||
key |= dfTexEffect.colorIgnored() << 16;
|
||||
key |= dfTexEffect.hasVertexColor() << 17;
|
||||
key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -422,12 +410,14 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(
|
||||
const SkMatrix& viewMatrix,
|
||||
GrTexture* texture,
|
||||
const GrTextureParams& params,
|
||||
uint32_t flags)
|
||||
uint32_t flags,
|
||||
bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fTextureAccess(texture, params)
|
||||
, fFlags(flags & kNonLCD_DistanceFieldEffectMask)
|
||||
, fInColor(NULL) {
|
||||
, fInColor(NULL)
|
||||
, fUsesLocalCoords(usesLocalCoords) {
|
||||
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
|
||||
this->initClassID<GrDistanceFieldPathGeoProc>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
@ -435,7 +425,7 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(
|
||||
fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
|
||||
}
|
||||
fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
|
||||
kVec2f_GrVertexAttribType));
|
||||
kVec2f_GrVertexAttribType));
|
||||
this->addTextureAccess(&fTextureAccess);
|
||||
}
|
||||
|
||||
@ -450,14 +440,6 @@ GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG
|
||||
return SkNEW_ARGS(GrGLDistanceFieldPathGeoProc, (*this, bt));
|
||||
}
|
||||
|
||||
void GrDistanceFieldPathGeoProc::initBatchTracker(GrBatchTracker* bt,
|
||||
const GrPipelineInfo& init) const {
|
||||
DistanceFieldPathBatchTracker* local = bt->cast<DistanceFieldPathBatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init,
|
||||
SkToBool(fInColor));
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc);
|
||||
@ -484,17 +466,13 @@ GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(SkRandom* random,
|
||||
GrTest::TestMatrix(random),
|
||||
textures[texIdx],
|
||||
params,
|
||||
random->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0);
|
||||
random->nextBool() ?
|
||||
kSimilarity_DistanceFieldEffectFlag : 0,
|
||||
random->nextBool());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct DistanceFieldLCDBatchTracker {
|
||||
GrGPInput fInputColorType;
|
||||
GrColor fColor;
|
||||
bool fUsesLocalCoords;
|
||||
};
|
||||
|
||||
class GrGLDistanceFieldLCDTextGeoProc : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLDistanceFieldLCDTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&)
|
||||
@ -505,7 +483,6 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const GrDistanceFieldLCDTextGeoProc& dfTexEffect =
|
||||
args.fGP.cast<GrDistanceFieldLCDTextGeoProc>();
|
||||
const DistanceFieldLCDBatchTracker& local = args.fBT.cast<DistanceFieldLCDBatchTracker>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
@ -514,8 +491,9 @@ public:
|
||||
vsBuilder->emitAttributes(dfTexEffect);
|
||||
|
||||
// setup pass through color
|
||||
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL,
|
||||
&fColorUniform);
|
||||
if (!dfTexEffect.colorIgnored()) {
|
||||
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEffect.viewMatrix());
|
||||
@ -652,12 +630,11 @@ public:
|
||||
|
||||
this->setUniformViewMatrix(pdman, dfTexEffect.viewMatrix());
|
||||
|
||||
const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatchTracker>();
|
||||
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
||||
if (dfTexEffect.color() != fColor) {
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(local.fColor, c);
|
||||
GrColorToRGBAFloat(dfTexEffect.color(), c);
|
||||
pdman.set4fv(fColorUniform, 1, c);
|
||||
fColor = local.fColor;
|
||||
fColor = dfTexEffect.color();
|
||||
}
|
||||
}
|
||||
|
||||
@ -667,9 +644,8 @@ public:
|
||||
GrProcessorKeyBuilder* b) {
|
||||
const GrDistanceFieldLCDTextGeoProc& dfTexEffect = gp.cast<GrDistanceFieldLCDTextGeoProc>();
|
||||
|
||||
const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatchTracker>();
|
||||
uint32_t key = dfTexEffect.getFlags();
|
||||
key |= local.fInputColorType << 16;
|
||||
key |= dfTexEffect.colorIgnored() << 16;
|
||||
key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -689,17 +665,18 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(
|
||||
GrColor color, const SkMatrix& viewMatrix,
|
||||
GrTexture* texture, const GrTextureParams& params,
|
||||
DistanceAdjust distanceAdjust,
|
||||
uint32_t flags)
|
||||
uint32_t flags, bool usesLocalCoords)
|
||||
: fColor(color)
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fTextureAccess(texture, params)
|
||||
, fDistanceAdjust(distanceAdjust)
|
||||
, fFlags(flags & kLCD_DistanceFieldEffectMask){
|
||||
, fFlags(flags & kLCD_DistanceFieldEffectMask)
|
||||
, fUsesLocalCoords(usesLocalCoords) {
|
||||
SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag));
|
||||
this->initClassID<GrDistanceFieldLCDTextGeoProc>();
|
||||
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
||||
fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
|
||||
kVec2s_GrVertexAttribType));
|
||||
kVec2s_GrVertexAttribType));
|
||||
this->addTextureAccess(&fTextureAccess);
|
||||
}
|
||||
|
||||
@ -715,13 +692,6 @@ GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt,
|
||||
return SkNEW_ARGS(GrGLDistanceFieldLCDTextGeoProc, (*this, bt));
|
||||
}
|
||||
|
||||
void GrDistanceFieldLCDTextGeoProc::initBatchTracker(GrBatchTracker* bt,
|
||||
const GrPipelineInfo& init) const {
|
||||
DistanceFieldLCDBatchTracker* local = bt->cast<DistanceFieldLCDBatchTracker>();
|
||||
local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc);
|
||||
@ -751,5 +721,6 @@ GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(SkRandom* random,
|
||||
GrTest::TestMatrix(random),
|
||||
textures[texIdx], params,
|
||||
wa,
|
||||
flags);
|
||||
flags,
|
||||
random->nextBool());
|
||||
}
|
||||
|
@ -49,15 +49,16 @@ public:
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
|
||||
GrTexture* tex, const GrTextureParams& params,
|
||||
float lum, uint32_t flags) {
|
||||
float lum, uint32_t flags, bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex, params, lum,
|
||||
flags));
|
||||
flags, usesLocalCoords));
|
||||
}
|
||||
#else
|
||||
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
|
||||
GrTexture* tex, const GrTextureParams& params,
|
||||
uint32_t flags) {
|
||||
return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex, params, flags));
|
||||
uint32_t flags, bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex, params, flags,
|
||||
usesLocalCoords));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -69,7 +70,10 @@ public:
|
||||
const Attribute* inColor() const { return fInColor; }
|
||||
const Attribute* inTextureCoords() const { return fInTextureCoords; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
bool hasVertexColor() const { return SkToBool(fInColor); }
|
||||
const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
float getDistanceAdjust() const { return fDistanceAdjust; }
|
||||
#endif
|
||||
@ -82,15 +86,13 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&) const override;
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
|
||||
|
||||
private:
|
||||
GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix,
|
||||
GrTexture* texture, const GrTextureParams& params,
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
float distanceAdjust,
|
||||
#endif
|
||||
uint32_t flags);
|
||||
uint32_t flags, bool usesLocalCoords);
|
||||
|
||||
GrColor fColor;
|
||||
SkMatrix fViewMatrix;
|
||||
@ -102,6 +104,7 @@ private:
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInColor;
|
||||
const Attribute* fInTextureCoords;
|
||||
bool fUsesLocalCoords;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
|
||||
|
||||
@ -119,8 +122,9 @@ class GrDistanceFieldPathGeoProc : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix, GrTexture* tex,
|
||||
const GrTextureParams& params,
|
||||
uint32_t flags) {
|
||||
return SkNEW_ARGS(GrDistanceFieldPathGeoProc, (color, viewMatrix, tex, params, flags));
|
||||
uint32_t flags, bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(GrDistanceFieldPathGeoProc, (color, viewMatrix, tex, params, flags,
|
||||
usesLocalCoords));
|
||||
}
|
||||
|
||||
virtual ~GrDistanceFieldPathGeoProc() {}
|
||||
@ -131,8 +135,11 @@ public:
|
||||
const Attribute* inColor() const { return fInColor; }
|
||||
const Attribute* inTextureCoords() const { return fInTextureCoords; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
bool hasVertexColor() const { return SkToBool(fInColor); }
|
||||
const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
||||
uint32_t getFlags() const { return fFlags; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps& caps,
|
||||
@ -141,11 +148,10 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&) const override;
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
|
||||
|
||||
private:
|
||||
GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, GrTexture* texture,
|
||||
const GrTextureParams& params, uint32_t flags);
|
||||
const GrTextureParams& params, uint32_t flags,
|
||||
bool usesLocalCoords);
|
||||
|
||||
GrColor fColor;
|
||||
SkMatrix fViewMatrix;
|
||||
@ -154,6 +160,7 @@ private:
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInColor;
|
||||
const Attribute* fInTextureCoords;
|
||||
bool fUsesLocalCoords;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
|
||||
|
||||
@ -185,9 +192,10 @@ public:
|
||||
|
||||
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
|
||||
GrTexture* tex, const GrTextureParams& params,
|
||||
DistanceAdjust distanceAdjust, uint32_t flags) {
|
||||
DistanceAdjust distanceAdjust, uint32_t flags,
|
||||
bool usesLocalCoords) {
|
||||
return SkNEW_ARGS(GrDistanceFieldLCDTextGeoProc,
|
||||
(color, viewMatrix, tex, params, distanceAdjust, flags));
|
||||
(color, viewMatrix, tex, params, distanceAdjust, flags, usesLocalCoords));
|
||||
}
|
||||
|
||||
virtual ~GrDistanceFieldLCDTextGeoProc() {}
|
||||
@ -198,8 +206,10 @@ public:
|
||||
const Attribute* inTextureCoords() const { return fInTextureCoords; }
|
||||
DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; }
|
||||
GrColor color() const { return fColor; }
|
||||
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
|
||||
const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
||||
uint32_t getFlags() const { return fFlags; }
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps& caps,
|
||||
@ -208,12 +218,11 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps&) const override;
|
||||
|
||||
void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override;
|
||||
|
||||
private:
|
||||
GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix,
|
||||
GrTexture* texture, const GrTextureParams& params,
|
||||
DistanceAdjust wa, uint32_t flags);
|
||||
DistanceAdjust wa, uint32_t flags,
|
||||
bool usesLocalCoords);
|
||||
|
||||
GrColor fColor;
|
||||
SkMatrix fViewMatrix;
|
||||
@ -222,6 +231,7 @@ private:
|
||||
uint32_t fFlags;
|
||||
const Attribute* fInPosition;
|
||||
const Attribute* fInTextureCoords;
|
||||
bool fUsesLocalCoords;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
|
||||
|
||||
|
@ -31,28 +31,18 @@ SkMatrix GrGLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatrix,
|
||||
return combined;
|
||||
}
|
||||
|
||||
void
|
||||
GrGLPrimitiveProcessor::setupColorPassThrough(GrGLGPBuilder* pb,
|
||||
GrGPInput inputType,
|
||||
const char* outputName,
|
||||
const GrGeometryProcessor::Attribute* colorAttr,
|
||||
UniformHandle* colorUniform) {
|
||||
void GrGLPrimitiveProcessor::setupUniformColor(GrGLGPBuilder* pb,
|
||||
const char* outputName,
|
||||
UniformHandle* colorUniform) {
|
||||
GrGLFragmentBuilder* fs = pb->getFragmentShaderBuilder();
|
||||
if (kUniform_GrGPInput == inputType) {
|
||||
SkASSERT(colorUniform);
|
||||
const char* stagedLocalVarName;
|
||||
*colorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Color",
|
||||
&stagedLocalVarName);
|
||||
fs->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
|
||||
} else if (kAttribute_GrGPInput == inputType) {
|
||||
SkASSERT(colorAttr);
|
||||
pb->addPassThroughAttribute(colorAttr, outputName);
|
||||
} else if (kAllOnes_GrGPInput == inputType) {
|
||||
fs->codeAppendf("%s = vec4(1);", outputName);
|
||||
}
|
||||
SkASSERT(colorUniform);
|
||||
const char* stagedLocalVarName;
|
||||
*colorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Color",
|
||||
&stagedLocalVarName);
|
||||
fs->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
|
||||
}
|
||||
|
||||
void GrGLPrimitiveProcessor::addUniformViewMatrix(GrGLGPBuilder* pb) {
|
||||
|
@ -74,16 +74,7 @@ public:
|
||||
static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoordTransform&);
|
||||
|
||||
protected:
|
||||
/** a helper which can setup vertex, constant, or uniform color depending on inputType.
|
||||
* This function will only do the minimum required to emit the correct shader code. If
|
||||
* inputType == attribute, then colorAttr must not be NULL. Likewise, if inputType == Uniform
|
||||
* then colorUniform must not be NULL.
|
||||
*/
|
||||
void setupColorPassThrough(GrGLGPBuilder* pb,
|
||||
GrGPInput inputType,
|
||||
const char* inputName,
|
||||
const GrPrimitiveProcessor::Attribute* colorAttr,
|
||||
UniformHandle* colorUniform);
|
||||
void setupUniformColor(GrGLGPBuilder* pb, const char* outputName, UniformHandle* colorUniform);
|
||||
|
||||
const char* uViewM() const { return fViewMatrixName; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user