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 "include/core/SkColor.h"
9 #include "include/core/SkPath.h"
10 #include "include/core/SkPathTypes.h"
11 #include "include/core/SkRect.h"
12 #include "include/core/SkScalar.h"
13 #include "include/core/SkTypes.h"
14 #include "src/core/SkBlitter.h"
15 #include "src/core/SkScan.h"
16 #include "tests/Test.h"
17
18 #include <cstdint>
19
20 struct FakeBlitter : public SkBlitter {
FakeBlitterFakeBlitter21 FakeBlitter()
22 : m_blitCount(0) { }
23
blitHFakeBlitter24 void blitH(int x, int y, int width) override {
25 m_blitCount++;
26 }
27
blitAntiHFakeBlitter28 void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override {
29 SkDEBUGFAIL("blitAntiH not implemented");
30 }
31
32 int m_blitCount;
33 };
34
35 // http://code.google.com/p/skia/issues/detail?id=87
36 // Lines which is not clipped by boundary based clipping,
37 // but skipped after tessellation, should be cleared by the blitter.
DEF_TEST(FillPathInverse,reporter)38 DEF_TEST(FillPathInverse, reporter) {
39 FakeBlitter blitter;
40 SkIRect clip;
41 SkPath path;
42 int height = 100;
43 int width = 200;
44 int expected_lines = 5;
45 clip.setLTRB(0, height - expected_lines, width, height);
46 path.moveTo(0.0f, 0.0f)
47 .quadTo(SkIntToScalar(width/2), SkIntToScalar(height),
48 SkIntToScalar(width), 0.0f)
49 .close()
50 .setFillType(SkPathFillType::kInverseWinding);
51 SkScan::FillPath(path, clip, &blitter);
52
53 REPORTER_ASSERT(reporter, blitter.m_blitCount == expected_lines);
54 }
55