| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrGeometryProcessor.h" | 8 #include "GrGeometryProcessor.h" |
| 9 | 9 |
| 10 #include "gl/GrGLGeometryProcessor.h" | 10 #include "gl/GrGLGeometryProcessor.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 fs->codeAppendf("%s = vec4(1);", outputName); | 55 fs->codeAppendf("%s = vec4(1);", outputName); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 59 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 60 | 60 |
| 61 struct PathBatchTracker { | 61 struct PathBatchTracker { |
| 62 GrGPInput fInputColorType; | 62 GrGPInput fInputColorType; |
| 63 GrGPInput fInputCoverageType; | 63 GrGPInput fInputCoverageType; |
| 64 GrColor fColor; | 64 GrColor fColor; |
| 65 bool fUsesLocalCoords; |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 class GrGLPathProcessor : public GrGLGeometryProcessor { | 68 class GrGLPathProcessor : public GrGLGeometryProcessor { |
| 68 public: | 69 public: |
| 69 GrGLPathProcessor(const GrPathProcessor&, const GrBatchTracker&) | 70 GrGLPathProcessor(const GrPathProcessor&, const GrBatchTracker&) |
| 70 : fColor(GrColor_ILLEGAL) {} | 71 : fColor(GrColor_ILLEGAL) {} |
| 71 | 72 |
| 72 void emitCode(const EmitArgs& args) SK_OVERRIDE { | 73 void emitCode(const EmitArgs& args) SK_OVERRIDE { |
| 73 GrGLGPBuilder* pb = args.fPB; | 74 GrGLGPBuilder* pb = args.fPB; |
| 74 GrGLGPFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder(); | 75 GrGLGPFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 112 } |
| 112 } | 113 } |
| 113 | 114 |
| 114 private: | 115 private: |
| 115 UniformHandle fColorUniform; | 116 UniformHandle fColorUniform; |
| 116 GrColor fColor; | 117 GrColor fColor; |
| 117 | 118 |
| 118 typedef GrGLGeometryProcessor INHERITED; | 119 typedef GrGLGeometryProcessor INHERITED; |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 GrPathProcessor::GrPathProcessor(GrColor color) : fColor(color) { | 122 GrPathProcessor::GrPathProcessor(GrColor color, const SkMatrix& localMatrix) |
| 123 : INHERITED(localMatrix) |
| 124 , fColor(color) { |
| 122 this->initClassID<GrPathProcessor>(); | 125 this->initClassID<GrPathProcessor>(); |
| 123 } | 126 } |
| 124 | 127 |
| 125 void GrPathProcessor::getInvariantOutputColor(GrInitInvariantOutput* out) const
{ | 128 void GrPathProcessor::getInvariantOutputColor(GrInitInvariantOutput* out) const
{ |
| 126 out->setKnownFourComponents(fColor); | 129 out->setKnownFourComponents(fColor); |
| 127 } | 130 } |
| 128 | 131 |
| 129 void GrPathProcessor::getInvariantOutputCoverage(GrInitInvariantOutput* out) con
st { | 132 void GrPathProcessor::getInvariantOutputCoverage(GrInitInvariantOutput* out) con
st { |
| 130 out->setKnownSingleComponent(0xff); | 133 out->setKnownSingleComponent(0xff); |
| 131 } | 134 } |
| 132 | 135 |
| 133 void GrPathProcessor::initBatchTracker(GrBatchTracker* bt, const InitBT& init) c
onst { | 136 void GrPathProcessor::initBatchTracker(GrBatchTracker* bt, const InitBT& init) c
onst { |
| 134 PathBatchTracker* local = bt->cast<PathBatchTracker>(); | 137 PathBatchTracker* local = bt->cast<PathBatchTracker>(); |
| 135 if (init.fColorIgnored) { | 138 if (init.fColorIgnored) { |
| 136 local->fInputColorType = kIgnored_GrGPInput; | 139 local->fInputColorType = kIgnored_GrGPInput; |
| 137 local->fColor = GrColor_ILLEGAL; | 140 local->fColor = GrColor_ILLEGAL; |
| 138 } else { | 141 } else { |
| 139 local->fInputColorType = kUniform_GrGPInput; | 142 local->fInputColorType = kUniform_GrGPInput; |
| 140 local->fColor = GrColor_ILLEGAL == init.fOverrideColor ? this->color() : | 143 local->fColor = GrColor_ILLEGAL == init.fOverrideColor ? this->color() : |
| 141 init.fOverrideC
olor; | 144 init.fOverrideC
olor; |
| 142 } | 145 } |
| 143 | 146 |
| 144 local->fInputCoverageType = init.fCoverageIgnored ? kIgnored_GrGPInput : kAl
lOnes_GrGPInput; | 147 local->fInputCoverageType = init.fCoverageIgnored ? kIgnored_GrGPInput : kAl
lOnes_GrGPInput; |
| 148 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 145 } | 149 } |
| 146 | 150 |
| 147 bool GrPathProcessor::canMakeEqual(const GrBatchTracker& m, | 151 bool GrPathProcessor::canMakeEqual(const GrBatchTracker& m, |
| 148 const GrPrimitiveProcessor& that, | 152 const GrPrimitiveProcessor& that, |
| 149 const GrBatchTracker& t) const { | 153 const GrBatchTracker& t) const { |
| 150 if (this->classID() != that.classID() || !this->hasSameTextureAccesses(that)
) { | 154 if (this->classID() != that.classID() || !this->hasSameTextureAccesses(that)
) { |
| 151 return false; | 155 return false; |
| 152 } | 156 } |
| 153 | 157 |
| 154 const PathBatchTracker& mine = m.cast<PathBatchTracker>(); | 158 const PathBatchTracker& mine = m.cast<PathBatchTracker>(); |
| 155 const PathBatchTracker& theirs = t.cast<PathBatchTracker>(); | 159 const PathBatchTracker& theirs = t.cast<PathBatchTracker>(); |
| 156 return CanCombineOutput(mine.fInputColorType, mine.fColor, | 160 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 161 that, theirs.fUsesLocalCoords) && |
| 162 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 157 theirs.fInputColorType, theirs.fColor) && | 163 theirs.fInputColorType, theirs.fColor) && |
| 158 CanCombineOutput(mine.fInputCoverageType, 0xff, | 164 CanCombineOutput(mine.fInputCoverageType, 0xff, |
| 159 theirs.fInputCoverageType, 0xff); | 165 theirs.fInputCoverageType, 0xff); |
| 160 } | 166 } |
| 161 | 167 |
| 162 void GrPathProcessor::getGLProcessorKey(const GrBatchTracker& bt, | 168 void GrPathProcessor::getGLProcessorKey(const GrBatchTracker& bt, |
| 163 const GrGLCaps& caps, | 169 const GrGLCaps& caps, |
| 164 GrProcessorKeyBuilder* b) const { | 170 GrProcessorKeyBuilder* b) const { |
| 165 GrGLPathProcessor::GenKey(*this, bt, caps, b); | 171 GrGLPathProcessor::GenKey(*this, bt, caps, b); |
| 166 } | 172 } |
| 167 | 173 |
| 168 GrGLGeometryProcessor* GrPathProcessor::createGLInstance(const GrBatchTracker& b
t) const { | 174 GrGLGeometryProcessor* GrPathProcessor::createGLInstance(const GrBatchTracker& b
t) const { |
| 169 return SkNEW_ARGS(GrGLPathProcessor, (*this, bt)); | 175 return SkNEW_ARGS(GrGLPathProcessor, (*this, bt)); |
| 170 } | 176 } |
| OLD | NEW |