OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrInOrderDrawBuffer_DEFINED | 8 #ifndef GrInOrderDrawBuffer_DEFINED |
9 #define GrInOrderDrawBuffer_DEFINED | 9 #define GrInOrderDrawBuffer_DEFINED |
10 | 10 |
11 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
12 #include "GrAllocPool.h" | 12 #include "GrAllocPool.h" |
13 #include "GrAllocator.h" | 13 #include "GrAllocator.h" |
14 #include "GrPath.h" | 14 #include "GrPath.h" |
15 | 15 |
16 #include "SkClipStack.h" | 16 #include "SkClipStack.h" |
17 #include "SkStrokeRec.h" | |
18 #include "SkTemplates.h" | 17 #include "SkTemplates.h" |
19 #include "SkTypes.h" | 18 #include "SkTypes.h" |
20 | 19 |
21 class GrGpu; | 20 class GrGpu; |
22 class GrIndexBufferAllocPool; | 21 class GrIndexBufferAllocPool; |
23 class GrVertexBufferAllocPool; | 22 class GrVertexBufferAllocPool; |
24 | 23 |
25 /** | 24 /** |
26 * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws
for eventual | 25 * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws
for eventual |
27 * playback into a GrGpu. In theory one draw buffer could playback into another.
When index or | 26 * playback into a GrGpu. In theory one draw buffer could playback into another.
When index or |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 virtual void clipWillBeSet(const GrClipData* newClip) SK_OVERRIDE; | 79 virtual void clipWillBeSet(const GrClipData* newClip) SK_OVERRIDE; |
81 | 80 |
82 private: | 81 private: |
83 enum Cmd { | 82 enum Cmd { |
84 kDraw_Cmd = 1, | 83 kDraw_Cmd = 1, |
85 kStencilPath_Cmd = 2, | 84 kStencilPath_Cmd = 2, |
86 kSetState_Cmd = 3, | 85 kSetState_Cmd = 3, |
87 kSetClip_Cmd = 4, | 86 kSetClip_Cmd = 4, |
88 kClear_Cmd = 5, | 87 kClear_Cmd = 5, |
89 kCopySurface_Cmd = 6, | 88 kCopySurface_Cmd = 6, |
90 kFillPath_Cmd = 7, | 89 kDrawPath_Cmd = 7, |
91 }; | 90 }; |
92 | 91 |
93 class DrawRecord : public DrawInfo { | 92 class DrawRecord : public DrawInfo { |
94 public: | 93 public: |
95 DrawRecord(const DrawInfo& info) : DrawInfo(info) {} | 94 DrawRecord(const DrawInfo& info) : DrawInfo(info) {} |
96 const GrVertexBuffer* fVertexBuffer; | 95 const GrVertexBuffer* fVertexBuffer; |
97 const GrIndexBuffer* fIndexBuffer; | 96 const GrIndexBuffer* fIndexBuffer; |
98 }; | 97 }; |
99 | 98 |
100 struct StencilPath : public ::SkNoncopyable { | 99 struct StencilPath : public ::SkNoncopyable { |
101 StencilPath(); | 100 StencilPath(); |
102 | 101 |
103 SkAutoTUnref<const GrPath> fPath; | 102 SkAutoTUnref<const GrPath> fPath; |
104 SkStrokeRec fStroke; | |
105 SkPath::FillType fFill; | 103 SkPath::FillType fFill; |
106 }; | 104 }; |
107 | 105 |
108 struct FillPath : public ::SkNoncopyable { | 106 struct DrawPath : public ::SkNoncopyable { |
109 FillPath(); | 107 DrawPath(); |
110 | 108 |
111 SkAutoTUnref<const GrPath> fPath; | 109 SkAutoTUnref<const GrPath> fPath; |
112 SkStrokeRec fStroke; | |
113 SkPath::FillType fFill; | 110 SkPath::FillType fFill; |
114 GrDeviceCoordTexture fDstCopy; | 111 GrDeviceCoordTexture fDstCopy; |
115 }; | 112 }; |
116 | 113 |
117 struct Clear : public ::SkNoncopyable { | 114 struct Clear : public ::SkNoncopyable { |
118 Clear() : fRenderTarget(NULL) {} | 115 Clear() : fRenderTarget(NULL) {} |
119 ~Clear() { SkSafeUnref(fRenderTarget); } | 116 ~Clear() { SkSafeUnref(fRenderTarget); } |
120 | 117 |
121 SkIRect fRect; | 118 SkIRect fRect; |
122 GrColor fColor; | 119 GrColor fColor; |
123 GrRenderTarget* fRenderTarget; | 120 GrRenderTarget* fRenderTarget; |
124 }; | 121 }; |
125 | 122 |
126 struct CopySurface : public ::SkNoncopyable { | 123 struct CopySurface : public ::SkNoncopyable { |
127 SkAutoTUnref<GrSurface> fDst; | 124 SkAutoTUnref<GrSurface> fDst; |
128 SkAutoTUnref<GrSurface> fSrc; | 125 SkAutoTUnref<GrSurface> fSrc; |
129 SkIRect fSrcRect; | 126 SkIRect fSrcRect; |
130 SkIPoint fDstPoint; | 127 SkIPoint fDstPoint; |
131 }; | 128 }; |
132 | 129 |
133 // overrides from GrDrawTarget | 130 // overrides from GrDrawTarget |
134 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; | 131 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; |
135 virtual void onDrawRect(const SkRect& rect, | 132 virtual void onDrawRect(const SkRect& rect, |
136 const SkMatrix* matrix, | 133 const SkMatrix* matrix, |
137 const SkRect* localRect, | 134 const SkRect* localRect, |
138 const SkMatrix* localMatrix) SK_OVERRIDE; | 135 const SkMatrix* localMatrix) SK_OVERRIDE; |
139 virtual void onStencilPath(const GrPath*, const SkStrokeRec& stroke, SkPath:
:FillType) SK_OVERRIDE; | 136 |
140 virtual void onFillPath(const GrPath*, const SkStrokeRec& stroke, SkPath::Fi
llType, | 137 virtual void onStencilPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; |
| 138 virtual void onDrawPath(const GrPath*, SkPath::FillType, |
141 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; | 139 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
| 140 |
142 virtual bool onReserveVertexSpace(size_t vertexSize, | 141 virtual bool onReserveVertexSpace(size_t vertexSize, |
143 int vertexCount, | 142 int vertexCount, |
144 void** vertices) SK_OVERRIDE; | 143 void** vertices) SK_OVERRIDE; |
145 virtual bool onReserveIndexSpace(int indexCount, | 144 virtual bool onReserveIndexSpace(int indexCount, |
146 void** indices) SK_OVERRIDE; | 145 void** indices) SK_OVERRIDE; |
147 virtual void releaseReservedVertexSpace() SK_OVERRIDE; | 146 virtual void releaseReservedVertexSpace() SK_OVERRIDE; |
148 virtual void releaseReservedIndexSpace() SK_OVERRIDE; | 147 virtual void releaseReservedIndexSpace() SK_OVERRIDE; |
149 virtual void onSetVertexSourceToArray(const void* vertexArray, | 148 virtual void onSetVertexSourceToArray(const void* vertexArray, |
150 int vertexCount) SK_OVERRIDE; | 149 int vertexCount) SK_OVERRIDE; |
151 virtual void onSetIndexSourceToArray(const void* indexArray, | 150 virtual void onSetIndexSourceToArray(const void* indexArray, |
(...skipping 22 matching lines...) Expand all Loading... |
174 // we lazily record state and clip changes in order to skip clips and states
that have no | 173 // we lazily record state and clip changes in order to skip clips and states
that have no |
175 // effect. | 174 // effect. |
176 bool needsNewState() const; | 175 bool needsNewState() const; |
177 bool needsNewClip() const; | 176 bool needsNewClip() const; |
178 | 177 |
179 // these functions record a command | 178 // these functions record a command |
180 void recordState(); | 179 void recordState(); |
181 void recordClip(); | 180 void recordClip(); |
182 DrawRecord* recordDraw(const DrawInfo&); | 181 DrawRecord* recordDraw(const DrawInfo&); |
183 StencilPath* recordStencilPath(); | 182 StencilPath* recordStencilPath(); |
184 FillPath* recordFillPath(); | 183 DrawPath* recordDrawPath(); |
185 Clear* recordClear(); | 184 Clear* recordClear(); |
186 CopySurface* recordCopySurface(); | 185 CopySurface* recordCopySurface(); |
187 | 186 |
188 // TODO: Use a single allocator for commands and records | 187 // TODO: Use a single allocator for commands and records |
189 enum { | 188 enum { |
190 kCmdPreallocCnt = 32, | 189 kCmdPreallocCnt = 32, |
191 kDrawPreallocCnt = 8, | 190 kDrawPreallocCnt = 8, |
192 kStencilPathPreallocCnt = 8, | 191 kStencilPathPreallocCnt = 8, |
193 kFillPathPreallocCnt = 8, | 192 kDrawPathPreallocCnt = 8, |
194 kStatePreallocCnt = 8, | 193 kStatePreallocCnt = 8, |
195 kClipPreallocCnt = 8, | 194 kClipPreallocCnt = 8, |
196 kClearPreallocCnt = 4, | 195 kClearPreallocCnt = 4, |
197 kGeoPoolStatePreAllocCnt = 4, | 196 kGeoPoolStatePreAllocCnt = 4, |
198 kCopySurfacePreallocCnt = 4, | 197 kCopySurfacePreallocCnt = 4, |
199 }; | 198 }; |
200 | 199 |
201 SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds; | 200 SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds; |
202 GrSTAllocator<kDrawPreallocCnt, DrawRecord> fDraws; | 201 GrSTAllocator<kDrawPreallocCnt, DrawRecord> fDraws; |
203 GrSTAllocator<kStatePreallocCnt, StencilPath> fStencilP
aths; | 202 GrSTAllocator<kStatePreallocCnt, StencilPath> fStencilP
aths; |
204 GrSTAllocator<kStatePreallocCnt, FillPath> fFillPath
s; | 203 GrSTAllocator<kStatePreallocCnt, DrawPath> fDrawPath
s; |
205 GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates; | 204 GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates; |
206 GrSTAllocator<kClearPreallocCnt, Clear> fClears; | 205 GrSTAllocator<kClearPreallocCnt, Clear> fClears; |
207 GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurf
aces; | 206 GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurf
aces; |
208 GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips; | 207 GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips; |
209 GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrig
ins; | 208 GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrig
ins; |
210 | 209 |
211 GrDrawTarget* fDstGpu; | 210 GrDrawTarget* fDstGpu; |
212 | 211 |
213 bool fClipSet; | 212 bool fClipSet; |
214 | 213 |
(...skipping 24 matching lines...) Expand all Loading... |
239 | 238 |
240 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } | 239 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } |
241 | 240 |
242 bool fFlushing; | 241 bool fFlushing; |
243 uint32_t fDrawID; | 242 uint32_t fDrawID; |
244 | 243 |
245 typedef GrDrawTarget INHERITED; | 244 typedef GrDrawTarget INHERITED; |
246 }; | 245 }; |
247 | 246 |
248 #endif | 247 #endif |
OLD | NEW |