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 "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 // Enable the clip bit |
|
bsalomon
2015/02/23 19:31:29
change/remove comment?
| |
| 73 this->enableState(GrPipelineBuilder::kClip_StateBit); | 74 if (clip) { |
| 75 fClip = *clip; | |
| 76 } | |
| 74 | 77 |
| 75 this->setState(GrPipelineBuilder::kDither_StateBit, paint.isDither()); | 78 this->setState(GrPipelineBuilder::kDither_StateBit, paint.isDither()); |
| 76 this->setState(GrPipelineBuilder::kHWAntialias_StateBit, paint.isAntiAlias() ); | 79 this->setState(GrPipelineBuilder::kHWAntialias_StateBit, paint.isAntiAlias() ); |
| 77 | 80 |
| 78 fColorProcInfoValid = false; | 81 fColorProcInfoValid = false; |
| 79 fCoverageProcInfoValid = false; | 82 fCoverageProcInfoValid = false; |
| 80 | 83 |
| 81 fColorCache = GrColor_ILLEGAL; | 84 fColorCache = GrColor_ILLEGAL; |
| 82 fCoverageCache = GrColor_ILLEGAL; | 85 fCoverageCache = GrColor_ILLEGAL; |
| 83 } | 86 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { | 195 void GrPipelineBuilder::calcCoverageInvariantOutput(GrColor coverage) const { |
| 193 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { | 196 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { |
| 194 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; | 197 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; |
| 195 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), | 198 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), |
| 196 this->numCoverageStages(), cover age, flags, | 199 this->numCoverageStages(), cover age, flags, |
| 197 true); | 200 true); |
| 198 fCoverageProcInfoValid = true; | 201 fCoverageProcInfoValid = true; |
| 199 fCoverageCache = coverage; | 202 fCoverageCache = coverage; |
| 200 } | 203 } |
| 201 } | 204 } |
| OLD | NEW |