| Index: src/gpu/effects/GrBitmapTextGeoProc.cpp
|
| diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
|
| index 313326561cda8a3aeb3220dd208d1bcd59407f16..a699b0410ea0031197513f67c168f9fc53040e40 100644
|
| --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
|
| +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
|
| @@ -47,17 +47,26 @@ public:
|
| this->addUniformViewMatrix(pb);
|
|
|
| // Setup position
|
| - SetupPosition(vsBuilder, gpArgs, cte.inPosition()->fName,
|
| - cte.viewMatrix(), this->uViewM());
|
| + SetupPosition(vsBuilder, gpArgs, cte.inPosition()->fName, cte.viewMatrix(), this->uViewM());
|
|
|
| // emit transforms
|
| this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->fName,
|
| cte.localMatrix(), args.fTransformsIn, args.fTransformsOut);
|
|
|
| GrGLGPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
|
| - fsBuilder->codeAppendf("%s = ", args.fOutputCoverage);
|
| - fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_GrSLType);
|
| - fsBuilder->codeAppend(";");
|
| + if (cte.maskFormat() == kARGB_GrMaskFormat) {
|
| + fsBuilder->codeAppendf("%s = ", args.fOutputColor);
|
| + fsBuilder->appendTextureLookupAndModulate(args.fOutputColor,
|
| + args.fSamplers[0],
|
| + v.fsIn(),
|
| + kVec2f_GrSLType);
|
| + fsBuilder->codeAppend(";");
|
| + fsBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
|
| + } else {
|
| + fsBuilder->codeAppendf("%s = ", args.fOutputCoverage);
|
| + fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_GrSLType);
|
| + fsBuilder->codeAppend(";");
|
| + }
|
| }
|
|
|
| virtual void setData(const GrGLProgramDataManager& pdman,
|
| @@ -86,7 +95,8 @@ public:
|
| uint32_t key = 0;
|
| key |= SkToBool(gp.inColor()) ? 0x1 : 0x0;
|
| key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0x2 : 0x0;
|
| - key |= ComputePosKey(gp.viewMatrix()) << 2;
|
| + key |= gp.maskFormat() == kARGB_GrMaskFormat ? 0x4 : 0x0;
|
| + key |= ComputePosKey(gp.viewMatrix()) << 3;
|
| b->add32(local.fInputColorType << 16 | key);
|
| }
|
|
|
| @@ -100,19 +110,22 @@ private:
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture,
|
| - const GrTextureParams& params, bool useColorAttrib,
|
| + const GrTextureParams& params, GrMaskFormat format,
|
| bool opaqueVertexColors, const SkMatrix& localMatrix)
|
| : INHERITED(color, SkMatrix::I(), localMatrix, opaqueVertexColors)
|
| , fTextureAccess(texture, params)
|
| - , fInColor(NULL) {
|
| + , fInColor(NULL)
|
| + , fMaskFormat(format) {
|
| this->initClassID<GrBitmapTextGeoProc>();
|
| fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
| - if (useColorAttrib) {
|
| +
|
| + bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat;
|
| + if (hasVertexColor) {
|
| fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
|
| this->setHasVertexColor();
|
| }
|
| fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
|
| - kVec2f_GrVertexAttribType));
|
| + kVec2f_GrVertexAttribType));
|
| this->addTextureAccess(&fTextureAccess);
|
| }
|
|
|
| @@ -121,15 +134,25 @@ bool GrBitmapTextGeoProc::onIsEqual(const GrGeometryProcessor& other) const {
|
| return SkToBool(this->inColor()) == SkToBool(gp.inColor());
|
| }
|
|
|
| +void GrBitmapTextGeoProc::onGetInvariantOutputColor(GrInitInvariantOutput* out) const {
|
| + if (kARGB_GrMaskFormat == fMaskFormat) {
|
| + out->setUnknownFourComponents();
|
| + }
|
| +}
|
| +
|
| void GrBitmapTextGeoProc::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
|
| - if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
|
| - out->setUnknownSingleComponent();
|
| - } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
|
| - out->setUnknownOpaqueFourComponents();
|
| - out->setUsingLCDCoverage();
|
| + if (kARGB_GrMaskFormat != fMaskFormat) {
|
| + if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
|
| + out->setUnknownSingleComponent();
|
| + } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
|
| + out->setUnknownOpaqueFourComponents();
|
| + out->setUsingLCDCoverage();
|
| + } else {
|
| + out->setUnknownFourComponents();
|
| + out->setUsingLCDCoverage();
|
| + }
|
| } else {
|
| - out->setUnknownFourComponents();
|
| - out->setUsingLCDCoverage();
|
| + out->setKnownSingleComponent(0xff);
|
| }
|
| }
|
|
|
| @@ -185,7 +208,22 @@ GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random,
|
| GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBilerp_FilterMode :
|
| GrTextureParams::kNone_FilterMode);
|
|
|
| + GrMaskFormat format;
|
| + switch (random->nextULessThan(3)) {
|
| + default:
|
| + SkFAIL("Incomplete enum\n");
|
| + case 0:
|
| + format = kA8_GrMaskFormat;
|
| + break;
|
| + case 1:
|
| + format = kA565_GrMaskFormat;
|
| + break;
|
| + case 2:
|
| + format = kARGB_GrMaskFormat;
|
| + break;
|
| + }
|
| +
|
| return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params,
|
| - random->nextBool(), random->nextBool(),
|
| + format, random->nextBool(),
|
| GrProcessorUnitTest::TestMatrix(random));
|
| }
|
|
|