Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: src/gpu/GrDrawTarget.h

Issue 845103005: GrBatchPrototype (Closed) Base URL: https://skia.googlesource.com/skia.git@lc2
Patch Set: a bit more tweaking Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "GrDrawState.h" 14 #include "GrDrawState.h"
15 #include "GrIndexBuffer.h" 15 #include "GrIndexBuffer.h"
16 #include "GrPathRendering.h" 16 #include "GrPathRendering.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
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(GrDrawState*, 256 void drawNonIndexed(GrDrawState*,
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 batchDraw(GrDrawState*,
bsalomon 2015/01/21 21:39:29 drawBatch? Just seems more consistent
264 GrBatch*,
265 GrPrimitiveType,
266 const SkRect* devBounds = NULL);
267
262 /** 268 /**
263 * Draws path into the stencil buffer. The fill must be either even/odd or 269 * 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 270 * winding (not inverse or hairline). It will respect the HW antialias flag
265 * on the draw state (if possible in the 3D API). Note, we will never have an inverse fill 271 * on the draw state (if possible in the 3D API). Note, we will never have an inverse fill
266 * with stencil path 272 * with stencil path
267 */ 273 */
268 void stencilPath(GrDrawState*, const GrPathProcessor*, const GrPath*,GrPathR endering::FillType); 274 void stencilPath(GrDrawState*, const GrPathProcessor*, const GrPath*,GrPathR endering::FillType);
269 275
270 /** 276 /**
271 * Draws a path. Fill must not be a hairline. It will respect the HW 277 * Draws a path. Fill must not be a hairline. It will respect the HW
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 // so that should be okay 523 // so that should be okay
518 }; 524 };
519 525
520 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } 526 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); }
521 527
522 /** 528 /**
523 * Used to communicate draws to GPUs / subclasses 529 * Used to communicate draws to GPUs / subclasses
524 */ 530 */
525 class DrawInfo { 531 class DrawInfo {
526 public: 532 public:
533 DrawInfo() { fDevBounds = NULL; }
527 DrawInfo(const DrawInfo& di) { (*this) = di; } 534 DrawInfo(const DrawInfo& di) { (*this) = di; }
528 DrawInfo& operator =(const DrawInfo& di); 535 DrawInfo& operator =(const DrawInfo& di);
529 536
530 GrPrimitiveType primitiveType() const { return fPrimitiveType; } 537 GrPrimitiveType primitiveType() const { return fPrimitiveType; }
531 int startVertex() const { return fStartVertex; } 538 int startVertex() const { return fStartVertex; }
532 int startIndex() const { return fStartIndex; } 539 int startIndex() const { return fStartIndex; }
533 int vertexCount() const { return fVertexCount; } 540 int vertexCount() const { return fVertexCount; }
534 int indexCount() const { return fIndexCount; } 541 int indexCount() const { return fIndexCount; }
535 int verticesPerInstance() const { return fVerticesPerInstance; } 542 int verticesPerInstance() const { return fVerticesPerInstance; }
536 int indicesPerInstance() const { return fIndicesPerInstance; } 543 int indicesPerInstance() const { return fIndicesPerInstance; }
537 int instanceCount() const { return fInstanceCount; } 544 int instanceCount() const { return fInstanceCount; }
538 545
546 void setPrimitiveType(GrPrimitiveType type) { fPrimitiveType = type; }
547 void setStartVertex(int startVertex) { fStartVertex = startVertex; }
548 void setStartIndex(int startIndex) { fStartIndex = startIndex; }
549 void setVertexCount(int vertexCount) { fVertexCount = vertexCount; }
550 void setIndexCount(int indexCount) { fIndexCount = indexCount; }
551 void setVerticesPerInstance(int verticesPerI) { fVerticesPerInstance = v erticesPerI; }
552 void setIndicesPerInstance(int indicesPerI) { fIndicesPerInstance = indi cesPerI; }
553 void setInstanceCount(int instanceCount) { fInstanceCount = instanceCoun t; }
554
539 bool isIndexed() const { return fIndexCount > 0; } 555 bool isIndexed() const { return fIndexCount > 0; }
540 #ifdef SK_DEBUG 556 #ifdef SK_DEBUG
541 bool isInstanced() const; // this version is longer because of asserts 557 bool isInstanced() const; // this version is longer because of asserts
542 #else 558 #else
543 bool isInstanced() const { return fInstanceCount > 0; } 559 bool isInstanced() const { return fInstanceCount > 0; }
544 #endif 560 #endif
545 561
546 // adds or remove instances 562 // adds or remove instances
547 void adjustInstanceCount(int instanceOffset); 563 void adjustInstanceCount(int instanceOffset);
548 // shifts the start vertex 564 // shifts the start vertex
549 void adjustStartVertex(int vertexOffset); 565 void adjustStartVertex(int vertexOffset);
550 // shifts the start index 566 // shifts the start index
551 void adjustStartIndex(int indexOffset); 567 void adjustStartIndex(int indexOffset);
552 568
553 void setDevBounds(const SkRect& bounds) { 569 void setDevBounds(const SkRect& bounds) {
554 fDevBoundsStorage = bounds; 570 fDevBoundsStorage = bounds;
555 fDevBounds = &fDevBoundsStorage; 571 fDevBounds = &fDevBoundsStorage;
556 } 572 }
557 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); } 573 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); }
558 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } 574 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); }
559 void setVertexBuffer(const GrVertexBuffer* vb) { 575 void setVertexBuffer(const GrVertexBuffer* vb) {
560 fVertexBuffer.reset(vb); 576 fVertexBuffer.reset(vb);
561 } 577 }
562 void setIndexBuffer(const GrIndexBuffer* ib) { 578 void setIndexBuffer(const GrIndexBuffer* ib) {
563 fIndexBuffer.reset(ib); 579 fIndexBuffer.reset(ib);
564 } 580 }
565 const SkRect* getDevBounds() const { return fDevBounds; } 581 const SkRect* getDevBounds() const { return fDevBounds; }
566 582
567 private: 583 private:
568 DrawInfo() { fDevBounds = NULL; }
569
570 friend class GrDrawTarget; 584 friend class GrDrawTarget;
571 585
572 GrPrimitiveType fPrimitiveType; 586 GrPrimitiveType fPrimitiveType;
573 587
574 int fStartVertex; 588 int fStartVertex;
575 int fStartIndex; 589 int fStartIndex;
576 int fVertexCount; 590 int fVertexCount;
577 int fIndexCount; 591 int fIndexCount;
578 592
579 int fInstanceCount; 593 int fInstanceCount;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 virtual void releaseReservedIndexSpace() = 0; 712 virtual void releaseReservedIndexSpace() = 0;
699 // subclass overrides to be notified just before geo src state is pushed/pop ped. 713 // subclass overrides to be notified just before geo src state is pushed/pop ped.
700 virtual void geometrySourceWillPush() = 0; 714 virtual void geometrySourceWillPush() = 0;
701 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; 715 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0;
702 // subclass called to perform drawing 716 // subclass called to perform drawing
703 virtual void onDraw(const GrDrawState&, 717 virtual void onDraw(const GrDrawState&,
704 const GrGeometryProcessor*, 718 const GrGeometryProcessor*,
705 const DrawInfo&, 719 const DrawInfo&,
706 const GrScissorState&, 720 const GrScissorState&,
707 const GrDeviceCoordTexture* dstCopy) = 0; 721 const GrDeviceCoordTexture* dstCopy) = 0;
722 virtual void onBatchDraw(GrBatch*,
723 const GrDrawState&,
724 GrPrimitiveType type,
725 const GrScissorState&,
726 const GrDeviceCoordTexture* dstCopy) = 0;
708 // TODO copy in order drawbuffer onDrawRect to here 727 // TODO copy in order drawbuffer onDrawRect to here
709 virtual void onDrawRect(GrDrawState*, 728 virtual void onDrawRect(GrDrawState*,
710 GrColor color, 729 GrColor color,
711 const SkMatrix& viewMatrix, 730 const SkMatrix& viewMatrix,
712 const SkRect& rect, 731 const SkRect& rect,
713 const SkRect* localRect, 732 const SkRect* localRect,
714 const SkMatrix* localMatrix) = 0; 733 const SkMatrix* localMatrix) = 0;
715 734
716 virtual void onStencilPath(const GrDrawState&, 735 virtual void onStencilPath(const GrDrawState&,
717 const GrPathProcessor*, 736 const GrPathProcessor*,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 virtual bool setupClip(GrDrawState*, 870 virtual bool setupClip(GrDrawState*,
852 GrDrawState::AutoRestoreEffects* are, 871 GrDrawState::AutoRestoreEffects* are,
853 GrDrawState::AutoRestoreStencil* ars, 872 GrDrawState::AutoRestoreStencil* ars,
854 GrScissorState* scissorState, 873 GrScissorState* scissorState,
855 const SkRect* devBounds) SK_OVERRIDE; 874 const SkRect* devBounds) SK_OVERRIDE;
856 875
857 typedef GrDrawTarget INHERITED; 876 typedef GrDrawTarget INHERITED;
858 }; 877 };
859 878
860 #endif 879 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698