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

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

Issue 685883003: Clip in grdrawtarget (Closed) Base URL: https://skia.googlesource.com/skia.git@drawtarget_on_clip_manager
Patch Set: add ccclip to ignore Created 6 years, 1 month 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/GrClipMaskManager.h ('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
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 456
457 /** 457 /**
458 * Release any resources that are cached but not currently in use. This 458 * Release any resources that are cached but not currently in use. This
459 * is intended to give an application some recourse when resources are low. 459 * is intended to give an application some recourse when resources are low.
460 */ 460 */
461 virtual void purgeResources() {}; 461 virtual void purgeResources() {};
462 462
463 /** 463 /**
464 * For subclass internal use to invoke a call to onDraw(). See DrawInfo belo w. 464 * For subclass internal use to invoke a call to onDraw(). See DrawInfo belo w.
465 */ 465 */
466 void executeDraw(const DrawInfo& info) { this->onDraw(info); } 466 void executeDraw(const DrawInfo& info,
467 const GrClipMaskManager::ScissorState& scissorState) {
468 this->onDraw(info, scissorState);
469 }
470
471 /**
472 * For subclass internal use to invoke a call to onStencilPath().
473 */
474 void executeStencilPath(const GrPath* path,
475 const GrClipMaskManager::ScissorState& scissorState,
476 const GrStencilSettings& stencilSettings) {
477 this->onStencilPath(path, scissorState, stencilSettings);
478 }
467 479
468 /** 480 /**
469 * For subclass internal use to invoke a call to onDrawPath(). 481 * For subclass internal use to invoke a call to onDrawPath().
470 */ 482 */
471 void executeDrawPath(const GrPath* path, GrPathRendering::FillType fill, 483 void executeDrawPath(const GrPath* path,
484 const GrClipMaskManager::ScissorState& scissorState,
485 const GrStencilSettings& stencilSettings,
472 const GrDeviceCoordTexture* dstCopy) { 486 const GrDeviceCoordTexture* dstCopy) {
473 this->onDrawPath(path, fill, dstCopy); 487 this->onDrawPath(path, scissorState, stencilSettings, dstCopy);
474 } 488 }
475 489
476 /** 490 /**
477 * For subclass internal use to invoke a call to onDrawPaths(). 491 * For subclass internal use to invoke a call to onDrawPaths().
478 */ 492 */
479 void executeDrawPaths(const GrPathRange* pathRange, 493 void executeDrawPaths(const GrPathRange* pathRange,
480 const uint32_t indices[], int count, 494 const uint32_t indices[],
481 const float transforms[], PathTransformType transforms Type, 495 int count,
482 GrPathRendering::FillType fill, 496 const float transforms[],
497 PathTransformType transformsType,
498 const GrClipMaskManager::ScissorState& scissorState,
499 const GrStencilSettings& stencilSettings,
483 const GrDeviceCoordTexture* dstCopy) { 500 const GrDeviceCoordTexture* dstCopy) {
484 this->onDrawPaths(pathRange, indices, count, transforms, transformsType, fill, dstCopy); 501 this->onDrawPaths(pathRange, indices, count, transforms, transformsType,
502 scissorState, stencilSettings, dstCopy);
485 } 503 }
486 504
487 //////////////////////////////////////////////////////////////////////////// 505 ////////////////////////////////////////////////////////////////////////////
488 506
489 /** 507 /**
490 * See AutoStateRestore below. 508 * See AutoStateRestore below.
491 */ 509 */
492 enum ASRInit { 510 enum ASRInit {
493 kPreserve_ASRInit, 511 kPreserve_ASRInit,
494 kReset_ASRInit 512 kReset_ASRInit
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 bool isIssued() { return fDrawTarget && fDrawTarget->isIssued(fDrawID); } 683 bool isIssued() { return fDrawTarget && fDrawTarget->isIssued(fDrawID); }
666 684
667 private: 685 private:
668 GrDrawTarget* fDrawTarget; 686 GrDrawTarget* fDrawTarget;
669 uint32_t fDrawID; // this may wrap, but we're doing direct compa rison 687 uint32_t fDrawID; // this may wrap, but we're doing direct compa rison
670 // so that should be okay 688 // so that should be okay
671 }; 689 };
672 690
673 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } 691 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); }
674 692
693
694 bool programUnitTest(int maxStages);
695
675 protected: 696 protected:
676 // Extend access to GrDrawState::convertToPEndeingExec to subclasses. 697 // Extend access to GrDrawState::convertToPEndeingExec to subclasses.
677 void convertDrawStateToPendingExec(GrDrawState* ds) { 698 void convertDrawStateToPendingExec(GrDrawState* ds) {
678 ds->convertToPendingExec(); 699 ds->convertToPendingExec();
679 } 700 }
680 701
681 enum GeometrySrcType { 702 enum GeometrySrcType {
682 kNone_GeometrySrcType, //<! src has not been specified 703 kNone_GeometrySrcType, //<! src has not been specified
683 kReserved_GeometrySrcType, //<! src was set using reserve*Space 704 kReserved_GeometrySrcType, //<! src was set using reserve*Space
684 kBuffer_GeometrySrcType //<! src was set using set*SourceToBuffer 705 kBuffer_GeometrySrcType //<! src was set using set*SourceToBuffer
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 // implemented by subclass to allocate space for reserved geom 850 // implemented by subclass to allocate space for reserved geom
830 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) = 0; 851 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) = 0;
831 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; 852 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0;
832 // implemented by subclass to handle release of reserved geom space 853 // implemented by subclass to handle release of reserved geom space
833 virtual void releaseReservedVertexSpace() = 0; 854 virtual void releaseReservedVertexSpace() = 0;
834 virtual void releaseReservedIndexSpace() = 0; 855 virtual void releaseReservedIndexSpace() = 0;
835 // subclass overrides to be notified just before geo src state is pushed/pop ped. 856 // subclass overrides to be notified just before geo src state is pushed/pop ped.
836 virtual void geometrySourceWillPush() = 0; 857 virtual void geometrySourceWillPush() = 0;
837 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; 858 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0;
838 // subclass called to perform drawing 859 // subclass called to perform drawing
839 virtual void onDraw(const DrawInfo&) = 0; 860 virtual void onDraw(const DrawInfo&, const GrClipMaskManager::ScissorState&) = 0;
840 // Implementation of drawRect. The geometry src and vertex attribs will alre ady 861 // Implementation of drawRect. The geometry src and vertex attribs will alre ady
841 // be saved before this is called and restored afterwards. A subclass may ov erride 862 // be saved before this is called and restored afterwards. A subclass may ov erride
842 // this to perform more optimal rect rendering. Its draws should be funneled through 863 // this to perform more optimal rect rendering. Its draws should be funneled through
843 // one of the public GrDrawTarget draw methods (e.g. drawNonIndexed, 864 // one of the public GrDrawTarget draw methods (e.g. drawNonIndexed,
844 // drawIndexedInstances, ...). The base class draws a two triangle fan using 865 // drawIndexedInstances, ...). The base class draws a two triangle fan using
845 // drawNonIndexed from reserved vertex space. 866 // drawNonIndexed from reserved vertex space.
846 virtual void onDrawRect(const SkRect& rect, 867 virtual void onDrawRect(const SkRect& rect,
847 const SkRect* localRect, 868 const SkRect* localRect,
848 const SkMatrix* localMatrix); 869 const SkMatrix* localMatrix);
849 870
850 virtual void onStencilPath(const GrPath*, GrPathRendering::FillType) = 0; 871 virtual void onStencilPath(const GrPath*,
851 virtual void onDrawPath(const GrPath*, GrPathRendering::FillType, 872 const GrClipMaskManager::ScissorState&,
873 const GrStencilSettings&) = 0;
874 virtual void onDrawPath(const GrPath*,
875 const GrClipMaskManager::ScissorState&,
876 const GrStencilSettings&,
852 const GrDeviceCoordTexture* dstCopy) = 0; 877 const GrDeviceCoordTexture* dstCopy) = 0;
853 virtual void onDrawPaths(const GrPathRange*, 878 virtual void onDrawPaths(const GrPathRange*,
854 const uint32_t indices[], int count, 879 const uint32_t indices[],
855 const float transforms[], PathTransformType, 880 int count,
856 GrPathRendering::FillType, const GrDeviceCoordTextu re*) = 0; 881 const float transforms[],
882 PathTransformType,
883 const GrClipMaskManager::ScissorState&,
884 const GrStencilSettings&,
885 const GrDeviceCoordTexture*) = 0;
857 886
858 virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect, 887 virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect,
859 GrRenderTarget* renderTarget) = 0; 888 GrRenderTarget* renderTarget) = 0;
860 889
861 890
862 virtual void didAddGpuTraceMarker() = 0; 891 virtual void didAddGpuTraceMarker() = 0;
863 virtual void didRemoveGpuTraceMarker() = 0; 892 virtual void didRemoveGpuTraceMarker() = 0;
864 893
865 // helpers for reserving vertex and index space. 894 // helpers for reserving vertex and index space.
866 bool reserveVertexSpace(size_t vertexSize, 895 bool reserveVertexSpace(size_t vertexSize,
867 int vertexCount, 896 int vertexCount,
868 void** vertices); 897 void** vertices);
869 bool reserveIndexSpace(int indexCount, void** indices); 898 bool reserveIndexSpace(int indexCount, void** indices);
870 899
871 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to 900 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to
872 // indicate non-indexed drawing. 901 // indicate non-indexed drawing.
873 bool checkDraw(GrPrimitiveType type, int startVertex, 902 bool checkDraw(GrPrimitiveType type, int startVertex,
874 int startIndex, int vertexCount, 903 int startIndex, int vertexCount,
875 int indexCount) const; 904 int indexCount) const;
876 // called when setting a new vert/idx source to unref prev vb/ib 905 // called when setting a new vert/idx source to unref prev vb/ib
877 void releasePreviousVertexSource(); 906 void releasePreviousVertexSource();
878 void releasePreviousIndexSource(); 907 void releasePreviousIndexSource();
879 908
880 // Check to see if this set of draw commands has been sent out 909 // Check to see if this set of draw commands has been sent out
881 virtual bool isIssued(uint32_t drawID) { return true; } 910 virtual bool isIssued(uint32_t drawID) { return true; }
911 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, GrStencilS ettings*);
882 virtual GrClipMaskManager* clipMaskManager() = 0; 912 virtual GrClipMaskManager* clipMaskManager() = 0;
913 virtual bool setupClip(const SkRect* devBounds,
914 GrDrawState::AutoRestoreEffects* are,
915 GrDrawState::AutoRestoreStencil* ars,
916 GrClipMaskManager::ScissorState* scissorState) = 0;
883 917
884 enum { 918 enum {
885 kPreallocGeoSrcStateStackCnt = 4, 919 kPreallocGeoSrcStateStackCnt = 4,
886 }; 920 };
887 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState Stack; 921 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState Stack;
888 const GrClipData* fClip; 922 const GrClipData* fClip;
889 GrDrawState* fDrawState; 923 GrDrawState* fDrawState;
890 GrDrawState fDefaultDraw State; 924 GrDrawState fDefaultDraw State;
891 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar get. 925 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar get.
892 GrContext* fContext; 926 GrContext* fContext;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 // get rid of them all. 964 // get rid of them all.
931 fClipMaskManager.purgeResources(); 965 fClipMaskManager.purgeResources();
932 }; 966 };
933 967
934 protected: 968 protected:
935 GrClipMaskManager fClipMaskManager; 969 GrClipMaskManager fClipMaskManager;
936 970
937 private: 971 private:
938 GrClipMaskManager* clipMaskManager() { return &fClipMaskManager; } 972 GrClipMaskManager* clipMaskManager() { return &fClipMaskManager; }
939 973
974 virtual bool setupClip(const SkRect* devBounds,
975 GrDrawState::AutoRestoreEffects* are,
976 GrDrawState::AutoRestoreStencil* ars,
977 GrClipMaskManager::ScissorState* scissorState) SK_OVE RRIDE;
978
940 typedef GrDrawTarget INHERITED; 979 typedef GrDrawTarget INHERITED;
941 }; 980 };
942 981
943 #endif 982 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.h ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698