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

Side by Side Diff: gm/stroke_rect_shader.cpp

Issue 2125663003: Add gm that tests shaded stroked rectangles. (Closed) Base URL: https://skia.googlesource.com/skia.git@fixgmwidth
Patch Set: cleanup Created 4 years, 5 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 | include/core/SkPaint.h » ('j') | include/core/SkPaint.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
robertphillips 2016/07/06 15:01:47 What's up with the naming of this file?
bsalomon 2016/07/06 15:57:53 I don't understand. What is up with it? The unders
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkGradientShader.h"
10
robertphillips 2016/07/06 15:01:47 Are we testing the degenerate rect cases somewhere
bsalomon 2016/07/06 15:57:53 The strokedrect GM tests more varieties of rects +
11 namespace skiagm {
12
robertphillips 2016/07/06 15:01:47 // Draw stroked rects (both AA and nonAA) with all
bsalomon 2016/07/06 15:57:53 Done.
13 DEF_SIMPLE_GM(stroke_rect_shader, canvas, 690, 300) {
14 static constexpr SkRect kRect {0, 0, 100, 100};
15 static constexpr SkPoint kPts[] {{kRect.fLeft, kRect.fTop}, {kRect.fRight, k Rect.fBottom}};
16 static constexpr SkColor kColors[] {SK_ColorRED, SK_ColorBLUE};
17 SkPaint paint;
robertphillips 2016/07/06 15:01:47 What are your thoughts on the style proposal that
bsalomon 2016/07/06 15:57:53 I don't agree with it, but I'm fine abiding by it.
18 auto shader = SkGradientShader::MakeLinear(kPts, kColors, nullptr, 2,
19 SkShader::kClamp_TileMode);
20 paint.setShader(std::move(shader));
21 paint.setStyle(SkPaint::kStroke_Style);
22 // Do a large initial translate so that local coords disagree with device co ords significantly
23 // for the first rect drawn.
robertphillips 2016/07/06 15:01:47 kRect.centerX(), kRect.centerY() ?
bsalomon 2016/07/06 15:57:53 Done.
24 canvas->translate(kRect.width() / 2, kRect.height() / 2);
25 static constexpr SkScalar kPad = 20;
26 for (auto aa : {false, true}) {
27 paint.setAntiAlias(aa);
28 canvas->save();
29
30 static constexpr SkScalar kStrokeWidth = 10;
31 paint.setStrokeWidth(kStrokeWidth);
32
33 paint.setStrokeJoin(SkPaint::kBevel_Join);
34 canvas->drawRect(kRect, paint);
35 canvas->translate(kRect.width() + kPad, 0);
36
37 paint.setStrokeJoin(SkPaint::kMiter_Join);
38 canvas->drawRect(kRect, paint);
39 canvas->translate(kRect.width() + kPad, 0);
40
41 // This miter limit should effectively produce a bevel join.
42 paint.setStrokeMiter(0.01);
43 canvas->drawRect(kRect, paint);
44 canvas->translate(kRect.width() + kPad, 0);
45
robertphillips 2016/07/06 15:01:47 Wrong comment ?
bsalomon 2016/07/06 15:57:53 Done.
46 // This miter limit should effectively produce a bevel join.
47 paint.setStrokeJoin(SkPaint::kRound_Join);
48 canvas->drawRect(kRect, paint);
49 canvas->translate(kRect.width() + kPad, 0);
50
robertphillips 2016/07/06 15:01:47 // Hairlines, make bevel and round joins appear th
bsalomon 2016/07/06 15:57:53 If we are going to test that I think it'd be bette
51 paint.setStrokeWidth(0);
52 canvas->drawRect(kRect, paint);
robertphillips 2016/07/06 15:01:47 Rm this translate ?
bsalomon 2016/07/06 15:57:53 Done.
53 canvas->translate(kRect.width() + kPad, 0);
54
55 canvas->restore();
56 canvas->translate(0, kRect.height() + kPad);
57 }
58 }
59
60 }
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPaint.h » ('j') | include/core/SkPaint.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698