OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrDrawTarget_DEFINED | 8 #ifndef GrDrawTarget_DEFINED |
9 #define GrDrawTarget_DEFINED | 9 #define GrDrawTarget_DEFINED |
10 | 10 |
11 #include "GrClipData.h" | 11 #include "GrClipData.h" |
12 #include "GrClipMaskManager.h" | 12 #include "GrClipMaskManager.h" |
13 #include "GrContext.h" | 13 #include "GrContext.h" |
14 #include "GrIndexBuffer.h" | 14 #include "GrIndexBuffer.h" |
15 #include "GrPathRendering.h" | 15 #include "GrPathRendering.h" |
16 #include "GrPipelineBuilder.h" | 16 #include "GrPipelineBuilder.h" |
17 #include "GrTraceMarker.h" | 17 #include "GrTraceMarker.h" |
18 #include "GrVertexBuffer.h" | 18 #include "GrVertexBuffer.h" |
19 | 19 |
20 #include "SkClipStack.h" | 20 #include "SkClipStack.h" |
21 #include "SkMatrix.h" | 21 #include "SkMatrix.h" |
22 #include "SkPath.h" | 22 #include "SkPath.h" |
23 #include "SkStrokeRec.h" | 23 #include "SkStrokeRec.h" |
24 #include "SkTArray.h" | 24 #include "SkTArray.h" |
25 #include "SkTLazy.h" | 25 #include "SkTLazy.h" |
26 #include "SkTypes.h" | 26 #include "SkTypes.h" |
27 #include "SkXfermode.h" | 27 #include "SkXfermode.h" |
28 | 28 |
| 29 class GrBatch; |
29 class GrClipData; | 30 class GrClipData; |
30 class GrDrawTargetCaps; | 31 class GrDrawTargetCaps; |
31 class GrPath; | 32 class GrPath; |
32 class GrPathRange; | 33 class GrPathRange; |
33 | 34 |
34 class GrDrawTarget : public SkRefCnt { | 35 class GrDrawTarget : public SkRefCnt { |
35 public: | 36 public: |
36 SK_DECLARE_INST_COUNT(GrDrawTarget) | 37 SK_DECLARE_INST_COUNT(GrDrawTarget) |
37 | 38 |
38 typedef GrPathRange::PathIndexType PathIndexType; | 39 typedef GrPathRange::PathIndexType PathIndexType; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 * @param devBounds optional bounds hint. This is a promise from the call
er, | 253 * @param devBounds optional bounds hint. This is a promise from the call
er, |
253 * not a request for clipping. | 254 * not a request for clipping. |
254 */ | 255 */ |
255 void drawNonIndexed(GrPipelineBuilder*, | 256 void drawNonIndexed(GrPipelineBuilder*, |
256 const GrGeometryProcessor*, | 257 const GrGeometryProcessor*, |
257 GrPrimitiveType type, | 258 GrPrimitiveType type, |
258 int startVertex, | 259 int startVertex, |
259 int vertexCount, | 260 int vertexCount, |
260 const SkRect* devBounds = NULL); | 261 const SkRect* devBounds = NULL); |
261 | 262 |
| 263 void drawBatch(GrPipelineBuilder*, |
| 264 GrBatch*, |
| 265 const SkRect* devBounds = NULL); |
| 266 |
262 /** | 267 /** |
263 * Draws path into the stencil buffer. The fill must be either even/odd or | 268 * Draws path into the stencil buffer. The fill must be either even/odd or |
264 * winding (not inverse or hairline). It will respect the HW antialias flag | 269 * winding (not inverse or hairline). It will respect the HW antialias flag |
265 * on the GrPipelineBuilder (if possible in the 3D API). Note, we will neve
r have an inverse | 270 * on the GrPipelineBuilder (if possible in the 3D API). Note, we will neve
r have an inverse |
266 * fill with stencil path | 271 * fill with stencil path |
267 */ | 272 */ |
268 void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, | 273 void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, |
269 GrPathRendering::FillType); | 274 GrPathRendering::FillType); |
270 | 275 |
271 /** | 276 /** |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 * and thus will finalize any reserved geometry. | 308 * and thus will finalize any reserved geometry. |
304 * | 309 * |
305 * @param rect the rect to draw | 310 * @param rect the rect to draw |
306 * @param localRect optional rect that specifies local coords to map onto | 311 * @param localRect optional rect that specifies local coords to map onto |
307 * rect. If NULL then rect serves as the local coords. | 312 * rect. If NULL then rect serves as the local coords. |
308 * @param localMatrix Optional local matrix. The local coordinates are speci
fied by localRect, | 313 * @param localMatrix Optional local matrix. The local coordinates are speci
fied by localRect, |
309 * or if it is NULL by rect. This matrix applies to the c
oordinate implied by | 314 * or if it is NULL by rect. This matrix applies to the c
oordinate implied by |
310 * that rectangle before it is input to GrCoordTransforms
that read local | 315 * that rectangle before it is input to GrCoordTransforms
that read local |
311 * coordinates | 316 * coordinates |
312 */ | 317 */ |
313 void drawRect(GrPipelineBuilder* ds, | 318 void drawRect(GrPipelineBuilder* pipelineBuilder, |
314 GrColor color, | 319 GrColor color, |
315 const SkMatrix& viewMatrix, | 320 const SkMatrix& viewMatrix, |
316 const SkRect& rect, | 321 const SkRect& rect, |
317 const SkRect* localRect, | 322 const SkRect* localRect, |
318 const SkMatrix* localMatrix) { | 323 const SkMatrix* localMatrix) { |
319 AutoGeometryPush agp(this); | 324 AutoGeometryPush agp(this); |
320 this->onDrawRect(ds, color, viewMatrix, rect, localRect, localMatrix); | 325 this->onDrawRect(pipelineBuilder, color, viewMatrix, rect, localRect, lo
calMatrix); |
321 } | 326 } |
322 | 327 |
323 /** | 328 /** |
324 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. | 329 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. |
325 */ | 330 */ |
326 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi
ewM, | 331 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi
ewM, |
327 const SkRect& rect) { | 332 const SkRect& rect) { |
328 this->drawRect(ds, color, viewM, rect, NULL, NULL); | 333 this->drawRect(ds, color, viewM, rect, NULL, NULL); |
329 } | 334 } |
330 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi
ewM, | 335 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi
ewM, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 // so that should be okay | 525 // so that should be okay |
521 }; | 526 }; |
522 | 527 |
523 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } | 528 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } |
524 | 529 |
525 /** | 530 /** |
526 * Used to communicate draws to GPUs / subclasses | 531 * Used to communicate draws to GPUs / subclasses |
527 */ | 532 */ |
528 class DrawInfo { | 533 class DrawInfo { |
529 public: | 534 public: |
| 535 DrawInfo() { fDevBounds = NULL; } |
530 DrawInfo(const DrawInfo& di) { (*this) = di; } | 536 DrawInfo(const DrawInfo& di) { (*this) = di; } |
531 DrawInfo& operator =(const DrawInfo& di); | 537 DrawInfo& operator =(const DrawInfo& di); |
532 | 538 |
533 GrPrimitiveType primitiveType() const { return fPrimitiveType; } | 539 GrPrimitiveType primitiveType() const { return fPrimitiveType; } |
534 int startVertex() const { return fStartVertex; } | 540 int startVertex() const { return fStartVertex; } |
535 int startIndex() const { return fStartIndex; } | 541 int startIndex() const { return fStartIndex; } |
536 int vertexCount() const { return fVertexCount; } | 542 int vertexCount() const { return fVertexCount; } |
537 int indexCount() const { return fIndexCount; } | 543 int indexCount() const { return fIndexCount; } |
538 int verticesPerInstance() const { return fVerticesPerInstance; } | 544 int verticesPerInstance() const { return fVerticesPerInstance; } |
539 int indicesPerInstance() const { return fIndicesPerInstance; } | 545 int indicesPerInstance() const { return fIndicesPerInstance; } |
540 int instanceCount() const { return fInstanceCount; } | 546 int instanceCount() const { return fInstanceCount; } |
541 | 547 |
| 548 void setPrimitiveType(GrPrimitiveType type) { fPrimitiveType = type; } |
| 549 void setStartVertex(int startVertex) { fStartVertex = startVertex; } |
| 550 void setStartIndex(int startIndex) { fStartIndex = startIndex; } |
| 551 void setVertexCount(int vertexCount) { fVertexCount = vertexCount; } |
| 552 void setIndexCount(int indexCount) { fIndexCount = indexCount; } |
| 553 void setVerticesPerInstance(int verticesPerI) { fVerticesPerInstance = v
erticesPerI; } |
| 554 void setIndicesPerInstance(int indicesPerI) { fIndicesPerInstance = indi
cesPerI; } |
| 555 void setInstanceCount(int instanceCount) { fInstanceCount = instanceCoun
t; } |
| 556 |
542 bool isIndexed() const { return fIndexCount > 0; } | 557 bool isIndexed() const { return fIndexCount > 0; } |
543 #ifdef SK_DEBUG | 558 #ifdef SK_DEBUG |
544 bool isInstanced() const; // this version is longer because of asserts | 559 bool isInstanced() const; // this version is longer because of asserts |
545 #else | 560 #else |
546 bool isInstanced() const { return fInstanceCount > 0; } | 561 bool isInstanced() const { return fInstanceCount > 0; } |
547 #endif | 562 #endif |
548 | 563 |
549 // adds or remove instances | 564 // adds or remove instances |
550 void adjustInstanceCount(int instanceOffset); | 565 void adjustInstanceCount(int instanceOffset); |
551 // shifts the start vertex | 566 // shifts the start vertex |
552 void adjustStartVertex(int vertexOffset); | 567 void adjustStartVertex(int vertexOffset); |
553 // shifts the start index | 568 // shifts the start index |
554 void adjustStartIndex(int indexOffset); | 569 void adjustStartIndex(int indexOffset); |
555 | 570 |
556 void setDevBounds(const SkRect& bounds) { | 571 void setDevBounds(const SkRect& bounds) { |
557 fDevBoundsStorage = bounds; | 572 fDevBoundsStorage = bounds; |
558 fDevBounds = &fDevBoundsStorage; | 573 fDevBounds = &fDevBoundsStorage; |
559 } | 574 } |
560 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get();
} | 575 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get();
} |
561 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } | 576 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } |
562 void setVertexBuffer(const GrVertexBuffer* vb) { | 577 void setVertexBuffer(const GrVertexBuffer* vb) { |
563 fVertexBuffer.reset(vb); | 578 fVertexBuffer.reset(vb); |
564 } | 579 } |
565 void setIndexBuffer(const GrIndexBuffer* ib) { | 580 void setIndexBuffer(const GrIndexBuffer* ib) { |
566 fIndexBuffer.reset(ib); | 581 fIndexBuffer.reset(ib); |
567 } | 582 } |
568 const SkRect* getDevBounds() const { return fDevBounds; } | 583 const SkRect* getDevBounds() const { return fDevBounds; } |
569 | 584 |
570 private: | 585 private: |
571 DrawInfo() { fDevBounds = NULL; } | |
572 | |
573 friend class GrDrawTarget; | 586 friend class GrDrawTarget; |
574 | 587 |
575 GrPrimitiveType fPrimitiveType; | 588 GrPrimitiveType fPrimitiveType; |
576 | 589 |
577 int fStartVertex; | 590 int fStartVertex; |
578 int fStartIndex; | 591 int fStartIndex; |
579 int fVertexCount; | 592 int fVertexCount; |
580 int fIndexCount; | 593 int fIndexCount; |
581 | 594 |
582 int fInstanceCount; | 595 int fInstanceCount; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 virtual void releaseReservedIndexSpace() = 0; | 714 virtual void releaseReservedIndexSpace() = 0; |
702 // subclass overrides to be notified just before geo src state is pushed/pop
ped. | 715 // subclass overrides to be notified just before geo src state is pushed/pop
ped. |
703 virtual void geometrySourceWillPush() = 0; | 716 virtual void geometrySourceWillPush() = 0; |
704 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; | 717 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; |
705 // subclass called to perform drawing | 718 // subclass called to perform drawing |
706 virtual void onDraw(const GrPipelineBuilder&, | 719 virtual void onDraw(const GrPipelineBuilder&, |
707 const GrGeometryProcessor*, | 720 const GrGeometryProcessor*, |
708 const DrawInfo&, | 721 const DrawInfo&, |
709 const GrScissorState&, | 722 const GrScissorState&, |
710 const GrDeviceCoordTexture* dstCopy) = 0; | 723 const GrDeviceCoordTexture* dstCopy) = 0; |
| 724 virtual void onDrawBatch(GrBatch*, |
| 725 const GrPipelineBuilder&, |
| 726 const GrScissorState&, |
| 727 const GrDeviceCoordTexture* dstCopy) = 0; |
711 // TODO copy in order drawbuffer onDrawRect to here | 728 // TODO copy in order drawbuffer onDrawRect to here |
712 virtual void onDrawRect(GrPipelineBuilder*, | 729 virtual void onDrawRect(GrPipelineBuilder*, |
713 GrColor color, | 730 GrColor color, |
714 const SkMatrix& viewMatrix, | 731 const SkMatrix& viewMatrix, |
715 const SkRect& rect, | 732 const SkRect& rect, |
716 const SkRect* localRect, | 733 const SkRect* localRect, |
717 const SkMatrix* localMatrix) = 0; | 734 const SkMatrix* localMatrix) = 0; |
718 | 735 |
719 virtual void onStencilPath(const GrPipelineBuilder&, | 736 virtual void onStencilPath(const GrPipelineBuilder&, |
720 const GrPathProcessor*, | 737 const GrPathProcessor*, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 virtual bool setupClip(GrPipelineBuilder*, | 871 virtual bool setupClip(GrPipelineBuilder*, |
855 GrPipelineBuilder::AutoRestoreEffects* are, | 872 GrPipelineBuilder::AutoRestoreEffects* are, |
856 GrPipelineBuilder::AutoRestoreStencil* ars, | 873 GrPipelineBuilder::AutoRestoreStencil* ars, |
857 GrScissorState* scissorState, | 874 GrScissorState* scissorState, |
858 const SkRect* devBounds) SK_OVERRIDE; | 875 const SkRect* devBounds) SK_OVERRIDE; |
859 | 876 |
860 typedef GrDrawTarget INHERITED; | 877 typedef GrDrawTarget INHERITED; |
861 }; | 878 }; |
862 | 879 |
863 #endif | 880 #endif |
OLD | NEW |