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

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

Issue 705593002: Refactor DrawTarget and GPU to be independent (Closed) Base URL: https://skia.googlesource.com/skia.git@early_clip
Patch Set: rebase on master 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/GrGpu.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('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 10 matching lines...) Expand all
21 static const int VERTEX_POOL_VB_COUNT = 4; 21 static const int VERTEX_POOL_VB_COUNT = 4;
22 static const size_t INDEX_POOL_IB_SIZE = 1 << 16; 22 static const size_t INDEX_POOL_IB_SIZE = 1 << 16;
23 static const int INDEX_POOL_IB_COUNT = 4; 23 static const int INDEX_POOL_IB_COUNT = 4;
24 24
25 //////////////////////////////////////////////////////////////////////////////// 25 ////////////////////////////////////////////////////////////////////////////////
26 26
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 : INHERITED(context) 31 : fResetTimestamp(kExpiredTimestamp+1)
32 , fResetTimestamp(kExpiredTimestamp+1)
33 , fResetBits(kAll_GrBackendState) 32 , fResetBits(kAll_GrBackendState)
34 , fVertexPool(NULL) 33 , fVertexPool(NULL)
35 , fIndexPool(NULL) 34 , fIndexPool(NULL)
36 , fVertexPoolUseCnt(0) 35 , fVertexPoolUseCnt(0)
37 , fIndexPoolUseCnt(0) 36 , fIndexPoolUseCnt(0)
38 , fQuadIndexBuffer(NULL) { 37 , fQuadIndexBuffer(NULL)
38 , fContext(context) {
39 fGeomPoolStateStack.push_back(); 39 fGeomPoolStateStack.push_back();
40 fDrawState = &fDefaultDrawState;
41 // We assume that fDrawState always owns a ref to the object it points at.
42 fDefaultDrawState.ref();
40 #ifdef SK_DEBUG 43 #ifdef SK_DEBUG
41 GeometryPoolState& poolState = fGeomPoolStateStack.back(); 44 GeometryPoolState& poolState = fGeomPoolStateStack.back();
42 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; 45 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER;
43 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX; 46 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX;
44 poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; 47 poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
45 poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX; 48 poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX;
46 #endif 49 #endif
50
51 GrDrawTarget::GeometrySrcState& geoSrc = fGeoSrcStateStack.push_back();
52 #ifdef SK_DEBUG
53 geoSrc.fVertexCount = DEBUG_INVAL_START_IDX;
54 geoSrc.fVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER;
55 geoSrc.fIndexCount = DEBUG_INVAL_START_IDX;
56 geoSrc.fIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
57 #endif
58 geoSrc.fVertexSrc = GrDrawTarget::kNone_GeometrySrcType;
59 geoSrc.fIndexSrc = GrDrawTarget::kNone_GeometrySrcType;
47 } 60 }
48 61
49 GrGpu::~GrGpu() { 62 GrGpu::~GrGpu() {
50 SkSafeSetNull(fQuadIndexBuffer); 63 SkSafeSetNull(fQuadIndexBuffer);
51 delete fVertexPool; 64 delete fVertexPool;
52 fVertexPool = NULL; 65 fVertexPool = NULL;
53 delete fIndexPool; 66 delete fIndexPool;
54 fIndexPool = NULL; 67 fIndexPool = NULL;
68 SkASSERT(1 == fGeoSrcStateStack.count());
69 SkDEBUGCODE(GrDrawTarget::GeometrySrcState& geoSrc = fGeoSrcStateStack.back( ));
70 SkASSERT(GrDrawTarget::kNone_GeometrySrcType == geoSrc.fIndexSrc);
71 SkASSERT(GrDrawTarget::kNone_GeometrySrcType == geoSrc.fVertexSrc);
72 SkSafeUnref(fDrawState);
55 } 73 }
56 74
57 void GrGpu::contextAbandoned() {} 75 void GrGpu::contextAbandoned() {}
58 76
59 //////////////////////////////////////////////////////////////////////////////// 77 ////////////////////////////////////////////////////////////////////////////////
60 78
61 GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, 79 GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc,
62 const void* srcData, size_t rowBytes) { 80 const void* srcData, size_t rowBytes) {
63 if (!this->caps()->isConfigTexturable(desc.fConfig)) { 81 if (!this->caps()->isConfigTexturable(desc.fConfig)) {
64 return NULL; 82 return NULL;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 SkFAIL("Can't get indices into buffer!"); 205 SkFAIL("Can't get indices into buffer!");
188 } 206 }
189 SkDELETE_ARRAY(data); 207 SkDELETE_ARRAY(data);
190 } else { 208 } else {
191 buffer->unmap(); 209 buffer->unmap();
192 } 210 }
193 } 211 }
194 return buffer; 212 return buffer;
195 } 213 }
196 214
197 void GrGpu::onClear(const SkIRect* rect, 215 void GrGpu::clear(const SkIRect* rect,
198 GrColor color, 216 GrColor color,
199 bool canIgnoreRect, 217 bool canIgnoreRect,
200 GrRenderTarget* renderTarget) { 218 GrRenderTarget* renderTarget) {
201 SkASSERT(renderTarget); 219 SkASSERT(renderTarget);
202 this->handleDirtyContext(); 220 this->handleDirtyContext();
203 this->onGpuClear(renderTarget, rect, color, canIgnoreRect); 221 this->onGpuClear(renderTarget, rect, color, canIgnoreRect);
204 } 222 }
205 223
206 void GrGpu::clearStencilClip(const SkIRect& rect, 224 void GrGpu::clearStencilClip(const SkIRect& rect,
207 bool insideClip, 225 bool insideClip,
208 GrRenderTarget* renderTarget) { 226 GrRenderTarget* renderTarget) {
209 if (NULL == renderTarget) { 227 if (NULL == renderTarget) {
210 renderTarget = this->getDrawState().getRenderTarget(); 228 renderTarget = this->getDrawState().getRenderTarget();
(...skipping 23 matching lines...) Expand all
234 return this->onWriteTexturePixels(texture, left, top, width, height, 252 return this->onWriteTexturePixels(texture, left, top, width, height,
235 config, buffer, rowBytes); 253 config, buffer, rowBytes);
236 } 254 }
237 255
238 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { 256 void GrGpu::resolveRenderTarget(GrRenderTarget* target) {
239 SkASSERT(target); 257 SkASSERT(target);
240 this->handleDirtyContext(); 258 this->handleDirtyContext();
241 this->onResolveRenderTarget(target); 259 this->onResolveRenderTarget(target);
242 } 260 }
243 261
262 void GrGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) {
263 // Make the dst of the copy be a render target because the default copySurfa ce draws to the dst.
264 desc->fOrigin = kDefault_GrSurfaceOrigin;
265 desc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
266 desc->fConfig = src->config();
267 }
268
269 typedef GrTraceMarkerSet::Iter TMIter;
270 void GrGpu::saveActiveTraceMarkers() {
271 if (this->caps()->gpuTracingSupport()) {
272 SkASSERT(0 == fStoredTraceMarkers.count());
273 fStoredTraceMarkers.addSet(fActiveTraceMarkers);
274 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMark ers.end(); ++iter) {
275 this->removeGpuTraceMarker(&(*iter));
276 }
277 }
278 }
279
280 void GrGpu::restoreActiveTraceMarkers() {
281 if (this->caps()->gpuTracingSupport()) {
282 SkASSERT(0 == fActiveTraceMarkers.count());
283 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMark ers.end(); ++iter) {
284 this->addGpuTraceMarker(&(*iter));
285 }
286 for (TMIter iter = fActiveTraceMarkers.begin(); iter != fActiveTraceMark ers.end(); ++iter) {
287 this->fStoredTraceMarkers.remove(*iter);
288 }
289 }
290 }
291
292 void GrGpu::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
293 if (this->caps()->gpuTracingSupport()) {
294 SkASSERT(fGpuTraceMarkerCount >= 0);
295 this->fActiveTraceMarkers.add(*marker);
296 this->didAddGpuTraceMarker();
297 ++fGpuTraceMarkerCount;
298 }
299 }
300
301 void GrGpu::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
302 if (this->caps()->gpuTracingSupport()) {
303 SkASSERT(fGpuTraceMarkerCount >= 1);
304 this->fActiveTraceMarkers.remove(*marker);
305 this->didRemoveGpuTraceMarker();
306 --fGpuTraceMarkerCount;
307 }
308 }
309
310 void GrGpu::setVertexSourceToBuffer(const GrVertexBuffer* buffer) {
311 this->releasePreviousVertexSource();
312 GrDrawTarget::GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
313 geoSrc.fVertexSrc = GrDrawTarget::kBuffer_GeometrySrcType;
314 geoSrc.fVertexBuffer = buffer;
315 buffer->ref();
316 geoSrc.fVertexSize = this->drawState()->getVertexStride();
317 }
318
319 void GrGpu::setIndexSourceToBuffer(const GrIndexBuffer* buffer) {
320 this->releasePreviousIndexSource();
321 GrDrawTarget::GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
322 geoSrc.fIndexSrc = GrDrawTarget::kBuffer_GeometrySrcType;
323 geoSrc.fIndexBuffer = buffer;
324 buffer->ref();
325 }
326
327 void GrGpu::setDrawState(GrDrawState* drawState) {
328 SkASSERT(fDrawState);
329 if (NULL == drawState) {
330 drawState = &fDefaultDrawState;
331 }
332 if (fDrawState != drawState) {
333 fDrawState->unref();
334 drawState->ref();
335 fDrawState = drawState;
336 }
337 }
338
339 void GrGpu::resetVertexSource() {
340 this->releasePreviousVertexSource();
341 GrDrawTarget::GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
342 geoSrc.fVertexSrc = GrDrawTarget::kNone_GeometrySrcType;
343 }
344
345 void GrGpu::resetIndexSource() {
346 this->releasePreviousIndexSource();
347 GrDrawTarget::GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
348 geoSrc.fIndexSrc = GrDrawTarget::kNone_GeometrySrcType;
349 }
350
351 void GrGpu::pushGeometrySource() {
352 this->geometrySourceWillPush();
353 GrDrawTarget::GeometrySrcState& newState = fGeoSrcStateStack.push_back();
354 newState.fIndexSrc = GrDrawTarget::kNone_GeometrySrcType;
355 newState.fVertexSrc = GrDrawTarget::kNone_GeometrySrcType;
356 #ifdef SK_DEBUG
357 newState.fVertexCount = ~0;
358 newState.fVertexBuffer = (GrVertexBuffer*)~0;
359 newState.fIndexCount = ~0;
360 newState.fIndexBuffer = (GrIndexBuffer*)~0;
361 #endif
362 }
363
364 void GrGpu::popGeometrySource() {
365 // if popping last element then pops are unbalanced with pushes
366 SkASSERT(fGeoSrcStateStack.count() > 1);
367
368 this->geometrySourceWillPop(fGeoSrcStateStack.fromBack(1));
369 this->releasePreviousVertexSource();
370 this->releasePreviousIndexSource();
371 fGeoSrcStateStack.pop_back();
372 }
373
244 //////////////////////////////////////////////////////////////////////////////// 374 ////////////////////////////////////////////////////////////////////////////////
245 375
246 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; 376 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1;
247 377
248 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); 378 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535);
249 379
250 static const uint16_t gQuadIndexPattern[] = { 380 static const uint16_t gQuadIndexPattern[] = {
251 0, 1, 2, 0, 2, 3 381 0, 1, 2, 0, 2, 3
252 }; 382 };
253 383
254 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { 384 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
255 if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) { 385 if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) {
256 SkSafeUnref(fQuadIndexBuffer); 386 SkSafeUnref(fQuadIndexBuffer);
257 GrGpu* me = const_cast<GrGpu*>(this); 387 GrGpu* me = const_cast<GrGpu*>(this);
258 fQuadIndexBuffer = me->createInstancedIndexBuffer(gQuadIndexPattern, 388 fQuadIndexBuffer = me->createInstancedIndexBuffer(gQuadIndexPattern,
259 6, 389 6,
260 MAX_QUADS, 390 MAX_QUADS,
261 4); 391 4);
262 } 392 }
263 393
264 return fQuadIndexBuffer; 394 return fQuadIndexBuffer;
265 } 395 }
266 396
267 //////////////////////////////////////////////////////////////////////////////// 397 ////////////////////////////////////////////////////////////////////////////////
268 398
269 void GrGpu::geometrySourceWillPush() { 399 void GrGpu::geometrySourceWillPush() {
270 const GeometrySrcState& geoSrc = this->getGeomSrc(); 400 const GrDrawTarget::GeometrySrcState& geoSrc = this->getGeomSrc();
271 if (kReserved_GeometrySrcType == geoSrc.fVertexSrc) { 401 if (GrDrawTarget::kReserved_GeometrySrcType == geoSrc.fVertexSrc) {
272 this->finalizeReservedVertices(); 402 this->finalizeReservedVertices();
273 } 403 }
274 if (kReserved_GeometrySrcType == geoSrc.fIndexSrc) { 404 if (GrDrawTarget::kReserved_GeometrySrcType == geoSrc.fIndexSrc) {
275 this->finalizeReservedIndices(); 405 this->finalizeReservedIndices();
276 } 406 }
277 GeometryPoolState& newState = fGeomPoolStateStack.push_back(); 407 GeometryPoolState& newState = fGeomPoolStateStack.push_back();
278 #ifdef SK_DEBUG 408 #ifdef SK_DEBUG
279 newState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; 409 newState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER;
280 newState.fPoolStartVertex = DEBUG_INVAL_START_IDX; 410 newState.fPoolStartVertex = DEBUG_INVAL_START_IDX;
281 newState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; 411 newState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
282 newState.fPoolStartIndex = DEBUG_INVAL_START_IDX; 412 newState.fPoolStartIndex = DEBUG_INVAL_START_IDX;
283 #else 413 #else
284 (void) newState; // silence compiler warning 414 (void) newState; // silence compiler warning
285 #endif 415 #endif
286 } 416 }
287 417
288 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { 418 void GrGpu::geometrySourceWillPop(const GrDrawTarget::GeometrySrcState& restored State) {
289 // if popping last entry then pops are unbalanced with pushes 419 // if popping last entry then pops are unbalanced with pushes
290 SkASSERT(fGeomPoolStateStack.count() > 1); 420 SkASSERT(fGeomPoolStateStack.count() > 1);
291 fGeomPoolStateStack.pop_back(); 421 fGeomPoolStateStack.pop_back();
292 } 422 }
293 423
294 void GrGpu::onDraw(const DrawInfo& info, const GrClipMaskManager::ScissorState& scissorState) { 424 void GrGpu::onDraw(const GrDrawTarget::DrawInfo& info,
425 const GrClipMaskManager::ScissorState& scissorState) {
295 this->handleDirtyContext(); 426 this->handleDirtyContext();
296 if (!this->flushGraphicsState(PrimTypeToDrawType(info.primitiveType()), 427 if (!this->flushGraphicsState(PrimTypeToDrawType(info.primitiveType()),
297 scissorState, 428 scissorState,
298 info.getDstCopy())) { 429 info.getDstCopy())) {
299 return; 430 return;
300 } 431 }
301 this->onGpuDraw(info); 432 this->onGpuDraw(info);
302 } 433 }
303 434
304 void GrGpu::onStencilPath(const GrPath* path, 435 void GrGpu::onStencilPath(const GrPath* path,
305 const GrClipMaskManager::ScissorState& scissorState, 436 const GrClipMaskManager::ScissorState& scissorState,
306 const GrStencilSettings& stencilSettings) { 437 const GrStencilSettings& stencilSettings) {
307 this->handleDirtyContext(); 438 this->handleDirtyContext();
308 439
309 if (!this->flushGraphicsState(kStencilPath_DrawType, scissorState, NULL)) { 440 if (!this->flushGraphicsState(kStencilPath_DrawType, scissorState, NULL)) {
310 return; 441 return;
311 } 442 }
312 443
313 this->pathRendering()->stencilPath(path, stencilSettings); 444 this->pathRendering()->stencilPath(path, stencilSettings);
314 } 445 }
315 446
316 447
317 void GrGpu::onDrawPath(const GrPath* path, 448 void GrGpu::onDrawPath(const GrPath* path,
318 const GrClipMaskManager::ScissorState& scissorState, 449 const GrClipMaskManager::ScissorState& scissorState,
319 const GrStencilSettings& stencilSettings, 450 const GrStencilSettings& stencilSettings,
320 const GrDeviceCoordTexture* dstCopy) { 451 const GrDeviceCoordTexture* dstCopy) {
321 this->handleDirtyContext(); 452 this->handleDirtyContext();
322 453
323 drawState()->setDefaultVertexAttribs();
324
325 if (!this->flushGraphicsState(kDrawPath_DrawType, scissorState, dstCopy)) { 454 if (!this->flushGraphicsState(kDrawPath_DrawType, scissorState, dstCopy)) {
326 return; 455 return;
327 } 456 }
328 457
329 this->pathRendering()->drawPath(path, stencilSettings); 458 this->pathRendering()->drawPath(path, stencilSettings);
330 } 459 }
331 460
332 void GrGpu::onDrawPaths(const GrPathRange* pathRange, 461 void GrGpu::onDrawPaths(const GrPathRange* pathRange,
333 const uint32_t indices[], 462 const uint32_t indices[],
334 int count, 463 int count,
335 const float transforms[], 464 const float transforms[],
336 PathTransformType transformsType, 465 GrDrawTarget::PathTransformType transformsType,
337 const GrClipMaskManager::ScissorState& scissorState, 466 const GrClipMaskManager::ScissorState& scissorState,
338 const GrStencilSettings& stencilSettings, 467 const GrStencilSettings& stencilSettings,
339 const GrDeviceCoordTexture* dstCopy) { 468 const GrDeviceCoordTexture* dstCopy) {
340 this->handleDirtyContext(); 469 this->handleDirtyContext();
341 470
342 drawState()->setDefaultVertexAttribs();
343
344 if (!this->flushGraphicsState(kDrawPaths_DrawType, scissorState, dstCopy)) { 471 if (!this->flushGraphicsState(kDrawPaths_DrawType, scissorState, dstCopy)) {
345 return; 472 return;
346 } 473 }
347 474
348 pathRange->willDrawPaths(indices, count); 475 pathRange->willDrawPaths(indices, count);
349 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran sformsType, 476 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran sformsType,
350 stencilSettings); 477 stencilSettings);
351 } 478 }
352 479
353 void GrGpu::finalizeReservedVertices() { 480 void GrGpu::finalizeReservedVertices() {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 &geomPoolState.fPoolIndexBuffer, 546 &geomPoolState.fPoolIndexBuffer,
420 &geomPoolState.fPoolStartIndex); 547 &geomPoolState.fPoolStartIndex);
421 if (NULL == *indices) { 548 if (NULL == *indices) {
422 return false; 549 return false;
423 } 550 }
424 ++fIndexPoolUseCnt; 551 ++fIndexPoolUseCnt;
425 return true; 552 return true;
426 } 553 }
427 554
428 void GrGpu::releaseReservedVertexSpace() { 555 void GrGpu::releaseReservedVertexSpace() {
429 const GeometrySrcState& geoSrc = this->getGeomSrc(); 556 const GrDrawTarget::GeometrySrcState& geoSrc = this->getGeomSrc();
430 SkASSERT(kReserved_GeometrySrcType == geoSrc.fVertexSrc); 557 SkASSERT(GrDrawTarget::kReserved_GeometrySrcType == geoSrc.fVertexSrc);
431 size_t bytes = geoSrc.fVertexCount * geoSrc.fVertexSize; 558 size_t bytes = geoSrc.fVertexCount * geoSrc.fVertexSize;
432 fVertexPool->putBack(bytes); 559 fVertexPool->putBack(bytes);
433 --fVertexPoolUseCnt; 560 --fVertexPoolUseCnt;
434 } 561 }
435 562
436 void GrGpu::releaseReservedIndexSpace() { 563 void GrGpu::releaseReservedIndexSpace() {
437 const GeometrySrcState& geoSrc = this->getGeomSrc(); 564 const GrDrawTarget::GeometrySrcState& geoSrc = this->getGeomSrc();
438 SkASSERT(kReserved_GeometrySrcType == geoSrc.fIndexSrc); 565 SkASSERT(GrDrawTarget::kReserved_GeometrySrcType == geoSrc.fIndexSrc);
439 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); 566 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t);
440 fIndexPool->putBack(bytes); 567 fIndexPool->putBack(bytes);
441 --fIndexPoolUseCnt; 568 --fIndexPoolUseCnt;
442 } 569 }
570
571 void GrGpu::releasePreviousVertexSource() {
572 GrDrawTarget::GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
573 switch (geoSrc.fVertexSrc) {
574 case GrDrawTarget::kNone_GeometrySrcType:
575 break;
576 case GrDrawTarget::kReserved_GeometrySrcType:
577 this->releaseReservedVertexSpace();
578 break;
579 case GrDrawTarget::kBuffer_GeometrySrcType:
580 geoSrc.fVertexBuffer->unref();
581 #ifdef SK_DEBUG
582 geoSrc.fVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER;
583 #endif
584 break;
585 default:
586 SkFAIL("Unknown Vertex Source Type.");
587 break;
588 }
589 }
590
591 void GrGpu::releasePreviousIndexSource() {
592 GrDrawTarget::GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
593 switch (geoSrc.fIndexSrc) {
594 case GrDrawTarget::kNone_GeometrySrcType: // these two don't require
595 break;
596 case GrDrawTarget::kReserved_GeometrySrcType:
597 this->releaseReservedIndexSpace();
598 break;
599 case GrDrawTarget::kBuffer_GeometrySrcType:
600 geoSrc.fIndexBuffer->unref();
601 #ifdef SK_DEBUG
602 geoSrc.fIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
603 #endif
604 break;
605 default:
606 SkFAIL("Unknown Index Source Type.");
607 break;
608 }
609 }
610
611 void GrGpu::releaseGeometry() {
612 int popCnt = fGeoSrcStateStack.count() - 1;
613 while (popCnt) {
614 this->popGeometrySource();
615 --popCnt;
616 }
617 this->resetVertexSource();
618 this->resetIndexSource();
619 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698