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