OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkAnimTimer.h" | 9 #include "SkAnimTimer.h" |
10 #include "SkView.h" | 10 #include "SkView.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkDrawable.h" | 12 #include "SkDrawable.h" |
13 #include "SkInterpolator.h" | 13 #include "SkInterpolator.h" |
14 #include "SkPictureRecorder.h" | 14 #include "SkPictureRecorder.h" |
15 #include "SkRandom.h" | 15 #include "SkRandom.h" |
| 16 #include "sk_tool_utils.h" |
16 | 17 |
17 const SkRect gUnitSquare = { -1, -1, 1, 1 }; | 18 const SkRect gUnitSquare = { -1, -1, 1, 1 }; |
18 | 19 |
19 static void color_to_floats(SkColor c, SkScalar f[4]) { | 20 static void color_to_floats(SkColor c, SkScalar f[4]) { |
20 f[0] = SkIntToScalar(SkColorGetA(c)); | 21 f[0] = SkIntToScalar(SkColorGetA(c)); |
21 f[1] = SkIntToScalar(SkColorGetR(c)); | 22 f[1] = SkIntToScalar(SkColorGetR(c)); |
22 f[2] = SkIntToScalar(SkColorGetG(c)); | 23 f[2] = SkIntToScalar(SkColorGetG(c)); |
23 f[3] = SkIntToScalar(SkColorGetB(c)); | 24 f[3] = SkIntToScalar(SkColorGetB(c)); |
24 } | 25 } |
25 | 26 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 89 |
89 SkPaint paint; | 90 SkPaint paint; |
90 paint.setAntiAlias(true); | 91 paint.setAntiAlias(true); |
91 | 92 |
92 if (fInterp) { | 93 if (fInterp) { |
93 SkScalar values[5]; | 94 SkScalar values[5]; |
94 SkInterpolator::Result res = fInterp->timeToValues(fTime, values); | 95 SkInterpolator::Result res = fInterp->timeToValues(fTime, values); |
95 fColor = floats_to_color(values); | 96 fColor = floats_to_color(values); |
96 | 97 |
97 canvas->save(); | 98 canvas->save(); |
98 canvas->translate(fR.centerX(), fR.centerY()); | 99 sk_tool_utils::rotate_about(canvas, values[4], fR.centerX(), fR.cent
erY()); |
99 canvas->rotate(values[4]); | |
100 canvas->translate(-fR.centerX(), -fR.centerY()); | |
101 | 100 |
102 switch (res) { | 101 switch (res) { |
103 case SkInterpolator::kFreezeEnd_Result: | 102 case SkInterpolator::kFreezeEnd_Result: |
104 delete fInterp; | 103 delete fInterp; |
105 fInterp = nullptr; | 104 fInterp = nullptr; |
106 break; | 105 break; |
107 default: | 106 default: |
108 break; | 107 break; |
109 } | 108 } |
110 } | 109 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } | 176 } |
178 | 177 |
179 private: | 178 private: |
180 typedef SampleView INHERITED; | 179 typedef SampleView INHERITED; |
181 }; | 180 }; |
182 | 181 |
183 ////////////////////////////////////////////////////////////////////////////// | 182 ////////////////////////////////////////////////////////////////////////////// |
184 | 183 |
185 static SkView* MyFactory() { return new HTView; } | 184 static SkView* MyFactory() { return new HTView; } |
186 static SkViewRegister reg(MyFactory); | 185 static SkViewRegister reg(MyFactory); |
OLD | NEW |