Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(905)

Side by Side Diff: src/gpu/GrOptDrawState.h

Issue 746423007: Draft change to start pulling uniform color into GP (Closed) Base URL: https://skia.googlesource.com/skia.git@no_factories
Patch Set: rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrOptDrawState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 class GrOptDrawState { 28 class GrOptDrawState {
29 public: 29 public:
30 SK_DECLARE_INST_COUNT(GrOptDrawState) 30 SK_DECLARE_INST_COUNT(GrOptDrawState)
31 31
32 typedef GrClipMaskManager::ScissorState ScissorState; 32 typedef GrClipMaskManager::ScissorState ScissorState;
33 33
34 GrOptDrawState(const GrDrawState& drawState, const GrGeometryProcessor*, con st GrPathProcessor*, 34 GrOptDrawState(const GrDrawState& drawState, const GrGeometryProcessor*, con st GrPathProcessor*,
35 const GrDrawTargetCaps&, const ScissorState&, 35 const GrDrawTargetCaps&, const ScissorState&,
36 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); 36 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType);
37 37
38 bool operator== (const GrOptDrawState& that) const; 38 /*
39 bool operator!= (const GrOptDrawState& that) const { return !(*this == that) ; } 39 * Returns true if it is possible to combine the two GrOptDrawStates and it will update 'this'
40 * to subsume 'that''s draw.
41 */
42 bool combineIfPossible(const GrOptDrawState& that);
40 43
41 /// @} 44 /// @}
42 45
43 ///////////////////////////////////////////////////////////////////////////
44 /// @name Color
45 ////
46
47 GrColor getColor() const { return fColor; }
48
49 /// @}
50
51 ///////////////////////////////////////////////////////////////////////////
52 /// @name Coverage
53 ////
54
55 uint8_t getCoverage() const { return fCoverage; }
56
57 GrColor getCoverageColor() const {
58 return GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage);
59 }
60
61 /// @}
62
63 /////////////////////////////////////////////////////////////////////////// 46 ///////////////////////////////////////////////////////////////////////////
64 /// @name Effect Stages 47 /// @name Effect Stages
65 /// Each stage hosts a GrProcessor. The effect produces an output color or c overage in the 48 /// Each stage hosts a GrProcessor. The effect produces an output color or c overage in the
66 /// fragment shader. Its inputs are the output from the previous stage as we ll as some variables 49 /// fragment shader. Its inputs are the output from the previous stage as we ll as some variables
67 /// available to it in the fragment and vertex shader (e.g. the vertex posit ion, the dst color, 50 /// available to it in the fragment and vertex shader (e.g. the vertex posit ion, the dst color,
68 /// the fragment position, local coordinates). 51 /// the fragment position, local coordinates).
69 /// 52 ///
70 /// The stages are divided into two sets, color-computing and coverage-compu ting. The final 53 /// The stages are divided into two sets, color-computing and coverage-compu ting. The final
71 /// color stage produces the final pixel color. The coverage-computing stage s function exactly 54 /// color stage produces the final pixel color. The coverage-computing stage s function exactly
72 /// as the color-computing but the output of the final coverage stage is tre ated as a fractional 55 /// as the color-computing but the output of the final coverage stage is tre ated as a fractional
73 /// pixel coverage rather than as input to the src/dst color blend step. 56 /// pixel coverage rather than as input to the src/dst color blend step.
74 /// 57 ///
75 /// The input color to the first color-stage is either the constant color or interpolated 58 /// The input color to the first color-stage is either the constant color or interpolated
76 /// per-vertex colors. The input to the first coverage stage is either a con stant coverage 59 /// per-vertex colors. The input to the first coverage stage is either a con stant coverage
77 /// (usually full-coverage) or interpolated per-vertex coverage. 60 /// (usually full-coverage) or interpolated per-vertex coverage.
78 //// 61 ////
79 62
80 int numColorStages() const { return fNumColorStages; } 63 int numColorStages() const { return fNumColorStages; }
81 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt ages; } 64 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt ages; }
82 int numFragmentStages() const { return fFragmentStages.count(); } 65 int numFragmentStages() const { return fFragmentStages.count(); }
83 int numTotalStages() const {
84 // the + 1 at the end is for the xferProcessor which will always be pres ent
85 return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 : 0 ) + 1;
86 }
87 66
67 // TODO remove the GP specific calls when the PathProc can provide the same interface
88 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get() ); } 68 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get() ); }
89 const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryPr ocessor.get(); } 69 const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryPr ocessor.get(); }
70 const GrPrimitiveProcessor* getPrimitiveProcessor() const { return fPrimitiv eProcessor.get(); }
90 const GrBatchTracker& getBatchTracker() const { return fBatchTracker; } 71 const GrBatchTracker& getBatchTracker() const { return fBatchTracker; }
91 72
92 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get( ); } 73 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get( ); }
93 74
94 const GrPendingFragmentStage& getColorStage(int idx) const { 75 const GrPendingFragmentStage& getColorStage(int idx) const {
95 SkASSERT(idx < this->numColorStages()); 76 SkASSERT(idx < this->numColorStages());
96 return fFragmentStages[idx]; 77 return fFragmentStages[idx];
97 } 78 }
98 const GrPendingFragmentStage& getCoverageStage(int idx) const { 79 const GrPendingFragmentStage& getCoverageStage(int idx) const {
99 SkASSERT(idx < this->numCoverageStages()); 80 SkASSERT(idx < this->numCoverageStages());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 kDisableColorWrite_Flag = 0x4, 184 kDisableColorWrite_Flag = 0x4,
204 }; 185 };
205 186
206 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; 187 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget;
207 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; 188 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray;
208 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr ocessor; 189 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr ocessor;
209 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitive Processor; 190 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitive Processor;
210 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; 191 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor;
211 RenderTarget fRenderTarget; 192 RenderTarget fRenderTarget;
212 ScissorState fScissorState; 193 ScissorState fScissorState;
213 GrColor fColor;
214 SkMatrix fViewMatrix; 194 SkMatrix fViewMatrix;
215 GrStencilSettings fStencilSettings; 195 GrStencilSettings fStencilSettings;
216 uint8_t fCoverage;
217 GrDrawState::DrawFace fDrawFace; 196 GrDrawState::DrawFace fDrawFace;
218 GrDeviceCoordTexture fDstCopy; 197 GrDeviceCoordTexture fDstCopy;
219 uint32_t fFlags; 198 uint32_t fFlags;
220 ProgramGeometryProcessor fGeometryProcessor; 199 ProgramGeometryProcessor fGeometryProcessor;
221 ProgramPrimitiveProcessor fPrimitiveProcessor; 200 ProgramPrimitiveProcessor fPrimitiveProcessor;
222 GrBatchTracker fBatchTracker; 201 GrBatchTracker fBatchTracker;
223 ProgramXferProcessor fXferProcessor; 202 ProgramXferProcessor fXferProcessor;
224 FragmentStageArray fFragmentStages; 203 FragmentStageArray fFragmentStages;
225 GrGpu::DrawType fDrawType; 204 GrGpu::DrawType fDrawType;
226 GrProgramDesc::DescInfo fDescInfo; 205 GrProgramDesc::DescInfo fDescInfo;
227 bool fFinalized; 206 bool fFinalized;
228 207
229 // This function is equivalent to the offset into fFragmentStages where cove rage stages begin. 208 // This function is equivalent to the offset into fFragmentStages where cove rage stages begin.
230 int fNumColorStages; 209 int fNumColorStages;
231 210
232 GrProgramDesc fDesc; 211 GrProgramDesc fDesc;
233 212
234 typedef SkRefCnt INHERITED; 213 typedef SkRefCnt INHERITED;
235 }; 214 };
236 215
237 #endif 216 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrOptDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698