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

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

Issue 477323006: Revert of Add GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrGpuResource.cpp » ('j') | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 fGeomPoolStateStack.push_back(); 42 fGeomPoolStateStack.push_back();
43 #ifdef SK_DEBUG 43 #ifdef SK_DEBUG
44 GeometryPoolState& poolState = fGeomPoolStateStack.back(); 44 GeometryPoolState& poolState = fGeomPoolStateStack.back();
45 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; 45 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER;
46 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX; 46 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX;
47 poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; 47 poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
48 poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX; 48 poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX;
49 #endif 49 #endif
50 } 50 }
51 51
52 GrGpu::~GrGpu() {} 52 GrGpu::~GrGpu() {
53 this->releaseResources();
54 }
53 55
54 void GrGpu::contextAbandonded() {} 56 void GrGpu::abandonResources() {
57
58 fClipMaskManager.releaseResources();
59
60 while (NULL != fObjectList.head()) {
61 fObjectList.head()->abandon();
62 }
63
64 SkASSERT(NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed());
65 SkSafeSetNull(fQuadIndexBuffer);
66 delete fVertexPool;
67 fVertexPool = NULL;
68 delete fIndexPool;
69 fIndexPool = NULL;
70 }
71
72 void GrGpu::releaseResources() {
73
74 fClipMaskManager.releaseResources();
75
76 while (NULL != fObjectList.head()) {
77 fObjectList.head()->release();
78 }
79
80 SkASSERT(NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed());
81 SkSafeSetNull(fQuadIndexBuffer);
82 delete fVertexPool;
83 fVertexPool = NULL;
84 delete fIndexPool;
85 fIndexPool = NULL;
86 }
87
88 void GrGpu::insertObject(GrGpuResource* object) {
89 SkASSERT(NULL != object);
90 SkASSERT(this == object->getGpu());
91
92 fObjectList.addToHead(object);
93 }
94
95 void GrGpu::removeObject(GrGpuResource* object) {
96 SkASSERT(NULL != object);
97 SkASSERT(this == object->getGpu());
98
99 fObjectList.remove(object);
100 }
101
102
103 void GrGpu::unimpl(const char msg[]) {
104 #ifdef SK_DEBUG
105 GrPrintf("--- GrGpu unimplemented(\"%s\")\n", msg);
106 #endif
107 }
55 108
56 //////////////////////////////////////////////////////////////////////////////// 109 ////////////////////////////////////////////////////////////////////////////////
57 110
58 GrTexture* GrGpu::createTexture(const GrTextureDesc& desc, 111 GrTexture* GrGpu::createTexture(const GrTextureDesc& desc,
59 const void* srcData, size_t rowBytes) { 112 const void* srcData, size_t rowBytes) {
60 if (!this->caps()->isConfigTexturable(desc.fConfig)) { 113 if (!this->caps()->isConfigTexturable(desc.fConfig)) {
61 return NULL; 114 return NULL;
62 } 115 }
63 116
64 if ((desc.fFlags & kRenderTarget_GrTextureFlagBit) && 117 if ((desc.fFlags & kRenderTarget_GrTextureFlagBit) &&
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 indices[6 * i + 0] = 4 * i + 0; 312 indices[6 * i + 0] = 4 * i + 0;
260 indices[6 * i + 1] = 4 * i + 1; 313 indices[6 * i + 1] = 4 * i + 1;
261 indices[6 * i + 2] = 4 * i + 2; 314 indices[6 * i + 2] = 4 * i + 2;
262 indices[6 * i + 3] = 4 * i + 0; 315 indices[6 * i + 3] = 4 * i + 0;
263 indices[6 * i + 4] = 4 * i + 2; 316 indices[6 * i + 4] = 4 * i + 2;
264 indices[6 * i + 5] = 4 * i + 3; 317 indices[6 * i + 5] = 4 * i + 3;
265 } 318 }
266 } 319 }
267 320
268 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { 321 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
269 if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) { 322 if (NULL == fQuadIndexBuffer) {
270 SkSafeUnref(fQuadIndexBuffer);
271 static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS; 323 static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS;
272 GrGpu* me = const_cast<GrGpu*>(this); 324 GrGpu* me = const_cast<GrGpu*>(this);
273 fQuadIndexBuffer = me->createIndexBuffer(SIZE, false); 325 fQuadIndexBuffer = me->createIndexBuffer(SIZE, false);
274 if (NULL != fQuadIndexBuffer) { 326 if (NULL != fQuadIndexBuffer) {
275 uint16_t* indices = (uint16_t*)fQuadIndexBuffer->map(); 327 uint16_t* indices = (uint16_t*)fQuadIndexBuffer->map();
276 if (NULL != indices) { 328 if (NULL != indices) {
277 fill_indices(indices, MAX_QUADS); 329 fill_indices(indices, MAX_QUADS);
278 fQuadIndexBuffer->unmap(); 330 fQuadIndexBuffer->unmap();
279 } else { 331 } else {
280 indices = (uint16_t*)sk_malloc_throw(SIZE); 332 indices = (uint16_t*)sk_malloc_throw(SIZE);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 } 571 }
520 572
521 void GrGpu::releaseIndexArray() { 573 void GrGpu::releaseIndexArray() {
522 // if index source was array, we stowed data in the pool 574 // if index source was array, we stowed data in the pool
523 const GeometrySrcState& geoSrc = this->getGeomSrc(); 575 const GeometrySrcState& geoSrc = this->getGeomSrc();
524 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); 576 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc);
525 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); 577 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t);
526 fIndexPool->putBack(bytes); 578 fIndexPool->putBack(bytes);
527 --fIndexPoolUseCnt; 579 --fIndexPoolUseCnt;
528 } 580 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrGpuResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698