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

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

Issue 845103005: GrBatchPrototype (Closed) Base URL: https://skia.googlesource.com/skia.git@lc2
Patch Set: removing dstread Created 5 years, 10 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
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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 // TODO devbounds should live on the batch
264 void drawBatch(GrPipelineBuilder*,
265 GrBatch*,
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 GrPipelineBuilder (if possible in the 3D API). Note, we will neve r have an inverse 271 * on the GrPipelineBuilder (if possible in the 3D API). Note, we will neve r have an inverse
266 * fill with stencil path 272 * fill with stencil path
267 */ 273 */
268 void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, 274 void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*,
269 GrPathRendering::FillType); 275 GrPathRendering::FillType);
270 276
271 /** 277 /**
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 * and thus will finalize any reserved geometry. 309 * and thus will finalize any reserved geometry.
304 * 310 *
305 * @param rect the rect to draw 311 * @param rect the rect to draw
306 * @param localRect optional rect that specifies local coords to map onto 312 * @param localRect optional rect that specifies local coords to map onto
307 * rect. If NULL then rect serves as the local coords. 313 * rect. If NULL then rect serves as the local coords.
308 * @param localMatrix Optional local matrix. The local coordinates are speci fied by localRect, 314 * @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 315 * 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 316 * that rectangle before it is input to GrCoordTransforms that read local
311 * coordinates 317 * coordinates
312 */ 318 */
313 void drawRect(GrPipelineBuilder* ds, 319 void drawRect(GrPipelineBuilder* pipelineBuilder,
314 GrColor color, 320 GrColor color,
315 const SkMatrix& viewMatrix, 321 const SkMatrix& viewMatrix,
316 const SkRect& rect, 322 const SkRect& rect,
317 const SkRect* localRect, 323 const SkRect* localRect,
318 const SkMatrix* localMatrix) { 324 const SkMatrix* localMatrix) {
319 AutoGeometryPush agp(this); 325 AutoGeometryPush agp(this);
320 this->onDrawRect(ds, color, viewMatrix, rect, localRect, localMatrix); 326 this->onDrawRect(pipelineBuilder, color, viewMatrix, rect, localRect, lo calMatrix);
321 } 327 }
322 328
323 /** 329 /**
324 * Helper for drawRect when the caller doesn't need separate local rects or matrices. 330 * Helper for drawRect when the caller doesn't need separate local rects or matrices.
325 */ 331 */
326 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi ewM, 332 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi ewM,
327 const SkRect& rect) { 333 const SkRect& rect) {
328 this->drawRect(ds, color, viewM, rect, NULL, NULL); 334 this->drawRect(ds, color, viewM, rect, NULL, NULL);
329 } 335 }
330 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi ewM, 336 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi ewM,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 // so that should be okay 526 // so that should be okay
521 }; 527 };
522 528
523 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } 529 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); }
524 530
525 /** 531 /**
526 * Used to communicate draws to GPUs / subclasses 532 * Used to communicate draws to GPUs / subclasses
527 */ 533 */
528 class DrawInfo { 534 class DrawInfo {
529 public: 535 public:
536 DrawInfo() { fDevBounds = NULL; }
530 DrawInfo(const DrawInfo& di) { (*this) = di; } 537 DrawInfo(const DrawInfo& di) { (*this) = di; }
531 DrawInfo& operator =(const DrawInfo& di); 538 DrawInfo& operator =(const DrawInfo& di);
532 539
533 GrPrimitiveType primitiveType() const { return fPrimitiveType; } 540 GrPrimitiveType primitiveType() const { return fPrimitiveType; }
534 int startVertex() const { return fStartVertex; } 541 int startVertex() const { return fStartVertex; }
535 int startIndex() const { return fStartIndex; } 542 int startIndex() const { return fStartIndex; }
536 int vertexCount() const { return fVertexCount; } 543 int vertexCount() const { return fVertexCount; }
537 int indexCount() const { return fIndexCount; } 544 int indexCount() const { return fIndexCount; }
538 int verticesPerInstance() const { return fVerticesPerInstance; } 545 int verticesPerInstance() const { return fVerticesPerInstance; }
539 int indicesPerInstance() const { return fIndicesPerInstance; } 546 int indicesPerInstance() const { return fIndicesPerInstance; }
540 int instanceCount() const { return fInstanceCount; } 547 int instanceCount() const { return fInstanceCount; }
541 548
549 void setPrimitiveType(GrPrimitiveType type) { fPrimitiveType = type; }
550 void setStartVertex(int startVertex) { fStartVertex = startVertex; }
551 void setStartIndex(int startIndex) { fStartIndex = startIndex; }
552 void setVertexCount(int vertexCount) { fVertexCount = vertexCount; }
553 void setIndexCount(int indexCount) { fIndexCount = indexCount; }
554 void setVerticesPerInstance(int verticesPerI) { fVerticesPerInstance = v erticesPerI; }
555 void setIndicesPerInstance(int indicesPerI) { fIndicesPerInstance = indi cesPerI; }
556 void setInstanceCount(int instanceCount) { fInstanceCount = instanceCoun t; }
557
542 bool isIndexed() const { return fIndexCount > 0; } 558 bool isIndexed() const { return fIndexCount > 0; }
543 #ifdef SK_DEBUG 559 #ifdef SK_DEBUG
544 bool isInstanced() const; // this version is longer because of asserts 560 bool isInstanced() const; // this version is longer because of asserts
545 #else 561 #else
546 bool isInstanced() const { return fInstanceCount > 0; } 562 bool isInstanced() const { return fInstanceCount > 0; }
547 #endif 563 #endif
548 564
549 // adds or remove instances 565 // adds or remove instances
550 void adjustInstanceCount(int instanceOffset); 566 void adjustInstanceCount(int instanceOffset);
551 // shifts the start vertex 567 // shifts the start vertex
552 void adjustStartVertex(int vertexOffset); 568 void adjustStartVertex(int vertexOffset);
553 // shifts the start index 569 // shifts the start index
554 void adjustStartIndex(int indexOffset); 570 void adjustStartIndex(int indexOffset);
555 571
556 void setDevBounds(const SkRect& bounds) { 572 void setDevBounds(const SkRect& bounds) {
557 fDevBoundsStorage = bounds; 573 fDevBoundsStorage = bounds;
558 fDevBounds = &fDevBoundsStorage; 574 fDevBounds = &fDevBoundsStorage;
559 } 575 }
560 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); } 576 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); }
561 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } 577 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); }
562 void setVertexBuffer(const GrVertexBuffer* vb) { 578 void setVertexBuffer(const GrVertexBuffer* vb) {
563 fVertexBuffer.reset(vb); 579 fVertexBuffer.reset(vb);
564 } 580 }
565 void setIndexBuffer(const GrIndexBuffer* ib) { 581 void setIndexBuffer(const GrIndexBuffer* ib) {
566 fIndexBuffer.reset(ib); 582 fIndexBuffer.reset(ib);
567 } 583 }
568 const SkRect* getDevBounds() const { return fDevBounds; } 584 const SkRect* getDevBounds() const { return fDevBounds; }
569 585
570 private: 586 private:
571 DrawInfo() { fDevBounds = NULL; }
572
573 friend class GrDrawTarget; 587 friend class GrDrawTarget;
574 588
575 GrPrimitiveType fPrimitiveType; 589 GrPrimitiveType fPrimitiveType;
576 590
577 int fStartVertex; 591 int fStartVertex;
578 int fStartIndex; 592 int fStartIndex;
579 int fVertexCount; 593 int fVertexCount;
580 int fIndexCount; 594 int fIndexCount;
581 595
582 int fInstanceCount; 596 int fInstanceCount;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 virtual void releaseReservedIndexSpace() = 0; 715 virtual void releaseReservedIndexSpace() = 0;
702 // subclass overrides to be notified just before geo src state is pushed/pop ped. 716 // subclass overrides to be notified just before geo src state is pushed/pop ped.
703 virtual void geometrySourceWillPush() = 0; 717 virtual void geometrySourceWillPush() = 0;
704 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; 718 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0;
705 // subclass called to perform drawing 719 // subclass called to perform drawing
706 virtual void onDraw(const GrPipelineBuilder&, 720 virtual void onDraw(const GrPipelineBuilder&,
707 const GrGeometryProcessor*, 721 const GrGeometryProcessor*,
708 const DrawInfo&, 722 const DrawInfo&,
709 const GrScissorState&, 723 const GrScissorState&,
710 const GrDeviceCoordTexture* dstCopy) = 0; 724 const GrDeviceCoordTexture* dstCopy) = 0;
725 virtual void onDrawBatch(GrBatch*,
726 const GrPipelineBuilder&,
727 const GrScissorState&,
728 const GrDeviceCoordTexture* dstCopy) = 0;
711 // TODO copy in order drawbuffer onDrawRect to here 729 // TODO copy in order drawbuffer onDrawRect to here
712 virtual void onDrawRect(GrPipelineBuilder*, 730 virtual void onDrawRect(GrPipelineBuilder*,
713 GrColor color, 731 GrColor color,
714 const SkMatrix& viewMatrix, 732 const SkMatrix& viewMatrix,
715 const SkRect& rect, 733 const SkRect& rect,
716 const SkRect* localRect, 734 const SkRect* localRect,
717 const SkMatrix* localMatrix) = 0; 735 const SkMatrix* localMatrix) = 0;
718 736
719 virtual void onStencilPath(const GrPipelineBuilder&, 737 virtual void onStencilPath(const GrPipelineBuilder&,
720 const GrPathProcessor*, 738 const GrPathProcessor*,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 virtual bool setupClip(GrPipelineBuilder*, 872 virtual bool setupClip(GrPipelineBuilder*,
855 GrPipelineBuilder::AutoRestoreEffects* are, 873 GrPipelineBuilder::AutoRestoreEffects* are,
856 GrPipelineBuilder::AutoRestoreStencil* ars, 874 GrPipelineBuilder::AutoRestoreStencil* ars,
857 GrScissorState* scissorState, 875 GrScissorState* scissorState,
858 const SkRect* devBounds) SK_OVERRIDE; 876 const SkRect* devBounds) SK_OVERRIDE;
859 877
860 typedef GrDrawTarget INHERITED; 878 typedef GrDrawTarget INHERITED;
861 }; 879 };
862 880
863 #endif 881 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698