| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrInOrderDrawBuffer_DEFINED | 8 #ifndef GrInOrderDrawBuffer_DEFINED |
| 9 #define GrInOrderDrawBuffer_DEFINED | 9 #define GrInOrderDrawBuffer_DEFINED |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // tracking for draws | 44 // tracking for draws |
| 45 DrawToken getCurrentDrawToken() SK_OVERRIDE { return DrawToken(this, fDrawID
); } | 45 DrawToken getCurrentDrawToken() SK_OVERRIDE { return DrawToken(this, fDrawID
); } |
| 46 | 46 |
| 47 void clearStencilClip(const SkIRect& rect, | 47 void clearStencilClip(const SkIRect& rect, |
| 48 bool insideClip, | 48 bool insideClip, |
| 49 GrRenderTarget* renderTarget) SK_OVERRIDE; | 49 GrRenderTarget* renderTarget) SK_OVERRIDE; |
| 50 | 50 |
| 51 void discard(GrRenderTarget*) SK_OVERRIDE; | 51 void discard(GrRenderTarget*) SK_OVERRIDE; |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 typedef GrGpu::DrawArgs DrawArgs; |
| 54 enum { | 55 enum { |
| 55 kDraw_Cmd = 1, | 56 kDraw_Cmd = 1, |
| 56 kStencilPath_Cmd = 2, | 57 kStencilPath_Cmd = 2, |
| 57 kSetState_Cmd = 3, | 58 kSetState_Cmd = 3, |
| 58 kClear_Cmd = 4, | 59 kClear_Cmd = 4, |
| 59 kCopySurface_Cmd = 5, | 60 kCopySurface_Cmd = 5, |
| 60 kDrawPath_Cmd = 6, | 61 kDrawPath_Cmd = 6, |
| 61 kDrawPaths_Cmd = 7, | 62 kDrawPaths_Cmd = 7, |
| 62 }; | 63 }; |
| 63 | 64 |
| 65 struct SetState; |
| 66 |
| 64 struct Cmd : ::SkNoncopyable { | 67 struct Cmd : ::SkNoncopyable { |
| 65 Cmd(uint8_t type) : fType(type) {} | 68 Cmd(uint8_t type) : fType(type) {} |
| 66 virtual ~Cmd() {} | 69 virtual ~Cmd() {} |
| 67 | 70 |
| 68 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) = 0; | 71 virtual void execute(GrInOrderDrawBuffer*, const SetState*) = 0; |
| 69 | 72 |
| 70 uint8_t fType; | 73 uint8_t fType; |
| 71 }; | 74 }; |
| 72 | 75 |
| 73 struct Draw : public Cmd { | 76 struct Draw : public Cmd { |
| 74 Draw(const DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {} | 77 Draw(const DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {} |
| 75 | 78 |
| 76 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 79 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
| 77 | 80 |
| 78 DrawInfo fInfo; | 81 DrawInfo fInfo; |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 struct StencilPath : public Cmd { | 84 struct StencilPath : public Cmd { |
| 82 StencilPath(const GrPath* path, GrRenderTarget* rt) | 85 StencilPath(const GrPath* path, GrRenderTarget* rt) |
| 83 : Cmd(kStencilPath_Cmd) | 86 : Cmd(kStencilPath_Cmd) |
| 84 , fRenderTarget(rt) | 87 , fRenderTarget(rt) |
| 85 , fPath(path) {} | 88 , fPath(path) {} |
| 86 | 89 |
| 87 const GrPath* path() const { return fPath.get(); } | 90 const GrPath* path() const { return fPath.get(); } |
| 88 | 91 |
| 89 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 92 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
| 90 | 93 |
| 91 SkMatrix fViewMatrix; | 94 SkMatrix fViewMatrix; |
| 92 bool fUseHWAA; | 95 bool fUseHWAA; |
| 93 GrStencilSettings fStencil; | 96 GrStencilSettings fStencil; |
| 94 GrScissorState fScissor; | 97 GrScissorState fScissor; |
| 95 private: | 98 private: |
| 96 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 99 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 97 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 100 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 98 }; | 101 }; |
| 99 | 102 |
| 100 struct DrawPath : public Cmd { | 103 struct DrawPath : public Cmd { |
| 101 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} | 104 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} |
| 102 | 105 |
| 103 const GrPath* path() const { return fPath.get(); } | 106 const GrPath* path() const { return fPath.get(); } |
| 104 | 107 |
| 105 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 108 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
| 106 | 109 |
| 107 GrStencilSettings fStencilSettings; | 110 GrStencilSettings fStencilSettings; |
| 108 | 111 |
| 109 private: | 112 private: |
| 110 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 113 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 111 }; | 114 }; |
| 112 | 115 |
| 113 struct DrawPaths : public Cmd { | 116 struct DrawPaths : public Cmd { |
| 114 DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRang
e(pathRange) {} | 117 DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRang
e(pathRange) {} |
| 115 | 118 |
| 116 const GrPathRange* pathRange() const { return fPathRange.get(); } | 119 const GrPathRange* pathRange() const { return fPathRange.get(); } |
| 117 | 120 |
| 118 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 121 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
| 119 | 122 |
| 120 int fIndicesLocation; | 123 int fIndicesLocation; |
| 121 PathIndexType fIndexType; | 124 PathIndexType fIndexType; |
| 122 int fTransformsLocation; | 125 int fTransformsLocation; |
| 123 PathTransformType fTransformType; | 126 PathTransformType fTransformType; |
| 124 int fCount; | 127 int fCount; |
| 125 GrStencilSettings fStencilSettings; | 128 GrStencilSettings fStencilSettings; |
| 126 | 129 |
| 127 private: | 130 private: |
| 128 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; | 131 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; |
| 129 }; | 132 }; |
| 130 | 133 |
| 131 // This is also used to record a discard by setting the color to GrColor_ILL
EGAL | 134 // This is also used to record a discard by setting the color to GrColor_ILL
EGAL |
| 132 struct Clear : public Cmd { | 135 struct Clear : public Cmd { |
| 133 Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} | 136 Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} |
| 134 | 137 |
| 135 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | 138 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
| 136 | 139 |
| 137 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 140 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
| 138 | 141 |
| 139 SkIRect fRect; | 142 SkIRect fRect; |
| 140 GrColor fColor; | 143 GrColor fColor; |
| 141 bool fCanIgnoreRect; | 144 bool fCanIgnoreRect; |
| 142 | 145 |
| 143 private: | 146 private: |
| 144 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 147 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 145 }; | 148 }; |
| 146 | 149 |
| 147 // This command is ONLY used by the clip mask manager to clear the stencil c
lip bits | 150 // This command is ONLY used by the clip mask manager to clear the stencil c
lip bits |
| 148 struct ClearStencilClip : public Cmd { | 151 struct ClearStencilClip : public Cmd { |
| 149 ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt
) {} | 152 ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt
) {} |
| 150 | 153 |
| 151 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | 154 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
| 152 | 155 |
| 153 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 156 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
| 154 | 157 |
| 155 SkIRect fRect; | 158 SkIRect fRect; |
| 156 bool fInsideClip; | 159 bool fInsideClip; |
| 157 | 160 |
| 158 private: | 161 private: |
| 159 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 162 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 160 }; | 163 }; |
| 161 | 164 |
| 162 struct CopySurface : public Cmd { | 165 struct CopySurface : public Cmd { |
| 163 CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDs
t(dst), fSrc(src) {} | 166 CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDs
t(dst), fSrc(src) {} |
| 164 | 167 |
| 165 GrSurface* dst() const { return fDst.get(); } | 168 GrSurface* dst() const { return fDst.get(); } |
| 166 GrSurface* src() const { return fSrc.get(); } | 169 GrSurface* src() const { return fSrc.get(); } |
| 167 | 170 |
| 168 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 171 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
| 169 | 172 |
| 170 SkIPoint fDstPoint; | 173 SkIPoint fDstPoint; |
| 171 SkIRect fSrcRect; | 174 SkIRect fSrcRect; |
| 172 | 175 |
| 173 private: | 176 private: |
| 174 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; | 177 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
| 175 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; | 178 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
| 176 }; | 179 }; |
| 177 | 180 |
| 178 struct SetState : public Cmd { | 181 struct SetState : public Cmd { |
| 179 SetState(const GrDrawState& drawState, const GrPrimitiveProcessor* primP
roc, | 182 SetState(const GrDrawState& drawState, const GrPrimitiveProcessor* primP
roc, |
| 180 const GrDrawTargetCaps& caps, | 183 const GrDrawTargetCaps& caps, |
| 181 const GrScissorState& scissor, const GrDeviceCoordTexture* dstC
opy, | 184 const GrScissorState& scissor, const GrDeviceCoordTexture* dstC
opy, |
| 182 GrGpu::DrawType drawType) | 185 GrGpu::DrawType drawType) |
| 183 : Cmd(kSetState_Cmd) | 186 : Cmd(kSetState_Cmd) |
| 187 , fPrimitiveProcessor(primProc) |
| 184 , fState(drawState, primProc, caps, scissor, dstCopy, drawType) {} | 188 , fState(drawState, primProc, caps, scissor, dstCopy, drawType) {} |
| 185 | 189 |
| 186 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 190 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
| 187 | 191 |
| 188 GrOptDrawState fState; | 192 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi
tiveProcessor; |
| 193 ProgramPrimitiveProcessor fPrimitiveProcessor; |
| 194 const GrOptDrawState fState; |
| 195 GrProgramDesc fDesc; |
| 196 GrBatchTracker fBatchTracker; |
| 189 }; | 197 }; |
| 190 | 198 |
| 191 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | 199 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. |
| 192 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 200 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
| 193 | 201 |
| 194 void onReset() SK_OVERRIDE; | 202 void onReset() SK_OVERRIDE; |
| 195 void onFlush() SK_OVERRIDE; | 203 void onFlush() SK_OVERRIDE; |
| 196 | 204 |
| 197 // overrides from GrDrawTarget | 205 // overrides from GrDrawTarget |
| 198 void onDraw(const GrDrawState&, | 206 void onDraw(const GrDrawState&, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } | 266 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } |
| 259 | 267 |
| 260 // TODO: Use a single allocator for commands and records | 268 // TODO: Use a single allocator for commands and records |
| 261 enum { | 269 enum { |
| 262 kCmdBufferInitialSizeInBytes = 8 * 1024, | 270 kCmdBufferInitialSizeInBytes = 8 * 1024, |
| 263 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 271 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
| 264 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 272 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
| 265 }; | 273 }; |
| 266 | 274 |
| 267 CmdBuffer fCmdBuffer; | 275 CmdBuffer fCmdBuffer; |
| 268 GrOptDrawState* fPrevState; | 276 SetState* fPrevState; |
| 269 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 277 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
| 270 SkTDArray<char> fPathIndexBuffer; | 278 SkTDArray<char> fPathIndexBuffer; |
| 271 SkTDArray<float> fPathTransformBuffer; | 279 SkTDArray<float> fPathTransformBuffer; |
| 272 uint32_t fDrawID; | 280 uint32_t fDrawID; |
| 273 | 281 |
| 274 typedef GrFlushToGpuDrawTarget INHERITED; | 282 typedef GrFlushToGpuDrawTarget INHERITED; |
| 275 }; | 283 }; |
| 276 | 284 |
| 277 #endif | 285 #endif |
| OLD | NEW |