blob: f0556c278fc45f70733a60a98e7bedf918f81a74 [file] [log] [blame]
reed@google.comdceecc72012-02-23 19:20:19 +00001/*
2 * Copyright 2012 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 "Test.h"
9#include "SkBitmap.h"
10#include "SkCanvas.h"
11
12static SkCanvas* create(SkBitmap::Config config, int w, int h, int rb,
13 void* addr = NULL) {
14 SkBitmap bm;
15 bm.setConfig(config, w, h, rb);
16 if (addr) {
17 bm.setPixels(addr);
18 } else {
19 bm.allocPixels();
20 }
21 return new SkCanvas(bm);
22}
23
mike@reedtribe.org6093e652012-04-14 12:55:17 +000024static SkCanvas* new_canvas(int w, int h) {
25 return create(SkBitmap::kARGB_8888_Config, w, h, 0, NULL);
26}
27
28static void test_bug533(skiatest::Reporter* reporter) {
29#ifdef SK_SCALAR_IS_FLOAT
30 /*
31 http://code.google.com/p/skia/issues/detail?id=533
32 This particular test/bug only applies to the float case, where the
33 coordinates are very large.
34 */
35 SkPath path;
36 path.moveTo(64, 3);
37 path.quadTo(-329936, -100000000, 1153, 330003);
38
39 SkPaint paint;
40 paint.setAntiAlias(true);
41
42 SkAutoTUnref<SkCanvas> canvas(new_canvas(640, 480));
43 canvas.get()->drawPath(path, paint);
44#endif
45}
46
reed@google.comdceecc72012-02-23 19:20:19 +000047// we used to assert if the bounds of the device (clip) was larger than 32K
48// even when the path itself was smaller. We just draw and hope in the debug
49// version to not assert.
50static void test_giantaa(skiatest::Reporter* reporter) {
51 const int W = 400;
52 const int H = 400;
mike@reedtribe.org6093e652012-04-14 12:55:17 +000053 SkAutoTUnref<SkCanvas> canvas(new_canvas(33000, 10));
54 canvas.get()->clear(0);
reed@google.comdceecc72012-02-23 19:20:19 +000055
56 SkPaint paint;
57 paint.setAntiAlias(true);
58 SkPath path;
59 path.addOval(SkRect::MakeXYWH(-10, -10, 20 + W, 20 + H));
mike@reedtribe.org6093e652012-04-14 12:55:17 +000060 canvas.get()->drawPath(path, paint);
reed@google.comdceecc72012-02-23 19:20:19 +000061}
62
63static void TestDrawPath(skiatest::Reporter* reporter) {
64 test_giantaa(reporter);
mike@reedtribe.org6093e652012-04-14 12:55:17 +000065 test_bug533(reporter);
reed@google.comdceecc72012-02-23 19:20:19 +000066}
67
68#include "TestClassDef.h"
69DEFINE_TESTCLASS("DrawPath", TestDrawPathClass, TestDrawPath)