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

Side by Side Diff: gm/dashing.cpp

Issue 326103002: Use vertex attributes for dash effect in gpu (Closed) Base URL: https://skia.googlesource.com/skia.git@dashPlumb2
Patch Set: Float fix Created 6 years, 6 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 | « expectations/gm/ignored-tests.txt ('k') | include/core/SkStrokeRec.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 2012 Google Inc. 2 * Copyright 2012 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 "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } gData[] = { 55 } gData[] = {
56 { 1, 1 }, 56 { 1, 1 },
57 { 4, 1 }, 57 { 4, 1 },
58 }; 58 };
59 59
60 SkPaint paint; 60 SkPaint paint;
61 paint.setStyle(SkPaint::kStroke_Style); 61 paint.setStyle(SkPaint::kStroke_Style);
62 62
63 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); 63 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
64 canvas->translate(0, SK_ScalarHalf); 64 canvas->translate(0, SK_ScalarHalf);
65
66 for (int width = 0; width <= 2; ++width) { 65 for (int width = 0; width <= 2; ++width) {
67 for (size_t data = 0; data < SK_ARRAY_COUNT(gData); ++data) { 66 for (size_t data = 0; data < SK_ARRAY_COUNT(gData); ++data) {
68 for (int aa = 0; aa <= 1; ++aa) { 67 for (int aa = 0; aa <= 1; ++aa) {
69 int w = width * width * width; 68 int w = width * width * width;
70 paint.setAntiAlias(SkToBool(aa)); 69 paint.setAntiAlias(SkToBool(aa));
71 paint.setStrokeWidth(SkIntToScalar(w)); 70 paint.setStrokeWidth(SkIntToScalar(w));
72 71
73 int scale = w ? w : 1; 72 int scale = w ? w : 1;
74 73
75 drawline(canvas, gData[data].fOnInterval * scale, 74 drawline(canvas, gData[data].fOnInterval * scale,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 226 }
228 227
229 p.setAntiAlias(true); 228 p.setAntiAlias(true);
230 229
231 for (int x = 0; x < 100; x += 14*strokeWidth) { 230 for (int x = 0; x < 100; x += 14*strokeWidth) {
232 pts[0].set(SkIntToScalar(x), 0); 231 pts[0].set(SkIntToScalar(x), 0);
233 pts[1].set(SkIntToScalar(x), lineLength); 232 pts[1].set(SkIntToScalar(x), lineLength);
234 233
235 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p); 234 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p);
236 } 235 }
237
238 } 236 }
239 237
240 virtual void onDraw(SkCanvas* canvas) { 238 virtual void onDraw(SkCanvas* canvas) {
241 // 1on/1off 1x1 squares with phase of 0 - points fastpath 239 // 1on/1off 1x1 squares with phase of 0 - points fastpath
242 canvas->save(); 240 canvas->save();
243 canvas->translate(2, 0); 241 canvas->translate(2, 0);
244 this->drawDashedLines(canvas, 100, 0, SK_Scalar1, 1, false); 242 this->drawDashedLines(canvas, 100, 0, SK_Scalar1, 1, false);
245 canvas->restore(); 243 canvas->restore();
246 244
247 // 1on/1off 1x1 squares with phase of .5 - rects fastpath (due to partia l squares) 245 // 1on/1off 1x1 squares with phase of .5 - rects fastpath (due to partia l squares)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 canvas->translate(0, SkIntToScalar(20)); 363 canvas->translate(0, SkIntToScalar(20));
366 } 364 }
367 } 365 }
368 } 366 }
369 } 367 }
370 368
371 for (int aa = 0; aa <= 1; ++aa) { 369 for (int aa = 0; aa <= 1; ++aa) {
372 paint.setAntiAlias(SkToBool(aa)); 370 paint.setAntiAlias(SkToBool(aa));
373 paint.setStrokeWidth(8.f); 371 paint.setStrokeWidth(8.f);
374 paint.setStrokeCap(SkPaint::kSquare_Cap); 372 paint.setStrokeCap(SkPaint::kSquare_Cap);
375
376 // Single dash element that is cut off at start and end 373 // Single dash element that is cut off at start and end
377 drawline(canvas, 32, 16, paint, 20.f, 0, 5.f); 374 drawline(canvas, 32, 16, paint, 20.f, 0, 5.f);
378 canvas->translate(0, SkIntToScalar(20)); 375 canvas->translate(0, SkIntToScalar(20));
379 376
380 // Two dash elements where each one is cut off at beginning and end respectively 377 // Two dash elements where each one is cut off at beginning and end respectively
381 drawline(canvas, 32, 16, paint, 56.f, 0, 5.f); 378 drawline(canvas, 32, 16, paint, 56.f, 0, 5.f);
382 canvas->translate(0, SkIntToScalar(20)); 379 canvas->translate(0, SkIntToScalar(20));
383 380
384 // Many dash elements where first and last are cut off at beginning and end respectively 381 // Many dash elements where first and last are cut off at beginning and end respectively
385 drawline(canvas, 32, 16, paint, 584.f, 0, 5.f); 382 drawline(canvas, 32, 16, paint, 584.f, 0, 5.f);
(...skipping 15 matching lines...) Expand all
401 398
402 static skiagm::GM* F0(void*) { return new DashingGM; } 399 static skiagm::GM* F0(void*) { return new DashingGM; }
403 static skiagm::GM* F1(void*) { return new Dashing2GM; } 400 static skiagm::GM* F1(void*) { return new Dashing2GM; }
404 static skiagm::GM* F2(void*) { return new Dashing3GM; } 401 static skiagm::GM* F2(void*) { return new Dashing3GM; }
405 static skiagm::GM* F3(void*) { return new Dashing4GM; } 402 static skiagm::GM* F3(void*) { return new Dashing4GM; }
406 403
407 static skiagm::GMRegistry gR0(F0); 404 static skiagm::GMRegistry gR0(F0);
408 static skiagm::GMRegistry gR1(F1); 405 static skiagm::GMRegistry gR1(F1);
409 static skiagm::GMRegistry gR2(F2); 406 static skiagm::GMRegistry gR2(F2);
410 static skiagm::GMRegistry gR3(F3); 407 static skiagm::GMRegistry gR3(F3);
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | include/core/SkStrokeRec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698