• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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/gm.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/effects/SkDashPathEffect.h"
11 
12 // Reproduces skbug.com/9331, drawing differently in debug and release builds.
13 DEF_SIMPLE_GM(bug9331, canvas, 256, 256) {
14     SkRect clip = {0, 0, 200, 150};
15     {
16         SkPaint paint;
17         paint.setColor(0x44FF0000);
18         canvas->drawRect(clip, paint);
19     }
20 
__anonde74cf3a0102(SkColor color, SkRect clip) 21     auto draw = [&](SkColor color, SkRect clip) {
22         SkScalar intervals[] = { 13, 17 };
23         SkScalar phase = 9;
24 
25         SkPaint paint;
26         paint.setColor(color);
27         paint.setStyle(SkPaint::kStroke_Style);
28         paint.setStrokeWidth(10);
29         paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), phase));
30 
31         canvas->save();
32             canvas->clipRect(clip);
33             canvas->drawRect({50,50, 150,150}, paint);
34         canvas->restore();
35     };
36 
37     draw(0xFF000000, clip);
38     draw(0xFF0000FF, clip.makeOffset(0,150));
39 }
40