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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 int fInstanceCount; | 848 int fInstanceCount; |
849 int fVerticesPerInstance; | 849 int fVerticesPerInstance; |
850 int fIndicesPerInstance; | 850 int fIndicesPerInstance; |
851 | 851 |
852 SkRect fDevBoundsStorage; | 852 SkRect fDevBoundsStorage; |
853 SkRect* fDevBounds; | 853 SkRect* fDevBounds; |
854 | 854 |
855 GrDeviceCoordTexture fDstCopy; | 855 GrDeviceCoordTexture fDstCopy; |
856 }; | 856 }; |
857 | 857 |
| 858 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required |
| 859 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it |
| 860 // needs to be accessed by GLPrograms to setup a correct drawstate |
| 861 bool setupDstReadIfNecessary(DrawInfo* info) { |
| 862 return this->setupDstReadIfNecessary(&info->fDstCopy, info->getDevBounds
()); |
| 863 } |
| 864 bool setupDstReadIfNecessary(GrDeviceCoordTexture* dstCopy, const SkRect* dr
awBounds); |
| 865 |
858 private: | 866 private: |
859 // A subclass can optionally overload this function to be notified before | 867 // A subclass can optionally overload this function to be notified before |
860 // vertex and index space is reserved. | 868 // vertex and index space is reserved. |
861 virtual void willReserveVertexAndIndexSpace(int vertexCount, int indexCount)
{} | 869 virtual void willReserveVertexAndIndexSpace(int vertexCount, int indexCount)
{} |
862 | 870 |
863 // implemented by subclass to allocate space for reserved geom | 871 // implemented by subclass to allocate space for reserved geom |
864 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) = 0; | 872 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) = 0; |
865 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; | 873 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; |
866 // implemented by subclass to handle release of reserved geom space | 874 // implemented by subclass to handle release of reserved geom space |
867 virtual void releaseReservedVertexSpace() = 0; | 875 virtual void releaseReservedVertexSpace() = 0; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 | 914 |
907 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to | 915 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to |
908 // indicate non-indexed drawing. | 916 // indicate non-indexed drawing. |
909 bool checkDraw(GrPrimitiveType type, int startVertex, | 917 bool checkDraw(GrPrimitiveType type, int startVertex, |
910 int startIndex, int vertexCount, | 918 int startIndex, int vertexCount, |
911 int indexCount) const; | 919 int indexCount) const; |
912 // called when setting a new vert/idx source to unref prev vb/ib | 920 // called when setting a new vert/idx source to unref prev vb/ib |
913 void releasePreviousVertexSource(); | 921 void releasePreviousVertexSource(); |
914 void releasePreviousIndexSource(); | 922 void releasePreviousIndexSource(); |
915 | 923 |
916 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required | |
917 // but couldn't be made. Otherwise, returns true. | |
918 bool setupDstReadIfNecessary(DrawInfo* info) { | |
919 return this->setupDstReadIfNecessary(&info->fDstCopy, info->getDevBounds
()); | |
920 } | |
921 bool setupDstReadIfNecessary(GrDeviceCoordTexture* dstCopy, const SkRect* dr
awBounds); | |
922 | |
923 // Check to see if this set of draw commands has been sent out | 924 // Check to see if this set of draw commands has been sent out |
924 virtual bool isIssued(uint32_t drawID) { return true; } | 925 virtual bool isIssued(uint32_t drawID) { return true; } |
925 | 926 |
926 enum { | 927 enum { |
927 kPreallocGeoSrcStateStackCnt = 4, | 928 kPreallocGeoSrcStateStackCnt = 4, |
928 }; | 929 }; |
929 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; | 930 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; |
930 const GrClipData* fClip; | 931 const GrClipData* fClip; |
931 GrDrawState* fDrawState; | 932 GrDrawState* fDrawState; |
932 GrDrawState fDefaultDraw
State; | 933 GrDrawState fDefaultDraw
State; |
933 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. | 934 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. |
934 GrContext* fContext; | 935 GrContext* fContext; |
935 // To keep track that we always have at least as many debug marker adds as r
emoves | 936 // To keep track that we always have at least as many debug marker adds as r
emoves |
936 int fGpuTraceMar
kerCount; | 937 int fGpuTraceMar
kerCount; |
937 GrTraceMarkerSet fActiveTrace
Markers; | 938 GrTraceMarkerSet fActiveTrace
Markers; |
938 GrTraceMarkerSet fStoredTrace
Markers; | 939 GrTraceMarkerSet fStoredTrace
Markers; |
939 | 940 |
940 typedef SkRefCnt INHERITED; | 941 typedef SkRefCnt INHERITED; |
941 }; | 942 }; |
942 | 943 |
943 #endif | 944 #endif |
OLD | NEW |