Chromium Code Reviews| 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 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 bool canIgnoreRect, | 74 bool canIgnoreRect, |
| 75 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; | 75 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; |
| 76 | 76 |
| 77 virtual void initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* des c) SK_OVERRIDE; | 77 virtual void initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* des c) SK_OVERRIDE; |
| 78 | 78 |
| 79 protected: | 79 protected: |
| 80 virtual void clipWillBeSet(const GrClipData* newClip) SK_OVERRIDE; | 80 virtual void clipWillBeSet(const GrClipData* newClip) SK_OVERRIDE; |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 enum Cmd { | 83 enum Cmd { |
| 84 kDraw_Cmd = 1, | 84 kDraw_Cmd = 1, |
| 85 kStencilPath_Cmd = 2, | 85 kStencilPath_Cmd = 2, |
| 86 kSetState_Cmd = 3, | 86 kSetState_Cmd = 3, |
| 87 kSetClip_Cmd = 4, | 87 kSetClip_Cmd = 4, |
| 88 kClear_Cmd = 5, | 88 kClear_Cmd = 5, |
| 89 kCopySurface_Cmd = 6, | 89 kCopySurface_Cmd = 6, |
| 90 kDrawPath_Cmd = 7, | 90 kDrawPath_Cmd = 7, |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 class DrawRecord : public DrawInfo { | 93 class DrawRecord : public DrawInfo { |
| 94 public: | 94 public: |
| 95 DrawRecord(const DrawInfo& info) : DrawInfo(info) {} | 95 DrawRecord(const DrawInfo& info) : DrawInfo(info) {} |
| 96 const GrVertexBuffer* fVertexBuffer; | 96 const GrVertexBuffer* fVertexBuffer; |
| 97 const GrIndexBuffer* fIndexBuffer; | 97 const GrIndexBuffer* fIndexBuffer; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 struct StencilPath : public ::SkNoncopyable { | 100 struct StencilPath : public ::SkNoncopyable { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 GrSurface* src, | 161 GrSurface* src, |
| 162 const SkIRect& srcRect, | 162 const SkIRect& srcRect, |
| 163 const SkIPoint& dstPoint) SK_OVERRIDE; | 163 const SkIPoint& dstPoint) SK_OVERRIDE; |
| 164 virtual bool onCanCopySurface(GrSurface* dst, | 164 virtual bool onCanCopySurface(GrSurface* dst, |
| 165 GrSurface* src, | 165 GrSurface* src, |
| 166 const SkIRect& srcRect, | 166 const SkIRect& srcRect, |
| 167 const SkIPoint& dstPoint) SK_OVERRIDE; | 167 const SkIPoint& dstPoint) SK_OVERRIDE; |
| 168 | 168 |
| 169 bool quickInsideClip(const SkRect& devBounds); | 169 bool quickInsideClip(const SkRect& devBounds); |
| 170 | 170 |
| 171 virtual void onInstantGpuTraceEvent(const char* marker) SK_OVERRIDE; | 171 virtual void onAddGpuTraceMarker() SK_OVERRIDE {}; |
| 172 virtual void onPushGpuTraceEvent(const char* marker) SK_OVERRIDE; | 172 virtual void onRemoveGpuTraceMarker() SK_OVERRIDE {}; |
| 173 virtual void onPopGpuTraceEvent() SK_OVERRIDE; | |
| 174 | |
| 175 | 173 |
| 176 // Attempts to concat instances from info onto the previous draw. info must represent an | 174 // Attempts to concat instances from info onto the previous draw. info must represent an |
| 177 // instanced draw. The caller must have already recorded a new draw state an d clip if necessary. | 175 // instanced draw. The caller must have already recorded a new draw state an d clip if necessary. |
| 178 int concatInstancedDraw(const DrawInfo& info); | 176 int concatInstancedDraw(const DrawInfo& info); |
| 179 | 177 |
| 180 // we lazily record state and clip changes in order to skip clips and states that have no | 178 // we lazily record state and clip changes in order to skip clips and states that have no |
| 181 // effect. | 179 // effect. |
| 182 bool needsNewState() const; | 180 bool needsNewState() const; |
| 183 bool needsNewClip() const; | 181 bool needsNewClip() const; |
| 184 | 182 |
| 185 // these functions record a command | 183 // these functions record a command |
| 186 void recordState(); | 184 void recordState(); |
| 187 void recordClip(); | 185 void recordClip(); |
| 188 DrawRecord* recordDraw(const DrawInfo&); | 186 DrawRecord* recordDraw(const DrawInfo&); |
| 189 StencilPath* recordStencilPath(); | 187 StencilPath* recordStencilPath(); |
| 190 DrawPath* recordDrawPath(); | 188 DrawPath* recordDrawPath(); |
| 191 Clear* recordClear(); | 189 Clear* recordClear(); |
| 192 CopySurface* recordCopySurface(); | 190 CopySurface* recordCopySurface(); |
| 191 | |
| 192 // get name out of trace set | |
| 193 const char* getCurrentTraceMarker(); | |
| 193 | 194 |
| 194 // TODO: Use a single allocator for commands and records | 195 // TODO: Use a single allocator for commands and records |
| 195 enum { | 196 enum { |
| 196 kCmdPreallocCnt = 32, | 197 kCmdPreallocCnt = 32, |
| 197 kDrawPreallocCnt = 8, | 198 kDrawPreallocCnt = 8, |
| 198 kStencilPathPreallocCnt = 8, | 199 kStencilPathPreallocCnt = 8, |
| 199 kDrawPathPreallocCnt = 8, | 200 kDrawPathPreallocCnt = 8, |
| 200 kStatePreallocCnt = 8, | 201 kStatePreallocCnt = 8, |
| 201 kClipPreallocCnt = 8, | 202 kClipPreallocCnt = 8, |
| 202 kClearPreallocCnt = 4, | 203 kClearPreallocCnt = 4, |
| 203 kGeoPoolStatePreAllocCnt = 4, | 204 kGeoPoolStatePreAllocCnt = 4, |
| 204 kCopySurfacePreallocCnt = 4, | 205 kCopySurfacePreallocCnt = 4, |
| 205 }; | 206 }; |
| 206 | 207 |
| 207 SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds; | 208 SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds; |
| 208 GrSTAllocator<kDrawPreallocCnt, DrawRecord> fDraws; | 209 GrSTAllocator<kDrawPreallocCnt, DrawRecord> fDraws; |
| 209 GrSTAllocator<kStatePreallocCnt, StencilPath> fStencilP aths; | 210 GrSTAllocator<kStatePreallocCnt, StencilPath> fStencilP aths; |
| 210 GrSTAllocator<kStatePreallocCnt, DrawPath> fDrawPath s; | 211 GrSTAllocator<kStatePreallocCnt, DrawPath> fDrawPath s; |
| 211 GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates; | 212 GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates; |
| 212 GrSTAllocator<kClearPreallocCnt, Clear> fClears; | 213 GrSTAllocator<kClearPreallocCnt, Clear> fClears; |
| 213 GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurf aces; | 214 GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurf aces; |
| 214 GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips; | 215 GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips; |
| 215 GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrig ins; | 216 GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrig ins; |
| 217 SkTDArray<GpuTraceMarker> fGpuCmdMa rkers; | |
| 218 SkTDArray<int> fNumMarke rsPerCmd; | |
| 216 | 219 |
| 217 GrDrawTarget* fDstGpu; | 220 GrDrawTarget* fDstGpu; |
| 218 | 221 |
| 219 bool fClipSet; | 222 bool fClipSet; |
| 220 | 223 |
| 221 enum ClipProxyState { | 224 enum ClipProxyState { |
| 222 kUnknown_ClipProxyState, | 225 kUnknown_ClipProxyState, |
| 223 kValid_ClipProxyState, | 226 kValid_ClipProxyState, |
| 224 kInvalid_ClipProxyState | 227 kInvalid_ClipProxyState |
| 225 }; | 228 }; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 238 // caller may conservatively over reserve vertices / indices. | 241 // caller may conservatively over reserve vertices / indices. |
| 239 // we release unused space back to allocator if possible | 242 // we release unused space back to allocator if possible |
| 240 // can only do this if there isn't an intervening pushGeometrySource() | 243 // can only do this if there isn't an intervening pushGeometrySource() |
| 241 size_t fUsedPoolVertexBytes; | 244 size_t fUsedPoolVertexBytes; |
| 242 size_t fUsedPoolIndexBytes; | 245 size_t fUsedPoolIndexBytes; |
| 243 }; | 246 }; |
| 244 SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> fGeoPoolStateStack; | 247 SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> fGeoPoolStateStack; |
| 245 | 248 |
| 246 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } | 249 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } |
| 247 | 250 |
| 251 void addToCmdBuffer(uint8_t cmd); | |
| 252 | |
| 253 inline uint8_t addTraceBit(uint8_t cmd) { | |
| 254 return cmd | 0x08; | |
|
bsalomon
2014/03/17 17:50:38
Can we put these in an enum?
e.g.
enum {
kTra
egdaniel
2014/03/17 19:49:12
yes!
On 2014/03/17 17:50:38, bsalomon wrote:
| |
| 255 } | |
| 256 | |
| 257 inline uint8_t stripTraceBit(uint8_t cmd) { | |
| 258 return cmd & 0x07; | |
|
bsalomon
2014/03/17 17:50:38
7f?
egdaniel
2014/03/17 19:49:12
Currently the commands we use only go to 7 so I ju
bsalomon
2014/03/19 13:28:44
Yeah, I think it is safer to use 7f. If someone up
egdaniel
2014/03/19 14:27:03
Assert has been added in the newest version
On 20
| |
| 259 } | |
| 260 | |
| 248 bool fFlushing; | 261 bool fFlushing; |
| 249 uint32_t fDrawID; | 262 uint32_t fDrawID; |
| 250 | 263 |
| 251 typedef GrDrawTarget INHERITED; | 264 typedef GrDrawTarget INHERITED; |
| 252 }; | 265 }; |
| 253 | 266 |
| 254 #endif | 267 #endif |
| OLD | NEW |