1 /*
2 * Copyright 2010 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 "Test.h"
9 #include "TestClassDef.h"
10 #include "SkRegion.h"
11 #include "SkPath.h"
12 #include "SkScan.h"
13 #include "SkBlitter.h"
14
15 struct FakeBlitter : public SkBlitter {
FakeBlitterFakeBlitter16 FakeBlitter()
17 : m_blitCount(0)
18 {}
19
blitHFakeBlitter20 virtual void blitH(int x, int y, int width) {
21 m_blitCount++;
22 }
23
24 int m_blitCount;
25 };
26
27 // http://code.google.com/p/skia/issues/detail?id=87
28 // Lines which is not clipped by boundary based clipping,
29 // but skipped after tessellation, should be cleared by the blitter.
DEF_TEST(FillPathInverse,reporter)30 DEF_TEST(FillPathInverse, reporter) {
31 FakeBlitter blitter;
32 SkIRect clip;
33 SkPath path;
34 int height = 100;
35 int width = 200;
36 int expected_lines = 5;
37 clip.set(0, height - expected_lines, width, height);
38 path.moveTo(0.0f, 0.0f);
39 path.quadTo(SkIntToScalar(width/2), SkIntToScalar(height),
40 SkIntToScalar(width), 0.0f);
41 path.close();
42 path.setFillType(SkPath::kInverseWinding_FillType);
43 SkScan::FillPath(path, clip, &blitter);
44
45 REPORTER_ASSERT(reporter, blitter.m_blitCount == expected_lines);
46 }
47