| 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 "GrPipeline.h" | 8 #include "GrPipeline.h" |
| 9 | 9 |
| 10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 void GrPipeline::internalConstructor(const GrPipelineBuilder& pipelineBuilder, | 43 void GrPipeline::internalConstructor(const GrPipelineBuilder& pipelineBuilder, |
| 44 const GrProcOptInfo& colorPOI, | 44 const GrProcOptInfo& colorPOI, |
| 45 const GrProcOptInfo& coveragePOI, | 45 const GrProcOptInfo& coveragePOI, |
| 46 const GrDrawTargetCaps& caps, | 46 const GrDrawTargetCaps& caps, |
| 47 const GrScissorState& scissorState, | 47 const GrScissorState& scissorState, |
| 48 const GrDeviceCoordTexture* dstCopy) { | 48 const GrDeviceCoordTexture* dstCopy) { |
| 49 // Create XferProcessor from DS's XPFactory | 49 // Create XferProcessor from DS's XPFactory |
| 50 SkAutoTUnref<GrXferProcessor> xferProcessor( | 50 SkAutoTUnref<GrXferProcessor> xferProcessor( |
| 51 pipelineBuilder.getXPFactory()->createXferProcessor(colorPOI, coveragePO
I, dstCopy, caps)); | 51 pipelineBuilder.getXPFactory()->createXferProcessor(colorPOI, coveragePO
I)); |
| 52 | 52 |
| 53 GrColor overrideColor = GrColor_ILLEGAL; | 53 GrColor overrideColor = GrColor_ILLEGAL; |
| 54 if (colorPOI.firstEffectiveStageIndex() != 0) { | 54 if (colorPOI.firstEffectiveStageIndex() != 0) { |
| 55 overrideColor = colorPOI.inputColorToEffectiveStage(); | 55 overrideColor = colorPOI.inputColorToEffectiveStage(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 GrXferProcessor::OptFlags optFlags; | 58 GrXferProcessor::OptFlags optFlags; |
| 59 if (xferProcessor) { | 59 if (xferProcessor) { |
| 60 fXferProcessor.reset(xferProcessor.get()); | 60 fXferProcessor.reset(xferProcessor.get()); |
| 61 | 61 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 75 fFlags = 0; | 75 fFlags = 0; |
| 76 fDrawFace = GrPipelineBuilder::kInvalid_DrawFace; | 76 fDrawFace = GrPipelineBuilder::kInvalid_DrawFace; |
| 77 return; | 77 return; |
| 78 } | 78 } |
| 79 | 79 |
| 80 fRenderTarget.reset(pipelineBuilder.fRenderTarget.get()); | 80 fRenderTarget.reset(pipelineBuilder.fRenderTarget.get()); |
| 81 SkASSERT(fRenderTarget); | 81 SkASSERT(fRenderTarget); |
| 82 fScissorState = scissorState; | 82 fScissorState = scissorState; |
| 83 fStencilSettings = pipelineBuilder.getStencil(); | 83 fStencilSettings = pipelineBuilder.getStencil(); |
| 84 fDrawFace = pipelineBuilder.getDrawFace(); | 84 fDrawFace = pipelineBuilder.getDrawFace(); |
| 85 // TODO move this out of GrPipeline |
| 86 if (dstCopy) { |
| 87 fDstCopy = *dstCopy; |
| 88 } |
| 85 | 89 |
| 86 fFlags = 0; | 90 fFlags = 0; |
| 87 if (pipelineBuilder.isHWAntialias()) { | 91 if (pipelineBuilder.isHWAntialias()) { |
| 88 fFlags |= kHWAA_Flag; | 92 fFlags |= kHWAA_Flag; |
| 89 } | 93 } |
| 90 if (pipelineBuilder.isDither()) { | 94 if (pipelineBuilder.isDither()) { |
| 91 fFlags |= kDither_Flag; | 95 fFlags |= kDither_Flag; |
| 92 } | 96 } |
| 93 | 97 |
| 94 int firstColorStageIdx = colorPOI.firstEffectiveStageIndex(); | 98 int firstColorStageIdx = colorPOI.firstEffectiveStageIndex(); |
| 95 | 99 |
| 96 // TODO: Once we can handle single or four channel input into coverage stage
s then we can use | 100 // TODO: Once we can handle single or four channel input into coverage stage
s then we can use |
| 97 // GrPipelineBuilder's coverageProcInfo (like color above) to set this initi
al information. | 101 // GrPipelineBuilder's coverageProcInfo (like color above) to set this initi
al information. |
| 98 int firstCoverageStageIdx = 0; | 102 int firstCoverageStageIdx = 0; |
| 99 | 103 |
| 100 GrXferProcessor::BlendInfo blendInfo; | 104 GrXferProcessor::BlendInfo blendInfo; |
| 101 fXferProcessor->getBlendInfo(&blendInfo); | 105 fXferProcessor->getBlendInfo(&blendInfo); |
| 102 | 106 |
| 103 this->adjustProgramFromOptimizations(pipelineBuilder, optFlags, colorPOI, co
veragePOI, | 107 this->adjustProgramFromOptimizations(pipelineBuilder, optFlags, colorPOI, co
veragePOI, |
| 104 &firstColorStageIdx, &firstCoverageStag
eIdx); | 108 &firstColorStageIdx, &firstCoverageStag
eIdx); |
| 105 | 109 |
| 110 fDescInfo.fReadsDst = fXferProcessor->willReadDstColor(); |
| 111 |
| 106 bool usesLocalCoords = false; | 112 bool usesLocalCoords = false; |
| 107 | 113 |
| 108 // Copy Stages from PipelineBuilder to Pipeline | 114 // Copy Stages from PipelineBuilder to Pipeline |
| 109 for (int i = firstColorStageIdx; i < pipelineBuilder.numColorStages(); ++i)
{ | 115 for (int i = firstColorStageIdx; i < pipelineBuilder.numColorStages(); ++i)
{ |
| 110 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | 116 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
| 111 GrPendingFragmentStage, | 117 GrPendingFragmentStage, |
| 112 (pipelineBuilder.fColorStages[i])); | 118 (pipelineBuilder.fColorStages[i])); |
| 113 usesLocalCoords = usesLocalCoords || | 119 usesLocalCoords = usesLocalCoords || |
| 114 pipelineBuilder.fColorStages[i].processor()->usesLocal
Coords(); | 120 pipelineBuilder.fColorStages[i].processor()->usesLocal
Coords(); |
| 115 } | 121 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 129 fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCover
age_OptFlag); | 135 fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCover
age_OptFlag); |
| 130 fInitBT.fUsesLocalCoords = usesLocalCoords; | 136 fInitBT.fUsesLocalCoords = usesLocalCoords; |
| 131 } | 137 } |
| 132 | 138 |
| 133 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin
eBuilder, | 139 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin
eBuilder, |
| 134 GrXferProcessor::OptFlags flags, | 140 GrXferProcessor::OptFlags flags, |
| 135 const GrProcOptInfo& colorPOI, | 141 const GrProcOptInfo& colorPOI, |
| 136 const GrProcOptInfo& coveragePOI
, | 142 const GrProcOptInfo& coveragePOI
, |
| 137 int* firstColorStageIdx, | 143 int* firstColorStageIdx, |
| 138 int* firstCoverageStageIdx) { | 144 int* firstCoverageStageIdx) { |
| 139 fReadsFragPosition = false; | 145 fDescInfo.fReadsFragPosition = false; |
| 140 | 146 |
| 141 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) || | 147 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) || |
| 142 (flags & GrXferProcessor::kOverrideColor_OptFlag)) { | 148 (flags & GrXferProcessor::kOverrideColor_OptFlag)) { |
| 143 *firstColorStageIdx = pipelineBuilder.numColorStages(); | 149 *firstColorStageIdx = pipelineBuilder.numColorStages(); |
| 144 } else { | 150 } else { |
| 145 fReadsFragPosition = colorPOI.readsFragPosition(); | 151 fDescInfo.fReadsFragPosition = colorPOI.readsFragPosition(); |
| 146 } | 152 } |
| 147 | 153 |
| 148 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) { | 154 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) { |
| 149 *firstCoverageStageIdx = pipelineBuilder.numCoverageStages(); | 155 *firstCoverageStageIdx = pipelineBuilder.numCoverageStages(); |
| 150 } else { | 156 } else { |
| 151 if (coveragePOI.readsFragPosition()) { | 157 if (coveragePOI.readsFragPosition()) { |
| 152 fReadsFragPosition = true; | 158 fDescInfo.fReadsFragPosition = true; |
| 153 } | 159 } |
| 154 } | 160 } |
| 155 } | 161 } |
| 156 | 162 |
| 157 //////////////////////////////////////////////////////////////////////////////// | 163 //////////////////////////////////////////////////////////////////////////////// |
| 158 | 164 |
| 159 bool GrPipeline::isEqual(const GrPipeline& that) const { | 165 bool GrPipeline::isEqual(const GrPipeline& that) const { |
| 160 if (this->getRenderTarget() != that.getRenderTarget() || | 166 if (this->getRenderTarget() != that.getRenderTarget() || |
| 161 this->fFragmentStages.count() != that.fFragmentStages.count() || | 167 this->fFragmentStages.count() != that.fFragmentStages.count() || |
| 162 this->fNumColorStages != that.fNumColorStages || | 168 this->fNumColorStages != that.fNumColorStages || |
| 163 this->fScissorState != that.fScissorState || | 169 this->fScissorState != that.fScissorState || |
| 164 this->fFlags != that.fFlags || | 170 this->fFlags != that.fFlags || |
| 165 this->fStencilSettings != that.fStencilSettings || | 171 this->fStencilSettings != that.fStencilSettings || |
| 166 this->fDrawFace != that.fDrawFace) { | 172 this->fDrawFace != that.fDrawFace || |
| 173 this->fDstCopy.texture() != that.fDstCopy.texture()) { |
| 167 return false; | 174 return false; |
| 168 } | 175 } |
| 169 | 176 |
| 170 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) { | 177 if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) { |
| 171 return false; | 178 return false; |
| 172 } | 179 } |
| 173 | 180 |
| 174 // The program desc comparison should have already assured that the stage co
unts match. | 181 // The program desc comparison should have already assured that the stage co
unts match. |
| 175 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); | 182 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); |
| 176 for (int i = 0; i < this->numFragmentStages(); i++) { | 183 for (int i = 0; i < this->numFragmentStages(); i++) { |
| 177 | 184 |
| 178 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { | 185 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { |
| 179 return false; | 186 return false; |
| 180 } | 187 } |
| 181 } | 188 } |
| 182 return true; | 189 return true; |
| 183 } | 190 } |
| 184 | 191 |
| OLD | NEW |