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

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

Issue 845103005: GrBatchPrototype (Closed) Base URL: https://skia.googlesource.com/skia.git@lc2
Patch Set: cleanup 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*,
264 GrBatch*,
265 GrPrimitiveType,
bsalomon 2015/01/20 16:14:03 what's primtype doing here?
joshualitt 2015/01/20 17:03:08 I'd prefer to roll out batch everywhere, and then
bsalomon 2015/01/20 20:49:58 I guess I just don't understand why it's here or w
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 671
658 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers ; } 672 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers ; }
659 673
660 // Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required 674 // Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required
661 // but couldn't be made. Otherwise, returns true. This method needs to be p rotected because it 675 // but couldn't be made. Otherwise, returns true. This method needs to be p rotected because it
662 // needs to be accessed by GLPrograms to setup a correct drawstate 676 // needs to be accessed by GLPrograms to setup a correct drawstate
663 bool setupDstReadIfNecessary(GrDrawState*, 677 bool setupDstReadIfNecessary(GrDrawState*,
664 const GrPrimitiveProcessor*, 678 const GrPrimitiveProcessor*,
665 GrDeviceCoordTexture* dstCopy, 679 GrDeviceCoordTexture* dstCopy,
666 const SkRect* drawBounds); 680 const SkRect* drawBounds);
681 bool setupDstReadIfNecessary(GrDrawState*,
682 const GrBatch*,
683 GrDeviceCoordTexture* dstCopy,
684 const SkRect* drawBounds);
667 685
668 private: 686 private:
669 /** 687 /**
670 * This will be called before allocating a texture as a dst for copySurface. This function 688 * This will be called before allocating a texture as a dst for copySurface. This function
671 * populates the dstDesc's config, flags, and origin so as to maximize effic iency and guarantee 689 * populates the dstDesc's config, flags, and origin so as to maximize effic iency and guarantee
672 * success of the copySurface call. 690 * success of the copySurface call.
673 */ 691 */
674 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { 692 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) {
675 if (!this->onInitCopySurfaceDstDesc(src, dstDesc)) { 693 if (!this->onInitCopySurfaceDstDesc(src, dstDesc)) {
676 dstDesc->fOrigin = kDefault_GrSurfaceOrigin; 694 dstDesc->fOrigin = kDefault_GrSurfaceOrigin;
(...skipping 22 matching lines...) Expand all
699 virtual void releaseReservedIndexSpace() = 0; 717 virtual void releaseReservedIndexSpace() = 0;
700 // subclass overrides to be notified just before geo src state is pushed/pop ped. 718 // subclass overrides to be notified just before geo src state is pushed/pop ped.
701 virtual void geometrySourceWillPush() = 0; 719 virtual void geometrySourceWillPush() = 0;
702 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; 720 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0;
703 // subclass called to perform drawing 721 // subclass called to perform drawing
704 virtual void onDraw(const GrDrawState&, 722 virtual void onDraw(const GrDrawState&,
705 const GrGeometryProcessor*, 723 const GrGeometryProcessor*,
706 const DrawInfo&, 724 const DrawInfo&,
707 const GrScissorState&, 725 const GrScissorState&,
708 const GrDeviceCoordTexture* dstCopy) = 0; 726 const GrDeviceCoordTexture* dstCopy) = 0;
727 virtual void onBatchDraw(GrBatch*,
728 const GrDrawState&,
729 GrPrimitiveType type,
730 const GrScissorState&,
731 const GrDeviceCoordTexture* dstCopy) = 0;
709 // TODO copy in order drawbuffer onDrawRect to here 732 // TODO copy in order drawbuffer onDrawRect to here
710 virtual void onDrawRect(GrDrawState*, 733 virtual void onDrawRect(GrDrawState*,
711 GrColor color, 734 GrColor color,
712 const SkMatrix& viewMatrix, 735 const SkMatrix& viewMatrix,
713 const SkRect& rect, 736 const SkRect& rect,
714 const SkRect* localRect, 737 const SkRect* localRect,
715 const SkMatrix* localMatrix) = 0; 738 const SkMatrix* localMatrix) = 0;
716 739
717 virtual void onStencilPath(const GrDrawState&, 740 virtual void onStencilPath(const GrDrawState&,
718 const GrPathProcessor*, 741 const GrPathProcessor*,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 virtual bool setupClip(GrDrawState*, 875 virtual bool setupClip(GrDrawState*,
853 GrDrawState::AutoRestoreEffects* are, 876 GrDrawState::AutoRestoreEffects* are,
854 GrDrawState::AutoRestoreStencil* ars, 877 GrDrawState::AutoRestoreStencil* ars,
855 GrScissorState* scissorState, 878 GrScissorState* scissorState,
856 const SkRect* devBounds) SK_OVERRIDE; 879 const SkRect* devBounds) SK_OVERRIDE;
857 880
858 typedef GrDrawTarget INHERITED; 881 typedef GrDrawTarget INHERITED;
859 }; 882 };
860 883
861 #endif 884 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698