| OLD | NEW |
| 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 475 |
| 476 /** | 476 /** |
| 477 * Release any resources that are cached but not currently in use. This | 477 * Release any resources that are cached but not currently in use. This |
| 478 * is intended to give an application some recourse when resources are low. | 478 * is intended to give an application some recourse when resources are low. |
| 479 */ | 479 */ |
| 480 virtual void purgeResources() {}; | 480 virtual void purgeResources() {}; |
| 481 | 481 |
| 482 /** | 482 /** |
| 483 * For subclass internal use to invoke a call to onDraw(). See DrawInfo belo
w. | 483 * For subclass internal use to invoke a call to onDraw(). See DrawInfo belo
w. |
| 484 */ | 484 */ |
| 485 void executeDraw(const DrawInfo& info) { this->onDraw(info); } | 485 void executeDraw(const DrawInfo& info, |
| 486 const GrClipMaskManager::ScissorState& scissorState) { |
| 487 this->onDraw(info, scissorState); |
| 488 } |
| 489 |
| 490 /** |
| 491 * For subclass internal use to invoke a call to onStencilPath(). |
| 492 */ |
| 493 void executeStencilPath(const GrPath* path, |
| 494 const GrClipMaskManager::ScissorState& scissorState, |
| 495 const GrStencilSettings& stencilSettings) { |
| 496 this->onStencilPath(path, scissorState, stencilSettings); |
| 497 } |
| 486 | 498 |
| 487 /** | 499 /** |
| 488 * For subclass internal use to invoke a call to onDrawPath(). | 500 * For subclass internal use to invoke a call to onDrawPath(). |
| 489 */ | 501 */ |
| 490 void executeDrawPath(const GrPath* path, GrPathRendering::FillType fill, | 502 void executeDrawPath(const GrPath* path, |
| 503 const GrClipMaskManager::ScissorState& scissorState, |
| 504 const GrStencilSettings& stencilSettings, |
| 491 const GrDeviceCoordTexture* dstCopy) { | 505 const GrDeviceCoordTexture* dstCopy) { |
| 492 this->onDrawPath(path, fill, dstCopy); | 506 this->onDrawPath(path, scissorState, stencilSettings, dstCopy); |
| 493 } | 507 } |
| 494 | 508 |
| 495 /** | 509 /** |
| 496 * For subclass internal use to invoke a call to onDrawPaths(). | 510 * For subclass internal use to invoke a call to onDrawPaths(). |
| 497 */ | 511 */ |
| 498 void executeDrawPaths(const GrPathRange* pathRange, | 512 void executeDrawPaths(const GrPathRange* pathRange, |
| 499 const uint32_t indices[], int count, | 513 const uint32_t indices[], |
| 500 const float transforms[], PathTransformType transforms
Type, | 514 int count, |
| 501 GrPathRendering::FillType fill, | 515 const float transforms[], |
| 516 PathTransformType transformsType, |
| 517 const GrClipMaskManager::ScissorState& scissorState, |
| 518 const GrStencilSettings& stencilSettings, |
| 502 const GrDeviceCoordTexture* dstCopy) { | 519 const GrDeviceCoordTexture* dstCopy) { |
| 503 this->onDrawPaths(pathRange, indices, count, transforms, transformsType,
fill, dstCopy); | 520 this->onDrawPaths(pathRange, indices, count, transforms, transformsType, |
| 521 scissorState, stencilSettings, dstCopy); |
| 504 } | 522 } |
| 505 | 523 |
| 506 //////////////////////////////////////////////////////////////////////////// | 524 //////////////////////////////////////////////////////////////////////////// |
| 507 | 525 |
| 508 /** | 526 /** |
| 509 * See AutoStateRestore below. | 527 * See AutoStateRestore below. |
| 510 */ | 528 */ |
| 511 enum ASRInit { | 529 enum ASRInit { |
| 512 kPreserve_ASRInit, | 530 kPreserve_ASRInit, |
| 513 kReset_ASRInit | 531 kReset_ASRInit |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 bool isIssued() { return fDrawTarget && fDrawTarget->isIssued(fDrawID);
} | 702 bool isIssued() { return fDrawTarget && fDrawTarget->isIssued(fDrawID);
} |
| 685 | 703 |
| 686 private: | 704 private: |
| 687 GrDrawTarget* fDrawTarget; | 705 GrDrawTarget* fDrawTarget; |
| 688 uint32_t fDrawID; // this may wrap, but we're doing direct compa
rison | 706 uint32_t fDrawID; // this may wrap, but we're doing direct compa
rison |
| 689 // so that should be okay | 707 // so that should be okay |
| 690 }; | 708 }; |
| 691 | 709 |
| 692 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } | 710 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } |
| 693 | 711 |
| 712 |
| 713 bool programUnitTest(int maxStages); |
| 714 |
| 694 protected: | 715 protected: |
| 695 // Extend access to GrDrawState::convertToPEndeingExec to subclasses. | 716 // Extend access to GrDrawState::convertToPEndeingExec to subclasses. |
| 696 void convertDrawStateToPendingExec(GrDrawState* ds) { | 717 void convertDrawStateToPendingExec(GrDrawState* ds) { |
| 697 ds->convertToPendingExec(); | 718 ds->convertToPendingExec(); |
| 698 } | 719 } |
| 699 | 720 |
| 700 enum GeometrySrcType { | 721 enum GeometrySrcType { |
| 701 kNone_GeometrySrcType, //<! src has not been specified | 722 kNone_GeometrySrcType, //<! src has not been specified |
| 702 kReserved_GeometrySrcType, //<! src was set using reserve*Space | 723 kReserved_GeometrySrcType, //<! src was set using reserve*Space |
| 703 kArray_GeometrySrcType, //<! src was set using set*SourceToArray | 724 kArray_GeometrySrcType, //<! src was set using set*SourceToArray |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 // subclass must consume array contents when set | 877 // subclass must consume array contents when set |
| 857 virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCou
nt) = 0; | 878 virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCou
nt) = 0; |
| 858 virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount)
= 0; | 879 virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount)
= 0; |
| 859 // subclass is notified that geom source will be set away from an array | 880 // subclass is notified that geom source will be set away from an array |
| 860 virtual void releaseVertexArray() = 0; | 881 virtual void releaseVertexArray() = 0; |
| 861 virtual void releaseIndexArray() = 0; | 882 virtual void releaseIndexArray() = 0; |
| 862 // subclass overrides to be notified just before geo src state is pushed/pop
ped. | 883 // subclass overrides to be notified just before geo src state is pushed/pop
ped. |
| 863 virtual void geometrySourceWillPush() = 0; | 884 virtual void geometrySourceWillPush() = 0; |
| 864 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; | 885 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; |
| 865 // subclass called to perform drawing | 886 // subclass called to perform drawing |
| 866 virtual void onDraw(const DrawInfo&) = 0; | 887 virtual void onDraw(const DrawInfo&, const GrClipMaskManager::ScissorState&)
= 0; |
| 867 // Implementation of drawRect. The geometry src and vertex attribs will alre
ady | 888 // Implementation of drawRect. The geometry src and vertex attribs will alre
ady |
| 868 // be saved before this is called and restored afterwards. A subclass may ov
erride | 889 // be saved before this is called and restored afterwards. A subclass may ov
erride |
| 869 // this to perform more optimal rect rendering. Its draws should be funneled
through | 890 // this to perform more optimal rect rendering. Its draws should be funneled
through |
| 870 // one of the public GrDrawTarget draw methods (e.g. drawNonIndexed, | 891 // one of the public GrDrawTarget draw methods (e.g. drawNonIndexed, |
| 871 // drawIndexedInstances, ...). The base class draws a two triangle fan using | 892 // drawIndexedInstances, ...). The base class draws a two triangle fan using |
| 872 // drawNonIndexed from reserved vertex space. | 893 // drawNonIndexed from reserved vertex space. |
| 873 virtual void onDrawRect(const SkRect& rect, | 894 virtual void onDrawRect(const SkRect& rect, |
| 874 const SkRect* localRect, | 895 const SkRect* localRect, |
| 875 const SkMatrix* localMatrix); | 896 const SkMatrix* localMatrix); |
| 876 | 897 |
| 877 virtual void onStencilPath(const GrPath*, GrPathRendering::FillType) = 0; | 898 virtual void onStencilPath(const GrPath*, |
| 878 virtual void onDrawPath(const GrPath*, GrPathRendering::FillType, | 899 const GrClipMaskManager::ScissorState&, |
| 900 const GrStencilSettings&) = 0; |
| 901 virtual void onDrawPath(const GrPath*, |
| 902 const GrClipMaskManager::ScissorState&, |
| 903 const GrStencilSettings&, |
| 879 const GrDeviceCoordTexture* dstCopy) = 0; | 904 const GrDeviceCoordTexture* dstCopy) = 0; |
| 880 virtual void onDrawPaths(const GrPathRange*, | 905 virtual void onDrawPaths(const GrPathRange*, |
| 881 const uint32_t indices[], int count, | 906 const uint32_t indices[], |
| 882 const float transforms[], PathTransformType, | 907 int count, |
| 883 GrPathRendering::FillType, const GrDeviceCoordTextu
re*) = 0; | 908 const float transforms[], |
| 909 PathTransformType, |
| 910 const GrClipMaskManager::ScissorState&, |
| 911 const GrStencilSettings&, |
| 912 const GrDeviceCoordTexture*) = 0; |
| 884 | 913 |
| 885 virtual void didAddGpuTraceMarker() = 0; | 914 virtual void didAddGpuTraceMarker() = 0; |
| 886 virtual void didRemoveGpuTraceMarker() = 0; | 915 virtual void didRemoveGpuTraceMarker() = 0; |
| 887 | 916 |
| 888 // helpers for reserving vertex and index space. | 917 // helpers for reserving vertex and index space. |
| 889 bool reserveVertexSpace(size_t vertexSize, | 918 bool reserveVertexSpace(size_t vertexSize, |
| 890 int vertexCount, | 919 int vertexCount, |
| 891 void** vertices); | 920 void** vertices); |
| 892 bool reserveIndexSpace(int indexCount, void** indices); | 921 bool reserveIndexSpace(int indexCount, void** indices); |
| 893 | 922 |
| 894 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to | 923 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to |
| 895 // indicate non-indexed drawing. | 924 // indicate non-indexed drawing. |
| 896 bool checkDraw(GrPrimitiveType type, int startVertex, | 925 bool checkDraw(GrPrimitiveType type, int startVertex, |
| 897 int startIndex, int vertexCount, | 926 int startIndex, int vertexCount, |
| 898 int indexCount) const; | 927 int indexCount) const; |
| 899 // called when setting a new vert/idx source to unref prev vb/ib | 928 // called when setting a new vert/idx source to unref prev vb/ib |
| 900 void releasePreviousVertexSource(); | 929 void releasePreviousVertexSource(); |
| 901 void releasePreviousIndexSource(); | 930 void releasePreviousIndexSource(); |
| 902 | 931 |
| 903 // Check to see if this set of draw commands has been sent out | 932 // Check to see if this set of draw commands has been sent out |
| 904 virtual bool isIssued(uint32_t drawID) { return true; } | 933 virtual bool isIssued(uint32_t drawID) { return true; } |
| 934 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, GrStencilS
ettings*); |
| 905 virtual GrClipMaskManager* clipMaskManager() = 0; | 935 virtual GrClipMaskManager* clipMaskManager() = 0; |
| 936 virtual bool setupClip(const SkRect* devBounds, |
| 937 GrDrawState::AutoRestoreEffects* are, |
| 938 GrDrawState::AutoRestoreStencil* ars, |
| 939 GrClipMaskManager::ScissorState* scissorState) = 0; |
| 906 | 940 |
| 907 enum { | 941 enum { |
| 908 kPreallocGeoSrcStateStackCnt = 4, | 942 kPreallocGeoSrcStateStackCnt = 4, |
| 909 }; | 943 }; |
| 910 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; | 944 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; |
| 911 const GrClipData* fClip; | 945 const GrClipData* fClip; |
| 912 GrDrawState* fDrawState; | 946 GrDrawState* fDrawState; |
| 913 GrDrawState fDefaultDraw
State; | 947 GrDrawState fDefaultDraw
State; |
| 914 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. | 948 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. |
| 915 GrContext* fContext; | 949 GrContext* fContext; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 // get rid of them all. | 987 // get rid of them all. |
| 954 fClipMaskManager.purgeResources(); | 988 fClipMaskManager.purgeResources(); |
| 955 }; | 989 }; |
| 956 | 990 |
| 957 protected: | 991 protected: |
| 958 GrClipMaskManager fClipMaskManager; | 992 GrClipMaskManager fClipMaskManager; |
| 959 | 993 |
| 960 private: | 994 private: |
| 961 GrClipMaskManager* clipMaskManager() { return &fClipMaskManager; } | 995 GrClipMaskManager* clipMaskManager() { return &fClipMaskManager; } |
| 962 | 996 |
| 997 virtual bool setupClip(const SkRect* devBounds, |
| 998 GrDrawState::AutoRestoreEffects* are, |
| 999 GrDrawState::AutoRestoreStencil* ars, |
| 1000 GrClipMaskManager::ScissorState* scissorState) SK_OVE
RRIDE; |
| 1001 |
| 963 typedef GrDrawTarget INHERITED; | 1002 typedef GrDrawTarget INHERITED; |
| 964 }; | 1003 }; |
| 965 | 1004 |
| 966 #endif | 1005 #endif |
| OLD | NEW |