OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 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 #ifndef GrOptDrawState_DEFINED | 8 #ifndef GrPipeline_DEFINED |
9 #define GrOptDrawState_DEFINED | 9 #define GrPipeline_DEFINED |
10 | 10 |
11 #include "GrColor.h" | 11 #include "GrColor.h" |
12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
13 #include "GrPendingFragmentStage.h" | 13 #include "GrPendingFragmentStage.h" |
14 #include "GrProgramDesc.h" | 14 #include "GrProgramDesc.h" |
15 #include "GrStencil.h" | 15 #include "GrStencil.h" |
16 #include "GrTypesPriv.h" | 16 #include "GrTypesPriv.h" |
17 #include "SkMatrix.h" | 17 #include "SkMatrix.h" |
18 #include "SkRefCnt.h" | 18 #include "SkRefCnt.h" |
19 | 19 |
20 class GrDeviceCoordTexture; | 20 class GrDeviceCoordTexture; |
21 class GrDrawState; | |
22 class GrPathProcessor; | 21 class GrPathProcessor; |
| 22 class GrPipelineBuilder; |
23 | 23 |
24 /** | 24 /** |
25 * Class that holds an optimized version of a GrDrawState. It is meant to be an
immutable class, | 25 * Class that holds an optimized version of a GrPipelineBuilder. It is meant to
be an immutable |
26 * and contains all data needed to set the state for a gpu draw. | 26 * class, and contains all data needed to set the state for a gpu draw. |
27 */ | 27 */ |
28 class GrOptDrawState { | 28 class GrPipeline { |
29 public: | 29 public: |
30 SK_DECLARE_INST_COUNT(GrOptDrawState) | 30 SK_DECLARE_INST_COUNT(GrPipeline) |
31 | 31 |
32 GrOptDrawState(const GrDrawState& drawState, const GrPrimitiveProcessor*, | 32 GrPipeline(const GrPipelineBuilder& pipelineBuilder, const GrPrimitiveProces
sor*, |
33 const GrDrawTargetCaps&, const GrScissorState&, | 33 const GrDrawTargetCaps&, const GrScissorState&, |
34 const GrDeviceCoordTexture* dstCopy); | 34 const GrDeviceCoordTexture* dstCopy); |
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 GrPipelines and it will
update 'this' |
38 * to subsume 'that''s draw. | 38 * to subsume 'that''s draw. |
39 */ | 39 */ |
40 bool isEqual(const GrOptDrawState& that) const; | 40 bool isEqual(const GrPipeline& 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 /// |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 bool isHWAntialiasState() const { return SkToBool(fFlags & kHWAA_Flag); } | 115 bool isHWAntialiasState() const { return SkToBool(fFlags & kHWAA_Flag); } |
116 bool mustSkip() const { return NULL == this->getRenderTarget(); } | 116 bool mustSkip() const { return NULL == this->getRenderTarget(); } |
117 | 117 |
118 /// @} | 118 /// @} |
119 | 119 |
120 /** | 120 /** |
121 * Gets whether the target is drawing clockwise, counterclockwise, | 121 * Gets whether the target is drawing clockwise, counterclockwise, |
122 * or both faces. | 122 * or both faces. |
123 * @return the current draw face(s). | 123 * @return the current draw face(s). |
124 */ | 124 */ |
125 GrDrawState::DrawFace getDrawFace() const { return fDrawFace; } | 125 GrPipelineBuilder::DrawFace getDrawFace() const { return fDrawFace; } |
126 | 126 |
127 /// @} | 127 /// @} |
128 | 128 |
129 /////////////////////////////////////////////////////////////////////////// | 129 /////////////////////////////////////////////////////////////////////////// |
130 | 130 |
131 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } | 131 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } |
132 | 132 |
133 const GrProgramDesc::DescInfo& descInfo() const { return fDescInfo; } | 133 const GrProgramDesc::DescInfo& descInfo() const { return fDescInfo; } |
134 | 134 |
135 const GrGeometryProcessor::InitBT& getInitBatchTracker() const { return fIni
tBT; } | 135 const GrGeometryProcessor::InitBT& getInitBatchTracker() const { return fIni
tBT; } |
136 | 136 |
137 private: | 137 private: |
138 /** | 138 /** |
139 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. | 139 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. |
140 */ | 140 */ |
141 void adjustProgramFromOptimizations(const GrDrawState& ds, | 141 void adjustProgramFromOptimizations(const GrPipelineBuilder& ds, |
142 GrXferProcessor::OptFlags, | 142 GrXferProcessor::OptFlags, |
143 const GrProcOptInfo& colorPOI, | 143 const GrProcOptInfo& colorPOI, |
144 const GrProcOptInfo& coveragePOI, | 144 const GrProcOptInfo& coveragePOI, |
145 int* firstColorStageIdx, | 145 int* firstColorStageIdx, |
146 int* firstCoverageStageIdx); | 146 int* firstCoverageStageIdx); |
147 | 147 |
148 /** | 148 /** |
149 * Calculates the primary and secondary output types of the shader. For cert
ain output types | 149 * Calculates the primary and secondary output types of the shader. For cert
ain output types |
150 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst | 150 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst |
151 * blend coeffs will represent those used by backend API. | 151 * blend coeffs will represent those used by backend API. |
152 */ | 152 */ |
153 void setOutputStateInfo(const GrDrawState& ds, GrXferProcessor::OptFlags, | 153 void setOutputStateInfo(const GrPipelineBuilder& ds, GrXferProcessor::OptFla
gs, |
154 const GrDrawTargetCaps&); | 154 const GrDrawTargetCaps&); |
155 | 155 |
156 enum Flags { | 156 enum Flags { |
157 kDither_Flag = 0x1, | 157 kDither_Flag = 0x1, |
158 kHWAA_Flag = 0x2, | 158 kHWAA_Flag = 0x2, |
159 }; | 159 }; |
160 | 160 |
161 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; | 161 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; |
162 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; | 162 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; |
163 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; | 163 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; |
164 RenderTarget fRenderTarget; | 164 RenderTarget fRenderTarget; |
165 GrScissorState fScissorState; | 165 GrScissorState fScissorState; |
166 GrStencilSettings fStencilSettings; | 166 GrStencilSettings fStencilSettings; |
167 GrDrawState::DrawFace fDrawFace; | 167 GrPipelineBuilder::DrawFace fDrawFace; |
168 GrDeviceCoordTexture fDstCopy; | 168 GrDeviceCoordTexture fDstCopy; |
169 uint32_t fFlags; | 169 uint32_t fFlags; |
170 ProgramXferProcessor fXferProcessor; | 170 ProgramXferProcessor fXferProcessor; |
171 FragmentStageArray fFragmentStages; | 171 FragmentStageArray fFragmentStages; |
172 GrProgramDesc::DescInfo fDescInfo; | 172 GrProgramDesc::DescInfo fDescInfo; |
173 GrGeometryProcessor::InitBT fInitBT; | 173 GrGeometryProcessor::InitBT fInitBT; |
174 | 174 |
175 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 175 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
176 int fNumColorStages; | 176 int fNumColorStages; |
177 | 177 |
178 GrProgramDesc fDesc; | 178 GrProgramDesc fDesc; |
179 | 179 |
180 typedef SkRefCnt INHERITED; | 180 typedef SkRefCnt INHERITED; |
181 }; | 181 }; |
182 | 182 |
183 #endif | 183 #endif |
OLD | NEW |