Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: tests/StrokeTest.cpp

Issue 953383002: fuzzer fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix up width and height in initializer Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkStroke.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPaint.h" 8 #include "SkPaint.h"
9 #include "SkPath.h" 9 #include "SkPath.h"
10 #include "SkRect.h" 10 #include "SkRect.h"
11 #include "SkStroke.h" 11 #include "SkStroke.h"
12 #include "Test.h" 12 #include "Test.h"
13 13
14 static bool equal(const SkRect& a, const SkRect& b) { 14 static bool equal(const SkRect& a, const SkRect& b) {
15 return SkScalarNearlyEqual(a.left(), b.left()) && 15 return SkScalarNearlyEqual(a.left(), b.left()) &&
16 SkScalarNearlyEqual(a.top(), b.top()) && 16 SkScalarNearlyEqual(a.top(), b.top()) &&
17 SkScalarNearlyEqual(a.right(), b.right()) && 17 SkScalarNearlyEqual(a.right(), b.right()) &&
18 SkScalarNearlyEqual(a.bottom(), b.bottom()); 18 SkScalarNearlyEqual(a.bottom(), b.bottom());
19 } 19 }
20 20
21 static void test_strokecubic(skiatest::Reporter* reporter) {
22 uint32_t hexCubicVals[] = {
23 0x424c1086, 0x44bcf0cb, // fX=51.0161362 fY=1511.52478
24 0x424c107c, 0x44bcf0cb, // fX=51.0160980 fY=1511.52478
25 0x424c10c2, 0x44bcf0cb, // fX=51.0163651 fY=1511.52478
26 0x424c1119, 0x44bcf0ca, // fX=51.0166969 fY=1511.52466
27 };
28 SkPoint cubicVals[] = {
29 {51.0161362f, 1511.52478f },
30 {51.0160980f, 1511.52478f },
31 {51.0163651f, 1511.52478f },
32 {51.0166969f, 1511.52466f },
33 };
34 SkPaint paint;
35
36 paint.setStyle(SkPaint::kStroke_Style);
37 paint.setStrokeWidth(0.394537568f);
38 SkPath path, fillPath;
39 path.moveTo(cubicVals[0]);
40 path.cubicTo(cubicVals[1], cubicVals[2], cubicVals[3]);
41 paint.getFillPath(path, &fillPath);
42 path.reset();
43 path.moveTo(SkBits2Float(hexCubicVals[0]), SkBits2Float(hexCubicVals[1]));
44 path.cubicTo(SkBits2Float(hexCubicVals[2]), SkBits2Float(hexCubicVals[3]),
45 SkBits2Float(hexCubicVals[4]), SkBits2Float(hexCubicVals[5]),
46 SkBits2Float(hexCubicVals[6]), SkBits2Float(hexCubicVals[7]));
47 paint.getFillPath(path, &fillPath);
48 }
49
21 static void test_strokerect(skiatest::Reporter* reporter) { 50 static void test_strokerect(skiatest::Reporter* reporter) {
22 const SkScalar width = SkIntToScalar(10); 51 const SkScalar width = SkIntToScalar(10);
23 SkPaint paint; 52 SkPaint paint;
24 53
25 paint.setStyle(SkPaint::kStroke_Style); 54 paint.setStyle(SkPaint::kStroke_Style);
26 paint.setStrokeWidth(width); 55 paint.setStrokeWidth(width);
27 56
28 SkRect r = { 0, 0, SkIntToScalar(200), SkIntToScalar(100) }; 57 SkRect r = { 0, 0, SkIntToScalar(200), SkIntToScalar(100) };
29 58
30 SkRect outer(r); 59 SkRect outer(r);
(...skipping 18 matching lines...) Expand all
49 if (isMiter) { 78 if (isMiter) {
50 SkRect inner(r); 79 SkRect inner(r);
51 inner.inset(width/2, width/2); 80 inner.inset(width/2, width/2);
52 REPORTER_ASSERT(reporter, equal(nested[0], outer)); 81 REPORTER_ASSERT(reporter, equal(nested[0], outer));
53 REPORTER_ASSERT(reporter, equal(nested[1], inner)); 82 REPORTER_ASSERT(reporter, equal(nested[1], inner));
54 } 83 }
55 } 84 }
56 } 85 }
57 86
58 DEF_TEST(Stroke, reporter) { 87 DEF_TEST(Stroke, reporter) {
88 test_strokecubic(reporter);
59 test_strokerect(reporter); 89 test_strokerect(reporter);
60 } 90 }
OLDNEW
« no previous file with comments | « src/core/SkStroke.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698