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 #ifndef GrPipeline_DEFINED | 8 #ifndef GrPipeline_DEFINED |
9 #define GrPipeline_DEFINED | 9 #define GrPipeline_DEFINED |
10 | 10 |
11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrFragmentProcessor.h" |
12 #include "GrGpu.h" | 13 #include "GrGpu.h" |
13 #include "GrNonAtomicRef.h" | 14 #include "GrNonAtomicRef.h" |
14 #include "GrPendingFragmentStage.h" | 15 #include "GrPendingProgramElement.h" |
15 #include "GrPrimitiveProcessor.h" | 16 #include "GrPrimitiveProcessor.h" |
16 #include "GrProgramDesc.h" | 17 #include "GrProgramDesc.h" |
17 #include "GrStencil.h" | 18 #include "GrStencil.h" |
18 #include "GrTypesPriv.h" | 19 #include "GrTypesPriv.h" |
19 #include "SkMatrix.h" | 20 #include "SkMatrix.h" |
20 #include "SkRefCnt.h" | 21 #include "SkRefCnt.h" |
21 | 22 |
22 class GrBatch; | 23 class GrBatch; |
23 class GrDeviceCoordTexture; | 24 class GrDeviceCoordTexture; |
24 class GrPipelineBuilder; | 25 class GrPipelineBuilder; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 78 } |
78 return true; | 79 return true; |
79 } | 80 } |
80 | 81 |
81 /// @} | 82 /// @} |
82 | 83 |
83 /////////////////////////////////////////////////////////////////////////// | 84 /////////////////////////////////////////////////////////////////////////// |
84 /// @name GrFragmentProcessors | 85 /// @name GrFragmentProcessors |
85 | 86 |
86 | 87 |
87 int numColorFragmentStages() const { return fNumColorStages; } | 88 int numColorFragmentProcessors() const { return fNumColorProcessors; } |
88 int numCoverageFragmentStages() const { return fFragmentStages.count() - fNu
mColorStages; } | 89 int numCoverageFragmentProcessors() const { |
89 int numFragmentStages() const { return fFragmentStages.count(); } | 90 return fFragmentProcessors.count() - fNumColorProcessors; |
| 91 } |
| 92 int numFragmentProcessors() const { return fFragmentProcessors.count(); } |
90 | 93 |
91 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } | 94 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } |
92 | 95 |
93 const GrPendingFragmentStage& getColorStage(int idx) const { | 96 const GrFragmentProcessor& getColorFragmentProcessor(int idx) const { |
94 SkASSERT(idx < this->numColorFragmentStages()); | 97 SkASSERT(idx < this->numColorFragmentProcessors()); |
95 return fFragmentStages[idx]; | 98 return *fFragmentProcessors[idx].get(); |
96 } | 99 } |
97 const GrPendingFragmentStage& getCoverageStage(int idx) const { | 100 |
98 SkASSERT(idx < this->numCoverageFragmentStages()); | 101 const GrFragmentProcessor& getCoverageFragmentProcessor(int idx) const { |
99 return fFragmentStages[fNumColorStages + idx]; | 102 SkASSERT(idx < this->numCoverageFragmentProcessors()); |
| 103 return *fFragmentProcessors[fNumColorProcessors + idx].get(); |
100 } | 104 } |
101 const GrPendingFragmentStage& getFragmentStage(int idx) const { | 105 |
102 return fFragmentStages[idx]; | 106 const GrFragmentProcessor& getFragmentProcessor(int idx) const { |
| 107 return *fFragmentProcessors[idx].get(); |
103 } | 108 } |
104 | 109 |
105 /// @} | 110 /// @} |
106 | 111 |
107 /** | 112 /** |
108 * Retrieves the currently set render-target. | 113 * Retrieves the currently set render-target. |
109 * | 114 * |
110 * @return The currently set render target. | 115 * @return The currently set render target. |
111 */ | 116 */ |
112 GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); } | 117 GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); } |
(...skipping 29 matching lines...) Expand all Loading... |
142 private: | 147 private: |
143 GrPipeline() { /** Initialized in factory function*/ } | 148 GrPipeline() { /** Initialized in factory function*/ } |
144 | 149 |
145 /** | 150 /** |
146 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. | 151 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. |
147 */ | 152 */ |
148 void adjustProgramFromOptimizations(const GrPipelineBuilder& ds, | 153 void adjustProgramFromOptimizations(const GrPipelineBuilder& ds, |
149 GrXferProcessor::OptFlags, | 154 GrXferProcessor::OptFlags, |
150 const GrProcOptInfo& colorPOI, | 155 const GrProcOptInfo& colorPOI, |
151 const GrProcOptInfo& coveragePOI, | 156 const GrProcOptInfo& coveragePOI, |
152 int* firstColorStageIdx, | 157 int* firstColorProcessorIdx, |
153 int* firstCoverageStageIdx); | 158 int* firstCoverageProcessorIdx); |
154 | 159 |
155 /** | 160 /** |
156 * Calculates the primary and secondary output types of the shader. For cert
ain output types | 161 * Calculates the primary and secondary output types of the shader. For cert
ain output types |
157 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst | 162 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst |
158 * blend coeffs will represent those used by backend API. | 163 * blend coeffs will represent those used by backend API. |
159 */ | 164 */ |
160 void setOutputStateInfo(const GrPipelineBuilder& ds, GrXferProcessor::OptFla
gs, | 165 void setOutputStateInfo(const GrPipelineBuilder& ds, GrXferProcessor::OptFla
gs, |
161 const GrCaps&); | 166 const GrCaps&); |
162 | 167 |
163 enum Flags { | 168 enum Flags { |
164 kDither_Flag = 0x1, | 169 kDither_Flag = 0x1, |
165 kHWAA_Flag = 0x2, | 170 kHWAA_Flag = 0x2, |
166 kSnapVertices_Flag = 0x4, | 171 kSnapVertices_Flag = 0x4, |
167 }; | 172 }; |
168 | 173 |
169 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; | 174 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; |
170 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; | 175 typedef GrPendingProgramElement<const GrFragmentProcessor> PendingFragmentPr
ocessor; |
| 176 typedef SkAutoSTArray<8, PendingFragmentProcessor> FragmentProcessorArray; |
171 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; | 177 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; |
172 RenderTarget fRenderTarget; | 178 RenderTarget fRenderTarget; |
173 GrScissorState fScissorState; | 179 GrScissorState fScissorState; |
174 GrStencilSettings fStencilSettings; | 180 GrStencilSettings fStencilSettings; |
175 GrPipelineBuilder::DrawFace fDrawFace; | 181 GrPipelineBuilder::DrawFace fDrawFace; |
176 uint32_t fFlags; | 182 uint32_t fFlags; |
177 ProgramXferProcessor fXferProcessor; | 183 ProgramXferProcessor fXferProcessor; |
178 FragmentStageArray fFragmentStages; | 184 FragmentProcessorArray fFragmentProcessors; |
179 bool fReadsFragPosition; | 185 bool fReadsFragPosition; |
180 | 186 |
181 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 187 // This value is also the index in fFragmentProcessors where coverage proces
sors begin. |
182 int fNumColorStages; | 188 int fNumColorProcessors; |
183 | 189 |
184 SkSTArray<8, const GrCoordTransform*, true> fCoordTransforms; | 190 SkSTArray<8, const GrCoordTransform*, true> fCoordTransforms; |
185 GrProgramDesc fDesc; | 191 GrProgramDesc fDesc; |
186 | 192 |
187 typedef SkRefCnt INHERITED; | 193 typedef SkRefCnt INHERITED; |
188 }; | 194 }; |
189 | 195 |
190 #endif | 196 #endif |
OLD | NEW |