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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 SK_DECLARE_INST_COUNT(GrPipeline) | 30 SK_DECLARE_INST_COUNT(GrPipeline) |
31 | 31 |
32 GrPipeline(const GrPipelineBuilder&, | 32 GrPipeline(const GrPipelineBuilder&, |
33 const GrProcOptInfo& colorPOI, | 33 const GrProcOptInfo& colorPOI, |
34 const GrProcOptInfo& coveragePOI, | 34 const GrProcOptInfo& coveragePOI, |
35 const GrDrawTargetCaps&, | 35 const GrDrawTargetCaps&, |
36 const GrScissorState&, | 36 const GrScissorState&, |
37 const GrDeviceCoordTexture* dstCopy); | 37 const GrDeviceCoordTexture* dstCopy); |
38 | 38 |
39 /* | 39 /* |
40 * Returns true if it is possible to combine the two GrPipelines and it will
update 'this' | 40 * Returns true if these pipelines are equivalent. |
41 * to subsume 'that''s draw. | |
42 */ | 41 */ |
43 bool isEqual(const GrPipeline& that) const; | 42 bool isEqual(const GrPipeline& that) const; |
44 | 43 |
45 /// @} | 44 /// @} |
46 | 45 |
47 /////////////////////////////////////////////////////////////////////////// | 46 /////////////////////////////////////////////////////////////////////////// |
48 /// @name Effect Stages | 47 /// @name GrFragmentProcessors |
49 /// Each stage hosts a GrProcessor. The effect produces an output color or c
overage in the | |
50 /// fragment shader. Its inputs are the output from the previous stage as we
ll as some variables | |
51 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, | |
52 /// the fragment position, local coordinates). | |
53 /// | |
54 /// The stages are divided into two sets, color-computing and coverage-compu
ting. The final | |
55 /// color stage produces the final pixel color. The coverage-computing stage
s function exactly | |
56 /// as the color-computing but the output of the final coverage stage is tre
ated as a fractional | |
57 /// pixel coverage rather than as input to the src/dst color blend step. | |
58 /// | |
59 /// The input color to the first color-stage is either the constant color or
interpolated | |
60 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage | |
61 /// (usually full-coverage) or interpolated per-vertex coverage. | |
62 //// | |
63 | 48 |
64 int numColorStages() const { return fNumColorStages; } | 49 |
65 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt
ages; } | 50 int numColorFragmentStages() const { return fNumColorStages; } |
| 51 int numCoverageFragmentStages() const { return fFragmentStages.count() - fNu
mColorStages; } |
66 int numFragmentStages() const { return fFragmentStages.count(); } | 52 int numFragmentStages() const { return fFragmentStages.count(); } |
67 | 53 |
68 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } | 54 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } |
69 | 55 |
70 const GrPendingFragmentStage& getColorStage(int idx) const { | 56 const GrPendingFragmentStage& getColorStage(int idx) const { |
71 SkASSERT(idx < this->numColorStages()); | 57 SkASSERT(idx < this->numColorFragmentStages()); |
72 return fFragmentStages[idx]; | 58 return fFragmentStages[idx]; |
73 } | 59 } |
74 const GrPendingFragmentStage& getCoverageStage(int idx) const { | 60 const GrPendingFragmentStage& getCoverageStage(int idx) const { |
75 SkASSERT(idx < this->numCoverageStages()); | 61 SkASSERT(idx < this->numCoverageFragmentStages()); |
76 return fFragmentStages[fNumColorStages + idx]; | 62 return fFragmentStages[fNumColorStages + idx]; |
77 } | 63 } |
78 const GrPendingFragmentStage& getFragmentStage(int idx) const { | 64 const GrPendingFragmentStage& getFragmentStage(int idx) const { |
79 return fFragmentStages[idx]; | 65 return fFragmentStages[idx]; |
80 } | 66 } |
81 | 67 |
82 /// @} | 68 /// @} |
83 | 69 |
84 /////////////////////////////////////////////////////////////////////////// | |
85 /// @name Render Target | |
86 //// | |
87 | |
88 /** | 70 /** |
89 * Retrieves the currently set render-target. | 71 * Retrieves the currently set render-target. |
90 * | 72 * |
91 * @return The currently set render target. | 73 * @return The currently set render target. |
92 */ | 74 */ |
93 GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); } | 75 GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); } |
94 | 76 |
95 /// @} | |
96 | |
97 /////////////////////////////////////////////////////////////////////////// | |
98 /// @name Stencil | |
99 //// | |
100 | |
101 const GrStencilSettings& getStencil() const { return fStencilSettings; } | 77 const GrStencilSettings& getStencil() const { return fStencilSettings; } |
102 | 78 |
103 /// @} | |
104 | |
105 /////////////////////////////////////////////////////////////////////////// | |
106 /// @name ScissorState | |
107 //// | |
108 | |
109 const GrScissorState& getScissorState() const { return fScissorState; } | 79 const GrScissorState& getScissorState() const { return fScissorState; } |
110 | 80 |
111 /// @} | |
112 | |
113 /////////////////////////////////////////////////////////////////////////// | |
114 /// @name Boolean Queries | |
115 //// | |
116 | |
117 bool isDitherState() const { return SkToBool(fFlags & kDither_Flag); } | 81 bool isDitherState() const { return SkToBool(fFlags & kDither_Flag); } |
118 bool isHWAntialiasState() const { return SkToBool(fFlags & kHWAA_Flag); } | 82 bool isHWAntialiasState() const { return SkToBool(fFlags & kHWAA_Flag); } |
| 83 // Skip any draws that refer to this pipeline (they should be a no-op). |
119 bool mustSkip() const { return NULL == this->getRenderTarget(); } | 84 bool mustSkip() const { return NULL == this->getRenderTarget(); } |
120 | 85 |
121 /// @} | |
122 | |
123 /** | 86 /** |
124 * Gets whether the target is drawing clockwise, counterclockwise, | 87 * Gets whether the target is drawing clockwise, counterclockwise, |
125 * or both faces. | 88 * or both faces. |
126 * @return the current draw face(s). | 89 * @return the current draw face(s). |
127 */ | 90 */ |
128 GrPipelineBuilder::DrawFace getDrawFace() const { return fDrawFace; } | 91 GrPipelineBuilder::DrawFace getDrawFace() const { return fDrawFace; } |
129 | 92 |
130 /// @} | |
131 | 93 |
132 /////////////////////////////////////////////////////////////////////////// | 94 /////////////////////////////////////////////////////////////////////////// |
133 | 95 |
134 bool readsFragPosition() const { return fReadsFragPosition; } | 96 bool readsFragPosition() const { return fReadsFragPosition; } |
135 | 97 |
136 const GrPipelineInfo& getInitBatchTracker() const { return fInitBT; } | 98 const GrPipelineInfo& getInitBatchTracker() const { return fInitBT; } |
137 | 99 |
138 private: | 100 private: |
139 /** | 101 /** |
140 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. | 102 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 136 |
175 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 137 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
176 int fNumColorStages; | 138 int fNumColorStages; |
177 | 139 |
178 GrProgramDesc fDesc; | 140 GrProgramDesc fDesc; |
179 | 141 |
180 typedef SkRefCnt INHERITED; | 142 typedef SkRefCnt INHERITED; |
181 }; | 143 }; |
182 | 144 |
183 #endif | 145 #endif |
OLD | NEW |