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/frame_rate_counter.h" | |
12 #include "cc/layer_tree_impl.h" | 13 #include "cc/layer_tree_impl.h" |
13 #include "cc/math_util.h" | 14 #include "cc/math_util.h" |
14 #include "cc/quad_sink.h" | 15 #include "cc/quad_sink.h" |
15 #include "cc/solid_color_draw_quad.h" | 16 #include "cc/solid_color_draw_quad.h" |
16 #include "cc/tile_draw_quad.h" | 17 #include "cc/tile_draw_quad.h" |
17 #include "ui/gfx/quad_f.h" | 18 #include "ui/gfx/quad_f.h" |
18 #include "ui/gfx/rect_conversions.h" | 19 #include "ui/gfx/rect_conversions.h" |
19 #include "ui/gfx/size_conversions.h" | 20 #include "ui/gfx/size_conversions.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 const float kMaxScaleRatioDuringPinch = 2.0f; | 23 const float kMaxScaleRatioDuringPinch = 2.0f; |
23 } | 24 } |
24 | 25 |
25 namespace cc { | 26 namespace cc { |
26 | 27 |
27 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) | 28 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) |
28 : LayerImpl(treeImpl, id), | 29 : LayerImpl(treeImpl, id), |
29 pile_(PicturePileImpl::Create()), | 30 pile_(PicturePileImpl::Create()), |
31 last_source_frame_number_(0), | |
32 last_impl_frame_number_(0), | |
30 last_update_time_(0), | 33 last_update_time_(0), |
31 last_content_scale_(0), | 34 last_content_scale_(0), |
32 ideal_contents_scale_(0), | 35 ideal_contents_scale_(0), |
33 is_mask_(false) { | 36 is_mask_(false) { |
34 } | 37 } |
35 | 38 |
36 PictureLayerImpl::~PictureLayerImpl() { | 39 PictureLayerImpl::~PictureLayerImpl() { |
37 } | 40 } |
38 | 41 |
39 const char* PictureLayerImpl::layerTypeAsString() const { | 42 const char* PictureLayerImpl::layerTypeAsString() const { |
(...skipping 19 matching lines...) Expand all Loading... | |
59 } | 62 } |
60 | 63 |
61 void PictureLayerImpl::pushPropertiesTo(LayerImpl* base_layer) { | 64 void PictureLayerImpl::pushPropertiesTo(LayerImpl* base_layer) { |
62 LayerImpl::pushPropertiesTo(base_layer); | 65 LayerImpl::pushPropertiesTo(base_layer); |
63 | 66 |
64 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); | 67 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); |
65 | 68 |
66 layer_impl->SetIsMask(is_mask_); | 69 layer_impl->SetIsMask(is_mask_); |
67 layer_impl->TransferTilingSet(tilings_.Pass()); | 70 layer_impl->TransferTilingSet(tilings_.Pass()); |
68 layer_impl->pile_ = pile_; | 71 layer_impl->pile_ = pile_; |
72 layer_impl->last_impl_frame_number_ = 0; | |
enne (OOO)
2013/01/25 18:17:52
I don't understand this. I think you'd want to se
danakj
2013/01/25 18:25:47
This is resetting the value on the target tree. Th
enne (OOO)
2013/01/25 18:51:26
You're right that this is called on the pending tr
danakj
2013/01/25 18:56:30
The goal is that when you activate the tree, it wo
enne (OOO)
2013/01/25 19:00:26
I think if you just sync the last source frame num
danakj
2013/01/25 20:45:25
Yes, I agree. Good observation. Special case is go
| |
69 pile_ = PicturePileImpl::Create(); | 73 pile_ = PicturePileImpl::Create(); |
70 pile_->set_slow_down_raster_scale_factor( | 74 pile_->set_slow_down_raster_scale_factor( |
71 layerTreeImpl()->debug_state().slowDownRasterScaleFactor); | 75 layerTreeImpl()->debug_state().slowDownRasterScaleFactor); |
72 } | 76 } |
73 | 77 |
74 | 78 |
75 void PictureLayerImpl::appendQuads(QuadSink& quadSink, | 79 void PictureLayerImpl::appendQuads(QuadSink& quadSink, |
76 AppendQuadsData& appendQuadsData) { | 80 AppendQuadsData& appendQuadsData) { |
77 const gfx::Rect& rect = visibleContentRect(); | 81 const gfx::Rect& rect = visibleContentRect(); |
78 gfx::Rect content_rect(gfx::Point(), contentBounds()); | 82 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 | 190 // During a pinch, a user could zoom in and out, so throwing away a tiling may |
187 // be premature. | 191 // be premature. |
188 if (!layerTreeImpl()->PinchGestureActive()) | 192 if (!layerTreeImpl()->PinchGestureActive()) |
189 CleanUpUnusedTilings(seen_tilings); | 193 CleanUpUnusedTilings(seen_tilings); |
190 } | 194 } |
191 | 195 |
192 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { | 196 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { |
193 // TODO(enne): implement me | 197 // TODO(enne): implement me |
194 } | 198 } |
195 | 199 |
196 void PictureLayerImpl::didUpdateTransforms() { | 200 void PictureLayerImpl::updateTilePriorities() { |
201 int current_source_frame_number = layerTreeImpl()->source_frame_number(); | |
202 bool first_update_in_new_source_frame = | |
203 current_source_frame_number != last_source_frame_number_; | |
204 | |
205 int current_impl_frame_number = | |
206 layerTreeImpl()->frame_rate_counter()->currentFrameNumber(); | |
enne (OOO)
2013/01/25 18:17:52
Can you expose this on LayerTreeImpl like source_f
danakj
2013/01/25 18:25:47
Yep.
| |
207 bool first_frame_in_new_impl_tree = | |
208 last_impl_frame_number_ == 0 || | |
209 current_impl_frame_number == last_impl_frame_number_; | |
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 // In active tree, this is only called during draw. We update priorities: | |
enne (OOO)
2013/01/25 18:17:52
How is ensureRSLL handled?
danakj
2013/01/25 18:25:47
ensureRSLL calls UDP(ACTIVE_TREE) which does not d
enne (OOO)
2013/01/25 18:51:26
Aha, thanks.
| |
215 // - On draws after the first frame in the tree. | |
216 if (first_frame_in_new_impl_tree && !first_update_in_new_source_frame) | |
217 return; | |
218 | |
197 gfx::Transform current_screen_space_transform = | 219 gfx::Transform current_screen_space_transform = |
198 screenSpaceTransform(); | 220 screenSpaceTransform(); |
199 double current_time = | 221 double current_time = |
200 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); | 222 (base::TimeTicks::Now() - 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_update_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_time - last_update_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; | |
240 last_impl_frame_number_ = current_impl_frame_number; | |
217 last_screen_space_transform_ = current_screen_space_transform; | 241 last_screen_space_transform_ = current_screen_space_transform; |
218 last_update_time_ = current_time; | 242 last_update_time_ = current_time; |
219 last_bounds_ = bounds(); | 243 last_bounds_ = bounds(); |
220 last_content_bounds_ = contentBounds(); | 244 last_content_bounds_ = contentBounds(); |
221 last_content_scale_ = contentsScaleX(); | 245 last_content_scale_ = contentsScaleX(); |
222 } | 246 } |
223 | 247 |
224 void PictureLayerImpl::didBecomeActive() { | 248 void PictureLayerImpl::didBecomeActive() { |
225 LayerImpl::didBecomeActive(); | 249 LayerImpl::didBecomeActive(); |
226 tilings_->DidBecomeActive(); | 250 tilings_->DidBecomeActive(); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) == | 549 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) == |
526 used_tilings.end()) | 550 used_tilings.end()) |
527 to_remove.push_back(tiling); | 551 to_remove.push_back(tiling); |
528 } | 552 } |
529 | 553 |
530 for (size_t i = 0; i < to_remove.size(); ++i) | 554 for (size_t i = 0; i < to_remove.size(); ++i) |
531 tilings_->Remove(to_remove[i]); | 555 tilings_->Remove(to_remove[i]); |
532 } | 556 } |
533 | 557 |
534 } // namespace cc | 558 } // namespace cc |
OLD | NEW |