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

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

Issue 716143004: Replace GrResourceCache with GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix asserts Created 6 years, 1 month 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/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrContext.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 "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 size_t flushSize = block.fBuffer->gpuMemorySize() - block.fBytesFree ; 124 size_t flushSize = block.fBuffer->gpuMemorySize() - block.fBytesFree ;
125 this->flushCpuData(fBlocks.back(), flushSize); 125 this->flushCpuData(fBlocks.back(), flushSize);
126 } 126 }
127 fBufferPtr = NULL; 127 fBufferPtr = NULL;
128 } 128 }
129 VALIDATE(); 129 VALIDATE();
130 } 130 }
131 131
132 #ifdef SK_DEBUG 132 #ifdef SK_DEBUG
133 void GrBufferAllocPool::validate(bool unusedBlockAllowed) const { 133 void GrBufferAllocPool::validate(bool unusedBlockAllowed) const {
134 bool wasDestroyed = false;
134 if (fBufferPtr) { 135 if (fBufferPtr) {
135 SkASSERT(!fBlocks.empty()); 136 SkASSERT(!fBlocks.empty());
136 if (fBlocks.back().fBuffer->isMapped()) { 137 if (fBlocks.back().fBuffer->isMapped()) {
137 GrGeometryBuffer* buf = fBlocks.back().fBuffer; 138 GrGeometryBuffer* buf = fBlocks.back().fBuffer;
138 SkASSERT(buf->mapPtr() == fBufferPtr); 139 SkASSERT(buf->mapPtr() == fBufferPtr);
139 } else { 140 } else {
140 SkASSERT(fCpuData.get() == fBufferPtr); 141 SkASSERT(fCpuData.get() == fBufferPtr);
141 } 142 }
142 } else { 143 } else {
143 SkASSERT(fBlocks.empty() || !fBlocks.back().fBuffer->isMapped()); 144 SkASSERT(fBlocks.empty() || !fBlocks.back().fBuffer->isMapped());
144 } 145 }
145 size_t bytesInUse = 0; 146 size_t bytesInUse = 0;
146 for (int i = 0; i < fBlocks.count() - 1; ++i) { 147 for (int i = 0; i < fBlocks.count() - 1; ++i) {
147 SkASSERT(!fBlocks[i].fBuffer->isMapped()); 148 SkASSERT(!fBlocks[i].fBuffer->isMapped());
148 } 149 }
149 for (int i = 0; i < fBlocks.count(); ++i) { 150 for (int i = 0; !wasDestroyed && i < fBlocks.count(); ++i) {
150 size_t bytes = fBlocks[i].fBuffer->gpuMemorySize() - fBlocks[i].fBytesFr ee; 151 if (fBlocks[i].fBuffer->wasDestroyed()) {
151 bytesInUse += bytes; 152 wasDestroyed = true;
152 SkASSERT(bytes || unusedBlockAllowed); 153 } else {
154 size_t bytes = fBlocks[i].fBuffer->gpuMemorySize() - fBlocks[i].fByt esFree;
155 bytesInUse += bytes;
156 SkASSERT(bytes || unusedBlockAllowed);
157 }
153 } 158 }
154 159
155 SkASSERT(bytesInUse == fBytesInUse); 160 if (!wasDestroyed) {
156 if (unusedBlockAllowed) { 161 SkASSERT(bytesInUse == fBytesInUse);
157 SkASSERT((fBytesInUse && !fBlocks.empty()) || 162 if (unusedBlockAllowed) {
158 (!fBytesInUse && (fBlocks.count() < 2))); 163 SkASSERT((fBytesInUse && !fBlocks.empty()) ||
159 } else { 164 (!fBytesInUse && (fBlocks.count() < 2)));
160 SkASSERT((0 == fBytesInUse) == fBlocks.empty()); 165 } else {
166 SkASSERT((0 == fBytesInUse) == fBlocks.empty());
167 }
161 } 168 }
162 } 169 }
163 #endif 170 #endif
164 171
165 void* GrBufferAllocPool::makeSpace(size_t size, 172 void* GrBufferAllocPool::makeSpace(size_t size,
166 size_t alignment, 173 size_t alignment,
167 const GrGeometryBuffer** buffer, 174 const GrGeometryBuffer** buffer,
168 size_t* offset) { 175 size_t* offset) {
169 VALIDATE(); 176 VALIDATE();
170 177
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return ptr; 468 return ptr;
462 } 469 }
463 470
464 int GrIndexBufferAllocPool::preallocatedBufferIndices() const { 471 int GrIndexBufferAllocPool::preallocatedBufferIndices() const {
465 return static_cast<int>(INHERITED::preallocatedBufferSize() / sizeof(uint16_ t)); 472 return static_cast<int>(INHERITED::preallocatedBufferSize() / sizeof(uint16_ t));
466 } 473 }
467 474
468 int GrIndexBufferAllocPool::currentBufferIndices() const { 475 int GrIndexBufferAllocPool::currentBufferIndices() const {
469 return currentBufferItems(sizeof(uint16_t)); 476 return currentBufferItems(sizeof(uint16_t));
470 } 477 }
OLDNEW
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698