| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 kFillPath_Cmd = 7, |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 class DrawRecord : public DrawInfo { | 93 class DrawRecord : public DrawInfo { |
| 93 public: | 94 public: |
| 94 DrawRecord(const DrawInfo& info) : DrawInfo(info) {} | 95 DrawRecord(const DrawInfo& info) : DrawInfo(info) {} |
| 95 const GrVertexBuffer* fVertexBuffer; | 96 const GrVertexBuffer* fVertexBuffer; |
| 96 const GrIndexBuffer* fIndexBuffer; | 97 const GrIndexBuffer* fIndexBuffer; |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 struct StencilPath : public ::SkNoncopyable { | 100 struct StencilPath : public ::SkNoncopyable { |
| 100 StencilPath(); | 101 StencilPath(); |
| 101 | 102 |
| 102 SkAutoTUnref<const GrPath> fPath; | 103 SkAutoTUnref<const GrPath> fPath; |
| 103 SkStrokeRec fStroke; | 104 SkStrokeRec fStroke; |
| 104 SkPath::FillType fFill; | 105 SkPath::FillType fFill; |
| 105 }; | 106 }; |
| 106 | 107 |
| 108 struct FillPath : public ::SkNoncopyable { |
| 109 FillPath(); |
| 110 |
| 111 SkAutoTUnref<const GrPath> fPath; |
| 112 SkStrokeRec fStroke; |
| 113 SkPath::FillType fFill; |
| 114 }; |
| 115 |
| 107 struct Clear : public ::SkNoncopyable { | 116 struct Clear : public ::SkNoncopyable { |
| 108 Clear() : fRenderTarget(NULL) {} | 117 Clear() : fRenderTarget(NULL) {} |
| 109 ~Clear() { SkSafeUnref(fRenderTarget); } | 118 ~Clear() { SkSafeUnref(fRenderTarget); } |
| 110 | 119 |
| 111 SkIRect fRect; | 120 SkIRect fRect; |
| 112 GrColor fColor; | 121 GrColor fColor; |
| 113 GrRenderTarget* fRenderTarget; | 122 GrRenderTarget* fRenderTarget; |
| 114 }; | 123 }; |
| 115 | 124 |
| 116 struct CopySurface : public ::SkNoncopyable { | 125 struct CopySurface : public ::SkNoncopyable { |
| 117 SkAutoTUnref<GrSurface> fDst; | 126 SkAutoTUnref<GrSurface> fDst; |
| 118 SkAutoTUnref<GrSurface> fSrc; | 127 SkAutoTUnref<GrSurface> fSrc; |
| 119 SkIRect fSrcRect; | 128 SkIRect fSrcRect; |
| 120 SkIPoint fDstPoint; | 129 SkIPoint fDstPoint; |
| 121 }; | 130 }; |
| 122 | 131 |
| 123 // overrides from GrDrawTarget | 132 // overrides from GrDrawTarget |
| 124 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; | 133 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; |
| 125 virtual void onDrawRect(const SkRect& rect, | 134 virtual void onDrawRect(const SkRect& rect, |
| 126 const SkMatrix* matrix, | 135 const SkMatrix* matrix, |
| 127 const SkRect* localRect, | 136 const SkRect* localRect, |
| 128 const SkMatrix* localMatrix) SK_OVERRIDE; | 137 const SkMatrix* localMatrix) SK_OVERRIDE; |
| 129 virtual void onStencilPath(const GrPath*, const SkStrokeRec& stroke, SkPath:
:FillType) SK_OVERRIDE; | 138 virtual void onStencilPath(const GrPath*, const SkStrokeRec& stroke, SkPath:
:FillType) SK_OVERRIDE; |
| 139 virtual void onFillPath(const GrPath*, const SkStrokeRec& stroke, SkPath::Fi
llType, |
| 140 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
| 130 virtual bool onReserveVertexSpace(size_t vertexSize, | 141 virtual bool onReserveVertexSpace(size_t vertexSize, |
| 131 int vertexCount, | 142 int vertexCount, |
| 132 void** vertices) SK_OVERRIDE; | 143 void** vertices) SK_OVERRIDE; |
| 133 virtual bool onReserveIndexSpace(int indexCount, | 144 virtual bool onReserveIndexSpace(int indexCount, |
| 134 void** indices) SK_OVERRIDE; | 145 void** indices) SK_OVERRIDE; |
| 135 virtual void releaseReservedVertexSpace() SK_OVERRIDE; | 146 virtual void releaseReservedVertexSpace() SK_OVERRIDE; |
| 136 virtual void releaseReservedIndexSpace() SK_OVERRIDE; | 147 virtual void releaseReservedIndexSpace() SK_OVERRIDE; |
| 137 virtual void onSetVertexSourceToArray(const void* vertexArray, | 148 virtual void onSetVertexSourceToArray(const void* vertexArray, |
| 138 int vertexCount) SK_OVERRIDE; | 149 int vertexCount) SK_OVERRIDE; |
| 139 virtual void onSetIndexSourceToArray(const void* indexArray, | 150 virtual void onSetIndexSourceToArray(const void* indexArray, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 162 // 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 |
| 163 // effect. | 174 // effect. |
| 164 bool needsNewState() const; | 175 bool needsNewState() const; |
| 165 bool needsNewClip() const; | 176 bool needsNewClip() const; |
| 166 | 177 |
| 167 // these functions record a command | 178 // these functions record a command |
| 168 void recordState(); | 179 void recordState(); |
| 169 void recordClip(); | 180 void recordClip(); |
| 170 DrawRecord* recordDraw(const DrawInfo&); | 181 DrawRecord* recordDraw(const DrawInfo&); |
| 171 StencilPath* recordStencilPath(); | 182 StencilPath* recordStencilPath(); |
| 183 FillPath* recordFillPath(); |
| 172 Clear* recordClear(); | 184 Clear* recordClear(); |
| 173 CopySurface* recordCopySurface(); | 185 CopySurface* recordCopySurface(); |
| 174 | 186 |
| 175 // TODO: Use a single allocator for commands and records | 187 // TODO: Use a single allocator for commands and records |
| 176 enum { | 188 enum { |
| 177 kCmdPreallocCnt = 32, | 189 kCmdPreallocCnt = 32, |
| 178 kDrawPreallocCnt = 8, | 190 kDrawPreallocCnt = 8, |
| 179 kStencilPathPreallocCnt = 8, | 191 kStencilPathPreallocCnt = 8, |
| 192 kFillPathPreallocCnt = 8, |
| 180 kStatePreallocCnt = 8, | 193 kStatePreallocCnt = 8, |
| 181 kClipPreallocCnt = 8, | 194 kClipPreallocCnt = 8, |
| 182 kClearPreallocCnt = 4, | 195 kClearPreallocCnt = 4, |
| 183 kGeoPoolStatePreAllocCnt = 4, | 196 kGeoPoolStatePreAllocCnt = 4, |
| 184 kCopySurfacePreallocCnt = 4, | 197 kCopySurfacePreallocCnt = 4, |
| 185 }; | 198 }; |
| 186 | 199 |
| 187 SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds; | 200 SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds; |
| 188 GrSTAllocator<kDrawPreallocCnt, DrawRecord> fDraws; | 201 GrSTAllocator<kDrawPreallocCnt, DrawRecord> fDraws; |
| 189 GrSTAllocator<kStatePreallocCnt, StencilPath> fStencilP
aths; | 202 GrSTAllocator<kStatePreallocCnt, StencilPath> fStencilP
aths; |
| 203 GrSTAllocator<kStatePreallocCnt, FillPath> fFillPath
s; |
| 190 GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates; | 204 GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates; |
| 191 GrSTAllocator<kClearPreallocCnt, Clear> fClears; | 205 GrSTAllocator<kClearPreallocCnt, Clear> fClears; |
| 192 GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurf
aces; | 206 GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurf
aces; |
| 193 GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips; | 207 GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips; |
| 194 GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrig
ins; | 208 GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrig
ins; |
| 195 | 209 |
| 196 GrDrawTarget* fDstGpu; | 210 GrDrawTarget* fDstGpu; |
| 197 | 211 |
| 198 bool fClipSet; | 212 bool fClipSet; |
| 199 | 213 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 224 | 238 |
| 225 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } | 239 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } |
| 226 | 240 |
| 227 bool fFlushing; | 241 bool fFlushing; |
| 228 uint32_t fDrawID; | 242 uint32_t fDrawID; |
| 229 | 243 |
| 230 typedef GrDrawTarget INHERITED; | 244 typedef GrDrawTarget INHERITED; |
| 231 }; | 245 }; |
| 232 | 246 |
| 233 #endif | 247 #endif |
| OLD | NEW |