| 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/picture_layer_impl.h" | 5 #include "cc/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "cc/append_quads_data.h" | 8 #include "cc/append_quads_data.h" |
| 9 #include "cc/checkerboard_draw_quad.h" | 9 #include "cc/checkerboard_draw_quad.h" |
| 10 #include "cc/debug_border_draw_quad.h" | 10 #include "cc/debug_border_draw_quad.h" |
| 11 #include "cc/debug_colors.h" | 11 #include "cc/debug_colors.h" |
| 12 #include "cc/layer_tree_impl.h" | 12 #include "cc/layer_tree_impl.h" |
| 13 #include "cc/math_util.h" | 13 #include "cc/math_util.h" |
| 14 #include "cc/quad_sink.h" | 14 #include "cc/quad_sink.h" |
| 15 #include "cc/solid_color_draw_quad.h" | 15 #include "cc/solid_color_draw_quad.h" |
| 16 #include "cc/tile_draw_quad.h" | 16 #include "cc/tile_draw_quad.h" |
| 17 #include "ui/gfx/quad_f.h" | 17 #include "ui/gfx/quad_f.h" |
| 18 #include "ui/gfx/rect_conversions.h" | 18 #include "ui/gfx/rect_conversions.h" |
| 19 #include "ui/gfx/size_conversions.h" | 19 #include "ui/gfx/size_conversions.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 const float kMaxScaleRatioDuringPinch = 2.0f; | 22 const float kMaxScaleRatioDuringPinch = 2.0f; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace cc { | 25 namespace cc { |
| 26 | 26 |
| 27 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) | 27 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) |
| 28 : LayerImpl(treeImpl, id), | 28 : LayerImpl(treeImpl, id), |
| 29 pile_(PicturePileImpl::Create()), | 29 pile_(PicturePileImpl::Create()), |
| 30 last_update_time_(0), | 30 last_source_frame_number_(0), |
| 31 last_impl_frame_time_(0), |
| 31 last_content_scale_(0), | 32 last_content_scale_(0), |
| 32 ideal_contents_scale_(0), | 33 ideal_contents_scale_(0), |
| 33 is_mask_(false) { | 34 is_mask_(false) { |
| 34 } | 35 } |
| 35 | 36 |
| 36 PictureLayerImpl::~PictureLayerImpl() { | 37 PictureLayerImpl::~PictureLayerImpl() { |
| 37 } | 38 } |
| 38 | 39 |
| 39 const char* PictureLayerImpl::layerTypeAsString() const { | 40 const char* PictureLayerImpl::layerTypeAsString() const { |
| 40 return "PictureLayer"; | 41 return "PictureLayer"; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 59 } | 60 } |
| 60 | 61 |
| 61 void PictureLayerImpl::pushPropertiesTo(LayerImpl* base_layer) { | 62 void PictureLayerImpl::pushPropertiesTo(LayerImpl* base_layer) { |
| 62 LayerImpl::pushPropertiesTo(base_layer); | 63 LayerImpl::pushPropertiesTo(base_layer); |
| 63 | 64 |
| 64 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); | 65 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); |
| 65 | 66 |
| 66 layer_impl->SetIsMask(is_mask_); | 67 layer_impl->SetIsMask(is_mask_); |
| 67 layer_impl->TransferTilingSet(tilings_.Pass()); | 68 layer_impl->TransferTilingSet(tilings_.Pass()); |
| 68 layer_impl->pile_ = pile_; | 69 layer_impl->pile_ = pile_; |
| 70 // Sync over the last source frame number so the active tree does not respond |
| 71 // to the source frame number changing in its tree. |
| 72 layer_impl->last_source_frame_number_ = last_source_frame_number_; |
| 73 layer_impl->last_impl_frame_time_ = last_impl_frame_time_; |
| 69 pile_ = PicturePileImpl::Create(); | 74 pile_ = PicturePileImpl::Create(); |
| 70 pile_->set_slow_down_raster_scale_factor( | 75 pile_->set_slow_down_raster_scale_factor( |
| 71 layerTreeImpl()->debug_state().slowDownRasterScaleFactor); | 76 layerTreeImpl()->debug_state().slowDownRasterScaleFactor); |
| 72 } | 77 } |
| 73 | 78 |
| 74 | 79 |
| 75 void PictureLayerImpl::appendQuads(QuadSink& quadSink, | 80 void PictureLayerImpl::appendQuads(QuadSink& quadSink, |
| 76 AppendQuadsData& appendQuadsData) { | 81 AppendQuadsData& appendQuadsData) { |
| 77 const gfx::Rect& rect = visibleContentRect(); | 82 const gfx::Rect& rect = visibleContentRect(); |
| 78 gfx::Rect content_rect(gfx::Point(), contentBounds()); | 83 gfx::Rect content_rect(gfx::Point(), contentBounds()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 drawTransformIsAnimating() || | 195 drawTransformIsAnimating() || |
| 191 screenSpaceTransformIsAnimating(); | 196 screenSpaceTransformIsAnimating(); |
| 192 if (!is_animating) | 197 if (!is_animating) |
| 193 CleanUpUnusedTilings(seen_tilings); | 198 CleanUpUnusedTilings(seen_tilings); |
| 194 } | 199 } |
| 195 | 200 |
| 196 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { | 201 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { |
| 197 // TODO(enne): implement me | 202 // TODO(enne): implement me |
| 198 } | 203 } |
| 199 | 204 |
| 200 void PictureLayerImpl::didUpdateTransforms() { | 205 void PictureLayerImpl::updateTilePriorities() { |
| 206 int current_source_frame_number = layerTreeImpl()->source_frame_number(); |
| 207 bool first_update_in_new_source_frame = |
| 208 current_source_frame_number != last_source_frame_number_; |
| 209 |
| 210 double current_frame_time = |
| 211 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
| 212 bool first_update_in_new_impl_frame = |
| 213 current_frame_time != last_impl_frame_time_; |
| 214 |
| 215 // In pending tree, this is always called. We update priorities: |
| 216 // - Immediately after a commit (first_update_in_new_source_frame). |
| 217 // - On animation ticks after the first frame in the tree |
| 218 // (first_update_in_new_impl_frame). |
| 219 // In active tree, this is only called during draw. We update priorities: |
| 220 // - On draw if properties were not already computed by the pending tree |
| 221 // and activated for the frame (first_update_in_new_impl_frame). |
| 222 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) |
| 223 return; |
| 224 |
| 201 gfx::Transform current_screen_space_transform = | 225 gfx::Transform current_screen_space_transform = |
| 202 screenSpaceTransform(); | 226 screenSpaceTransform(); |
| 203 double current_time = | |
| 204 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); | |
| 205 double time_delta = 0; | 227 double time_delta = 0; |
| 206 if (last_update_time_ != 0 && last_bounds_ == bounds() && | 228 if (last_impl_frame_time_ != 0 && last_bounds_ == bounds() && |
| 207 last_content_bounds_ == contentBounds() && | 229 last_content_bounds_ == contentBounds() && |
| 208 last_content_scale_ == contentsScaleX()) { | 230 last_content_scale_ == contentsScaleX()) { |
| 209 time_delta = current_time - last_update_time_; | 231 time_delta = current_frame_time - last_impl_frame_time_; |
| 210 } | 232 } |
| 211 WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 233 WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 212 tilings_->UpdateTilePriorities( | 234 tilings_->UpdateTilePriorities( |
| 213 tree, | 235 tree, |
| 214 layerTreeImpl()->device_viewport_size(), | 236 layerTreeImpl()->device_viewport_size(), |
| 215 last_content_scale_, | 237 last_content_scale_, |
| 216 contentsScaleX(), | 238 contentsScaleX(), |
| 217 last_screen_space_transform_, | 239 last_screen_space_transform_, |
| 218 current_screen_space_transform, | 240 current_screen_space_transform, |
| 219 time_delta); | 241 time_delta); |
| 220 | 242 |
| 243 last_source_frame_number_ = current_source_frame_number; |
| 221 last_screen_space_transform_ = current_screen_space_transform; | 244 last_screen_space_transform_ = current_screen_space_transform; |
| 222 last_update_time_ = current_time; | 245 last_impl_frame_time_ = current_frame_time; |
| 223 last_bounds_ = bounds(); | 246 last_bounds_ = bounds(); |
| 224 last_content_bounds_ = contentBounds(); | 247 last_content_bounds_ = contentBounds(); |
| 225 last_content_scale_ = contentsScaleX(); | 248 last_content_scale_ = contentsScaleX(); |
| 226 } | 249 } |
| 227 | 250 |
| 228 void PictureLayerImpl::didBecomeActive() { | 251 void PictureLayerImpl::didBecomeActive() { |
| 229 LayerImpl::didBecomeActive(); | 252 LayerImpl::didBecomeActive(); |
| 230 tilings_->DidBecomeActive(); | 253 tilings_->DidBecomeActive(); |
| 231 } | 254 } |
| 232 | 255 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) == | 576 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) == |
| 554 used_tilings.end()) | 577 used_tilings.end()) |
| 555 to_remove.push_back(tiling); | 578 to_remove.push_back(tiling); |
| 556 } | 579 } |
| 557 | 580 |
| 558 for (size_t i = 0; i < to_remove.size(); ++i) | 581 for (size_t i = 0; i < to_remove.size(); ++i) |
| 559 tilings_->Remove(to_remove[i]); | 582 tilings_->Remove(to_remove[i]); |
| 560 } | 583 } |
| 561 | 584 |
| 562 } // namespace cc | 585 } // namespace cc |
| OLD | NEW |