Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrPipeline.h" | 8 #include "GrPipeline.h" |
| 9 | 9 |
| 10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 // GrPipelineBuilder's coverageProcInfo (like color above) to set this initi al information. | 80 // GrPipelineBuilder's coverageProcInfo (like color above) to set this initi al information. |
| 81 int firstCoverageStageIdx = 0; | 81 int firstCoverageStageIdx = 0; |
| 82 | 82 |
| 83 this->adjustProgramFromOptimizations(pipelineBuilder, optFlags, colorPOI, co veragePOI, | 83 this->adjustProgramFromOptimizations(pipelineBuilder, optFlags, colorPOI, co veragePOI, |
| 84 &firstColorStageIdx, &firstCoverageStag eIdx); | 84 &firstColorStageIdx, &firstCoverageStag eIdx); |
| 85 | 85 |
| 86 bool usesLocalCoords = false; | 86 bool usesLocalCoords = false; |
| 87 | 87 |
| 88 // Copy Stages from PipelineBuilder to Pipeline | 88 // Copy Stages from PipelineBuilder to Pipeline |
| 89 for (int i = firstColorStageIdx; i < pipelineBuilder.numColorFragmentStages( ); ++i) { | 89 for (int i = firstColorStageIdx; i < pipelineBuilder.numColorFragmentStages( ); ++i) { |
| 90 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | 90 const GrFragmentStage& fps = pipelineBuilder.fColorStages[i]; |
| 91 GrPendingFragmentStage, | 91 const GrFragmentProcessor* fp = fps.processor(); |
|
bsalomon
2015/08/05 17:22:12
does this all work for the nested case?
joshualitt
2015/08/05 17:46:21
good catch
| |
| 92 (pipelineBuilder.fColorStages[i])); | 92 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, GrPendingFragmentStage, (fps)); |
| 93 usesLocalCoords = usesLocalCoords || | 93 usesLocalCoords = usesLocalCoords || fp->usesLocalCoords(); |
| 94 pipelineBuilder.fColorStages[i].processor()->usesLocal Coords(); | 94 for (int t = 0; t < fp->numTransforms(); t++) { |
| 95 fCoordTransforms.push_back(&fp->coordTransform(t)); | |
| 96 } | |
| 95 } | 97 } |
| 96 | 98 |
| 97 fNumColorStages = fFragmentStages.count(); | 99 fNumColorStages = fFragmentStages.count(); |
| 98 for (int i = firstCoverageStageIdx; i < pipelineBuilder.numCoverageFragmentS tages(); ++i) { | 100 for (int i = firstCoverageStageIdx; i < pipelineBuilder.numCoverageFragmentS tages(); ++i) { |
| 99 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | 101 const GrFragmentStage& fps = pipelineBuilder.fCoverageStages[i]; |
| 100 GrPendingFragmentStage, | 102 const GrFragmentProcessor* fp = fps.processor(); |
| 101 (pipelineBuilder.fCoverageStages[i])); | 103 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, GrPendingFragmentStage, (fps)); |
| 102 usesLocalCoords = usesLocalCoords || | 104 usesLocalCoords = usesLocalCoords || fp->usesLocalCoords(); |
| 103 pipelineBuilder.fCoverageStages[i].processor()->usesLo calCoords(); | 105 for (int t = 0; t < fp->numTransforms(); t++) { |
| 106 fCoordTransforms.push_back(&fp->coordTransform(t)); | |
| 107 } | |
| 104 } | 108 } |
| 105 | 109 |
| 106 // Setup info we need to pass to GrPrimitiveProcessors that are used with th is GrPipeline. | 110 // Setup info we need to pass to GrPrimitiveProcessors that are used with th is GrPipeline. |
| 107 fInfoForPrimitiveProcessor.fFlags = 0; | 111 fInfoForPrimitiveProcessor.fFlags = 0; |
| 108 if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) { | 112 if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) { |
| 109 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsColor_GrPipel ineInfoFlag; | 113 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsColor_GrPipel ineInfoFlag; |
| 110 } | 114 } |
| 111 if (GrColor_ILLEGAL != overrideColor) { | 115 if (GrColor_ILLEGAL != overrideColor) { |
| 112 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kUseOverrideColor_G rPipelineInfoFlag; | 116 fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kUseOverrideColor_G rPipelineInfoFlag; |
| 113 fInfoForPrimitiveProcessor.fOverrideColor = overrideColor; | 117 fInfoForPrimitiveProcessor.fOverrideColor = overrideColor; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 *firstCoverageStageIdx = pipelineBuilder.numCoverageFragmentStages(); | 149 *firstCoverageStageIdx = pipelineBuilder.numCoverageFragmentStages(); |
| 146 } else { | 150 } else { |
| 147 if (coveragePOI.readsFragPosition()) { | 151 if (coveragePOI.readsFragPosition()) { |
| 148 fReadsFragPosition = true; | 152 fReadsFragPosition = true; |
| 149 } | 153 } |
| 150 } | 154 } |
| 151 } | 155 } |
| 152 | 156 |
| 153 //////////////////////////////////////////////////////////////////////////////// | 157 //////////////////////////////////////////////////////////////////////////////// |
| 154 | 158 |
| 155 bool GrPipeline::isEqual(const GrPipeline& that) const { | 159 bool GrPipeline::isEqual(const GrPipeline& that, bool ignoreCoordTransforms) con st { |
| 156 // If we point to the same pipeline, then we are necessarily equal | 160 // If we point to the same pipeline, then we are necessarily equal |
| 157 if (this == &that) { | 161 if (this == &that) { |
| 158 return true; | 162 return true; |
| 159 } | 163 } |
| 160 | 164 |
| 161 if (this->getRenderTarget() != that.getRenderTarget() || | 165 if (this->getRenderTarget() != that.getRenderTarget() || |
| 162 this->fFragmentStages.count() != that.fFragmentStages.count() || | 166 this->fFragmentStages.count() != that.fFragmentStages.count() || |
| 163 this->fNumColorStages != that.fNumColorStages || | 167 this->fNumColorStages != that.fNumColorStages || |
| 164 this->fScissorState != that.fScissorState || | 168 this->fScissorState != that.fScissorState || |
| 165 this->fFlags != that.fFlags || | 169 this->fFlags != that.fFlags || |
| 166 this->fStencilSettings != that.fStencilSettings || | 170 this->fStencilSettings != that.fStencilSettings || |
| 167 this->fDrawFace != that.fDrawFace) { | 171 this->fDrawFace != that.fDrawFace) { |
| 168 return false; | 172 return false; |
| 169 } | 173 } |
| 170 | 174 |
| 171 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) { | 175 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) { |
| 172 return false; | 176 return false; |
| 173 } | 177 } |
| 174 | 178 |
| 175 // The program desc comparison should have already assured that the stage co unts match. | |
| 176 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); | |
| 177 for (int i = 0; i < this->numFragmentStages(); i++) { | 179 for (int i = 0; i < this->numFragmentStages(); i++) { |
| 178 | 180 if (!this->getFragmentStage(i).processor()->isEqual(*that.getFragmentSta ge(i).processor(), |
| 179 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { | 181 ignoreCoordTransform s)) { |
| 180 return false; | 182 return false; |
| 181 } | 183 } |
| 182 } | 184 } |
| 183 return true; | 185 return true; |
| 184 } | 186 } |
| 185 | 187 |
| OLD | NEW |