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

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

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