Rename CustomCoordTextureEffect to GrBitmapTextGeoProc.
authoregdaniel <egdaniel@google.com>
Tue, 9 Dec 2014 18:35:58 +0000 (10:35 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 9 Dec 2014 18:35:58 +0000 (10:35 -0800)
Also add in explicit set for LCD text in invariantOutput.

BUG=skia:

Review URL: https://codereview.chromium.org/786293002

gyp/gpu.gypi
include/gpu/GrInvariantOutput.h
src/gpu/GrBitmapTextContext.cpp
src/gpu/GrProcOptInfo.h
src/gpu/effects/GrBitmapTextGeoProc.cpp [moved from src/gpu/effects/GrCustomCoordsTextureEffect.cpp with 65% similarity]
src/gpu/effects/GrBitmapTextGeoProc.h [moved from src/gpu/effects/GrCustomCoordsTextureEffect.h with 77% similarity]
src/gpu/effects/GrDistanceFieldTextureEffect.cpp

index 09b7dbe..32603fe 100644 (file)
       '<(skia_src_path)/gpu/effects/GrConvexPolyEffect.h',
       '<(skia_src_path)/gpu/effects/GrBicubicEffect.cpp',
       '<(skia_src_path)/gpu/effects/GrBicubicEffect.h',
-      '<(skia_src_path)/gpu/effects/GrCustomCoordsTextureEffect.cpp',
-      '<(skia_src_path)/gpu/effects/GrCustomCoordsTextureEffect.h',
+      '<(skia_src_path)/gpu/effects/GrBitmapTextGeoProc.cpp',
+      '<(skia_src_path)/gpu/effects/GrBitmapTextGeoProc.h',
       '<(skia_src_path)/gpu/effects/GrDashingEffect.cpp',
       '<(skia_src_path)/gpu/effects/GrDashingEffect.h',
       '<(skia_src_path)/gpu/effects/GrDistanceFieldTextureEffect.cpp',
index 4f61999..1d3eda1 100644 (file)
 class GrInvariantOutput {
 public:
     GrInvariantOutput(GrColor color, GrColorComponentFlags flags, bool isSingleComponent)
-        : fColor(color), fValidFlags(flags), fIsSingleComponent(isSingleComponent),
-          fNonMulStageFound(false), fWillUseInputColor(true) {}
+        : fColor(color)
+        , fValidFlags(flags)
+        , fIsSingleComponent(isSingleComponent)
+        , fNonMulStageFound(false)
+        , fWillUseInputColor(true)
+        , fIsLCDCoverage(false) {}
 
     virtual ~GrInvariantOutput() {}
 
@@ -92,6 +96,12 @@ public:
         }
     }
 
+    // Temporary setter to handle LCD text correctly until we improve texture pixel config queries
+    // and thus can rely solely on number of coverage components for RGA vs single channel coverage.
+    void setUsingLCDCoverage() {
+        fIsLCDCoverage = true;
+    }
+
     GrColor color() const { return fColor; }
     uint8_t validFlags() const { return fValidFlags; }
 
@@ -101,13 +111,6 @@ public:
      */
     SkDEBUGCODE(void validate() const;)
 
-protected:
-    GrColor fColor;
-    uint32_t fValidFlags;
-    bool fIsSingleComponent;
-    bool fNonMulStageFound;
-    bool fWillUseInputColor;
-
 private:
     friend class GrProcOptInfo;
 
@@ -149,11 +152,21 @@ private:
 
     void resetNonMulStageFound() { fNonMulStageFound = false; }
 
+    bool isLCDCoverage() const { return fIsLCDCoverage; }
+
     SkDEBUGCODE(bool colorComponentsAllEqual() const;)
     /**
      * If alpha is valid, check that any valid R,G,B values are <= A
      */
     SkDEBUGCODE(bool validPreMulColor() const;)
+
+    GrColor fColor;
+    uint32_t fValidFlags;
+    bool fIsSingleComponent;
+    bool fNonMulStageFound;
+    bool fWillUseInputColor;
+    bool fIsLCDCoverage; // Temorary data member until texture pixel configs are updated
+
 };
 
 #endif
index 48054f4..9816af9 100755 (executable)
@@ -27,7 +27,7 @@
 #include "SkStrokeRec.h"
 #include "SkTextMapStateProc.h"
 
-#include "effects/GrCustomCoordsTextureEffect.h"
+#include "effects/GrBitmapTextGeoProc.h"
 #include "effects/GrSimpleTextureEffect.h"
 
 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
