aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/bug5252.cpp
blob: 981aab5b5aa0e58ecb025091bdb2ef5af1eb4d05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#include "gm.h"
#include "SkCanvas.h"
#include "SkRect.h"
#include "SkPath.h"

DEF_SIMPLE_GM(bug5252, canvas, 500, 500) {
	canvas->translate(SkIntToScalar(10), SkIntToScalar(20));

	SkPath clip1;
	clip1.addOval(SkRect::MakeWH(225, 200));
	canvas->clipPath(clip1); // bug

	SkPath clip2;
	clip2.addRect(SkRect::MakeWH(220, 200));
	//canvas->clipPath(clip2); // ok

	SkPaint pa;
	pa.setStyle(SkPaint::kStroke_Style);
	pa.setAntiAlias(true);
	pa.setStrokeWidth(1.0f);
	for (int i = 0; i < 15; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			SkAutoCanvasRestore acs(canvas, true);

			canvas->translate(i * 15.f, j * 20.f);
			canvas->drawRect(SkRect::MakeXYWH(5, 5, 10, 15),pa);
			SkPath path;
			path.moveTo(6, 6);
			path.cubicTo(14, 10, 13, 12, 10, 12);
			path.cubicTo(7, 15, 8, 17, 14, 18);
			canvas->drawPath(path, pa);
		}
	}
}