| 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 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 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 /* |
| 39 * the Equality operator may update GrOptDrawState's GrBatchTracker object t
o subsume that's |
| 40 * GrBatchTracker into this's GrBatchTracker. |
| 41 */ |
| 38 bool operator== (const GrOptDrawState& that) const; | 42 bool operator== (const GrOptDrawState& that) const; |
| 39 bool operator!= (const GrOptDrawState& that) const { return !(*this == that)
; } | 43 bool operator!= (const GrOptDrawState& that) const { return !(*this == that)
; } |
| 40 | 44 |
| 41 /// @} | 45 /// @} |
| 42 | 46 |
| 43 /////////////////////////////////////////////////////////////////////////// | 47 /////////////////////////////////////////////////////////////////////////// |
| 44 /// @name Color | 48 /// @name Color |
| 45 //// | 49 //// |
| 46 | 50 |
| 47 GrColor getColor() const { return fColor; } | 51 GrColor getColor() const { return fColor; } |
| 48 | 52 |
| 49 /// @} | 53 /// @} |
| 50 | 54 |
| 51 /////////////////////////////////////////////////////////////////////////// | 55 /////////////////////////////////////////////////////////////////////////// |
| 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 /////////////////////////////////////////////////////////////////////////// | |
| 64 /// @name Effect Stages | 56 /// @name Effect Stages |
| 65 /// Each stage hosts a GrProcessor. The effect produces an output color or c
overage in the | 57 /// 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 | 58 /// 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, | 59 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, |
| 68 /// the fragment position, local coordinates). | 60 /// the fragment position, local coordinates). |
| 69 /// | 61 /// |
| 70 /// The stages are divided into two sets, color-computing and coverage-compu
ting. The final | 62 /// 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 | 63 /// 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 | 64 /// 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. | 65 /// pixel coverage rather than as input to the src/dst color blend step. |
| 74 /// | 66 /// |
| 75 /// The input color to the first color-stage is either the constant color or
interpolated | 67 /// 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 | 68 /// 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. | 69 /// (usually full-coverage) or interpolated per-vertex coverage. |
| 78 //// | 70 //// |
| 79 | 71 |
| 80 int numColorStages() const { return fNumColorStages; } | 72 int numColorStages() const { return fNumColorStages; } |
| 81 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt
ages; } | 73 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt
ages; } |
| 82 int numFragmentStages() const { return fFragmentStages.count(); } | 74 int numFragmentStages() const { return fFragmentStages.count(); } |
| 83 int numTotalStages() const { | 75 int numTotalStages() const { |
| 84 // the + 1 at the end is for the xferProcessor which will always be pres
ent | 76 // the + 1 at the end is for the xferProcessor which will always be pres
ent |
| 85 return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 : 0
) + 1; | 77 return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 : 0
) + 1; |
| 86 } | 78 } |
| 87 | 79 |
| 80 // TODO remove the GP specific calls when the PathProc can provide the same
interface |
| 88 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()
); } | 81 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()
); } |
| 89 const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryPr
ocessor.get(); } | 82 const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryPr
ocessor.get(); } |
| 83 const GrPrimitiveProcessor* getPrimitiveProcessor() const { return fPrimitiv
eProcessor.get(); } |
| 90 const GrBatchTracker& getBatchTracker() const { return fBatchTracker; } | 84 const GrBatchTracker& getBatchTracker() const { return fBatchTracker; } |
| 91 | 85 |
| 92 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } | 86 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } |
| 93 | 87 |
| 94 const GrPendingFragmentStage& getColorStage(int idx) const { | 88 const GrPendingFragmentStage& getColorStage(int idx) const { |
| 95 SkASSERT(idx < this->numColorStages()); | 89 SkASSERT(idx < this->numColorStages()); |
| 96 return fFragmentStages[idx]; | 90 return fFragmentStages[idx]; |
| 97 } | 91 } |
| 98 const GrPendingFragmentStage& getCoverageStage(int idx) const { | 92 const GrPendingFragmentStage& getCoverageStage(int idx) const { |
| 99 SkASSERT(idx < this->numCoverageStages()); | 93 SkASSERT(idx < this->numCoverageStages()); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; | 200 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; |
| 207 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; | 201 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; |
| 208 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; | 202 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; |
| 209 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitive
Processor; | 203 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitive
Processor; |
| 210 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; | 204 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; |
| 211 RenderTarget fRenderTarget; | 205 RenderTarget fRenderTarget; |
| 212 ScissorState fScissorState; | 206 ScissorState fScissorState; |
| 213 GrColor fColor; | 207 GrColor fColor; |
| 214 SkMatrix fViewMatrix; | 208 SkMatrix fViewMatrix; |
| 215 GrStencilSettings fStencilSettings; | 209 GrStencilSettings fStencilSettings; |
| 216 uint8_t fCoverage; | |
| 217 GrDrawState::DrawFace fDrawFace; | 210 GrDrawState::DrawFace fDrawFace; |
| 218 GrDeviceCoordTexture fDstCopy; | 211 GrDeviceCoordTexture fDstCopy; |
| 219 uint32_t fFlags; | 212 uint32_t fFlags; |
| 220 ProgramGeometryProcessor fGeometryProcessor; | 213 ProgramGeometryProcessor fGeometryProcessor; |
| 221 ProgramPrimitiveProcessor fPrimitiveProcessor; | 214 ProgramPrimitiveProcessor fPrimitiveProcessor; |
| 222 GrBatchTracker fBatchTracker; | 215 mutable GrBatchTracker fBatchTracker; |
| 223 ProgramXferProcessor fXferProcessor; | 216 ProgramXferProcessor fXferProcessor; |
| 224 FragmentStageArray fFragmentStages; | 217 FragmentStageArray fFragmentStages; |
| 225 GrGpu::DrawType fDrawType; | 218 GrGpu::DrawType fDrawType; |
| 226 GrProgramDesc::DescInfo fDescInfo; | 219 GrProgramDesc::DescInfo fDescInfo; |
| 227 bool fFinalized; | 220 bool fFinalized; |
| 228 | 221 |
| 229 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 222 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
| 230 int fNumColorStages; | 223 int fNumColorStages; |
| 231 | 224 |
| 232 GrProgramDesc fDesc; | 225 GrProgramDesc fDesc; |
| 233 | 226 |
| 234 typedef SkRefCnt INHERITED; | 227 typedef SkRefCnt INHERITED; |
| 235 }; | 228 }; |
| 236 | 229 |
| 237 #endif | 230 #endif |
| OLD | NEW |