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 #ifndef GrOptDrawState_DEFINED | 8 #ifndef GrOptDrawState_DEFINED |
9 #define GrOptDrawState_DEFINED | 9 #define GrOptDrawState_DEFINED |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 SK_DECLARE_INST_COUNT(GrOptDrawState) | 30 SK_DECLARE_INST_COUNT(GrOptDrawState) |
31 | 31 |
32 GrOptDrawState(const GrDrawState& drawState, const GrPrimitiveProcessor*, | 32 GrOptDrawState(const GrDrawState& drawState, const GrPrimitiveProcessor*, |
33 const GrDrawTargetCaps&, const GrScissorState&, | 33 const GrDrawTargetCaps&, const GrScissorState&, |
34 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); | 34 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); |
35 | 35 |
36 /* | 36 /* |
37 * Returns true if it is possible to combine the two GrOptDrawStates and it
will update 'this' | 37 * Returns true if it is possible to combine the two GrOptDrawStates and it
will update 'this' |
38 * to subsume 'that''s draw. | 38 * to subsume 'that''s draw. |
39 */ | 39 */ |
40 bool combineIfPossible(const GrOptDrawState& that); | 40 bool isEqual(const GrOptDrawState& that) const; |
41 | 41 |
42 /// @} | 42 /// @} |
43 | 43 |
44 /////////////////////////////////////////////////////////////////////////// | 44 /////////////////////////////////////////////////////////////////////////// |
45 /// @name Effect Stages | 45 /// @name Effect Stages |
46 /// Each stage hosts a GrProcessor. The effect produces an output color or c
overage in the | 46 /// Each stage hosts a GrProcessor. The effect produces an output color or c
overage in the |
47 /// fragment shader. Its inputs are the output from the previous stage as we
ll as some variables | 47 /// fragment shader. Its inputs are the output from the previous stage as we
ll as some variables |
48 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, | 48 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, |
49 /// the fragment position, local coordinates). | 49 /// the fragment position, local coordinates). |
50 /// | 50 /// |
51 /// The stages are divided into two sets, color-computing and coverage-compu
ting. The final | 51 /// The stages are divided into two sets, color-computing and coverage-compu
ting. The final |
52 /// color stage produces the final pixel color. The coverage-computing stage
s function exactly | 52 /// color stage produces the final pixel color. The coverage-computing stage
s function exactly |
53 /// as the color-computing but the output of the final coverage stage is tre
ated as a fractional | 53 /// as the color-computing but the output of the final coverage stage is tre
ated as a fractional |
54 /// pixel coverage rather than as input to the src/dst color blend step. | 54 /// pixel coverage rather than as input to the src/dst color blend step. |
55 /// | 55 /// |
56 /// The input color to the first color-stage is either the constant color or
interpolated | 56 /// The input color to the first color-stage is either the constant color or
interpolated |
57 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage | 57 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage |
58 /// (usually full-coverage) or interpolated per-vertex coverage. | 58 /// (usually full-coverage) or interpolated per-vertex coverage. |
59 //// | 59 //// |
60 | 60 |
61 int numColorStages() const { return fNumColorStages; } | 61 int numColorStages() const { return fNumColorStages; } |
62 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt
ages; } | 62 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt
ages; } |
63 int numFragmentStages() const { return fFragmentStages.count(); } | 63 int numFragmentStages() const { return fFragmentStages.count(); } |
64 | 64 |
65 const GrPrimitiveProcessor* getPrimitiveProcessor() const { return fPrimitiv
eProcessor.get(); } | |
66 const GrBatchTracker& getBatchTracker() const { return fBatchTracker; } | |
67 | |
68 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } | 65 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } |
69 | 66 |
70 const GrPendingFragmentStage& getColorStage(int idx) const { | 67 const GrPendingFragmentStage& getColorStage(int idx) const { |
71 SkASSERT(idx < this->numColorStages()); | 68 SkASSERT(idx < this->numColorStages()); |
72 return fFragmentStages[idx]; | 69 return fFragmentStages[idx]; |
73 } | 70 } |
74 const GrPendingFragmentStage& getCoverageStage(int idx) const { | 71 const GrPendingFragmentStage& getCoverageStage(int idx) const { |
75 SkASSERT(idx < this->numCoverageStages()); | 72 SkASSERT(idx < this->numCoverageStages()); |
76 return fFragmentStages[fNumColorStages + idx]; | 73 return fFragmentStages[fNumColorStages + idx]; |
77 } | 74 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 GrDrawState::DrawFace getDrawFace() const { return fDrawFace; } | 125 GrDrawState::DrawFace getDrawFace() const { return fDrawFace; } |
129 | 126 |
130 /// @} | 127 /// @} |
131 | 128 |
132 /////////////////////////////////////////////////////////////////////////// | 129 /////////////////////////////////////////////////////////////////////////// |
133 | 130 |
134 GrGpu::DrawType drawType() const { return fDrawType; } | 131 GrGpu::DrawType drawType() const { return fDrawType; } |
135 | 132 |
136 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } | 133 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } |
137 | 134 |
138 // Finalize *MUST* be called before programDesc() | 135 const GrProgramDesc::DescInfo& descInfo() const { return fDescInfo; } |
139 void finalize(GrGpu*); | |
140 | 136 |
141 const GrProgramDesc& programDesc() const { SkASSERT(fFinalized); return fDes
c; } | 137 const GrGeometryProcessor::InitBT& getInitBatchTracker() const { return fIni
tBT; } |
142 | 138 |
143 private: | 139 private: |
144 /** | 140 /** |
145 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. | 141 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. |
146 */ | 142 */ |
147 void adjustProgramFromOptimizations(const GrDrawState& ds, | 143 void adjustProgramFromOptimizations(const GrDrawState& ds, |
148 GrXferProcessor::OptFlags, | 144 GrXferProcessor::OptFlags, |
149 const GrProcOptInfo& colorPOI, | 145 const GrProcOptInfo& colorPOI, |
150 const GrProcOptInfo& coveragePOI, | 146 const GrProcOptInfo& coveragePOI, |
151 int* firstColorStageIdx, | 147 int* firstColorStageIdx, |
152 int* firstCoverageStageIdx); | 148 int* firstCoverageStageIdx); |
153 | 149 |
154 /** | 150 /** |
155 * Calculates the primary and secondary output types of the shader. For cert
ain output types | 151 * Calculates the primary and secondary output types of the shader. For cert
ain output types |
156 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst | 152 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst |
157 * blend coeffs will represent those used by backend API. | 153 * blend coeffs will represent those used by backend API. |
158 */ | 154 */ |
159 void setOutputStateInfo(const GrDrawState& ds, GrXferProcessor::OptFlags, | 155 void setOutputStateInfo(const GrDrawState& ds, GrXferProcessor::OptFlags, |
160 const GrDrawTargetCaps&); | 156 const GrDrawTargetCaps&); |
161 | 157 |
162 enum Flags { | 158 enum Flags { |
163 kDither_Flag = 0x1, | 159 kDither_Flag = 0x1, |
164 kHWAA_Flag = 0x2, | 160 kHWAA_Flag = 0x2, |
165 }; | 161 }; |
166 | 162 |
167 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; | 163 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; |
168 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; | 164 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; |
169 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; | |
170 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitive
Processor; | |
171 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; | 165 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; |
172 RenderTarget fRenderTarget; | 166 RenderTarget fRenderTarget; |
173 GrScissorState fScissorState; | 167 GrScissorState fScissorState; |
174 GrStencilSettings fStencilSettings; | 168 GrStencilSettings fStencilSettings; |
175 GrDrawState::DrawFace fDrawFace; | 169 GrDrawState::DrawFace fDrawFace; |
176 GrDeviceCoordTexture fDstCopy; | 170 GrDeviceCoordTexture fDstCopy; |
177 uint32_t fFlags; | 171 uint32_t fFlags; |
178 ProgramPrimitiveProcessor fPrimitiveProcessor; | |
179 GrBatchTracker fBatchTracker; | |
180 ProgramXferProcessor fXferProcessor; | 172 ProgramXferProcessor fXferProcessor; |
181 FragmentStageArray fFragmentStages; | 173 FragmentStageArray fFragmentStages; |
182 GrGpu::DrawType fDrawType; | 174 GrGpu::DrawType fDrawType; |
183 GrProgramDesc::DescInfo fDescInfo; | 175 GrProgramDesc::DescInfo fDescInfo; |
184 bool fFinalized; | 176 GrGeometryProcessor::InitBT fInitBT; |
185 | 177 |
186 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 178 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
187 int fNumColorStages; | 179 int fNumColorStages; |
188 | 180 |
189 GrProgramDesc fDesc; | 181 GrProgramDesc fDesc; |
190 | 182 |
191 typedef SkRefCnt INHERITED; | 183 typedef SkRefCnt INHERITED; |
192 }; | 184 }; |
193 | 185 |
194 #endif | 186 #endif |
OLD | NEW |