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

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

Powered by Google App Engine
This is Rietveld 408576698