@@ -547,10 +547,10 @@ void GrBitmapTextContext::flush() {
         } else {
             uint32_t textureUniqueID = fCurrTexture->getUniqueID();
             if (textureUniqueID != fEffectTextureUniqueID) {
-                bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat;
-                fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture,
-                                                                                   params,
-                                                                                   hasColor));
+                bool useColorAttrib = kA8_GrMaskFormat == fCurrMaskFormat;
+                fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(fCurrTexture,
+                                                                           params,
+                                                                           useColorAttrib));
                 fEffectTextureUniqueID = textureUniqueID;
             }
             drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
index bb657d2..ceccf32 100644 (file)
@@ -37,6 +37,12 @@ public:
     bool isOpaque() const { return fInOut.isOpaque(); }
     bool isSingleComponent() const { return fInOut.isSingleComponent(); }
 
+    // TODO: Once texture pixel configs quaries are updated, we no longer need this function.
+    // For now this function will correctly tell us if we are using LCD text or not and should only
+    // be called when looking at the coverage output.
+    bool isFourChannelOutput() const { return !fInOut.isSingleComponent() &&
+                                               fInOut.isLCDCoverage(); }
+
     GrColor color() const { return fInOut.color(); }
     uint8_t validFlags() const { return fInOut.validFlags(); }
 
similarity index 65%
rename from src/gpu/effects/GrCustomCoordsTextureEffect.cpp
rename to src/gpu/effects/GrBitmapTextGeoProc.cpp
index a132e86..6eaaf30 100644 (file)
@@ -5,7 +5,7 @@
  * found in the LICENSE file.
  */
 
-#include "GrCustomCoordsTextureEffect.h"
+#include "GrBitmapTextGeoProc.h"
 #include "GrInvariantOutput.h"
 #include "GrTexture.h"
 #include "gl/GrGLProcessor.h"
 #include "gl/GrGLGeometryProcessor.h"
 #include "gl/builders/GrGLProgramBuilder.h"
 
-class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor {
+class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor {
 public:
-    GrGLCustomCoordsTextureEffect(const GrGeometryProcessor&,
-                                  const GrBatchTracker&) {}
+    GrGLBitmapTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&) {}
 
     virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
-        const GrCustomCoordsTextureEffect& cte =
-                args.fGP.cast<GrCustomCoordsTextureEffect>();
+        const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
 
         GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
 
@@ -55,7 +53,7 @@ public:
                               const GrBatchTracker&,
                               const GrGLCaps&,
                               GrProcessorKeyBuilder* b) {
-        const GrCustomCoordsTextureEffect& gp = proc.cast<GrCustomCoordsTextureEffect>();
+        const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
 
         b->add32(SkToBool(gp.inColor()));
     }
@@ -67,13 +65,12 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////////
 
-GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture,
-                                                         const GrTextureParams& params,
-                                                         bool hasColor)
+GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrTexture* texture, const GrTextureParams& params,
+                                         bool useColorAttrib)
     : fTextureAccess(texture, params), fInColor(NULL) {
-    this->initClassID<GrCustomCoordsTextureEffect>();
+    this->initClassID<GrBitmapTextGeoProc>();
     fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
-    if (hasColor) {
+    if (useColorAttrib) {
         fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVertexAttribType));
         this->setHasVertexColor();
     }
@@ -82,39 +79,41 @@ GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture,
     this->addTextureAccess(&fTextureAccess);
 }
 
-bool GrCustomCoordsTextureEffect::onIsEqual(const GrGeometryProcessor& other) const {
-    const GrCustomCoordsTextureEffect& gp = other.cast<GrCustomCoordsTextureEffect>();
+bool GrBitmapTextGeoProc::onIsEqual(const GrGeometryProcessor& other) const {
+    const GrBitmapTextGeoProc& gp = other.cast<GrBitmapTextGeoProc>();
     return SkToBool(this->inColor()) == SkToBool(gp.inColor());
 }
 
-void GrCustomCoordsTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
+void GrBitmapTextGeoProc::onComputeInvariantOutput(GrInvariantOutput* inout) const {
     if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
         inout->mulByUnknownAlpha();
     } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
         inout->mulByUnknownOpaqueColor();
+        inout->setUsingLCDCoverage();
     } else {
         inout->mulByUnknownColor();
+        inout->setUsingLCDCoverage();
     }
 }
 
