| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { | 177 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { |
| 176 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { | 178 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { |
| 177 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; | 179 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; |
| 178 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), | 180 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), |
| 179 this->numCoverageStages(), cover
age, flags, | 181 this->numCoverageStages(), cover
age, flags, |
| 180 true); | 182 true); |
| 181 fCoverageProcInfoValid = true; | 183 fCoverageProcInfoValid = true; |
| 182 fCoverageCache = coverage; | 184 fCoverageCache = coverage; |
| 183 } | 185 } |
| 184 } | 186 } |
| OLD | NEW |