180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2010 Google Inc.
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "Test.h"
9910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger#include "TestClassDef.h"
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkRegion.h"
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkPath.h"
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkScan.h"
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkBlitter.h"
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct FakeBlitter : public SkBlitter {
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  FakeBlitter()
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru      : m_blitCount(0)
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  {}
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  virtual void blitH(int x, int y, int width) {
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    m_blitCount++;
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  }
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  int m_blitCount;
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// http://code.google.com/p/skia/issues/detail?id=87
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// Lines which is not clipped by boundary based clipping,
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// but skipped after tessellation, should be cleared by the blitter.
30910f694aefb0b671dd8522a9afe9b6be645701c1Derek SollenbergerDEF_TEST(FillPathInverse, reporter) {
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  FakeBlitter blitter;
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  SkIRect clip;
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  SkPath path;
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  int height = 100;
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  int width  = 200;
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  int expected_lines = 5;
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  clip.set(0, height - expected_lines, width, height);
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  path.moveTo(0.0f, 0.0f);
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  path.quadTo(SkIntToScalar(width/2), SkIntToScalar(height),
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru              SkIntToScalar(width), 0.0f);
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  path.close();
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  path.setFillType(SkPath::kInverseWinding_FillType);
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  SkScan::FillPath(path, clip, &blitter);
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru  REPORTER_ASSERT(reporter, blitter.m_blitCount == expected_lines);
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
47