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

Side by Side Diff: src/gpu/effects/GrDashingEffect.cpp

Issue 968873006: valgrind fix (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | 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 2014 Google Inc. 2 * Copyright 2014 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 "GrDashingEffect.h" 8 #include "GrDashingEffect.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 bool useAA = this->useAA(); 333 bool useAA = this->useAA();
334 bool fullDash = this->fullDash(); 334 bool fullDash = this->fullDash();
335 335
336 // We do two passes over all of the dashes. First we setup the start, e nd, and bounds, 336 // We do two passes over all of the dashes. First we setup the start, e nd, and bounds,
337 // rectangles. We preserve all of this work in the rects / draws arrays below. Then we 337 // rectangles. We preserve all of this work in the rects / draws arrays below. Then we
338 // iterate again over these decomposed dashes to generate vertices 338 // iterate again over these decomposed dashes to generate vertices
339 SkSTArray<128, SkRect, true> rects; 339 SkSTArray<128, SkRect, true> rects;
340 SkSTArray<128, DashDraw, true> draws; 340 SkSTArray<128, DashDraw, true> draws;
341 341
342 int totalRectCount = 0; 342 int totalRectCount = 0;
343 int rectOffset = 0;
343 for (int i = 0; i < instanceCount; i++) { 344 for (int i = 0; i < instanceCount; i++) {
344 Geometry& args = fGeoData[i]; 345 Geometry& args = fGeoData[i];
345 346
346 bool hasCap = SkPaint::kButt_Cap != cap && 0 != args.fSrcStrokeWidth ; 347 bool hasCap = SkPaint::kButt_Cap != cap && 0 != args.fSrcStrokeWidth ;
347 348
348 // We always want to at least stroke out half a pixel on each side i n device space 349 // We always want to at least stroke out half a pixel on each side i n device space
349 // so 0.5f / perpScale gives us this min in src space 350 // so 0.5f / perpScale gives us this min in src space
350 SkScalar halfSrcStroke = 351 SkScalar halfSrcStroke =
351 SkMaxScalar(args.fSrcStrokeWidth * 0.5f, 0.5f / args.fPerpen dicularScale); 352 SkMaxScalar(args.fSrcStrokeWidth * 0.5f, 0.5f / args.fPerpen dicularScale);
352 353
353 SkScalar strokeAdj; 354 SkScalar strokeAdj;
354 if (!hasCap) { 355 if (!hasCap) {
355 strokeAdj = 0.f; 356 strokeAdj = 0.f;
356 } else { 357 } else {
357 strokeAdj = halfSrcStroke; 358 strokeAdj = halfSrcStroke;
358 } 359 }
359 360
360 SkScalar startAdj = 0; 361 SkScalar startAdj = 0;
361 362
362 SkMatrix& combinedMatrix = args.fSrcRotInv; 363 SkMatrix& combinedMatrix = args.fSrcRotInv;
363 combinedMatrix.postConcat(args.fViewMatrix); 364 combinedMatrix.postConcat(args.fViewMatrix);
364 365
365 bool lineDone = false; 366 bool lineDone = false;
366 367
367 // Too simplify the algorithm, we always push back rects for start a nd end rect. 368 // Too simplify the algorithm, we always push back rects for start a nd end rect.
368 // Otherwise we'd have to track start / end rects for each individua l geometry 369 // Otherwise we'd have to track start / end rects for each individua l geometry
369 SkRect& bounds = rects.push_back(); 370 rects.push_back();
370 SkRect& startRect = rects.push_back(); 371 rects.push_back();
371 SkRect& endRect = rects.push_back(); 372 rects.push_back();
373 SkRect& bounds = rects[rectOffset++];
374 SkRect& startRect = rects[rectOffset++];
375 SkRect& endRect = rects[rectOffset++];
372 376
373 bool hasStartRect = false; 377 bool hasStartRect = false;
374 // If we are using AA, check to see if we are drawing a partial dash at the start. If so 378 // If we are using AA, check to see if we are drawing a partial dash at the start. If so
375 // draw it separately here and adjust our start point accordingly 379 // draw it separately here and adjust our start point accordingly
376 if (useAA) { 380 if (useAA) {
377 if (args.fPhase > 0 && args.fPhase < args.fIntervals[0]) { 381 if (args.fPhase > 0 && args.fPhase < args.fIntervals[0]) {
378 SkPoint startPts[2]; 382 SkPoint startPts[2];
379 startPts[0] = args.fPtsRot[0]; 383 startPts[0] = args.fPtsRot[0];
380 startPts[1].fY = startPts[0].fY; 384 startPts[1].fY = startPts[0].fY;
381 startPts[1].fX = SkMinScalar(startPts[0].fX + args.fInterval s[0] - args.fPhase, 385 startPts[1].fX = SkMinScalar(startPts[0].fX + args.fInterval s[0] - args.fPhase,
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 switch (cap) { 1252 switch (cap) {
1249 case kRound_DashCap: 1253 case kRound_DashCap:
1250 return DashingCircleEffect::Create(color, edgeType, localMatrix); 1254 return DashingCircleEffect::Create(color, edgeType, localMatrix);
1251 case kNonRound_DashCap: 1255 case kNonRound_DashCap:
1252 return DashingLineEffect::Create(color, edgeType, localMatrix); 1256 return DashingLineEffect::Create(color, edgeType, localMatrix);
1253 default: 1257 default:
1254 SkFAIL("Unexpected dashed cap."); 1258 SkFAIL("Unexpected dashed cap.");
1255 } 1259 }
1256 return NULL; 1260 return NULL;
1257 } 1261 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698