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

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

Issue 1483103003: Make onPrepareDraws const (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: merge Created 5 years 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/GrAtlasTextBatch.cpp ('k') | src/gpu/batches/GrDrawAtlasBatch.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 2011 Google Inc. 2 * Copyright 2011 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 "GrDefaultPathRenderer.h" 8 #include "GrDefaultPathRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 245 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
246 246
247 // setup batch properties 247 // setup batch properties
248 fBatch.fColorIgnored = !overrides.readsColor(); 248 fBatch.fColorIgnored = !overrides.readsColor();
249 fBatch.fColor = fGeoData[0].fColor; 249 fBatch.fColor = fGeoData[0].fColor;
250 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); 250 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
251 fBatch.fCoverageIgnored = !overrides.readsCoverage(); 251 fBatch.fCoverageIgnored = !overrides.readsCoverage();
252 } 252 }
253 253
254 void onPrepareDraws(Target* target) override { 254 void onPrepareDraws(Target* target) const override {
255 SkAutoTUnref<const GrGeometryProcessor> gp; 255 SkAutoTUnref<const GrGeometryProcessor> gp;
256 { 256 {
257 using namespace GrDefaultGeoProcFactory; 257 using namespace GrDefaultGeoProcFactory;
258 Color color(this->color()); 258 Color color(this->color());
259 Coverage coverage(this->coverage()); 259 Coverage coverage(this->coverage());
260 if (this->coverageIgnored()) { 260 if (this->coverageIgnored()) {
261 coverage.fType = Coverage::kNone_Type; 261 coverage.fType = Coverage::kNone_Type;
262 } 262 }
263 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP osition_Type : 263 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP osition_Type :
264 LocalCoords::kUnus ed_Type); 264 LocalCoords::kUnus ed_Type);
265 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord s, 265 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord s,
266 this->viewMatrix())); 266 this->viewMatrix()));
267 } 267 }
268 268
269 size_t vertexStride = gp->getVertexStride(); 269 size_t vertexStride = gp->getVertexStride();
270 SkASSERT(vertexStride == sizeof(SkPoint)); 270 SkASSERT(vertexStride == sizeof(SkPoint));
271 271
272 target->initDraw(gp, this->pipeline()); 272 target->initDraw(gp, this->pipeline());
273 273
274 int instanceCount = fGeoData.count(); 274 int instanceCount = fGeoData.count();
275 275
276 // compute number of vertices 276 // compute number of vertices
277 int maxVertices = 0; 277 int maxVertices = 0;
278 278
279 // We will use index buffers if we have multiple paths or one path with multiple contours 279 // We will use index buffers if we have multiple paths or one path with multiple contours
280 bool isIndexed = instanceCount > 1; 280 bool isIndexed = instanceCount > 1;
281 for (int i = 0; i < instanceCount; i++) { 281 for (int i = 0; i < instanceCount; i++) {
282 Geometry& args = fGeoData[i]; 282 const Geometry& args = fGeoData[i];
283 283
284 int contourCount; 284 int contourCount;
285 maxVertices += GrPathUtils::worstCasePointCount(args.fPath, &contour Count, 285 maxVertices += GrPathUtils::worstCasePointCount(args.fPath, &contour Count,
286 args.fTolerance); 286 args.fTolerance);
287 287
288 isIndexed = isIndexed || contourCount > 1; 288 isIndexed = isIndexed || contourCount > 1;
289 } 289 }
290 290
291 if (maxVertices == 0 || maxVertices > ((int)SK_MaxU16 + 1)) { 291 if (maxVertices == 0 || maxVertices > ((int)SK_MaxU16 + 1)) {
292 SkDebugf("Cannot render path (%d)\n", maxVertices); 292 SkDebugf("Cannot render path (%d)\n", maxVertices);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 if (!indices) { 334 if (!indices) {
335 SkDebugf("Could not allocate indices\n"); 335 SkDebugf("Could not allocate indices\n");
336 return; 336 return;
337 } 337 }
338 } 338 }
339 339
340 // fill buffers 340 // fill buffers
341 int vertexOffset = 0; 341 int vertexOffset = 0;
342 int indexOffset = 0; 342 int indexOffset = 0;
343 for (int i = 0; i < instanceCount; i++) { 343 for (int i = 0; i < instanceCount; i++) {
344 Geometry& args = fGeoData[i]; 344 const Geometry& args = fGeoData[i];
345 345
346 int vertexCnt = 0; 346 int vertexCnt = 0;
347 int indexCnt = 0; 347 int indexCnt = 0;
348 if (!this->createGeom(verts, 348 if (!this->createGeom(verts,
349 vertexOffset, 349 vertexOffset,
350 indices, 350 indices,
351 indexOffset, 351 indexOffset,
352 &vertexCnt, 352 &vertexCnt,
353 &indexCnt, 353 &indexCnt,
354 args.fPath, 354 args.fPath,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 424 }
425 425
426 bool createGeom(void* vertices, 426 bool createGeom(void* vertices,
427 size_t vertexOffset, 427 size_t vertexOffset,
428 void* indices, 428 void* indices,
429 size_t indexOffset, 429 size_t indexOffset,
430 int* vertexCnt, 430 int* vertexCnt,
431 int* indexCnt, 431 int* indexCnt,
432 const SkPath& path, 432 const SkPath& path,
433 SkScalar srcSpaceTol, 433 SkScalar srcSpaceTol,
434 bool isIndexed) { 434 bool isIndexed) const {
435 { 435 {
436 SkScalar srcSpaceTolSqd = SkScalarMul(srcSpaceTol, srcSpaceTol); 436 SkScalar srcSpaceTolSqd = SkScalarMul(srcSpaceTol, srcSpaceTol);
437 437
438 uint16_t indexOffsetU16 = (uint16_t)indexOffset; 438 uint16_t indexOffsetU16 = (uint16_t)indexOffset;
439 uint16_t vertexOffsetU16 = (uint16_t)vertexOffset; 439 uint16_t vertexOffsetU16 = (uint16_t)vertexOffset;
440 440
441 uint16_t* idxBase = reinterpret_cast<uint16_t*>(indices) + indexOffs etU16; 441 uint16_t* idxBase = reinterpret_cast<uint16_t*>(indices) + indexOffs etU16;
442 uint16_t* idx = idxBase; 442 uint16_t* idx = idxBase;
443 uint16_t subpathIdxStart = vertexOffsetU16; 443 uint16_t subpathIdxStart = vertexOffsetU16;
444 444
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 geometry.fColor = color; 764 geometry.fColor = color;
765 geometry.fPath = path; 765 geometry.fPath = path;
766 geometry.fTolerance = srcSpaceTol; 766 geometry.fTolerance = srcSpaceTol;
767 767
768 viewMatrix.mapRect(&bounds); 768 viewMatrix.mapRect(&bounds);
769 uint8_t coverage = GrRandomCoverage(random); 769 uint8_t coverage = GrRandomCoverage(random);
770 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds ); 770 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds );
771 } 771 }
772 772
773 #endif 773 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAtlasTextBatch.cpp ('k') | src/gpu/batches/GrDrawAtlasBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698