blob: fc6dc8a2bb074d024585b5c30aab620d27dbdab6 [file] [log] [blame]
Mike Kleinf8153012019-08-12 13:11:26 -04001/*
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.
13DEF_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
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}