joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 1 | #include "GrPathProcessor.h" |
| 2 | |
| 3 | #include "gl/GrGLPathProcessor.h" |
| 4 | #include "gl/GrGLGpu.h" |
| 5 | |
| 6 | GrPathProcessor::GrPathProcessor(GrColor color, |
| 7 | const SkMatrix& viewMatrix, |
| 8 | const SkMatrix& localMatrix) |
| 9 | : INHERITED(viewMatrix, localMatrix, true) |
| 10 | , fColor(color) { |
| 11 | this->initClassID<GrPathProcessor>(); |
| 12 | } |
| 13 | |
| 14 | void GrPathProcessor::getInvariantOutputColor(GrInitInvariantOutput* out) const { |
| 15 | out->setKnownFourComponents(fColor); |
| 16 | } |
| 17 | |
| 18 | void GrPathProcessor::getInvariantOutputCoverage(GrInitInvariantOutput* out) const { |
| 19 | out->setKnownSingleComponent(0xff); |
| 20 | } |
| 21 | |
| 22 | void GrPathProcessor::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const { |
| 23 | PathBatchTracker* local = bt->cast<PathBatchTracker>(); |
| 24 | if (init.fColorIgnored) { |
| 25 | local->fInputColorType = kIgnored_GrGPInput; |
| 26 | local->fColor = GrColor_ILLEGAL; |
| 27 | } else { |
| 28 | local->fInputColorType = kUniform_GrGPInput; |
| 29 | local->fColor = GrColor_ILLEGAL == init.fOverrideColor ? this->color() : |
| 30 | init.fOverrideColor; |
| 31 | } |
| 32 | |
| 33 | local->fInputCoverageType = init.fCoverageIgnored ? kIgnored_GrGPInput : kAllOnes_GrGPInput; |
| 34 | local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 35 | } |
| 36 | |
| 37 | bool GrPathProcessor::canMakeEqual(const GrBatchTracker& m, |
| 38 | const GrPrimitiveProcessor& that, |
| 39 | const GrBatchTracker& t) const { |
| 40 | if (this->classID() != that.classID() || !this->hasSameTextureAccesses(that)) { |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | if (!this->viewMatrix().cheapEqualTo(that.viewMatrix())) { |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | const PathBatchTracker& mine = m.cast<PathBatchTracker>(); |
| 49 | const PathBatchTracker& theirs = t.cast<PathBatchTracker>(); |
| 50 | return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 51 | that, theirs.fUsesLocalCoords) && |
| 52 | CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 53 | theirs.fInputColorType, theirs.fColor) && |
| 54 | CanCombineOutput(mine.fInputCoverageType, 0xff, |
| 55 | theirs.fInputCoverageType, 0xff); |
| 56 | } |
| 57 | |
| 58 | void GrPathProcessor::getGLProcessorKey(const GrBatchTracker& bt, |
| 59 | const GrGLCaps& caps, |
| 60 | GrProcessorKeyBuilder* b) const { |
| 61 | GrGLPathProcessor::GenKey(*this, bt, caps, b); |
| 62 | } |
| 63 | |
| 64 | GrGLPrimitiveProcessor* GrPathProcessor::createGLInstance(const GrBatchTracker& bt, |
| 65 | const GrGLCaps& caps) const { |
| 66 | SkASSERT(caps.nvprSupport() != GrGLCaps::kNone_NvprSupport); |
| 67 | if (caps.nvprSupport() == GrGLCaps::kLegacy_NvprSupport) { |
| 68 | return SkNEW_ARGS(GrGLLegacyPathProcessor, (*this, bt, |
| 69 | caps.maxFixedFunctionTextureCoords())); |
| 70 | } else { |
| 71 | return SkNEW_ARGS(GrGLNormalPathProcessor, (*this, bt)); |
| 72 | } |
| 73 | } |