OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrOptDrawState.h" | 8 #include "GrOptDrawState.h" |
9 | 9 |
10 #include "GrDrawState.h" | 10 #include "GrDrawState.h" |
11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.h" |
| 12 #include "GrInvariantOutput.h" |
12 #include "gl/GrGpuGL.h" | 13 #include "gl/GrGpuGL.h" |
13 | 14 |
14 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, | 15 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
15 BlendOptFlags blendOptFlags, | 16 BlendOptFlags blendOptFlags, |
16 GrBlendCoeff optSrcCoeff, | 17 GrBlendCoeff optSrcCoeff, |
17 GrBlendCoeff optDstCoeff, | 18 GrBlendCoeff optDstCoeff, |
18 GrGpu* gpu, | 19 GrGpu* gpu, |
19 const GrDeviceCoordTexture* dstCopy, | 20 const GrDeviceCoordTexture* dstCopy, |
20 GrGpu::DrawType drawType) { | 21 GrGpu::DrawType drawType) { |
21 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType); | 22 fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 239 } |
239 fVACount -= numToRemove; | 240 fVACount -= numToRemove; |
240 fVAPtr = fOptVA.get(); | 241 fVAPtr = fOptVA.get(); |
241 } | 242 } |
242 | 243 |
243 void GrOptDrawState::computeEffectiveColorStages(const GrDrawState& ds, | 244 void GrOptDrawState::computeEffectiveColorStages(const GrDrawState& ds, |
244 GrProgramDesc::DescInfo* descIn
fo, | 245 GrProgramDesc::DescInfo* descIn
fo, |
245 int* firstColorStageIdx, | 246 int* firstColorStageIdx, |
246 uint8_t* fixedFunctionVAToRemov
e) { | 247 uint8_t* fixedFunctionVAToRemov
e) { |
247 // Set up color and flags for ConstantColorComponent checks | 248 // Set up color and flags for ConstantColorComponent checks |
248 GrProcessor::InvariantOutput inout; | 249 GrInvariantOutput inout; |
249 inout.fIsSingleComponent = false; | 250 inout.fIsSingleComponent = false; |
250 if (!descInfo->hasColorVertexAttribute()) { | 251 if (!descInfo->hasColorVertexAttribute()) { |
251 inout.fColor = ds.getColor(); | 252 inout.fColor = ds.getColor(); |
252 inout.fValidFlags = kRGBA_GrColorComponentFlags; | 253 inout.fValidFlags = kRGBA_GrColorComponentFlags; |
253 } else { | 254 } else { |
254 if (ds.vertexColorsAreOpaque()) { | 255 if (ds.vertexColorsAreOpaque()) { |
255 inout.fColor = 0xFF << GrColor_SHIFT_A; | 256 inout.fColor = 0xFF << GrColor_SHIFT_A; |
256 inout.fValidFlags = kA_GrColorComponentFlag; | 257 inout.fValidFlags = kA_GrColorComponentFlag; |
257 } else { | 258 } else { |
258 inout.fValidFlags = 0; | 259 inout.fValidFlags = 0; |
(...skipping 24 matching lines...) Expand all Loading... |
283 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds, | 284 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds, |
284 GrProgramDesc::DescInfo* des
cInfo, | 285 GrProgramDesc::DescInfo* des
cInfo, |
285 int* firstCoverageStageIdx)
{ | 286 int* firstCoverageStageIdx)
{ |
286 // We do not try to optimize out constantColor coverage effects here. It is
extremely rare | 287 // We do not try to optimize out constantColor coverage effects here. It is
extremely rare |
287 // to have a coverage effect that returns a constant value for all four chan
nels. Thus we | 288 // to have a coverage effect that returns a constant value for all four chan
nels. Thus we |
288 // save having to make extra virtual calls by not checking for it. | 289 // save having to make extra virtual calls by not checking for it. |
289 | 290 |
290 // Don't do any optimizations on coverage stages. It should not be the case
where we do not use | 291 // Don't do any optimizations on coverage stages. It should not be the case
where we do not use |
291 // input coverage in an effect | 292 // input coverage in an effect |
292 #ifdef OptCoverageStages | 293 #ifdef OptCoverageStages |
293 GrProcessor::InvariantOutput inout; | 294 GrInvariantOutput inout; |
294 for (int i = 0; i < ds.numCoverageStages(); ++i) { | 295 for (int i = 0; i < ds.numCoverageStages(); ++i) { |
295 const GrFragmentProcessor* fp = ds.getCoverageStage(i).getProcessor(); | 296 const GrFragmentProcessor* fp = ds.getCoverageStage(i).getProcessor(); |
296 fp->computeInvariantOutput(&inout); | 297 fp->computeInvariantOutput(&inout); |
297 if (!inout.fWillUseInputColor) { | 298 if (!inout.fWillUseInputColor) { |
298 *firstCoverageStageIdx = i; | 299 *firstCoverageStageIdx = i; |
299 descInfo->fInputCoverageIsUsed = false; | 300 descInfo->fInputCoverageIsUsed = false; |
300 } | 301 } |
301 } | 302 } |
302 #endif | 303 #endif |
303 } | 304 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex !=
-1; | 383 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex !=
-1; |
383 for (int i = 0; i < this->numFragmentStages(); i++) { | 384 for (int i = 0; i < this->numFragmentStages(); i++) { |
384 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF
ragmentStage(i), | 385 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF
ragmentStage(i), |
385 explicitLocalCoords)) { | 386 explicitLocalCoords)) { |
386 return false; | 387 return false; |
387 } | 388 } |
388 } | 389 } |
389 return true; | 390 return true; |
390 } | 391 } |
391 | 392 |
OLD | NEW |