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

Side by Side Diff: tests/PathTest.cpp

Issue 1703943003: add interp path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test to error if conics don't match Created 4 years, 10 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/SkPathRef.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 2011 Google Inc. 2 * Copyright 2011 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkGeometry.h" 9 #include "SkGeometry.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 3886 matching lines...) Expand 10 before | Expand all | Expand 10 after
3897 SkPath q; 3897 SkPath q;
3898 q.moveTo(10, 10); 3898 q.moveTo(10, 10);
3899 SkPathPriv::AddGenIDChangeListener(q, new ChangeListener(&changed)); 3899 SkPathPriv::AddGenIDChangeListener(q, new ChangeListener(&changed));
3900 REPORTER_ASSERT(reporter, !changed); 3900 REPORTER_ASSERT(reporter, !changed);
3901 } 3901 }
3902 // q went out of scope. 3902 // q went out of scope.
3903 REPORTER_ASSERT(reporter, changed); 3903 REPORTER_ASSERT(reporter, changed);
3904 } 3904 }
3905 }; 3905 };
3906 3906
3907 static void test_interp(skiatest::Reporter* reporter) {
3908 SkPath p1, p2, out;
3909 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
3910 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
3911 REPORTER_ASSERT(reporter, p1 == out);
3912 REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
3913 REPORTER_ASSERT(reporter, p1 == out);
3914 p1.moveTo(0, 2);
3915 p1.lineTo(0, 4);
3916 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
3917 REPORTER_ASSERT(reporter, !p1.interpolate(p2, 1, &out));
3918 p2.moveTo(6, 0);
3919 p2.lineTo(8, 0);
3920 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
3921 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
3922 REPORTER_ASSERT(reporter, p2 == out);
3923 REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
3924 REPORTER_ASSERT(reporter, p1 == out);
3925 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
3926 REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(3, 1, 4, 2));
3927 p1.reset();
3928 p1.moveTo(4, 4);
3929 p1.conicTo(5, 4, 5, 5, 1 / SkScalarSqrt(2));
3930 p2.reset();
3931 p2.moveTo(4, 2);
3932 p2.conicTo(7, 2, 7, 5, 1 / SkScalarSqrt(2));
3933 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
3934 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
3935 REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(4, 3, 6, 5));
3936 p2.reset();
3937 p2.moveTo(4, 2);
3938 p2.conicTo(6, 3, 6, 5, 1);
3939 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
3940 p2.reset();
3941 p2.moveTo(4, 4);
3942 p2.conicTo(5, 4, 5, 5, 0.5f);
3943 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
3944 }
3945
3946 DEF_TEST(PathInterp, reporter) {
3947 test_interp(reporter);
3948 }
3949
3907 DEF_TEST(PathContains, reporter) { 3950 DEF_TEST(PathContains, reporter) {
3908 test_contains(reporter); 3951 test_contains(reporter);
3909 } 3952 }
3910 3953
3911 DEF_TEST(Paths, reporter) { 3954 DEF_TEST(Paths, reporter) {
3912 test_path_crbug364224(); 3955 test_path_crbug364224();
3913 3956
3914 SkTSize<SkScalar>::Make(3,4); 3957 SkTSize<SkScalar>::Make(3,4);
3915 3958
3916 SkPath p, empty; 3959 SkPath p, empty;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
4054 PathTest_Private::TestPathTo(reporter); 4097 PathTest_Private::TestPathTo(reporter);
4055 PathRefTest_Private::TestPathRef(reporter); 4098 PathRefTest_Private::TestPathRef(reporter);
4056 PathTest_Private::TestPathrefListeners(reporter); 4099 PathTest_Private::TestPathrefListeners(reporter);
4057 test_dump(reporter); 4100 test_dump(reporter);
4058 test_path_crbug389050(reporter); 4101 test_path_crbug389050(reporter);
4059 test_path_crbugskia2820(reporter); 4102 test_path_crbugskia2820(reporter);
4060 test_skbug_3469(reporter); 4103 test_skbug_3469(reporter);
4061 test_skbug_3239(reporter); 4104 test_skbug_3239(reporter);
4062 test_bounds_crbug_513799(reporter); 4105 test_bounds_crbug_513799(reporter);
4063 } 4106 }
OLDNEW
« no previous file with comments | « src/core/SkPathRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698