Index: src/gpu/effects/GrBitmapTextGeoProc.cpp |
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp |
index ad06792fb5ac2afe3c7b70727bba3f6540d82dbd..a7261c05495dce8c1ef546261c8ba208427a68b2 100644 |
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp |
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp |
@@ -15,6 +15,12 @@ |
#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&) |
@@ -22,6 +28,7 @@ |
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(); |
@@ -43,13 +50,8 @@ |
} |
// Setup pass through color |
- if (!cte.colorIgnored()) { |
- if (cte.hasVertexColor()) { |
- pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor); |
- } else { |
- this->setupUniformColor(pb, args.fOutputColor, &fColorUniform); |
- } |
- } |
+ this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, cte.inColor(), |
+ &fColorUniform); |
// Setup position |
this->setupPosition(pb, gpArgs, cte.inPosition()->fName); |
@@ -77,12 +79,12 @@ |
virtual void setData(const GrGLProgramDataManager& pdman, |
const GrPrimitiveProcessor& gp, |
const GrBatchTracker& bt) override { |
- const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>(); |
- if (btgp.color() != fColor && !btgp.hasVertexColor()) { |
+ const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); |
+ if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) { |
GrGLfloat c[4]; |
- GrColorToRGBAFloat(btgp.color(), c); |
+ GrColorToRGBAFloat(local.fColor, c); |
pdman.set4fv(fColorUniform, 1, c); |
- fColor = btgp.color(); |
+ fColor = local.fColor; |
} |
} |
@@ -97,12 +99,16 @@ |
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 |= gp.usesLocalCoords() && gp.localMatrix().hasPerspective() ? 0x1 : 0x0; |
- key |= gp.colorIgnored() ? 0x2 : 0x0; |
- key |= gp.maskFormat() << 3; |
- b->add32(key); |
+ 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); |
} |
private: |
@@ -116,18 +122,15 @@ |
GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, |
const GrTextureParams& params, GrMaskFormat format, |
- const SkMatrix& localMatrix, bool usesLocalCoords) |
+ const SkMatrix& localMatrix) |
: 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)); |
@@ -147,6 +150,13 @@ |
GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt, |
const GrGLSLCaps& caps) const { |
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; |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -187,5 +197,5 @@ |
} |
return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params, |
- format, GrTest::TestMatrix(random), random->nextBool()); |
-} |
+ format, GrTest::TestMatrix(random)); |
+} |