| 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 |
| 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 GrBatch; |
| 20 class GrDeviceCoordTexture; | 21 class GrDeviceCoordTexture; |
| 21 class GrDrawState; | 22 class GrDrawState; |
| 22 class GrPathProcessor; | |
| 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 GrDrawState. It is meant to be an
immutable class, |
| 26 * and contains all data needed to set the state for a gpu draw. | 26 * and contains all data needed to set the state for a gpu draw. |
| 27 */ | 27 */ |
| 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 // TODO get rid of this version of the constructor when we use batch everywh
ere |
| 32 GrOptDrawState(const GrDrawState& drawState, const GrPrimitiveProcessor*, | 33 GrOptDrawState(const GrDrawState& drawState, const GrPrimitiveProcessor*, |
| 33 const GrDrawTargetCaps&, const GrScissorState&, | 34 const GrDrawTargetCaps&, const GrScissorState&, |
| 34 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); | 35 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); |
| 35 | 36 |
| 37 GrOptDrawState(GrBatch*, |
| 38 const GrDrawState& drawState, |
| 39 const GrDrawTargetCaps&, const GrScissorState&, |
| 40 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); |
| 41 |
| 42 |
| 36 /* | 43 /* |
| 37 * Returns true if it is possible to combine the two GrOptDrawStates and it
will update 'this' | 44 * Returns true if it is possible to combine the two GrOptDrawStates and it
will update 'this' |
| 38 * to subsume 'that''s draw. | 45 * to subsume 'that''s draw. |
| 39 */ | 46 */ |
| 40 bool combineIfPossible(const GrOptDrawState& that); | 47 bool combineIfPossible(GrOptDrawState& that); |
| 41 | 48 |
| 42 /// @} | 49 /// @} |
| 43 | 50 |
| 44 /////////////////////////////////////////////////////////////////////////// | 51 /////////////////////////////////////////////////////////////////////////// |
| 45 /// @name Effect Stages | 52 /// @name Effect Stages |
| 46 /// Each stage hosts a GrProcessor. The effect produces an output color or c
overage in the | 53 /// 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 | 54 /// 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, | 55 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, |
| 49 /// the fragment position, local coordinates). | 56 /// the fragment position, local coordinates). |
| 50 /// | 57 /// |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 136 |
| 130 /// @} | 137 /// @} |
| 131 | 138 |
| 132 /////////////////////////////////////////////////////////////////////////// | 139 /////////////////////////////////////////////////////////////////////////// |
| 133 | 140 |
| 134 GrGpu::DrawType drawType() const { return fDrawType; } | 141 GrGpu::DrawType drawType() const { return fDrawType; } |
| 135 | 142 |
| 136 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } | 143 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } |
| 137 | 144 |
| 138 // Finalize *MUST* be called before programDesc() | 145 // Finalize *MUST* be called before programDesc() |
| 146 // TODO we need to move the descriptor out of GrOptDrawState. The program D
escriptor should be |
| 147 // a combination of OptState descriptor(which can be created when optstate i
s constructed) |
| 148 // and GrGeometryProcessor key. |
| 139 void finalize(GrGpu*); | 149 void finalize(GrGpu*); |
| 140 | 150 |
| 141 const GrProgramDesc& programDesc() const { SkASSERT(fFinalized); return fDes
c; } | 151 const GrProgramDesc& programDesc() const { SkASSERT(fFinalized); return fDes
c; } |
| 142 | 152 |
| 153 void flush(GrGpu*, GrVertexBufferAllocPool*, GrIndexBufferAllocPool*); |
| 154 |
| 155 // TODO this is unfortunate, but GrBatch needs to initialize the batch track
er on the GP |
| 156 // NOBODY ELSE should be using this. Once we use GrBatch everywhere we can
remove this |
| 157 GrBatchTracker* batchTracker() { return &fBatchTracker; } |
| 158 |
| 159 // TODO this goes away when I pull primitive processor off optstate |
| 160 void setPrimitiveProcessor(const GrPrimitiveProcessor* primProc) { |
| 161 fFinalized = false; |
| 162 fPrimitiveProcessor.reset(primProc); |
| 163 } |
| 164 |
| 143 private: | 165 private: |
| 166 // TODO we can have one constructor once GrBatch is complete |
| 167 void internalConstructor(GrGeometryProcessor::InitBT*, |
| 168 const GrDrawState&, |
| 169 const GrProcOptInfo& colorPOI, |
| 170 const GrProcOptInfo& coveragePOI, |
| 171 const GrDrawTargetCaps&, |
| 172 const GrScissorState&, |
| 173 const GrDeviceCoordTexture* dstCopy); |
| 174 |
| 144 /** | 175 /** |
| 145 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. | 176 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. |
| 146 */ | 177 */ |
| 147 void adjustProgramFromOptimizations(const GrDrawState& ds, | 178 void adjustProgramFromOptimizations(const GrDrawState& ds, |
| 148 GrXferProcessor::OptFlags, | 179 GrXferProcessor::OptFlags, |
| 149 const GrProcOptInfo& colorPOI, | 180 const GrProcOptInfo& colorPOI, |
| 150 const GrProcOptInfo& coveragePOI, | 181 const GrProcOptInfo& coveragePOI, |
| 151 int* firstColorStageIdx, | 182 int* firstColorStageIdx, |
| 152 int* firstCoverageStageIdx); | 183 int* firstCoverageStageIdx); |
| 153 | 184 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 216 |
| 186 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 217 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
| 187 int fNumColorStages; | 218 int fNumColorStages; |
| 188 | 219 |
| 189 GrProgramDesc fDesc; | 220 GrProgramDesc fDesc; |
| 190 | 221 |
| 191 typedef SkRefCnt INHERITED; | 222 typedef SkRefCnt INHERITED; |
| 192 }; | 223 }; |
| 193 | 224 |
| 194 #endif | 225 #endif |
| OLD | NEW |