OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 332 |
333 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { | 333 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { |
334 return tiling_->tiling_data_.max_texture_size(); | 334 return tiling_->tiling_data_.max_texture_size(); |
335 } | 335 } |
336 | 336 |
337 void PictureLayerTiling::Reset() { | 337 void PictureLayerTiling::Reset() { |
338 live_tiles_rect_ = gfx::Rect(); | 338 live_tiles_rect_ = gfx::Rect(); |
339 tiles_.clear(); | 339 tiles_.clear(); |
340 } | 340 } |
341 | 341 |
342 namespace { | |
343 | |
344 bool NearlyOne(SkMScalar lhs) { | |
345 return std::abs(lhs-1.0) < std::numeric_limits<float>::epsilon(); | |
346 } | |
347 | |
348 bool NearlyZero(SkMScalar lhs) { | |
349 return std::abs(lhs) < std::numeric_limits<float>::epsilon(); | |
350 } | |
351 | |
352 bool ApproximatelyTranslation(const SkMatrix44& matrix) { | |
353 return | |
354 NearlyOne(matrix.get(0, 0)) && | |
355 NearlyZero(matrix.get(1, 0)) && | |
356 NearlyZero(matrix.get(2, 0)) && | |
357 matrix.get(3, 0) == 0 && | |
358 NearlyZero(matrix.get(0, 1)) && | |
359 NearlyOne(matrix.get(1, 1)) && | |
360 NearlyZero(matrix.get(2, 1)) && | |
361 matrix.get(3, 1) == 0 && | |
362 NearlyZero(matrix.get(0, 2)) && | |
363 NearlyZero(matrix.get(1, 2)) && | |
364 NearlyOne(matrix.get(2, 2)) && | |
365 matrix.get(3, 2) == 0 && | |
366 matrix.get(3, 3) == 1; | |
367 } | |
368 | |
369 } // namespace | |
370 | |
371 void PictureLayerTiling::UpdateTilePriorities( | 342 void PictureLayerTiling::UpdateTilePriorities( |
372 WhichTree tree, | 343 WhichTree tree, |
373 gfx::Size device_viewport, | 344 gfx::Size device_viewport, |
374 gfx::Rect viewport_in_layer_space, | 345 gfx::Rect viewport_in_layer_space, |
375 gfx::Rect visible_layer_rect, | 346 gfx::Rect visible_layer_rect, |
376 gfx::Size last_layer_bounds, | 347 gfx::Size last_layer_bounds, |
377 gfx::Size current_layer_bounds, | 348 gfx::Size current_layer_bounds, |
378 float last_layer_contents_scale, | 349 float last_layer_contents_scale, |
379 float current_layer_contents_scale, | 350 float current_layer_contents_scale, |
380 const gfx::Transform& last_screen_transform, | 351 const gfx::Transform& last_screen_transform, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 last_layer_bounds == current_layer_bounds) { | 388 last_layer_bounds == current_layer_bounds) { |
418 time_delta = | 389 time_delta = |
419 current_frame_time_in_seconds - last_impl_frame_time_in_seconds_; | 390 current_frame_time_in_seconds - last_impl_frame_time_in_seconds_; |
420 } | 391 } |
421 | 392 |
422 gfx::Rect view_rect(device_viewport); | 393 gfx::Rect view_rect(device_viewport); |
423 float current_scale = current_layer_contents_scale / contents_scale_; | 394 float current_scale = current_layer_contents_scale / contents_scale_; |
424 float last_scale = last_layer_contents_scale / contents_scale_; | 395 float last_scale = last_layer_contents_scale / contents_scale_; |
425 | 396 |
426 // Fast path tile priority calculation when both transforms are translations. | 397 // Fast path tile priority calculation when both transforms are translations. |
427 if (ApproximatelyTranslation(last_screen_transform.matrix()) && | 398 if (MathUtil::IsApproximatelyPureTranslation( |
428 ApproximatelyTranslation(current_screen_transform.matrix())) { | 399 last_screen_transform, std::numeric_limits<float>::epsilon()) && |
| 400 MathUtil::IsApproximatelyPureTranslation( |
| 401 current_screen_transform, std::numeric_limits<float>::epsilon())) { |
429 gfx::Vector2dF current_offset( | 402 gfx::Vector2dF current_offset( |
430 current_screen_transform.matrix().get(0, 3), | 403 current_screen_transform.matrix().get(0, 3), |
431 current_screen_transform.matrix().get(1, 3)); | 404 current_screen_transform.matrix().get(1, 3)); |
432 gfx::Vector2dF last_offset( | 405 gfx::Vector2dF last_offset( |
433 last_screen_transform.matrix().get(0, 3), | 406 last_screen_transform.matrix().get(0, 3), |
434 last_screen_transform.matrix().get(1, 3)); | 407 last_screen_transform.matrix().get(1, 3)); |
435 | 408 |
436 for (TilingData::Iterator iter(&tiling_data_, interest_rect); | 409 for (TilingData::Iterator iter(&tiling_data_, interest_rect); |
437 iter; ++iter) { | 410 iter; ++iter) { |
438 TileMap::iterator find = tiles_.find(iter.index()); | 411 TileMap::iterator find = tiles_.find(iter.index()); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 | 761 |
789 // If our delta is less then our event distance, we're done. | 762 // If our delta is less then our event distance, we're done. |
790 if (delta < event.distance) | 763 if (delta < event.distance) |
791 break; | 764 break; |
792 } | 765 } |
793 | 766 |
794 return gfx::Rect(origin_x, origin_y, width, height); | 767 return gfx::Rect(origin_x, origin_y, width, height); |
795 } | 768 } |
796 | 769 |
797 } // namespace cc | 770 } // namespace cc |
OLD | NEW |