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 "GrBlend.h" | 10 #include "GrBlend.h" |
11 #include "GrPaint.h" | 11 #include "GrPaint.h" |
12 #include "GrPipeline.h" | 12 #include "GrPipeline.h" |
13 #include "GrProcOptInfo.h" | 13 #include "GrProcOptInfo.h" |
14 #include "GrXferProcessor.h" | 14 #include "GrXferProcessor.h" |
15 #include "batches/GrBatch.h" | 15 #include "batches/GrBatch.h" |
16 #include "effects/GrPorterDuffXferProcessor.h" | 16 #include "effects/GrPorterDuffXferProcessor.h" |
17 | 17 |
18 GrPipelineBuilder::GrPipelineBuilder() | 18 GrPipelineBuilder::GrPipelineBuilder() |
19 : fProcDataManager(new GrProcessorDataManager), fFlags(0x0), fDrawFace(kBoth
_DrawFace) { | 19 : fFlags(0x0), fDrawFace(kBoth_DrawFace) { |
20 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) | 20 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
21 } | 21 } |
22 | 22 |
23 GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, GrRenderTarget* rt, c
onst GrClip& clip) { | 23 GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, GrRenderTarget* rt, c
onst GrClip& clip) { |
24 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) | 24 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
25 | 25 |
26 // TODO keep this logically const using an AutoReset | |
27 fProcDataManager.reset( | |
28 const_cast<GrProcessorDataManager*>(SkRef(paint.processorDataManager())
)); | |
29 | |
30 for (int i = 0; i < paint.numColorFragmentProcessors(); ++i) { | 26 for (int i = 0; i < paint.numColorFragmentProcessors(); ++i) { |
31 fColorFragmentProcessors.push_back(SkRef(paint.getColorFragmentProcessor
(i))); | 27 fColorFragmentProcessors.push_back(SkRef(paint.getColorFragmentProcessor
(i))); |
32 } | 28 } |
33 | 29 |
34 for (int i = 0; i < paint.numCoverageFragmentProcessors(); ++i) { | 30 for (int i = 0; i < paint.numCoverageFragmentProcessors(); ++i) { |
35 fCoverageFragmentProcessors.push_back(SkRef(paint.getCoverageFragmentPro
cessor(i))); | 31 fCoverageFragmentProcessors.push_back(SkRef(paint.getCoverageFragmentPro
cessor(i))); |
36 } | 32 } |
37 | 33 |
38 fXPFactory.reset(SkRef(paint.getXPFactory())); | 34 fXPFactory.reset(SkRef(paint.getXPFactory())); |
39 | 35 |
(...skipping 30 matching lines...) Expand all Loading... |
70 } | 66 } |
71 fPipelineBuilder->fColorFragmentProcessors.pop_back_n(m); | 67 fPipelineBuilder->fColorFragmentProcessors.pop_back_n(m); |
72 | 68 |
73 int n = fPipelineBuilder->numCoverageFragmentProcessors() - fCoverageEff
ectCnt; | 69 int n = fPipelineBuilder->numCoverageFragmentProcessors() - fCoverageEff
ectCnt; |
74 SkASSERT(n >= 0); | 70 SkASSERT(n >= 0); |
75 for (int i = 0; i < n; ++i) { | 71 for (int i = 0; i < n; ++i) { |
76 fPipelineBuilder->fCoverageFragmentProcessors.fromBack(i)->unref(); | 72 fPipelineBuilder->fCoverageFragmentProcessors.fromBack(i)->unref(); |
77 } | 73 } |
78 fPipelineBuilder->fCoverageFragmentProcessors.pop_back_n(n); | 74 fPipelineBuilder->fCoverageFragmentProcessors.pop_back_n(n); |
79 SkDEBUGCODE(--fPipelineBuilder->fBlockEffectRemovalCnt;) | 75 SkDEBUGCODE(--fPipelineBuilder->fBlockEffectRemovalCnt;) |
80 fPipelineBuilder->getProcessorDataManager()->restoreToSaveMarker(/*fSave
Marker*/); | |
81 } | 76 } |
82 fPipelineBuilder = const_cast<GrPipelineBuilder*>(pipelineBuilder); | 77 fPipelineBuilder = const_cast<GrPipelineBuilder*>(pipelineBuilder); |
83 if (nullptr != pipelineBuilder) { | 78 if (nullptr != pipelineBuilder) { |
84 fColorEffectCnt = pipelineBuilder->numColorFragmentProcessors(); | 79 fColorEffectCnt = pipelineBuilder->numColorFragmentProcessors(); |
85 fCoverageEffectCnt = pipelineBuilder->numCoverageFragmentProcessors(); | 80 fCoverageEffectCnt = pipelineBuilder->numCoverageFragmentProcessors(); |
86 SkDEBUGCODE(++pipelineBuilder->fBlockEffectRemovalCnt;) | 81 SkDEBUGCODE(++pipelineBuilder->fBlockEffectRemovalCnt;) |
87 fSaveMarker = pipelineBuilder->processorDataManager()->currentSaveMarker
(); | |
88 } | 82 } |
89 } | 83 } |
90 | 84 |
91 //////////////////////////////////////////////////////////////////////////////// | 85 //////////////////////////////////////////////////////////////////////////////// |
92 | 86 |
93 GrPipelineBuilder::~GrPipelineBuilder() { | 87 GrPipelineBuilder::~GrPipelineBuilder() { |
94 SkASSERT(0 == fBlockEffectRemovalCnt); | 88 SkASSERT(0 == fBlockEffectRemovalCnt); |
95 for (int i = 0; i < fColorFragmentProcessors.count(); ++i) { | 89 for (int i = 0; i < fColorFragmentProcessors.count(); ++i) { |
96 fColorFragmentProcessors[i]->unref(); | 90 fColorFragmentProcessors[i]->unref(); |
97 } | 91 } |
(...skipping 17 matching lines...) Expand all Loading... |
115 | 109 |
116 void GrPipelineBuilder::calcColorInvariantOutput(const GrDrawBatch* batch) const
{ | 110 void GrPipelineBuilder::calcColorInvariantOutput(const GrDrawBatch* batch) const
{ |
117 fColorProcInfo.calcColorWithBatch(batch, fColorFragmentProcessors.begin(), | 111 fColorProcInfo.calcColorWithBatch(batch, fColorFragmentProcessors.begin(), |
118 this->numColorFragmentProcessors()); | 112 this->numColorFragmentProcessors()); |
119 } | 113 } |
120 | 114 |
121 void GrPipelineBuilder::calcCoverageInvariantOutput(const GrDrawBatch* batch) co
nst { | 115 void GrPipelineBuilder::calcCoverageInvariantOutput(const GrDrawBatch* batch) co
nst { |
122 fCoverageProcInfo.calcCoverageWithBatch(batch, fCoverageFragmentProcessors.b
egin(), | 116 fCoverageProcInfo.calcCoverageWithBatch(batch, fCoverageFragmentProcessors.b
egin(), |
123 this->numCoverageFragmentProcessors(
)); | 117 this->numCoverageFragmentProcessors(
)); |
124 } | 118 } |
OLD | NEW |