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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "sk_tool_utils_flags.h" | 9 #include "sk_tool_utils_flags.h" |
10 | 10 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 227 |
228 for (int y = dst.fTop; y < dst.fBottom; ++y) { | 228 for (int y = dst.fTop; y < dst.fBottom; ++y) { |
229 for (int x = dst.fLeft; x < dst.fRight; ++x) { | 229 for (int x = dst.fLeft; x < dst.fRight; ++x) { |
230 norm.fX = (x + 0.5f - center.fX) / halfSize.fX; | 230 norm.fX = (x + 0.5f - center.fX) / halfSize.fX; |
231 norm.fY = (y + 0.5f - center.fY) / halfSize.fY; | 231 norm.fY = (y + 0.5f - center.fY) / halfSize.fY; |
232 | 232 |
233 SkScalar tmp = norm.fX * norm.fX + norm.fY * norm.fY; | 233 SkScalar tmp = norm.fX * norm.fX + norm.fY * norm.fY; |
234 if (tmp >= 1.0f) { | 234 if (tmp >= 1.0f) { |
235 norm.set(0.0f, 0.0f, 1.0f); | 235 norm.set(0.0f, 0.0f, 1.0f); |
236 } else { | 236 } else { |
237 norm.fZ = sqrt(1.0f - tmp); | 237 norm.fZ = sqrtf(1.0f - tmp); |
238 } | 238 } |
239 | 239 |
240 norm_to_rgb(bm, x, y, norm); | 240 norm_to_rgb(bm, x, y, norm); |
241 } | 241 } |
242 } | 242 } |
243 } | 243 } |
244 | 244 |
245 void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst) { | 245 void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst) { |
246 const SkPoint center = SkPoint::Make(dst.fLeft + (dst.width() / 2.0f), | 246 const SkPoint center = SkPoint::Make(dst.fLeft + (dst.width() / 2.0f), |
247 dst.fTop + (dst.height() / 2.0f)); | 247 dst.fTop + (dst.height() / 2.0f)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 norm = leftUp; | 312 norm = leftUp; |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 norm_to_rgb(bm, x, y, norm); | 316 norm_to_rgb(bm, x, y, norm); |
317 } | 317 } |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 } // namespace sk_tool_utils | 321 } // namespace sk_tool_utils |
OLD | NEW |