| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 kDrawPaths_Cmd = 8, |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 class DrawRecord : public DrawInfo { | 94 class DrawRecord : public DrawInfo { |
| 94 public: | 95 public: |
| 95 DrawRecord(const DrawInfo& info) : DrawInfo(info) {} | 96 DrawRecord(const DrawInfo& info) : DrawInfo(info) {} |
| 96 const GrVertexBuffer* fVertexBuffer; | 97 const GrVertexBuffer* fVertexBuffer; |
| 97 const GrIndexBuffer* fIndexBuffer; | 98 const GrIndexBuffer* fIndexBuffer; |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 struct StencilPath : public ::SkNoncopyable { | 101 struct StencilPath : public ::SkNoncopyable { |
| 101 StencilPath(); | 102 StencilPath(); |
| 102 | 103 |
| 103 SkAutoTUnref<const GrPath> fPath; | 104 SkAutoTUnref<const GrPath> fPath; |
| 104 SkPath::FillType fFill; | 105 SkPath::FillType fFill; |
| 105 }; | 106 }; |
| 106 | 107 |
| 107 struct DrawPath : public ::SkNoncopyable { | 108 struct DrawPath : public ::SkNoncopyable { |
| 108 DrawPath(); | 109 DrawPath(); |
| 109 | 110 |
| 110 SkAutoTUnref<const GrPath> fPath; | 111 SkAutoTUnref<const GrPath> fPath; |
| 111 SkPath::FillType fFill; | 112 SkPath::FillType fFill; |
| 112 GrDeviceCoordTexture fDstCopy; | 113 GrDeviceCoordTexture fDstCopy; |
| 113 }; | 114 }; |
| 114 | 115 |
| 116 struct DrawPaths : public ::SkNoncopyable { |
| 117 DrawPaths(); |
| 118 ~DrawPaths(); |
| 119 |
| 120 size_t fPathCount; |
| 121 const GrPath** fPaths; |
| 122 SkMatrix* fTransforms; |
| 123 SkPath::FillType fFill; |
| 124 SkStrokeRec::Style fStroke; |
| 125 GrDeviceCoordTexture fDstCopy; |
| 126 }; |
| 127 |
| 115 struct Clear : public ::SkNoncopyable { | 128 struct Clear : public ::SkNoncopyable { |
| 116 Clear() : fRenderTarget(NULL) {} | 129 Clear() : fRenderTarget(NULL) {} |
| 117 ~Clear() { SkSafeUnref(fRenderTarget); } | 130 ~Clear() { SkSafeUnref(fRenderTarget); } |
| 118 | 131 |
| 119 SkIRect fRect; | 132 SkIRect fRect; |
| 120 GrColor fColor; | 133 GrColor fColor; |
| 121 bool fCanIgnoreRect; | 134 bool fCanIgnoreRect; |
| 122 GrRenderTarget* fRenderTarget; | 135 GrRenderTarget* fRenderTarget; |
| 123 }; | 136 }; |
| 124 | 137 |
| 125 struct CopySurface : public ::SkNoncopyable { | 138 struct CopySurface : public ::SkNoncopyable { |
| 126 SkAutoTUnref<GrSurface> fDst; | 139 SkAutoTUnref<GrSurface> fDst; |
| 127 SkAutoTUnref<GrSurface> fSrc; | 140 SkAutoTUnref<GrSurface> fSrc; |
| 128 SkIRect fSrcRect; | 141 SkIRect fSrcRect; |
| 129 SkIPoint fDstPoint; | 142 SkIPoint fDstPoint; |
| 130 }; | 143 }; |
| 131 | 144 |
| 132 // overrides from GrDrawTarget | 145 // overrides from GrDrawTarget |
| 133 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; | 146 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; |
| 134 virtual void onDrawRect(const SkRect& rect, | 147 virtual void onDrawRect(const SkRect& rect, |
| 135 const SkMatrix* matrix, | 148 const SkMatrix* matrix, |
| 136 const SkRect* localRect, | 149 const SkRect* localRect, |
| 137 const SkMatrix* localMatrix) SK_OVERRIDE; | 150 const SkMatrix* localMatrix) SK_OVERRIDE; |
| 138 | 151 |
| 139 virtual void onStencilPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; | 152 virtual void onStencilPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; |
| 140 virtual void onDrawPath(const GrPath*, SkPath::FillType, | 153 virtual void onDrawPath(const GrPath*, SkPath::FillType, |
| 141 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; | 154 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
| 155 virtual void onDrawPaths(size_t, const GrPath**, const SkMatrix*, |
| 156 SkPath::FillType, SkStrokeRec::Style, |
| 157 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
| 142 | 158 |
| 143 virtual bool onReserveVertexSpace(size_t vertexSize, | 159 virtual bool onReserveVertexSpace(size_t vertexSize, |
| 144 int vertexCount, | 160 int vertexCount, |
| 145 void** vertices) SK_OVERRIDE; | 161 void** vertices) SK_OVERRIDE; |
| 146 virtual bool onReserveIndexSpace(int indexCount, | 162 virtual bool onReserveIndexSpace(int indexCount, |
| 147 void** indices) SK_OVERRIDE; | 163 void** indices) SK_OVERRIDE; |
| 148 virtual void releaseReservedVertexSpace() SK_OVERRIDE; | 164 virtual void releaseReservedVertexSpace() SK_OVERRIDE; |
| 149 virtual void releaseReservedIndexSpace() SK_OVERRIDE; | 165 virtual void releaseReservedIndexSpace() SK_OVERRIDE; |
| 150 virtual void onSetVertexSourceToArray(const void* vertexArray, | 166 virtual void onSetVertexSourceToArray(const void* vertexArray, |
| 151 int vertexCount) SK_OVERRIDE; | 167 int vertexCount) SK_OVERRIDE; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 181 // effect. | 197 // effect. |
| 182 bool needsNewState() const; | 198 bool needsNewState() const; |
| 183 bool needsNewClip() const; | 199 bool needsNewClip() const; |
| 184 | 200 |
| 185 // these functions record a command | 201 // these functions record a command |
| 186 void recordState(); | 202 void recordState(); |
| 187 void recordClip(); | 203 void recordClip(); |
| 188 DrawRecord* recordDraw(const DrawInfo&); | 204 DrawRecord* recordDraw(const DrawInfo&); |
| 189 StencilPath* recordStencilPath(); | 205 StencilPath* recordStencilPath(); |
| 190 DrawPath* recordDrawPath(); | 206 DrawPath* recordDrawPath(); |
| 207 DrawPaths* recordDrawPaths(); |
| 191 Clear* recordClear(); | 208 Clear* recordClear(); |
| 192 CopySurface* recordCopySurface(); | 209 CopySurface* recordCopySurface(); |
| 193 | 210 |
| 194 // TODO: Use a single allocator for commands and records | 211 // TODO: Use a single allocator for commands and records |
| 195 enum { | 212 enum { |
| 196 kCmdPreallocCnt = 32, | 213 kCmdPreallocCnt = 32, |
| 197 kDrawPreallocCnt = 8, | 214 kDrawPreallocCnt = 8, |
| 198 kStencilPathPreallocCnt = 8, | 215 kStencilPathPreallocCnt = 8, |
| 199 kDrawPathPreallocCnt = 8, | 216 kDrawPathPreallocCnt = 8, |
| 217 kDrawPathsPreallocCnt = 8, |
| 200 kStatePreallocCnt = 8, | 218 kStatePreallocCnt = 8, |
| 201 kClipPreallocCnt = 8, | 219 kClipPreallocCnt = 8, |
| 202 kClearPreallocCnt = 4, | 220 kClearPreallocCnt = 4, |
| 203 kGeoPoolStatePreAllocCnt = 4, | 221 kGeoPoolStatePreAllocCnt = 4, |
| 204 kCopySurfacePreallocCnt = 4, | 222 kCopySurfacePreallocCnt = 4, |
| 205 }; | 223 }; |
| 206 | 224 |
| 207 SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds; | 225 SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds; |
| 208 GrSTAllocator<kDrawPreallocCnt, DrawRecord> fDraws; | 226 GrSTAllocator<kDrawPreallocCnt, DrawRecord> fDraws; |
| 209 GrSTAllocator<kStatePreallocCnt, StencilPath> fStencilP
aths; | 227 GrSTAllocator<kStencilPathPreallocCnt, StencilPath> fStencilP
aths; |
| 210 GrSTAllocator<kStatePreallocCnt, DrawPath> fDrawPath
s; | 228 GrSTAllocator<kDrawPathPreallocCnt, DrawPath> fDrawPath
; |
| 229 GrSTAllocator<kDrawPathsPreallocCnt, DrawPaths> fDrawPath
s; |
| 211 GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates; | 230 GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates; |
| 212 GrSTAllocator<kClearPreallocCnt, Clear> fClears; | 231 GrSTAllocator<kClearPreallocCnt, Clear> fClears; |
| 213 GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurf
aces; | 232 GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurf
aces; |
| 214 GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips; | 233 GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips; |
| 215 GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrig
ins; | 234 GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrig
ins; |
| 216 | 235 |
| 217 GrDrawTarget* fDstGpu; | 236 GrDrawTarget* fDstGpu; |
| 218 | 237 |
| 219 bool fClipSet; | 238 bool fClipSet; |
| 220 | 239 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 245 | 264 |
| 246 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } | 265 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } |
| 247 | 266 |
| 248 bool fFlushing; | 267 bool fFlushing; |
| 249 uint32_t fDrawID; | 268 uint32_t fDrawID; |
| 250 | 269 |
| 251 typedef GrDrawTarget INHERITED; | 270 typedef GrDrawTarget INHERITED; |
| 252 }; | 271 }; |
| 253 | 272 |
| 254 #endif | 273 #endif |
| OLD | NEW |