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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // During a pinch, a user could zoom in and out, so throwing away a tiling may | 191 // During a pinch, a user could zoom in and out, so throwing away a tiling may |
187 // be premature. | 192 // be premature. |
188 if (!layerTreeImpl()->PinchGestureActive()) | 193 if (!layerTreeImpl()->PinchGestureActive()) |
189 CleanUpUnusedTilings(seen_tilings); | 194 CleanUpUnusedTilings(seen_tilings); |
190 } | 195 } |
191 | 196 |
192 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { | 197 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { |
193 // TODO(enne): implement me | 198 // TODO(enne): implement me |
194 } | 199 } |
195 | 200 |
196 void PictureLayerImpl::didUpdateTransforms() { | 201 void PictureLayerImpl::updateTilePriorities() { |
| 202 int current_source_frame_number = layerTreeImpl()->source_frame_number(); |
| 203 bool first_update_in_new_source_frame = |
| 204 current_source_frame_number != last_source_frame_number_; |
| 205 |
| 206 double current_frame_time = |
| 207 (layerTreeImpl()->current_frame_time() - base::TimeTicks()).InSecondsF(); |
| 208 bool first_update_in_new_impl_frame = |
| 209 current_frame_time != last_impl_frame_time_; |
| 210 |
| 211 // In pending tree, this is always called. We update priorities: |
| 212 // - Immediately after a commit (first_update_in_new_source_frame). |
| 213 // - On animation ticks after the first frame in the tree |
| 214 // (first_update_in_new_impl_frame). |
| 215 // In active tree, this is only called during draw. We update priorities: |
| 216 // - On draw if properties were not already computed by the pending tree |
| 217 // and activated for the frame (first_update_in_new_impl_frame). |
| 218 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) |
| 219 return; |
| 220 |
197 gfx::Transform current_screen_space_transform = | 221 gfx::Transform current_screen_space_transform = |
198 screenSpaceTransform(); | 222 screenSpaceTransform(); |
199 double current_time = | |
200 (layerTreeImpl()->current_frame_time() - base::TimeTicks()).InSecondsF(); | |
201 double time_delta = 0; | 223 double time_delta = 0; |
202 if (last_update_time_ != 0 && last_bounds_ == bounds() && | 224 if (last_impl_frame_time_ != 0 && last_bounds_ == bounds() && |
203 last_content_bounds_ == contentBounds() && | 225 last_content_bounds_ == contentBounds() && |
204 last_content_scale_ == contentsScaleX()) { | 226 last_content_scale_ == contentsScaleX()) { |
205 time_delta = current_time - last_update_time_; | 227 time_delta = current_frame_time - last_impl_frame_time_; |
206 } | 228 } |
207 WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 229 WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
208 tilings_->UpdateTilePriorities( | 230 tilings_->UpdateTilePriorities( |
209 tree, | 231 tree, |
210 layerTreeImpl()->device_viewport_size(), | 232 layerTreeImpl()->device_viewport_size(), |
211 last_content_scale_, | 233 last_content_scale_, |
212 contentsScaleX(), | 234 contentsScaleX(), |
213 last_screen_space_transform_, | 235 last_screen_space_transform_, |
214 current_screen_space_transform, | 236 current_screen_space_transform, |
215 time_delta); | 237 time_delta); |
216 | 238 |
| 239 last_source_frame_number_ = current_source_frame_number; |
217 last_screen_space_transform_ = current_screen_space_transform; | 240 last_screen_space_transform_ = current_screen_space_transform; |
218 last_update_time_ = current_time; | 241 last_impl_frame_time_ = current_frame_time; |
219 last_bounds_ = bounds(); | 242 last_bounds_ = bounds(); |
220 last_content_bounds_ = contentBounds(); | 243 last_content_bounds_ = contentBounds(); |
221 last_content_scale_ = contentsScaleX(); | 244 last_content_scale_ = contentsScaleX(); |
222 } | 245 } |
223 | 246 |
224 void PictureLayerImpl::didBecomeActive() { | 247 void PictureLayerImpl::didBecomeActive() { |
225 LayerImpl::didBecomeActive(); | 248 LayerImpl::didBecomeActive(); |
226 tilings_->DidBecomeActive(); | 249 tilings_->DidBecomeActive(); |
227 } | 250 } |
228 | 251 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) == | 548 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) == |
526 used_tilings.end()) | 549 used_tilings.end()) |
527 to_remove.push_back(tiling); | 550 to_remove.push_back(tiling); |
528 } | 551 } |
529 | 552 |
530 for (size_t i = 0; i < to_remove.size(); ++i) | 553 for (size_t i = 0; i < to_remove.size(); ++i) |
531 tilings_->Remove(to_remove[i]); | 554 tilings_->Remove(to_remove[i]); |
532 } | 555 } |
533 | 556 |
534 } // namespace cc | 557 } // namespace cc |
OLD | NEW |