| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 struct Cmd : ::SkNoncopyable { | 109 struct Cmd : ::SkNoncopyable { |
| 110 Cmd(uint8_t type) : fType(type) {} | 110 Cmd(uint8_t type) : fType(type) {} |
| 111 virtual ~Cmd() {} | 111 virtual ~Cmd() {} |
| 112 | 112 |
| 113 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) = 0; | 113 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) = 0; |
| 114 | 114 |
| 115 uint8_t fType; | 115 uint8_t fType; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 struct Draw : public Cmd { | 118 struct Draw : public Cmd { |
| 119 Draw(const DrawInfo& info, const ScissorState& scissorState) | 119 Draw(const DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {} |
| 120 : Cmd(kDraw_Cmd) | |
| 121 , fInfo(info) | |
| 122 , fScissorState(scissorState){} | |
| 123 | 120 |
| 124 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); | 121 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
| 125 | 122 |
| 126 DrawInfo fInfo; | 123 DrawInfo fInfo; |
| 127 ScissorState fScissorState; | |
| 128 }; | 124 }; |
| 129 | 125 |
| 130 struct StencilPath : public Cmd { | 126 struct StencilPath : public Cmd { |
| 131 StencilPath(const GrPath* path) : Cmd(kStencilPath_Cmd), fPath(path) {} | 127 StencilPath(const GrPath* path) : Cmd(kStencilPath_Cmd), fPath(path) {} |
| 132 | 128 |
| 133 const GrPath* path() const { return fPath.get(); } | 129 const GrPath* path() const { return fPath.get(); } |
| 134 | 130 |
| 135 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); | 131 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
| 136 | 132 |
| 137 ScissorState fScissorState; | |
| 138 GrStencilSettings fStencilSettings; | 133 GrStencilSettings fStencilSettings; |
| 139 | 134 |
| 140 private: | 135 private: |
| 141 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 136 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 142 }; | 137 }; |
| 143 | 138 |
| 144 struct DrawPath : public Cmd { | 139 struct DrawPath : public Cmd { |
| 145 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} | 140 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} |
| 146 | 141 |
| 147 const GrPath* path() const { return fPath.get(); } | 142 const GrPath* path() const { return fPath.get(); } |
| 148 | 143 |
| 149 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); | 144 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
| 150 | 145 |
| 151 GrDeviceCoordTexture fDstCopy; | 146 GrDeviceCoordTexture fDstCopy; |
| 152 ScissorState fScissorState; | |
| 153 GrStencilSettings fStencilSettings; | 147 GrStencilSettings fStencilSettings; |
| 154 | 148 |
| 155 private: | 149 private: |
| 156 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 150 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 157 }; | 151 }; |
| 158 | 152 |
| 159 struct DrawPaths : public Cmd { | 153 struct DrawPaths : public Cmd { |
| 160 DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRang
e(pathRange) {} | 154 DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRang
e(pathRange) {} |
| 161 | 155 |
| 162 const GrPathRange* pathRange() const { return fPathRange.get(); } | 156 const GrPathRange* pathRange() const { return fPathRange.get(); } |
| 163 | 157 |
| 164 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); | 158 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
| 165 | 159 |
| 166 int fIndicesLocation; | 160 int fIndicesLocation; |
| 167 size_t fCount; | 161 size_t fCount; |
| 168 int fTransformsLocation; | 162 int fTransformsLocation; |
| 169 PathTransformType fTransformsType; | 163 PathTransformType fTransformsType; |
| 170 GrDeviceCoordTexture fDstCopy; | 164 GrDeviceCoordTexture fDstCopy; |
| 171 ScissorState fScissorState; | |
| 172 GrStencilSettings fStencilSettings; | 165 GrStencilSettings fStencilSettings; |
| 173 | 166 |
| 174 private: | 167 private: |
| 175 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; | 168 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; |
| 176 }; | 169 }; |
| 177 | 170 |
| 178 // This is also used to record a discard by setting the color to GrColor_ILL
EGAL | 171 // This is also used to record a discard by setting the color to GrColor_ILL
EGAL |
| 179 struct Clear : public Cmd { | 172 struct Clear : public Cmd { |
| 180 Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} | 173 Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} |
| 181 | 174 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 GrGpu::DrawType fDrawType; | 224 GrGpu::DrawType fDrawType; |
| 232 GrDeviceCoordTexture fDstCopy; | 225 GrDeviceCoordTexture fDstCopy; |
| 233 }; | 226 }; |
| 234 | 227 |
| 235 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | 228 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. |
| 236 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 229 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
| 237 | 230 |
| 238 // overrides from GrDrawTarget | 231 // overrides from GrDrawTarget |
| 239 void onDraw(const GrDrawState&, | 232 void onDraw(const GrDrawState&, |
| 240 const DrawInfo&, | 233 const DrawInfo&, |
| 241 const GrClipMaskManager::ScissorState&) SK_OVERRIDE; | 234 const ScissorState&) SK_OVERRIDE; |
| 242 void onDrawRect(GrDrawState*, | 235 void onDrawRect(GrDrawState*, |
| 243 const SkRect& rect, | 236 const SkRect& rect, |
| 244 const SkRect* localRect, | 237 const SkRect* localRect, |
| 245 const SkMatrix* localMatrix) SK_OVERRIDE; | 238 const SkMatrix* localMatrix) SK_OVERRIDE; |
| 246 | 239 |
| 247 void onStencilPath(const GrDrawState&, | 240 void onStencilPath(const GrDrawState&, |
| 248 const GrPath*, | 241 const GrPath*, |
| 249 const GrClipMaskManager::ScissorState&, | 242 const ScissorState&, |
| 250 const GrStencilSettings&) SK_OVERRIDE; | 243 const GrStencilSettings&) SK_OVERRIDE; |
| 251 void onDrawPath(const GrDrawState&, | 244 void onDrawPath(const GrDrawState&, |
| 252 const GrPath*, | 245 const GrPath*, |
| 253 const GrClipMaskManager::ScissorState&, | 246 const ScissorState&, |
| 254 const GrStencilSettings&, | 247 const GrStencilSettings&, |
| 255 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; | 248 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
| 256 void onDrawPaths(const GrDrawState&, | 249 void onDrawPaths(const GrDrawState&, |
| 257 const GrPathRange*, | 250 const GrPathRange*, |
| 258 const uint32_t indices[], | 251 const uint32_t indices[], |
| 259 int count, | 252 int count, |
| 260 const float transforms[], | 253 const float transforms[], |
| 261 PathTransformType, | 254 PathTransformType, |
| 262 const GrClipMaskManager::ScissorState&, | 255 const ScissorState&, |
| 263 const GrStencilSettings&, | 256 const GrStencilSettings&, |
| 264 const GrDeviceCoordTexture*) SK_OVERRIDE; | 257 const GrDeviceCoordTexture*) SK_OVERRIDE; |
| 265 void onClear(const SkIRect* rect, | 258 void onClear(const SkIRect* rect, |
| 266 GrColor color, | 259 GrColor color, |
| 267 bool canIgnoreRect, | 260 bool canIgnoreRect, |
| 268 GrRenderTarget* renderTarget) SK_OVERRIDE; | 261 GrRenderTarget* renderTarget) SK_OVERRIDE; |
| 269 void setDrawBuffers(DrawInfo*) SK_OVERRIDE; | 262 void setDrawBuffers(DrawInfo*) SK_OVERRIDE; |
| 270 | 263 |
| 271 bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertice
s) SK_OVERRIDE; | 264 bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertice
s) SK_OVERRIDE; |
| 272 bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE; | 265 bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE; |
| 273 void releaseReservedVertexSpace() SK_OVERRIDE; | 266 void releaseReservedVertexSpace() SK_OVERRIDE; |
| 274 void releaseReservedIndexSpace() SK_OVERRIDE; | 267 void releaseReservedIndexSpace() SK_OVERRIDE; |
| 275 void geometrySourceWillPush() SK_OVERRIDE; | 268 void geometrySourceWillPush() SK_OVERRIDE; |
| 276 void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRID
E; | 269 void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRID
E; |
| 277 void willReserveVertexAndIndexSpace(int vertexCount, | 270 void willReserveVertexAndIndexSpace(int vertexCount, |
| 278 size_t vertexStride, | 271 size_t vertexStride, |
| 279 int indexCount) SK_OVERRIDE; | 272 int indexCount) SK_OVERRIDE; |
| 280 | 273 |
| 281 // Attempts to concat instances from info onto the previous draw. info must
represent an | 274 // Attempts to concat instances from info onto the previous draw. info must
represent an |
| 282 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. | 275 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. |
| 283 int concatInstancedDraw(const GrDrawState&, | 276 int concatInstancedDraw(const GrDrawState&, const DrawInfo&); |
| 284 const DrawInfo&, | |
| 285 const GrClipMaskManager::ScissorState&); | |
| 286 | 277 |
| 287 // Determines whether the current draw operation requires a new GrOptDrawSta
te and if so | 278 // Determines whether the current draw operation requires a new GrOptDrawSta
te and if so |
| 288 // records it. If the draw can be skipped false is returned and no new GrOpt
DrawState is | 279 // records it. If the draw can be skipped false is returned and no new GrOpt
DrawState is |
| 289 // recorded. | 280 // recorded. |
| 290 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, | 281 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, |
| 291 GrGpu::DrawType, | 282 GrGpu::DrawType, |
| 283 const GrClipMaskManager:
:ScissorState&, |
| 292 const GrDeviceCoordTextu
re*); | 284 const GrDeviceCoordTextu
re*); |
| 293 // We lazily record clip changes in order to skip clips that have no effect. | 285 // We lazily record clip changes in order to skip clips that have no effect. |
| 294 void recordClipIfNecessary(); | 286 void recordClipIfNecessary(); |
| 295 // Records any trace markers for a command after adding it to the buffer. | 287 // Records any trace markers for a command after adding it to the buffer. |
| 296 void recordTraceMarkersIfNecessary(); | 288 void recordTraceMarkersIfNecessary(); |
| 297 | 289 |
| 298 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } | 290 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } |
| 299 | 291 |
| 300 // TODO: Use a single allocator for commands and records | 292 // TODO: Use a single allocator for commands and records |
| 301 enum { | 293 enum { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 328 SkTDArray<uint32_t> fPathIndexBuffer; | 320 SkTDArray<uint32_t> fPathIndexBuffer; |
| 329 SkTDArray<float> fPathTransformBuffer; | 321 SkTDArray<float> fPathTransformBuffer; |
| 330 GeoPoolStateStack fGeoPoolStateStack; | 322 GeoPoolStateStack fGeoPoolStateStack; |
| 331 bool fFlushing; | 323 bool fFlushing; |
| 332 uint32_t fDrawID; | 324 uint32_t fDrawID; |
| 333 | 325 |
| 334 typedef GrClipTarget INHERITED; | 326 typedef GrClipTarget INHERITED; |
| 335 }; | 327 }; |
| 336 | 328 |
| 337 #endif | 329 #endif |
| OLD | NEW |