Index: src/gpu/effects/GrBitmapTextGeoProc.cpp |
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp |
index a7261c05495dce8c1ef546261c8ba208427a68b2..ad06792fb5ac2afe3c7b70727bba3f6540d82dbd 100644 |
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp |
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp |
@@ -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()); |
} |