-void GrCustomCoordsTextureEffect::getGLProcessorKey(const GrBatchTracker& bt,
-                                                    const GrGLCaps& caps,
-                                                    GrProcessorKeyBuilder* b) const {
-    GrGLCustomCoordsTextureEffect::GenKey(*this, bt, caps, b);
+void GrBitmapTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt,
+                                            const GrGLCaps& caps,
+                                            GrProcessorKeyBuilder* b) const {
+    GrGLBitmapTextGeoProc::GenKey(*this, bt, caps, b);
 }
 
 GrGLGeometryProcessor*
-GrCustomCoordsTextureEffect::createGLInstance(const GrBatchTracker& bt) const {
-    return SkNEW_ARGS(GrGLCustomCoordsTextureEffect, (*this, bt));
+GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt) const {
+    return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt));
 }
 ///////////////////////////////////////////////////////////////////////////////
 
-GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCustomCoordsTextureEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
 
-GrGeometryProcessor* GrCustomCoordsTextureEffect::TestCreate(SkRandom* random,
-                                                             GrContext*,
-                                                             const GrDrawTargetCaps&,
-                                                             GrTexture* textures[]) {
+GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random,
+                                                     GrContext*,
+                                                     const GrDrawTargetCaps&,
+                                                     GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
                                       GrProcessorUnitTest::kAlphaTextureIdx;
     static const SkShader::TileMode kTileModes[] = {
@@ -129,5 +128,5 @@ GrGeometryProcessor* GrCustomCoordsTextureEffect::TestCreate(SkRandom* random,
     GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBilerp_FilterMode :
                                                            GrTextureParams::kNone_FilterMode);
 
-    return GrCustomCoordsTextureEffect::Create(textures[texIdx], params, random->nextBool());
+    return GrBitmapTextGeoProc::Create(textures[texIdx], params, random->nextBool());
 }
similarity index 77%
rename from src/gpu/effects/GrCustomCoordsTextureEffect.h
rename to src/gpu/effects/GrBitmapTextGeoProc.h
index a2b62ed..ecbf4f9 100644 (file)
@@ -5,13 +5,13 @@
  * found in the LICENSE file.
  */
 
-#ifndef GrCustomCoordsTextureEffect_DEFINED
-#define GrCustomCoordsTextureEffect_DEFINED
+#ifndef GrBitmapTextGeoProc_DEFINED
+#define GrBitmapTextGeoProc_DEFINED
 
 #include "GrProcessor.h"
 #include "GrGeometryProcessor.h"
 
-class GrGLCustomCoordsTextureEffect;
+class GrGLBitmapTextGeoProc;
 class GrInvariantOutput;
 
 /**
@@ -19,13 +19,14 @@ class GrInvariantOutput;
  * It allows explicit specification of the filtering and wrap modes (GrTextureParams). The input
  * coords are a custom attribute.
  */
-class GrCustomCoordsTextureEffect : public GrGeometryProcessor {
+class GrBitmapTextGeoProc : public GrGeometryProcessor {
 public:
-    static GrGeometryProcessor* Create(GrTexture* tex, const GrTextureParams& p, bool hasColor) {
-        return SkNEW_ARGS(GrCustomCoordsTextureEffect, (tex, p, hasColor));
+    static GrGeometryProcessor* Create(GrTexture* tex, const GrTextureParams& p,
+                                       bool useColorAttrib) {
+        return SkNEW_ARGS(GrBitmapTextGeoProc, (tex, p, useColorAttrib));
     }
 
-    virtual ~GrCustomCoordsTextureEffect() {}
+    virtual ~GrBitmapTextGeoProc() {}
 
     virtual const char* name() const SK_OVERRIDE { return "Texture"; }
 
@@ -40,7 +41,7 @@ public:
     virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
 
 private:
-    GrCustomCoordsTextureEffect(GrTexture* texture, const GrTextureParams& params, bool hasColor);
+    GrBitmapTextGeoProc(GrTexture* texture, const GrTextureParams& params, bool useColorAttrib);
 
     virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
 
index 0570305..eff2ee5 100755 (executable)
@@ -659,6 +659,7 @@ bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrGeometryProcessor& other
 
 void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
     inout->mulByUnknownColor();
+    inout->setUsingLCDCoverage();
 }
 
 void GrDistanceFieldLCDTextureEffect::getGLProcessorKey(const GrBatchTracker& bt,