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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) { | 27 GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) { |
28 fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get())); | 28 fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get())); |
29 fFlagBits = that.fFlagBits; | 29 fFlagBits = that.fFlagBits; |
30 fStencilSettings = that.fStencilSettings; | 30 fStencilSettings = that.fStencilSettings; |
31 fDrawFace = that.fDrawFace; | 31 fDrawFace = that.fDrawFace; |
32 fXPFactory.reset(SkRef(that.getXPFactory())); | 32 fXPFactory.reset(SkRef(that.getXPFactory())); |
33 fColorStages = that.fColorStages; | 33 fColorStages = that.fColorStages; |
34 fCoverageStages = that.fCoverageStages; | 34 fCoverageStages = that.fCoverageStages; |
| 35 fClip = that.fClip; |
35 | 36 |
36 fColorProcInfoValid = that.fColorProcInfoValid; | 37 fColorProcInfoValid = that.fColorProcInfoValid; |
37 fCoverageProcInfoValid = that.fCoverageProcInfoValid; | 38 fCoverageProcInfoValid = that.fCoverageProcInfoValid; |
38 fColorCache = that.fColorCache; | 39 fColorCache = that.fColorCache; |
39 fCoverageCache = that.fCoverageCache; | 40 fCoverageCache = that.fCoverageCache; |
40 if (fColorProcInfoValid) { | 41 if (fColorProcInfoValid) { |
41 fColorProcInfo = that.fColorProcInfo; | 42 fColorProcInfo = that.fColorProcInfo; |
42 } | 43 } |
43 if (fCoverageProcInfoValid) { | 44 if (fCoverageProcInfoValid) { |
44 fCoverageProcInfo = that.fCoverageProcInfo; | 45 fCoverageProcInfo = that.fCoverageProcInfo; |
45 } | 46 } |
46 return *this; | 47 return *this; |
47 } | 48 } |
48 | 49 |
49 void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt) { | 50 void GrPipelineBuilder::setFromPaint(const GrPaint& paint, GrRenderTarget* rt, c
onst GrClip* clip) { |
50 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages()); | 51 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages()); |
51 | 52 |
52 fColorStages.reset(); | 53 fColorStages.reset(); |
53 fCoverageStages.reset(); | 54 fCoverageStages.reset(); |
54 | 55 |
55 for (int i = 0; i < paint.numColorStages(); ++i) { | 56 for (int i = 0; i < paint.numColorStages(); ++i) { |
56 fColorStages.push_back(paint.getColorStage(i)); | 57 fColorStages.push_back(paint.getColorStage(i)); |
57 } | 58 } |
58 | 59 |
59 for (int i = 0; i < paint.numCoverageStages(); ++i) { | 60 for (int i = 0; i < paint.numCoverageStages(); ++i) { |
60 fCoverageStages.push_back(paint.getCoverageStage(i)); | 61 fCoverageStages.push_back(paint.getCoverageStage(i)); |
61 } | 62 } |
62 | 63 |
63 fXPFactory.reset(SkRef(paint.getXPFactory())); | 64 fXPFactory.reset(SkRef(paint.getXPFactory())); |
64 | 65 |
65 this->setRenderTarget(rt); | 66 this->setRenderTarget(rt); |
66 | 67 |
67 // These have no equivalent in GrPaint, set them to defaults | 68 // These have no equivalent in GrPaint, set them to defaults |
68 fDrawFace = kBoth_DrawFace; | 69 fDrawFace = kBoth_DrawFace; |
69 fStencilSettings.setDisabled(); | 70 fStencilSettings.setDisabled(); |
70 fFlagBits = 0; | 71 fFlagBits = 0; |
71 | 72 |
72 // Enable the clip bit | 73 if (clip) { |
73 this->enableState(GrPipelineBuilder::kClip_StateBit); | 74 fClip = *clip; |
| 75 } |
74 | 76 |
75 this->setState(GrPipelineBuilder::kDither_StateBit, paint.isDither()); | 77 this->setState(GrPipelineBuilder::kDither_StateBit, paint.isDither()); |
76 this->setState(GrPipelineBuilder::kHWAntialias_StateBit, paint.isAntiAlias()
); | 78 this->setState(GrPipelineBuilder::kHWAntialias_StateBit, paint.isAntiAlias()
); |
77 | 79 |
78 fColorProcInfoValid = false; | 80 fColorProcInfoValid = false; |
79 fCoverageProcInfoValid = false; | 81 fCoverageProcInfoValid = false; |
80 | 82 |
81 fColorCache = GrColor_ILLEGAL; | 83 fColorCache = GrColor_ILLEGAL; |
82 fCoverageCache = GrColor_ILLEGAL; | 84 fCoverageCache = GrColor_ILLEGAL; |
83 } | 85 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { | 194 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { |
193 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { | 195 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { |
194 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; | 196 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; |
195 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), | 197 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), |
196 this->numCoverageStages(), cover
age, flags, | 198 this->numCoverageStages(), cover
age, flags, |
197 true); | 199 true); |
198 fCoverageProcInfoValid = true; | 200 fCoverageProcInfoValid = true; |
199 fCoverageCache = coverage; | 201 fCoverageCache = coverage; |
200 } | 202 } |
201 } | 203 } |
OLD | NEW |