1/*
2 * Copyright (C) 2010 The Chromium Authors. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "Test.h"
18#include "SkRegion.h"
19#include "SkPath.h"
20#include "SkScan.h"
21#include "SkBlitter.h"
22
23namespace {
24
25struct FakeBlitter : public SkBlitter {
26  FakeBlitter()
27      : m_blitCount(0)
28  {}
29
30  virtual void blitH(int x, int y, int width) {
31    m_blitCount++;
32  }
33
34  int m_blitCount;
35};
36
37}
38
39// http://code.google.com/p/skia/issues/detail?id=87
40// Lines which is not clipped by boundary based clipping,
41// but skipped after tessellation, should be cleared by the blitter.
42static void TestFillPathInverse(skiatest::Reporter* reporter) {
43  FakeBlitter blitter;
44  SkRegion clip;
45  SkPath path;
46  int height = 100;
47  int width  = 200;
48  int expected_lines = 5;
49  clip.setRect(0, height - expected_lines, width, height);
50  path.moveTo(0.0, 0.0);
51  path.quadTo(width/2, height, width, 0.0);
52  path.close();
53  path.setFillType(SkPath::kInverseWinding_FillType);
54  SkScan::FillPath(path, clip, &blitter);
55
56  REPORTER_ASSERT(reporter, blitter.m_blitCount == expected_lines);
57}
58
59#include "TestClassDef.h"
60DEFINE_TESTCLASS("FillPath", FillPathTestClass, TestFillPathInverse)
61