| 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 "GrPipelineBuilder.h" | 8 #include "GrPipelineBuilder.h" |
| 9 | 9 |
| 10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
| 11 #include "GrBlend.h" | 11 #include "GrBlend.h" |
| 12 #include "GrPaint.h" | 12 #include "GrPaint.h" |
| 13 #include "GrPipeline.h" | 13 #include "GrPipeline.h" |
| 14 #include "GrProcOptInfo.h" | 14 #include "GrProcOptInfo.h" |
| 15 #include "GrXferProcessor.h" | 15 #include "GrXferProcessor.h" |
| 16 #include "effects/GrPorterDuffXferProcessor.h" | 16 #include "effects/GrPorterDuffXferProcessor.h" |
| 17 | 17 |
| 18 GrPipelineBuilder::GrPipelineBuilder() | 18 GrPipelineBuilder::GrPipelineBuilder() |
| 19 : fFlags(0x0) | 19 : fProcDataManager(SkNEW(GrProcessorDataManager)) |
| 20 , fFlags(0x0) |
| 20 , fDrawFace(kBoth_DrawFace) | 21 , fDrawFace(kBoth_DrawFace) |
| 21 , fColorProcInfoValid(false) | 22 , fColorProcInfoValid(false) |
| 22 , fCoverageProcInfoValid(false) | 23 , fCoverageProcInfoValid(false) |
| 23 , fColorCache(GrColor_ILLEGAL) | 24 , fColorCache(GrColor_ILLEGAL) |
| 24 , fCoverageCache(GrColor_ILLEGAL) { | 25 , fCoverageCache(GrColor_ILLEGAL) { |
| 25 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) | 26 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
| 26 } | 27 } |
| 27 | 28 |
| 28 GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) { | 29 GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) { |
| 30 fProcDataManager.reset(SkNEW_ARGS(GrProcessorDataManager, (*that.processorDa
taManager()))); |
| 29 fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get())); | 31 fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get())); |
| 30 fFlags = that.fFlags; | 32 fFlags = that.fFlags; |
| 31 fStencilSettings = that.fStencilSettings; | 33 fStencilSettings = that.fStencilSettings; |
| 32 fDrawFace = that.fDrawFace; | 34 fDrawFace = that.fDrawFace; |
| 33 fXPFactory.reset(SkRef(that.getXPFactory())); | 35 fXPFactory.reset(SkRef(that.getXPFactory())); |
| 34 fColorStages = that.fColorStages; | 36 fColorStages = that.fColorStages; |
| 35 fCoverageStages = that.fCoverageStages; | 37 fCoverageStages = that.fCoverageStages; |
| 36 fClip = that.fClip; | 38 fClip = that.fClip; |
| 37 | 39 |
| 38 fColorProcInfoValid = that.fColorProcInfoValid; | 40 fColorProcInfoValid = that.fColorProcInfoValid; |
| 39 fCoverageProcInfoValid = that.fCoverageProcInfoValid; | 41 fCoverageProcInfoValid = that.fCoverageProcInfoValid; |
| 40 fColorCache = that.fColorCache; | 42 fColorCache = that.fColorCache; |
| 41 fCoverageCache = that.fCoverageCache; | 43 fCoverageCache = that.fCoverageCache; |
| 42 if (fColorProcInfoValid) { | 44 if (fColorProcInfoValid) { |
| 43 fColorProcInfo = that.fColorProcInfo; | 45 fColorProcInfo = that.fColorProcInfo; |
| 44 } | 46 } |
| 45 if (fCoverageProcInfoValid) { | 47 if (fCoverageProcInfoValid) { |
| 46 fCoverageProcInfo = that.fCoverageProcInfo; | 48 fCoverageProcInfo = that.fCoverageProcInfo; |
| 47 } | 49 } |
| 48 return *this; | 50 return *this; |
| 49 } | 51 } |
| 50 | 52 |
| 51 void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt, c
onst GrClip& clip) { | 53 void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt, c
onst GrClip& clip) { |
| 52 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages()); | 54 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages()); |
| 53 | 55 |
| 56 // TODO keep this logically const using an AutoReset |
| 57 fProcDataManager.reset( |
| 58 const_cast<GrProcessorDataManager*>(SkRef(paint.processorDataManager())
)); |
| 59 |
| 54 fColorStages.reset(); | 60 fColorStages.reset(); |
| 55 fCoverageStages.reset(); | 61 fCoverageStages.reset(); |
| 56 | 62 |
| 57 for (int i = 0; i < paint.numColorStages(); ++i) { | 63 for (int i = 0; i < paint.numColorStages(); ++i) { |
| 58 fColorStages.push_back(paint.getColorStage(i)); | 64 fColorStages.push_back(paint.getColorStage(i)); |
| 59 } | 65 } |
| 60 | 66 |
| 61 for (int i = 0; i < paint.numCoverageStages(); ++i) { | 67 for (int i = 0; i < paint.numCoverageStages(); ++i) { |
| 62 fCoverageStages.push_back(paint.getCoverageStage(i)); | 68 fCoverageStages.push_back(paint.getCoverageStage(i)); |
| 63 } | 69 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { | 175 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { |
| 170 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { | 176 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { |
| 171 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; | 177 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; |
| 172 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), | 178 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), |
| 173 this->numCoverageFragmentStages(
), coverage, flags, | 179 this->numCoverageFragmentStages(
), coverage, flags, |
| 174 true); | 180 true); |
| 175 fCoverageProcInfoValid = true; | 181 fCoverageProcInfoValid = true; |
| 176 fCoverageCache = coverage; | 182 fCoverageCache = coverage; |
| 177 } | 183 } |
| 178 } | 184 } |
| OLD | NEW |