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 "GrBatch.h" |
10 #include "GrDrawState.h" | 11 #include "GrDrawState.h" |
11 #include "GrDrawTargetCaps.h" | 12 #include "GrDrawTargetCaps.h" |
12 #include "GrGpu.h" | 13 #include "GrGpu.h" |
13 #include "GrProcOptInfo.h" | 14 #include "GrProcOptInfo.h" |
14 #include "GrXferProcessor.h" | 15 #include "GrXferProcessor.h" |
15 | 16 |
16 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, | 17 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
17 const GrPrimitiveProcessor* primProc, | 18 const GrPrimitiveProcessor* primProc, |
18 const GrDrawTargetCaps& caps, | 19 const GrDrawTargetCaps& caps, |
19 const GrScissorState& scissorState, | 20 const GrScissorState& scissorState, |
20 const GrDeviceCoordTexture* dstCopy, | 21 const GrDeviceCoordTexture* dstCopy, |
21 GrGpu::DrawType drawType) { | 22 GrGpu::DrawType drawType) { |
22 fDrawType = drawType; | |
23 | |
24 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(primProc); | 23 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(primProc); |
25 const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(primProc); | 24 const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(primProc); |
26 | 25 |
| 26 this->internalConstructor(drawState, colorPOI, coveragePOI, caps, scissorSta
te, dstCopy, |
| 27 drawType); |
| 28 } |
| 29 |
| 30 GrOptDrawState::GrOptDrawState(GrBatch* batch, |
| 31 const GrDrawState& drawState, |
| 32 const GrDrawTargetCaps& caps, |
| 33 const GrScissorState& scissorState, |
| 34 const GrDeviceCoordTexture* dstCopy, |
| 35 GrGpu::DrawType drawType) { |
| 36 GrBatchOpt batchOpt; |
| 37 batchOpt.fCanTweakAlphaForCoverage = drawState.canTweakAlphaForCoverage(); |
| 38 batch->initBatchOpt(batchOpt); |
| 39 |
| 40 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(batch); |
| 41 const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(batch); |
| 42 |
| 43 this->internalConstructor(drawState, colorPOI, coveragePOI, caps, scissorSta
te, dstCopy, |
| 44 drawType); |
| 45 } |
| 46 |
| 47 void GrOptDrawState::internalConstructor(const GrDrawState& drawState, |
| 48 const GrProcOptInfo& colorPOI, |
| 49 const GrProcOptInfo& coveragePOI, |
| 50 const GrDrawTargetCaps& caps, |
| 51 const GrScissorState& scissorState, |
| 52 const GrDeviceCoordTexture* dstCopy, |
| 53 GrGpu::DrawType drawType) { |
| 54 |
| 55 fDrawType = drawType; |
| 56 |
27 // Create XferProcessor from DS's XPFactory | 57 // Create XferProcessor from DS's XPFactory |
28 SkAutoTUnref<GrXferProcessor> xferProcessor( | 58 SkAutoTUnref<GrXferProcessor> xferProcessor( |
29 drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI)); | 59 drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI)); |
30 | 60 |
31 GrColor overrideColor = GrColor_ILLEGAL; | 61 GrColor overrideColor = GrColor_ILLEGAL; |
32 if (colorPOI.firstEffectiveStageIndex() != 0) { | 62 if (colorPOI.firstEffectiveStageIndex() != 0) { |
33 overrideColor = colorPOI.inputColorToEffectiveStage(); | 63 overrideColor = colorPOI.inputColorToEffectiveStage(); |
34 } | 64 } |
35 | 65 |
36 GrXferProcessor::OptFlags optFlags; | 66 GrXferProcessor::OptFlags optFlags; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); | 191 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); |
162 for (int i = 0; i < this->numFragmentStages(); i++) { | 192 for (int i = 0; i < this->numFragmentStages(); i++) { |
163 | 193 |
164 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { | 194 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { |
165 return false; | 195 return false; |
166 } | 196 } |
167 } | 197 } |
168 return true; | 198 return true; |
169 } | 199 } |
170 | 200 |
OLD | NEW |