FillPathTest.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include "include/core/SkPath.h"
  8. #include "include/core/SkRegion.h"
  9. #include "src/core/SkBlitter.h"
  10. #include "src/core/SkScan.h"
  11. #include "tests/Test.h"
  12. struct FakeBlitter : public SkBlitter {
  13. FakeBlitter()
  14. : m_blitCount(0) { }
  15. void blitH(int x, int y, int width) override {
  16. m_blitCount++;
  17. }
  18. void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override {
  19. SkDEBUGFAIL("blitAntiH not implemented");
  20. }
  21. int m_blitCount;
  22. };
  23. // http://code.google.com/p/skia/issues/detail?id=87
  24. // Lines which is not clipped by boundary based clipping,
  25. // but skipped after tessellation, should be cleared by the blitter.
  26. DEF_TEST(FillPathInverse, reporter) {
  27. FakeBlitter blitter;
  28. SkIRect clip;
  29. SkPath path;
  30. int height = 100;
  31. int width = 200;
  32. int expected_lines = 5;
  33. clip.set(0, height - expected_lines, width, height);
  34. path.moveTo(0.0f, 0.0f)
  35. .quadTo(SkIntToScalar(width/2), SkIntToScalar(height),
  36. SkIntToScalar(width), 0.0f)
  37. .close()
  38. .setFillType(SkPath::kInverseWinding_FillType);
  39. SkScan::FillPath(path, clip, &blitter);
  40. REPORTER_ASSERT(reporter, blitter.m_blitCount == expected_lines);
  41. }