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

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

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl 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/GrTessellatingPathRenderer.cpp ('k') | src/gpu/batches/GrAAStrokeRectBatch.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 * 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 "GrAAFillRectBatch.h" 8 #include "GrAAFillRectBatch.h"
9 9
10 #include "GrBatchFlushState.h"
10 #include "GrColor.h" 11 #include "GrColor.h"
11 #include "GrDefaultGeoProcFactory.h" 12 #include "GrDefaultGeoProcFactory.h"
12 #include "GrResourceKey.h" 13 #include "GrResourceKey.h"
13 #include "GrResourceProvider.h" 14 #include "GrResourceProvider.h"
14 #include "GrTypes.h" 15 #include "GrTypes.h"
15 #include "GrVertexBatch.h" 16 #include "GrVertexBatch.h"
16 #include "SkMatrix.h" 17 #include "SkMatrix.h"
17 #include "SkRect.h" 18 #include "SkRect.h"
18 19
19 GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey); 20 GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 90 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
90 91
91 // setup batch properties 92 // setup batch properties
92 fBatch.fColorIgnored = !opt.readsColor(); 93 fBatch.fColorIgnored = !opt.readsColor();
93 fBatch.fColor = fGeoData[0].fColor; 94 fBatch.fColor = fGeoData[0].fColor;
94 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); 95 fBatch.fUsesLocalCoords = opt.readsLocalCoords();
95 fBatch.fCoverageIgnored = !opt.readsCoverage(); 96 fBatch.fCoverageIgnored = !opt.readsCoverage();
96 fBatch.fCanTweakAlphaForCoverage = opt.canTweakAlphaForCoverage(); 97 fBatch.fCanTweakAlphaForCoverage = opt.canTweakAlphaForCoverage();
97 } 98 }
98 99
99 void generateGeometry(GrBatchTarget* batchTarget) override { 100 void onPrepareDraws(Target* target) override {
100 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 101 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
101 102
102 SkAutoTUnref<const GrGeometryProcessor> gp(CreateFillRectGP(canTweakAlph aForCoverage, 103 SkAutoTUnref<const GrGeometryProcessor> gp(CreateFillRectGP(canTweakAlph aForCoverage,
103 this->viewMa trix(), 104 this->viewMa trix(),
104 this->usesLo calCoords(), 105 this->usesLo calCoords(),
105 Base::LocalC oordsType(), 106 Base::LocalC oordsType(),
106 this->covera geIgnored())); 107 this->covera geIgnored()));
107 if (!gp) { 108 if (!gp) {
108 SkDebugf("Couldn't create GrGeometryProcessor\n"); 109 SkDebugf("Couldn't create GrGeometryProcessor\n");
109 return; 110 return;
110 } 111 }
111 112
112 batchTarget->initDraw(gp, this->pipeline()); 113 target->initDraw(gp, this->pipeline());
113 114
114 size_t vertexStride = gp->getVertexStride(); 115 size_t vertexStride = gp->getVertexStride();
115 SkASSERT(Base::StrideCheck(vertexStride, canTweakAlphaForCoverage, 116 SkASSERT(Base::StrideCheck(vertexStride, canTweakAlphaForCoverage,
116 this->usesLocalCoords())); 117 this->usesLocalCoords()));
117 int instanceCount = fGeoData.count(); 118 int instanceCount = fGeoData.count();
118 119
119 SkAutoTUnref<const GrIndexBuffer> indexBuffer(get_index_buffer( 120 SkAutoTUnref<const GrIndexBuffer> indexBuffer(get_index_buffer(target->r esourceProvider()));
120 batchTarget->resourceProvider()));
121 InstancedHelper helper; 121 InstancedHelper helper;
122 void* vertices = helper.init(batchTarget, kTriangles_GrPrimitiveType, ve rtexStride, 122 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS tride,
123 indexBuffer, kVertsPerAAFillRect, kIndicesP erAAFillRect, 123 indexBuffer, kVertsPerAAFillRect, kIndicesP erAAFillRect,
124 instanceCount); 124 instanceCount);
125 if (!vertices || !indexBuffer) { 125 if (!vertices || !indexBuffer) {
126 SkDebugf("Could not allocate vertices\n"); 126 SkDebugf("Could not allocate vertices\n");
127 return; 127 return;
128 } 128 }
129 129
130 for (int i = 0; i < instanceCount; i++) { 130 for (int i = 0; i < instanceCount; i++) {
131 this->generateAAFillRectGeometry(vertices, 131 this->generateAAFillRectGeometry(vertices,
132 i * kVertsPerAAFillRect * vertexStr ide, 132 i * kVertsPerAAFillRect * vertexStr ide,
133 vertexStride, 133 vertexStride,
134 fGeoData[i], 134 fGeoData[i],
135 canTweakAlphaForCoverage); 135 canTweakAlphaForCoverage);
136 } 136 }
137 helper.issueDraw(batchTarget); 137 helper.recordDraw(target);
138 } 138 }
139 139
140 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 140 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
141 141
142 // to avoid even the initial copy of the struct, we have a getter for the fi rst item which 142 // to avoid even the initial copy of the struct, we have a getter for the fi rst item which
143 // is used to seed the batch with its initial geometry. After seeding, the client should call 143 // is used to seed the batch with its initial geometry. After seeding, the client should call
144 // init() so the Batch can initialize itself 144 // init() so the Batch can initialize itself
145 Geometry* geometry() { return &fGeoData[0]; } 145 Geometry* geometry() { return &fGeoData[0]; }
146 void init() { 146 void init() {
147 const Geometry& geo = fGeoData[0]; 147 const Geometry& geo = fGeoData[0];
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { 454 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
455 GrColor color = GrRandomColor(random); 455 GrColor color = GrRandomColor(random);
456 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 456 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
457 SkMatrix localMatrix = GrTest::TestMatrix(random); 457 SkMatrix localMatrix = GrTest::TestMatrix(random);
458 SkRect rect = GrTest::TestRect(random); 458 SkRect rect = GrTest::TestRect(random);
459 SkRect devRect = GrTest::TestRect(random); 459 SkRect devRect = GrTest::TestRect(random);
460 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct); 460 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct);
461 } 461 }
462 462
463 #endif 463 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | src/gpu/batches/GrAAStrokeRectBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698