Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: src/gpu/GrGpu.cpp

Issue 14367030: Remove GR_STATIC_RECT_VB (take 2) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrGpu.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 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 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 16 matching lines...) Expand all
27 #define DEBUG_INVAL_BUFFER 0xdeadcafe 27 #define DEBUG_INVAL_BUFFER 0xdeadcafe
28 #define DEBUG_INVAL_START_IDX -1 28 #define DEBUG_INVAL_START_IDX -1
29 29
30 GrGpu::GrGpu(GrContext* context) 30 GrGpu::GrGpu(GrContext* context)
31 : GrDrawTarget(context) 31 : GrDrawTarget(context)
32 , fResetTimestamp(kExpiredTimestamp+1) 32 , fResetTimestamp(kExpiredTimestamp+1)
33 , fVertexPool(NULL) 33 , fVertexPool(NULL)
34 , fIndexPool(NULL) 34 , fIndexPool(NULL)
35 , fVertexPoolUseCnt(0) 35 , fVertexPoolUseCnt(0)
36 , fIndexPoolUseCnt(0) 36 , fIndexPoolUseCnt(0)
37 , fUnitSquareVertexBuffer(NULL)
38 , fQuadIndexBuffer(NULL) 37 , fQuadIndexBuffer(NULL)
39 , fContextIsDirty(true) { 38 , fContextIsDirty(true) {
40 39
41 fClipMaskManager.setGpu(this); 40 fClipMaskManager.setGpu(this);
42 41
43 fGeomPoolStateStack.push_back(); 42 fGeomPoolStateStack.push_back();
44 #if GR_DEBUG 43 #if GR_DEBUG
45 GeometryPoolState& poolState = fGeomPoolStateStack.back(); 44 GeometryPoolState& poolState = fGeomPoolStateStack.back();
46 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; 45 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER;
47 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX; 46 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX;
(...skipping 12 matching lines...) Expand all
60 59
61 void GrGpu::abandonResources() { 60 void GrGpu::abandonResources() {
62 61
63 fClipMaskManager.releaseResources(); 62 fClipMaskManager.releaseResources();
64 63
65 while (NULL != fResourceList.head()) { 64 while (NULL != fResourceList.head()) {
66 fResourceList.head()->abandon(); 65 fResourceList.head()->abandon();
67 } 66 }
68 67
69 GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid()); 68 GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
70 GrAssert(NULL == fUnitSquareVertexBuffer ||
71 !fUnitSquareVertexBuffer->isValid());
72 GrSafeSetNull(fQuadIndexBuffer); 69 GrSafeSetNull(fQuadIndexBuffer);
73 GrSafeSetNull(fUnitSquareVertexBuffer);
74 delete fVertexPool; 70 delete fVertexPool;
75 fVertexPool = NULL; 71 fVertexPool = NULL;
76 delete fIndexPool; 72 delete fIndexPool;
77 fIndexPool = NULL; 73 fIndexPool = NULL;
78 } 74 }
79 75
80 void GrGpu::releaseResources() { 76 void GrGpu::releaseResources() {
81 77
82 fClipMaskManager.releaseResources(); 78 fClipMaskManager.releaseResources();
83 79
84 while (NULL != fResourceList.head()) { 80 while (NULL != fResourceList.head()) {
85 fResourceList.head()->release(); 81 fResourceList.head()->release();
86 } 82 }
87 83
88 GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid()); 84 GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
89 GrAssert(NULL == fUnitSquareVertexBuffer ||
90 !fUnitSquareVertexBuffer->isValid());
91 GrSafeSetNull(fQuadIndexBuffer); 85 GrSafeSetNull(fQuadIndexBuffer);
92 GrSafeSetNull(fUnitSquareVertexBuffer);
93 delete fVertexPool; 86 delete fVertexPool;
94 fVertexPool = NULL; 87 fVertexPool = NULL;
95 delete fIndexPool; 88 delete fIndexPool;
96 fIndexPool = NULL; 89 fIndexPool = NULL;
97 } 90 }
98 91
99 void GrGpu::insertResource(GrResource* resource) { 92 void GrGpu::insertResource(GrResource* resource) {
100 GrAssert(NULL != resource); 93 GrAssert(NULL != resource);
101 GrAssert(this == resource->getGpu()); 94 GrAssert(this == resource->getGpu());
102 95
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 GrCrash("Can't get indices into buffer!"); 283 GrCrash("Can't get indices into buffer!");
291 } 284 }
292 GrFree(indices); 285 GrFree(indices);
293 } 286 }
294 } 287 }
295 } 288 }
296 289
297 return fQuadIndexBuffer; 290 return fQuadIndexBuffer;
298 } 291 }
299 292
300 const GrVertexBuffer* GrGpu::getUnitSquareVertexBuffer() const {
301 if (NULL == fUnitSquareVertexBuffer) {
302
303 static const GrPoint DATA[] = {
304 { 0, 0 },
305 { SK_Scalar1, 0 },
306 { SK_Scalar1, SK_Scalar1 },
307 { 0, SK_Scalar1 }
308 #if 0
309 GrPoint(0, 0),
310 GrPoint(SK_Scalar1,0),
311 GrPoint(SK_Scalar1,SK_Scalar1),
312 GrPoint(0, SK_Scalar1)
313 #endif
314 };
315 static const size_t SIZE = sizeof(DATA);
316
317 GrGpu* me = const_cast<GrGpu*>(this);
318 fUnitSquareVertexBuffer = me->createVertexBuffer(SIZE, false);
319 if (NULL != fUnitSquareVertexBuffer) {
320 if (!fUnitSquareVertexBuffer->updateData(DATA, SIZE)) {
321 fUnitSquareVertexBuffer->unref();
322 fUnitSquareVertexBuffer = NULL;
323 GrCrash("Can't get vertices into buffer!");
324 }
325 }
326 }
327
328 return fUnitSquareVertexBuffer;
329 }
330
331 //////////////////////////////////////////////////////////////////////////////// 293 ////////////////////////////////////////////////////////////////////////////////
332 294
333 bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* ds tCopy) { 295 bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* ds tCopy) {
334 296
335 if (!fClipMaskManager.setupClipping(this->getClip())) { 297 if (!fClipMaskManager.setupClipping(this->getClip())) {
336 return false; 298 return false;
337 } 299 }
338 300
339 if (!this->flushGraphicsState(type, dstCopy)) { 301 if (!this->flushGraphicsState(type, dstCopy)) {
340 return false; 302 return false;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 487 }
526 488
527 void GrGpu::releaseIndexArray() { 489 void GrGpu::releaseIndexArray() {
528 // if index source was array, we stowed data in the pool 490 // if index source was array, we stowed data in the pool
529 const GeometrySrcState& geoSrc = this->getGeomSrc(); 491 const GeometrySrcState& geoSrc = this->getGeomSrc();
530 GrAssert(kArray_GeometrySrcType == geoSrc.fIndexSrc); 492 GrAssert(kArray_GeometrySrcType == geoSrc.fIndexSrc);
531 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); 493 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t);
532 fIndexPool->putBack(bytes); 494 fIndexPool->putBack(bytes);
533 --fIndexPoolUseCnt; 495 --fIndexPoolUseCnt;
534 } 496 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698