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

Side by Side Diff: src/gpu/batches/GrBatch.cpp

Issue 1278643006: Make GrBatch carry its own GrPipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 5 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/batches/GrBatch.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 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrBatch.h" 8 #include "GrBatch.h"
9 #include "GrBatchTarget.h" 9 #include "GrBatchTarget.h"
10 #include "GrResourceProvider.h" 10 #include "GrResourceProvider.h"
(...skipping 30 matching lines...) Expand all
41 GrBATCH_SPEW(int32_t GrBatch::gCurrBatchUniqueID = GrBatch::kIllegalBatchID;) 41 GrBATCH_SPEW(int32_t GrBatch::gCurrBatchUniqueID = GrBatch::kIllegalBatchID;)
42 42
43 void* GrBatch::operator new(size_t size) { 43 void* GrBatch::operator new(size_t size) {
44 return MemoryPoolAccessor().pool()->allocate(size); 44 return MemoryPoolAccessor().pool()->allocate(size);
45 } 45 }
46 46
47 void GrBatch::operator delete(void* target) { 47 void GrBatch::operator delete(void* target) {
48 return MemoryPoolAccessor().pool()->release(target); 48 return MemoryPoolAccessor().pool()->release(target);
49 } 49 }
50 50
51 GrBatch::GrBatch()
52 : fClassID(kIllegalBatchID)
53 , fNumberOfDraws(0)
54 , fPipelineInstalled(false)
55 #if GR_BATCH_SPEW
56 , fUniqueID(GenID(&gCurrBatchUniqueID))
57 #endif
58 {
59 SkDEBUGCODE(fUsed = false;)
60 }
61
62 GrBatch::~GrBatch() {
63 if (fPipelineInstalled) {
64 this->pipeline()->~GrPipeline();
65 }
66 }
67
51 void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType primType, 68 void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType primType,
52 size_t vertexStride, const GrIndexBuffer* i ndexBuffer, 69 size_t vertexStride, const GrIndexBuffer* i ndexBuffer,
53 int verticesPerInstance, int indicesPerInst ance, 70 int verticesPerInstance, int indicesPerInst ance,
54 int instancesToDraw) { 71 int instancesToDraw) {
55 SkASSERT(batchTarget); 72 SkASSERT(batchTarget);
56 if (!indexBuffer) { 73 if (!indexBuffer) {
57 return NULL; 74 return NULL;
58 } 75 }
59 const GrVertexBuffer* vertexBuffer; 76 const GrVertexBuffer* vertexBuffer;
60 int firstVertex; 77 int firstVertex;
(...skipping 17 matching lines...) Expand all
78 void* GrBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride, int quadsToDraw) { 95 void* GrBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride, int quadsToDraw) {
79 SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer( 96 SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer(
80 batchTarget->resourceProvider()->refQuadIndexBuffer()); 97 batchTarget->resourceProvider()->refQuadIndexBuffer());
81 if (!quadIndexBuffer) { 98 if (!quadIndexBuffer) {
82 SkDebugf("Could not get quad index buffer."); 99 SkDebugf("Could not get quad index buffer.");
83 return NULL; 100 return NULL;
84 } 101 }
85 return this->INHERITED::init(batchTarget, kTriangles_GrPrimitiveType, vertex Stride, 102 return this->INHERITED::init(batchTarget, kTriangles_GrPrimitiveType, vertex Stride,
86 quadIndexBuffer, kVerticesPerQuad, kIndicesPerQ uad, quadsToDraw); 103 quadIndexBuffer, kVerticesPerQuad, kIndicesPerQ uad, quadsToDraw);
87 } 104 }
105
106 bool GrBatch::installPipeline(const GrPipeline::CreateArgs& args) {
107 GrPipelineOptimizations opts;
108 void* location = fPipelineStorage.get();
109 if (!GrPipeline::CreateAt(location, args, &opts)) {
110 return false;
111 }
112 this->initBatchTracker(opts);
113 fPipelineInstalled = true;
114 return true;
115 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrBatch.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698