| 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 | 9 |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone() const { | 24 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone() const { |
| 25 return make_scoped_ptr(new PictureLayerTiling(*this)); | 25 return make_scoped_ptr(new PictureLayerTiling(*this)); |
| 26 } | 26 } |
| 27 | 27 |
| 28 PictureLayerTiling::PictureLayerTiling(float contents_scale) | 28 PictureLayerTiling::PictureLayerTiling(float contents_scale) |
| 29 : client_(NULL), | 29 : client_(NULL), |
| 30 contents_scale_(contents_scale), | 30 contents_scale_(contents_scale), |
| 31 tiling_data_(gfx::Size(), gfx::Size(), true), | 31 tiling_data_(gfx::Size(), gfx::Size(), true), |
| 32 resolution_(NON_IDEAL_RESOLUTION), | 32 resolution_(NON_IDEAL_RESOLUTION), |
| 33 last_source_frame_number_(0), | 33 last_source_frame_number_(0), |
| 34 last_impl_frame_time_(0) { | 34 last_impl_frame_time_(0.0) { |
| 35 } | 35 } |
| 36 | 36 |
| 37 PictureLayerTiling::~PictureLayerTiling() { | 37 PictureLayerTiling::~PictureLayerTiling() { |
| 38 } | 38 } |
| 39 | 39 |
| 40 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { | 40 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { |
| 41 client_ = client; | 41 client_ = client; |
| 42 } | 42 } |
| 43 | 43 |
| 44 gfx::Rect PictureLayerTiling::ContentRect() const { | 44 gfx::Rect PictureLayerTiling::ContentRect() const { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 WhichTree tree, | 342 WhichTree tree, |
| 343 gfx::Size device_viewport, | 343 gfx::Size device_viewport, |
| 344 const gfx::RectF& viewport_in_layer_space, | 344 const gfx::RectF& viewport_in_layer_space, |
| 345 const gfx::RectF& visible_layer_rect, | 345 const gfx::RectF& visible_layer_rect, |
| 346 gfx::Size last_layer_bounds, | 346 gfx::Size last_layer_bounds, |
| 347 gfx::Size current_layer_bounds, | 347 gfx::Size current_layer_bounds, |
| 348 float last_layer_contents_scale, | 348 float last_layer_contents_scale, |
| 349 float current_layer_contents_scale, | 349 float current_layer_contents_scale, |
| 350 const gfx::Transform& last_screen_transform, | 350 const gfx::Transform& last_screen_transform, |
| 351 const gfx::Transform& current_screen_transform, | 351 const gfx::Transform& current_screen_transform, |
| 352 int current_source_frame_number, | |
| 353 double current_frame_time, | 352 double current_frame_time, |
| 354 bool store_screen_space_quads_on_tiles, | 353 bool store_screen_space_quads_on_tiles, |
| 355 size_t max_tiles_for_interest_area) { | 354 size_t max_tiles_for_interest_area) { |
| 356 if (ContentRect().IsEmpty()) | 355 if (ContentRect().IsEmpty()) |
| 357 return; | 356 return; |
| 358 | 357 |
| 359 bool first_update_in_new_source_frame = | |
| 360 current_source_frame_number != last_source_frame_number_; | |
| 361 | |
| 362 bool first_update_in_new_impl_frame = | |
| 363 current_frame_time != last_impl_frame_time_; | |
| 364 | |
| 365 // In pending tree, this is always called. We update priorities: | |
| 366 // - Immediately after a commit (first_update_in_new_source_frame). | |
| 367 // - On animation ticks after the first frame in the tree | |
| 368 // (first_update_in_new_impl_frame). | |
| 369 // In active tree, this is only called during draw. We update priorities: | |
| 370 // - On draw if properties were not already computed by the pending tree | |
| 371 // and activated for the frame (first_update_in_new_impl_frame). | |
| 372 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) | |
| 373 return; | |
| 374 | |
| 375 double time_delta = 0; | 358 double time_delta = 0; |
| 376 if (last_impl_frame_time_ != 0 && last_layer_bounds == current_layer_bounds) | 359 if (last_impl_frame_time_ != 0 && last_layer_bounds == current_layer_bounds) |
| 377 time_delta = current_frame_time - last_impl_frame_time_; | 360 time_delta = current_frame_time - last_impl_frame_time_; |
| 378 | 361 |
| 379 gfx::Rect viewport_in_content_space = | 362 gfx::Rect viewport_in_content_space = |
| 380 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, | 363 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, |
| 381 contents_scale_)); | 364 contents_scale_)); |
| 382 gfx::Rect visible_content_rect = | 365 gfx::Rect visible_content_rect = |
| 383 gfx::ToEnclosingRect(gfx::ScaleRect(visible_layer_rect, | 366 gfx::ToEnclosingRect(gfx::ScaleRect(visible_layer_rect, |
| 384 contents_scale_)); | 367 contents_scale_)); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 bool clipped; | 482 bool clipped; |
| 500 priority.set_current_screen_quad( | 483 priority.set_current_screen_quad( |
| 501 MathUtil::MapQuad(current_screen_transform, | 484 MathUtil::MapQuad(current_screen_transform, |
| 502 gfx::QuadF(current_layer_content_rect), | 485 gfx::QuadF(current_layer_content_rect), |
| 503 &clipped)); | 486 &clipped)); |
| 504 } | 487 } |
| 505 tile->SetPriority(tree, priority); | 488 tile->SetPriority(tree, priority); |
| 506 } | 489 } |
| 507 } | 490 } |
| 508 | 491 |
| 509 last_source_frame_number_ = current_source_frame_number; | |
| 510 last_impl_frame_time_ = current_frame_time; | 492 last_impl_frame_time_ = current_frame_time; |
| 511 } | 493 } |
| 512 | 494 |
| 513 void PictureLayerTiling::DidBecomeActive() { | 495 void PictureLayerTiling::DidBecomeActive() { |
| 514 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 496 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 515 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); | 497 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); |
| 516 it->second->SetPriority(PENDING_TREE, TilePriority()); | 498 it->second->SetPriority(PENDING_TREE, TilePriority()); |
| 517 | 499 |
| 518 // Tile holds a ref onto a picture pile. If the tile never gets invalidated | 500 // Tile holds a ref onto a picture pile. If the tile never gets invalidated |
| 519 // and recreated, then that picture pile ref could exist indefinitely. To | 501 // and recreated, then that picture pile ref could exist indefinitely. To |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 635 |
| 654 // If our delta is less then our event distance, we're done. | 636 // If our delta is less then our event distance, we're done. |
| 655 if (delta < event.distance) | 637 if (delta < event.distance) |
| 656 break; | 638 break; |
| 657 } | 639 } |
| 658 | 640 |
| 659 return gfx::Rect(origin_x, origin_y, width, height); | 641 return gfx::Rect(origin_x, origin_y, width, height); |
| 660 } | 642 } |
| 661 | 643 |
| 662 } // namespace cc | 644 } // namespace cc |
| OLD | NEW |