bug5252.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2016 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 "gm/gm.h"
  8. #include "include/core/SkCanvas.h"
  9. #include "include/core/SkPaint.h"
  10. #include "include/core/SkPath.h"
  11. #include "include/core/SkRect.h"
  12. #include "include/core/SkScalar.h"
  13. DEF_SIMPLE_GM(bug5252, canvas, 500, 500) {
  14. canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
  15. SkPath clip1;
  16. clip1.addOval(SkRect::MakeWH(225, 200));
  17. canvas->clipPath(clip1); // bug
  18. SkPath clip2;
  19. clip2.addRect(SkRect::MakeWH(220, 200));
  20. //canvas->clipPath(clip2); // ok
  21. SkPaint pa;
  22. pa.setStyle(SkPaint::kStroke_Style);
  23. pa.setAntiAlias(true);
  24. pa.setStrokeWidth(1.0f);
  25. for (int i = 0; i < 15; i++)
  26. {
  27. for (int j = 0; j < 10; j++)
  28. {
  29. SkAutoCanvasRestore acs(canvas, true);
  30. canvas->translate(i * 15.f, j * 20.f);
  31. canvas->drawRect(SkRect::MakeXYWH(5, 5, 10, 15),pa);
  32. SkPath path;
  33. path.moveTo(6, 6);
  34. path.cubicTo(14, 10, 13, 12, 10, 12);
  35. path.cubicTo(7, 15, 8, 17, 14, 18);
  36. canvas->drawPath(path, pa);
  37. }
  38. }
  39. }