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

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

Issue 947443003: Move clip off of draw target (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 5 years, 9 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/GrDistanceFieldTextContext.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 "GrClip.h"
12 #include "GrClipMaskManager.h" 12 #include "GrClipMaskManager.h"
13 #include "GrContext.h" 13 #include "GrContext.h"
14 #include "GrPathProcessor.h" 14 #include "GrPathProcessor.h"
15 #include "GrPrimitiveProcessor.h" 15 #include "GrPrimitiveProcessor.h"
16 #include "GrIndexBuffer.h" 16 #include "GrIndexBuffer.h"
17 #include "GrPathRendering.h" 17 #include "GrPathRendering.h"
18 #include "GrPipelineBuilder.h" 18 #include "GrPipelineBuilder.h"
19 #include "GrTraceMarker.h" 19 #include "GrTraceMarker.h"
20 #include "GrVertexBuffer.h" 20 #include "GrVertexBuffer.h"
21 21
22 #include "SkClipStack.h" 22 #include "SkClipStack.h"
23 #include "SkMatrix.h" 23 #include "SkMatrix.h"
24 #include "SkPath.h" 24 #include "SkPath.h"
25 #include "SkStrokeRec.h" 25 #include "SkStrokeRec.h"
26 #include "SkTArray.h" 26 #include "SkTArray.h"
27 #include "SkTLazy.h" 27 #include "SkTLazy.h"
28 #include "SkTypes.h" 28 #include "SkTypes.h"
29 #include "SkXfermode.h" 29 #include "SkXfermode.h"
30 30
31 class GrBatch; 31 class GrBatch;
32 class GrClipData; 32 class GrClip;
33 class GrDrawTargetCaps; 33 class GrDrawTargetCaps;
34 class GrPath; 34 class GrPath;
35 class GrPathRange; 35 class GrPathRange;
36 class GrPipeline; 36 class GrPipeline;
37 37
38 class GrDrawTarget : public SkRefCnt { 38 class GrDrawTarget : public SkRefCnt {
39 public: 39 public:
40 SK_DECLARE_INST_COUNT(GrDrawTarget) 40 SK_DECLARE_INST_COUNT(GrDrawTarget)
41 41
42 typedef GrPathRange::PathIndexType PathIndexType; 42 typedef GrPathRange::PathIndexType PathIndexType;
43 typedef GrPathRendering::PathTransformType PathTransformType; 43 typedef GrPathRendering::PathTransformType PathTransformType;
44 44
45 /////////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////////
46 46
47 // The context may not be fully constructed and should not be used during Gr DrawTarget 47 // The context may not be fully constructed and should not be used during Gr DrawTarget
48 // construction. 48 // construction.
49 GrDrawTarget(GrContext* context); 49 GrDrawTarget(GrContext* context);
50 virtual ~GrDrawTarget(); 50 virtual ~GrDrawTarget();
51 51
52 /** 52 /**
53 * Gets the capabilities of the draw target. 53 * Gets the capabilities of the draw target.
54 */ 54 */
55 const GrDrawTargetCaps* caps() const { return fCaps.get(); } 55 const GrDrawTargetCaps* caps() const { return fCaps.get(); }
56 56
57 /** 57 /**
58 * Sets the current clip to the region specified by clip. All draws will be
59 * clipped against this clip if kClip_StateBit is enabled.
60 *
61 * Setting the clip may (or may not) zero out the client's stencil bits.
62 *
63 * @param description of the clipping region
64 */
65 void setClip(const GrClipData* clip);
66
67 /**
68 * Gets the current clip.
69 *
70 * @return the clip.
71 */
72 const GrClipData* getClip() const;
73
74 /**
75 * There are two types of "sources" of geometry (vertices and indices) for 58 * There are two types of "sources" of geometry (vertices and indices) for
76 * draw calls made on the target. When performing an indexed draw, the 59 * draw calls made on the target. When performing an indexed draw, the
77 * indices and vertices can use different source types. Once a source is 60 * indices and vertices can use different source types. Once a source is
78 * specified it can be used for multiple draws. However, the time at which 61 * specified it can be used for multiple draws. However, the time at which
79 * the geometry data is no longer editable depends on the source type. 62 * the geometry data is no longer editable depends on the source type.
80 * 63 *
81 * Sometimes it is necessary to perform a draw while upstack code has 64 * Sometimes it is necessary to perform a draw while upstack code has
82 * already specified geometry that it isn't finished with. So there are push 65 * already specified geometry that it isn't finished with. So there are push
83 * and pop methods. This allows the client to push the sources, draw 66 * and pop methods. This allows the client to push the sources, draw
84 * something using alternate sources, and then pop to restore the original 67 * something using alternate sources, and then pop to restore the original
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 * not a request for clipping. 240 * not a request for clipping.
258 */ 241 */
259 void drawNonIndexed(GrPipelineBuilder*, 242 void drawNonIndexed(GrPipelineBuilder*,
260 const GrGeometryProcessor*, 243 const GrGeometryProcessor*,
261 GrPrimitiveType type, 244 GrPrimitiveType type,
262 int startVertex, 245 int startVertex,
263 int vertexCount, 246 int vertexCount,
264 const SkRect* devBounds = NULL); 247 const SkRect* devBounds = NULL);
265 248
266 // TODO devbounds should live on the batch 249 // TODO devbounds should live on the batch
267 void drawBatch(GrPipelineBuilder*, 250 void drawBatch(GrPipelineBuilder*, GrBatch*, const SkRect* devBounds = NULL) ;
268 GrBatch*,
269 const SkRect* devBounds = NULL);
270 251
271 /** 252 /**
272 * Draws path into the stencil buffer. The fill must be either even/odd or 253 * Draws path into the stencil buffer. The fill must be either even/odd or
273 * winding (not inverse or hairline). It will respect the HW antialias flag 254 * winding (not inverse or hairline). It will respect the HW antialias flag
274 * on the GrPipelineBuilder (if possible in the 3D API). Note, we will neve r have an inverse 255 * on the GrPipelineBuilder (if possible in the 3D API). Note, we will neve r have an inverse
275 * fill with stencil path 256 * fill with stencil path
276 */ 257 */
277 void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, 258 void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*,
278 GrPathRendering::FillType); 259 GrPathRendering::FillType);
279 260
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 private: 449 private:
469 void reset(); 450 void reset();
470 451
471 GrDrawTarget* fTarget; 452 GrDrawTarget* fTarget;
472 void* fVertices; 453 void* fVertices;
473 void* fIndices; 454 void* fIndices;
474 }; 455 };
475 456
476 //////////////////////////////////////////////////////////////////////////// 457 ////////////////////////////////////////////////////////////////////////////
477 458
478 class AutoClipRestore : public ::SkNoncopyable {
479 public:
480 AutoClipRestore(GrDrawTarget* target) {
481 fTarget = target;
482 fClip = fTarget->getClip();
483 }
484
485 AutoClipRestore(GrDrawTarget* target, const SkIRect& newClip);
486
487 ~AutoClipRestore() {
488 fTarget->setClip(fClip);
489 }
490 private:
491 GrDrawTarget* fTarget;
492 const GrClipData* fClip;
493 SkTLazy<SkClipStack> fStack;
494 GrClipData fReplacementClip;
495 };
496
497 ////////////////////////////////////////////////////////////////////////////
498
499 /** 459 /**
500 * Saves the geometry src state at construction and restores in the destruct or. It also saves 460 * Saves the geometry src state at construction and restores in the destruct or. It also saves
501 * and then restores the vertex attrib state. 461 * and then restores the vertex attrib state.
502 */ 462 */
503 class AutoGeometryPush : public ::SkNoncopyable { 463 class AutoGeometryPush : public ::SkNoncopyable {
504 public: 464 public:
505 AutoGeometryPush(GrDrawTarget* target) { 465 AutoGeometryPush(GrDrawTarget* target) {
506 SkASSERT(target); 466 SkASSERT(target);
507 fTarget = target; 467 fTarget = target;
508 target->pushGeometrySource(); 468 target->pushGeometrySource();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 // but couldn't be made. Otherwise, returns true. This method needs to be p rotected because it 641 // but couldn't be made. Otherwise, returns true. This method needs to be p rotected because it
682 // needs to be accessed by GLPrograms to setup a correct drawstate 642 // needs to be accessed by GLPrograms to setup a correct drawstate
683 bool setupDstReadIfNecessary(const GrPipelineBuilder&, 643 bool setupDstReadIfNecessary(const GrPipelineBuilder&,
684 const GrProcOptInfo& colorPOI, 644 const GrProcOptInfo& colorPOI,
685 const GrProcOptInfo& coveragePOI, 645 const GrProcOptInfo& coveragePOI,
686 GrDeviceCoordTexture* dstCopy, 646 GrDeviceCoordTexture* dstCopy,
687 const SkRect* drawBounds); 647 const SkRect* drawBounds);
688 648
689 struct PipelineInfo { 649 struct PipelineInfo {
690 PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor , 650 PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor ,
691 const GrPrimitiveProcessor* primProc, const SkRect* devBoun ds, 651 const GrPrimitiveProcessor* primProc,
692 GrDrawTarget* target); 652 const SkRect* devBounds, GrDrawTarget* target);
693 653
694 PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor , 654 PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor ,
695 const GrBatch* batch, const SkRect* devBounds, GrDrawTarget * target); 655 const GrBatch* batch, const SkRect* devBounds,
656 GrDrawTarget* target);
696 657
697 bool willBlendWithDst(const GrPrimitiveProcessor* primProc) const { 658 bool willBlendWithDst(const GrPrimitiveProcessor* primProc) const {
698 return fPipelineBuilder->willBlendWithDst(primProc); 659 return fPipelineBuilder->willBlendWithDst(primProc);
699 } 660 }
700 private: 661 private:
701 friend class GrDrawTarget; 662 friend class GrDrawTarget;
702 663
703 bool mustSkipDraw() const { return (NULL == fPipelineBuilder); } 664 bool mustSkipDraw() const { return (NULL == fPipelineBuilder); }
704 665
705 GrPipelineBuilder* fPipelineBuilder; 666 GrPipelineBuilder* fPipelineBuilder;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 virtual bool setupClip(GrPipelineBuilder*, 792 virtual bool setupClip(GrPipelineBuilder*,
832 GrPipelineBuilder::AutoRestoreEffects* are, 793 GrPipelineBuilder::AutoRestoreEffects* are,
833 GrPipelineBuilder::AutoRestoreStencil* ars, 794 GrPipelineBuilder::AutoRestoreStencil* ars,
834 GrScissorState* scissorState, 795 GrScissorState* scissorState,
835 const SkRect* devBounds) = 0; 796 const SkRect* devBounds) = 0;
836 797
837 enum { 798 enum {
838 kPreallocGeoSrcStateStackCnt = 4, 799 kPreallocGeoSrcStateStackCnt = 4,
839 }; 800 };
840 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState Stack; 801 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState Stack;
841 const GrClipData* fClip;
842 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar get. 802 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar get.
843 GrContext* fContext; 803 GrContext* fContext;
844 // To keep track that we always have at least as many debug marker adds as r emoves 804 // To keep track that we always have at least as many debug marker adds as r emoves
845 int fGpuTraceMar kerCount; 805 int fGpuTraceMar kerCount;
846 GrTraceMarkerSet fActiveTrace Markers; 806 GrTraceMarkerSet fActiveTrace Markers;
847 GrTraceMarkerSet fStoredTrace Markers; 807 GrTraceMarkerSet fStoredTrace Markers;
848 808
849 typedef SkRefCnt INHERITED; 809 typedef SkRefCnt INHERITED;
850 }; 810 };
851 811
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 virtual bool setupClip(GrPipelineBuilder*, 851 virtual bool setupClip(GrPipelineBuilder*,
892 GrPipelineBuilder::AutoRestoreEffects* are, 852 GrPipelineBuilder::AutoRestoreEffects* are,
893 GrPipelineBuilder::AutoRestoreStencil* ars, 853 GrPipelineBuilder::AutoRestoreStencil* ars,
894 GrScissorState* scissorState, 854 GrScissorState* scissorState,
895 const SkRect* devBounds) SK_OVERRIDE; 855 const SkRect* devBounds) SK_OVERRIDE;
896 856
897 typedef GrDrawTarget INHERITED; 857 typedef GrDrawTarget INHERITED;
898 }; 858 };
899 859
900 #endif 860 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698