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