Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2014 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 "SkInterpolator.h" | |
| 9 | |
| 10 #include "Test.h" | |
| 11 | |
| 12 static SkScalar* iset(SkScalar array[3], int a, int b, int c) { | |
| 13 array[0] = SkIntToScalar(a); | |
| 14 array[1] = SkIntToScalar(b); | |
| 15 array[2] = SkIntToScalar(c); | |
| 16 return array; | |
| 17 } | |
| 18 | |
| 19 DEF_TEST(Interpolator, reporter) { | |
| 20 SkInterpolator inter(3, 2); | |
| 21 SkScalar v1[3], v2[3], v[3]; | |
| 22 //SkScalar vv[3]; | |
| 23 SkInterpolator::Result result; | |
| 24 | |
| 25 inter.setKeyFrame(0, 100, iset(v1, 10, 20, 30), 0); | |
| 26 inter.setKeyFrame(1, 200, iset(v2, 110, 220, 330)); | |
| 27 | |
| 28 result = inter.timeToValues(0, v); | |
| 29 REPORTER_ASSERT(reporter, result == SkInterpolator::kFreezeStart_Result); | |
| 30 REPORTER_ASSERT(reporter, memcmp(v, v1, sizeof(v)) == 0); | |
| 31 | |
| 32 result = inter.timeToValues(99, v); | |
| 33 REPORTER_ASSERT(reporter, result == SkInterpolator::kFreezeStart_Result); | |
| 34 REPORTER_ASSERT(reporter, memcmp(v, v1, sizeof(v)) == 0); | |
| 35 | |
| 36 result = inter.timeToValues(100, v); | |
| 37 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result); | |
| 38 REPORTER_ASSERT(reporter, memcmp(v, v1, sizeof(v)) == 0); | |
| 39 | |
| 40 result = inter.timeToValues(200, v); | |
| 41 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result); | |
| 42 REPORTER_ASSERT(reporter, memcmp(v, v2, sizeof(v)) == 0); | |
| 43 | |
| 44 result = inter.timeToValues(201, v); | |
| 45 REPORTER_ASSERT(reporter, result == SkInterpolator::kFreezeEnd_Result); | |
| 46 REPORTER_ASSERT(reporter, memcmp(v, v2, sizeof(v)) == 0); | |
| 47 | |
| 48 result = inter.timeToValues(150, v); | |
| 49 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result); | |
| 50 //REPORTER_ASSERT(reporter, memcmp(v, iset(vv, 60, 120, 180), sizeof(v)) == 0); | |
|
mtklein
2014/06/25 20:12:39
Interesting.
Maybe move this all down together wi
tfarina
2014/06/25 20:20:04
Done.
| |
| 51 | |
| 52 result = inter.timeToValues(125, v); | |
| 53 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result); | |
| 54 result = inter.timeToValues(175, v); | |
| 55 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result); | |
| 56 } | |
| OLD | NEW |