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

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

Issue 1131553002: Isolate GrBufferAllocPools inside GrBatchTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 5 years, 7 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/GrBatchTarget.cpp ('k') | src/gpu/GrCommandBuilder.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 "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 SkASSERT(kVertex_BufferType == fBufferType); 351 SkASSERT(kVertex_BufferType == fBufferType);
352 return fGpu->createVertexBuffer(size, true); 352 return fGpu->createVertexBuffer(size, true);
353 } 353 }
354 } 354 }
355 355
356 //////////////////////////////////////////////////////////////////////////////// 356 ////////////////////////////////////////////////////////////////////////////////
357 357
358 GrVertexBufferAllocPool::GrVertexBufferAllocPool(GrGpu* gpu, 358 GrVertexBufferAllocPool::GrVertexBufferAllocPool(GrGpu* gpu,
359 size_t bufferSize, 359 size_t bufferSize,
360 int preallocBufferCnt) 360 int preallocBufferCnt)
361 : GrBufferAllocPool(gpu, 361 : GrBufferAllocPool(gpu,
362 kVertex_BufferType, 362 kVertex_BufferType,
363 bufferSize, 363 bufferSize,
364 preallocBufferCnt) { 364 preallocBufferCnt) {
365 } 365 }
366 366
367 void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize, 367 void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize,
368 int vertexCount, 368 int vertexCount,
369 const GrVertexBuffer** buffer, 369 const GrVertexBuffer** buffer,
370 int* startVertex) { 370 int* startVertex) {
371 371
372 SkASSERT(vertexCount >= 0); 372 SkASSERT(vertexCount >= 0);
373 SkASSERT(buffer); 373 SkASSERT(buffer);
374 SkASSERT(startVertex); 374 SkASSERT(startVertex);
375 375
376 size_t offset = 0; // assign to suppress warning 376 size_t offset = 0; // assign to suppress warning
377 const GrGeometryBuffer* geomBuffer = NULL; // assign to suppress warning 377 const GrGeometryBuffer* geomBuffer = NULL; // assign to suppress warning
378 void* ptr = INHERITED::makeSpace(vertexSize * vertexCount, 378 void* ptr = INHERITED::makeSpace(vertexSize * vertexCount,
379 vertexSize, 379 vertexSize,
380 &geomBuffer, 380 &geomBuffer,
381 &offset); 381 &offset);
382 382
383 *buffer = (const GrVertexBuffer*) geomBuffer; 383 *buffer = (const GrVertexBuffer*) geomBuffer;
384 SkASSERT(0 == offset % vertexSize); 384 SkASSERT(0 == offset % vertexSize);
385 *startVertex = static_cast<int>(offset / vertexSize); 385 *startVertex = static_cast<int>(offset / vertexSize);
386 return ptr; 386 return ptr;
387 } 387 }
388 388
389 //////////////////////////////////////////////////////////////////////////////// 389 ////////////////////////////////////////////////////////////////////////////////
390 390
391 GrIndexBufferAllocPool::GrIndexBufferAllocPool(GrGpu* gpu, 391 GrIndexBufferAllocPool::GrIndexBufferAllocPool(GrGpu* gpu,
392 size_t bufferSize, 392 size_t bufferSize,
393 int preallocBufferCnt) 393 int preallocBufferCnt)
394 : GrBufferAllocPool(gpu, 394 : GrBufferAllocPool(gpu,
395 kIndex_BufferType, 395 kIndex_BufferType,
396 bufferSize, 396 bufferSize,
397 preallocBufferCnt) { 397 preallocBufferCnt) {
398 } 398 }
399 399
400 void* GrIndexBufferAllocPool::makeSpace(int indexCount, 400 void* GrIndexBufferAllocPool::makeSpace(int indexCount,
401 const GrIndexBuffer** buffer, 401 const GrIndexBuffer** buffer,
402 int* startIndex) { 402 int* startIndex) {
403 403
404 SkASSERT(indexCount >= 0); 404 SkASSERT(indexCount >= 0);
405 SkASSERT(buffer); 405 SkASSERT(buffer);
406 SkASSERT(startIndex); 406 SkASSERT(startIndex);
407 407
408 size_t offset = 0; // assign to suppress warning 408 size_t offset = 0; // assign to suppress warning
409 const GrGeometryBuffer* geomBuffer = NULL; // assign to suppress warning 409 const GrGeometryBuffer* geomBuffer = NULL; // assign to suppress warning
410 void* ptr = INHERITED::makeSpace(indexCount * sizeof(uint16_t), 410 void* ptr = INHERITED::makeSpace(indexCount * sizeof(uint16_t),
411 sizeof(uint16_t), 411 sizeof(uint16_t),
412 &geomBuffer, 412 &geomBuffer,
413 &offset); 413 &offset);
414 414
415 *buffer = (const GrIndexBuffer*) geomBuffer; 415 *buffer = (const GrIndexBuffer*) geomBuffer;
416 SkASSERT(0 == offset % sizeof(uint16_t)); 416 SkASSERT(0 == offset % sizeof(uint16_t));
417 *startIndex = static_cast<int>(offset / sizeof(uint16_t)); 417 *startIndex = static_cast<int>(offset / sizeof(uint16_t));
418 return ptr; 418 return ptr;
419 } 419 }
420 420
421 421
OLDNEW
« no previous file with comments | « src/gpu/GrBatchTarget.cpp ('k') | src/gpu/GrCommandBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698