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

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

Issue 1293583002: Introduce GrBatch subclasses GrDrawBatch and GrVertexBatch to prepare for non-drawing batches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove duplicated fields in GrVertexBatch 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/GrAAStrokeRectBatch.h ('k') | src/gpu/batches/GrBWFillRectBatch.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 "GrAAStrokeRectBatch.h" 8 #include "GrAAStrokeRectBatch.h"
9 9
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gBevelIndices) == kBevelIndexCnt); 197 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gBevelIndices) == kBevelIndexCnt);
198 198
199 GR_DEFINE_STATIC_UNIQUE_KEY(gBevelIndexBufferKey); 199 GR_DEFINE_STATIC_UNIQUE_KEY(gBevelIndexBufferKey);
200 return resourceProvider->findOrCreateInstancedIndexBuffer(gBevelIndices, 200 return resourceProvider->findOrCreateInstancedIndexBuffer(gBevelIndices,
201 kBevelIndexCnt, kNumBevelRectsInIndexBuffer, kBevelVertexCnt, 201 kBevelIndexCnt, kNumBevelRectsInIndexBuffer, kBevelVertexCnt,
202 gBevelIndexBufferKey); 202 gBevelIndexBufferKey);
203 } 203 }
204 } 204 }
205 205
206 bool GrAAStrokeRectBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { 206 bool GrAAStrokeRectBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
207 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline( ), t->bounds(), 207 GrAAStrokeRectBatch* that = t->cast<GrAAStrokeRectBatch>();
208 caps)) { 208
209 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeli ne(),
210 that->bounds(), caps)) {
209 return false; 211 return false;
210 } 212 }
211 213
212 GrAAStrokeRectBatch* that = t->cast<GrAAStrokeRectBatch>();
213
214 // TODO batch across miterstroke changes 214 // TODO batch across miterstroke changes
215 if (this->miterStroke() != that->miterStroke()) { 215 if (this->miterStroke() != that->miterStroke()) {
216 return false; 216 return false;
217 } 217 }
218 218
219 // We apply the viewmatrix to the rect points on the cpu. However, if the p ipeline uses 219 // We apply the viewmatrix to the rect points on the cpu. However, if the p ipeline uses
220 // local coords then we won't be able to batch. We could actually upload th e viewmatrix 220 // local coords then we won't be able to batch. We could actually upload th e viewmatrix
221 // using vertex attributes in these cases, but haven't investigated that 221 // using vertex attributes in these cases, but haven't investigated that
222 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->viewMa trix())) { 222 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->viewMa trix())) {
223 return false; 223 return false;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 } 350 }
351 } 351 }
352 352
353 //////////////////////////////////////////////////////////////////////////////// /////////////////// 353 //////////////////////////////////////////////////////////////////////////////// ///////////////////
354 354
355 #ifdef GR_TEST_UTILS 355 #ifdef GR_TEST_UTILS
356 356
357 #include "GrBatchTest.h" 357 #include "GrBatchTest.h"
358 358
359 BATCH_TEST_DEFINE(AAStrokeRectBatch) { 359 DRAW_BATCH_TEST_DEFINE(AAStrokeRectBatch) {
360 bool miterStroke = random->nextBool(); 360 bool miterStroke = random->nextBool();
361 361
362 // Create mock stroke rect 362 // Create mock stroke rect
363 SkRect outside = GrTest::TestRect(random); 363 SkRect outside = GrTest::TestRect(random);
364 SkScalar minDim = SkMinScalar(outside.width(), outside.height()); 364 SkScalar minDim = SkMinScalar(outside.width(), outside.height());
365 SkScalar strokeWidth = minDim * 0.1f; 365 SkScalar strokeWidth = minDim * 0.1f;
366 SkRect outsideAssist = outside; 366 SkRect outsideAssist = outside;
367 outsideAssist.outset(strokeWidth, strokeWidth); 367 outsideAssist.outset(strokeWidth, strokeWidth);
368 SkRect inside = outside; 368 SkRect inside = outside;
369 inside.inset(strokeWidth, strokeWidth); 369 inside.inset(strokeWidth, strokeWidth);
370 370
371 GrAAStrokeRectBatch::Geometry geo; 371 GrAAStrokeRectBatch::Geometry geo;
372 geo.fColor = GrRandomColor(random); 372 geo.fColor = GrRandomColor(random);
373 geo.fDevOutside = outside; 373 geo.fDevOutside = outside;
374 geo.fDevOutsideAssist = outsideAssist; 374 geo.fDevOutsideAssist = outsideAssist;
375 geo.fDevInside = inside; 375 geo.fDevInside = inside;
376 geo.fMiterStroke = miterStroke; 376 geo.fMiterStroke = miterStroke;
377 377
378 return GrAAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random)); 378 return GrAAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random));
379 } 379 }
380 380
381 #endif 381 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAStrokeRectBatch.h ('k') | src/gpu/batches/GrBWFillRectBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698