| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 261 } |
| 262 | 262 |
| 263 LayerTreeHostImpl::LayerTreeHostImpl( | 263 LayerTreeHostImpl::LayerTreeHostImpl( |
| 264 const LayerTreeSettings& settings, | 264 const LayerTreeSettings& settings, |
| 265 LayerTreeHostImplClient* client, | 265 LayerTreeHostImplClient* client, |
| 266 Proxy* proxy, | 266 Proxy* proxy, |
| 267 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 267 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 268 SharedBitmapManager* shared_bitmap_manager, | 268 SharedBitmapManager* shared_bitmap_manager, |
| 269 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 269 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 270 int id) | 270 int id) |
| 271 : BeginFrameSourceMixIn(), | 271 : client_(client), |
| 272 client_(client), | |
| 273 proxy_(proxy), | 272 proxy_(proxy), |
| 274 use_gpu_rasterization_(false), | 273 use_gpu_rasterization_(false), |
| 275 input_handler_client_(NULL), | 274 input_handler_client_(NULL), |
| 276 did_lock_scrolling_layer_(false), | 275 did_lock_scrolling_layer_(false), |
| 277 should_bubble_scrolls_(false), | 276 should_bubble_scrolls_(false), |
| 278 wheel_scrolling_(false), | 277 wheel_scrolling_(false), |
| 279 scroll_affects_scroll_handler_(false), | 278 scroll_affects_scroll_handler_(false), |
| 280 scroll_layer_id_when_mouse_over_scrollbar_(0), | 279 scroll_layer_id_when_mouse_over_scrollbar_(0), |
| 281 tile_priorities_dirty_(false), | 280 tile_priorities_dirty_(false), |
| 282 root_layer_scroll_offset_delegate_(NULL), | 281 root_layer_scroll_offset_delegate_(NULL), |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 resourceless_software_draw_ = resourceless_software_draw; | 1423 resourceless_software_draw_ = resourceless_software_draw; |
| 1425 } | 1424 } |
| 1426 | 1425 |
| 1427 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 1426 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
| 1428 if (damage_rect.IsEmpty()) | 1427 if (damage_rect.IsEmpty()) |
| 1429 return; | 1428 return; |
| 1430 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1429 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
| 1431 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1430 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
| 1432 } | 1431 } |
| 1433 | 1432 |
| 1434 void LayerTreeHostImpl::BeginFrame(const BeginFrameArgs& args) { | |
| 1435 CallOnBeginFrame(args); | |
| 1436 } | |
| 1437 | |
| 1438 void LayerTreeHostImpl::DidSwapBuffers() { | 1433 void LayerTreeHostImpl::DidSwapBuffers() { |
| 1439 client_->DidSwapBuffersOnImplThread(); | 1434 client_->DidSwapBuffersOnImplThread(); |
| 1440 } | 1435 } |
| 1441 | 1436 |
| 1442 void LayerTreeHostImpl::DidSwapBuffersComplete() { | 1437 void LayerTreeHostImpl::DidSwapBuffersComplete() { |
| 1443 client_->DidSwapBuffersCompleteOnImplThread(); | 1438 client_->DidSwapBuffersCompleteOnImplThread(); |
| 1444 } | 1439 } |
| 1445 | 1440 |
| 1446 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { | 1441 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { |
| 1447 // TODO(piman): We may need to do some validation on this ack before | 1442 // TODO(piman): We may need to do some validation on this ack before |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 TRACE_EVENT_FLOW_STEP0( | 1660 TRACE_EVENT_FLOW_STEP0( |
| 1666 "input", | 1661 "input", |
| 1667 "LatencyInfo.Flow", | 1662 "LatencyInfo.Flow", |
| 1668 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), | 1663 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), |
| 1669 "SwapBuffers"); | 1664 "SwapBuffers"); |
| 1670 } | 1665 } |
| 1671 renderer_->SwapBuffers(metadata); | 1666 renderer_->SwapBuffers(metadata); |
| 1672 return true; | 1667 return true; |
| 1673 } | 1668 } |
| 1674 | 1669 |
| 1675 void LayerTreeHostImpl::OnNeedsBeginFramesChange(bool enable) { | |
| 1676 if (output_surface_) | |
| 1677 output_surface_->SetNeedsBeginFrame(enable); | |
| 1678 else | |
| 1679 DCHECK(!enable); | |
| 1680 } | |
| 1681 | |
| 1682 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1670 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 1683 // Sample the frame time now. This time will be used for updating animations | 1671 // Sample the frame time now. This time will be used for updating animations |
| 1684 // when we draw. | 1672 // when we draw. |
| 1685 UpdateCurrentBeginFrameArgs(args); | 1673 UpdateCurrentBeginFrameArgs(args); |
| 1686 // Cache the begin impl frame interval | 1674 // Cache the begin impl frame interval |
| 1687 begin_impl_frame_interval_ = args.interval; | 1675 begin_impl_frame_interval_ = args.interval; |
| 1688 } | 1676 } |
| 1689 | 1677 |
| 1690 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1678 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
| 1691 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1679 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
| (...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3272 // Try to use the current frame time to keep animations non-jittery. But if | 3260 // Try to use the current frame time to keep animations non-jittery. But if |
| 3273 // we're not in a frame (because this is during an input event or a delayed | 3261 // we're not in a frame (because this is during an input event or a delayed |
| 3274 // task), fall back to physical time. This should still be monotonic. | 3262 // task), fall back to physical time. This should still be monotonic. |
| 3275 if (current_begin_frame_args_.IsValid()) | 3263 if (current_begin_frame_args_.IsValid()) |
| 3276 return current_begin_frame_args_; | 3264 return current_begin_frame_args_; |
| 3277 return BeginFrameArgs::Create(gfx::FrameTime::Now(), | 3265 return BeginFrameArgs::Create(gfx::FrameTime::Now(), |
| 3278 base::TimeTicks(), | 3266 base::TimeTicks(), |
| 3279 BeginFrameArgs::DefaultInterval()); | 3267 BeginFrameArgs::DefaultInterval()); |
| 3280 } | 3268 } |
| 3281 | 3269 |
| 3282 void LayerTreeHostImpl::AsValueInto(base::debug::TracedValue* value) const { | |
| 3283 return AsValueWithFrameInto(NULL, value); | |
| 3284 } | |
| 3285 | |
| 3286 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3270 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 3287 LayerTreeHostImpl::AsValue() const { | 3271 LayerTreeHostImpl::AsValue() const { |
| 3288 return AsValueWithFrame(NULL); | 3272 return AsValueWithFrame(NULL); |
| 3289 } | 3273 } |
| 3290 | 3274 |
| 3291 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3275 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 3292 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { | 3276 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { |
| 3293 scoped_refptr<base::debug::TracedValue> state = | 3277 scoped_refptr<base::debug::TracedValue> state = |
| 3294 new base::debug::TracedValue(); | 3278 new base::debug::TracedValue(); |
| 3295 AsValueWithFrameInto(frame, state.get()); | 3279 AsValueWithFrameInto(frame, state.get()); |
| 3296 return state; | 3280 return state; |
| 3297 } | 3281 } |
| 3298 | 3282 |
| 3283 void LayerTreeHostImpl::AsValueInto(base::debug::TracedValue* value) const { |
| 3284 return AsValueWithFrameInto(NULL, value); |
| 3285 } |
| 3286 |
| 3299 void LayerTreeHostImpl::AsValueWithFrameInto( | 3287 void LayerTreeHostImpl::AsValueWithFrameInto( |
| 3300 FrameData* frame, | 3288 FrameData* frame, |
| 3301 base::debug::TracedValue* state) const { | 3289 base::debug::TracedValue* state) const { |
| 3302 if (this->pending_tree_) { | 3290 if (this->pending_tree_) { |
| 3303 state->BeginDictionary("activation_state"); | 3291 state->BeginDictionary("activation_state"); |
| 3304 ActivationStateAsValueInto(state); | 3292 ActivationStateAsValueInto(state); |
| 3305 state->EndDictionary(); | 3293 state->EndDictionary(); |
| 3306 } | 3294 } |
| 3307 state->BeginDictionary("device_viewport_size"); | 3295 state->BeginDictionary("device_viewport_size"); |
| 3308 MathUtil::AddToTracedValue(device_viewport_size_, state); | 3296 MathUtil::AddToTracedValue(device_viewport_size_, state); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3514 } | 3502 } |
| 3515 | 3503 |
| 3516 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3504 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3517 std::vector<PictureLayerImpl*>::iterator it = | 3505 std::vector<PictureLayerImpl*>::iterator it = |
| 3518 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3506 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3519 DCHECK(it != picture_layers_.end()); | 3507 DCHECK(it != picture_layers_.end()); |
| 3520 picture_layers_.erase(it); | 3508 picture_layers_.erase(it); |
| 3521 } | 3509 } |
| 3522 | 3510 |
| 3523 } // namespace cc | 3511 } // namespace cc |
| OLD | NEW |