| 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 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 269 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 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 resourceless_software_draw_ = resourceless_software_draw; | 1430 resourceless_software_draw_ = resourceless_software_draw; |
| 1432 } | 1431 } |
| 1433 | 1432 |
| 1434 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 1433 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
| 1435 if (damage_rect.IsEmpty()) | 1434 if (damage_rect.IsEmpty()) |
| 1436 return; | 1435 return; |
| 1437 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1436 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
| 1438 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1437 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
| 1439 } | 1438 } |
| 1440 | 1439 |
| 1441 void LayerTreeHostImpl::BeginFrame(const BeginFrameArgs& args) { | |
| 1442 CallOnBeginFrame(args); | |
| 1443 } | |
| 1444 | |
| 1445 void LayerTreeHostImpl::DidSwapBuffers() { | 1440 void LayerTreeHostImpl::DidSwapBuffers() { |
| 1446 client_->DidSwapBuffersOnImplThread(); | 1441 client_->DidSwapBuffersOnImplThread(); |
| 1447 } | 1442 } |
| 1448 | 1443 |
| 1449 void LayerTreeHostImpl::DidSwapBuffersComplete() { | 1444 void LayerTreeHostImpl::DidSwapBuffersComplete() { |
| 1450 client_->DidSwapBuffersCompleteOnImplThread(); | 1445 client_->DidSwapBuffersCompleteOnImplThread(); |
| 1451 } | 1446 } |
| 1452 | 1447 |
| 1453 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { | 1448 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { |
| 1454 // TODO(piman): We may need to do some validation on this ack before | 1449 // 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... |
| 1672 TRACE_EVENT_FLOW_STEP0( | 1667 TRACE_EVENT_FLOW_STEP0( |
| 1673 "input", | 1668 "input", |
| 1674 "LatencyInfo.Flow", | 1669 "LatencyInfo.Flow", |
| 1675 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), | 1670 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), |
| 1676 "SwapBuffers"); | 1671 "SwapBuffers"); |
| 1677 } | 1672 } |
| 1678 renderer_->SwapBuffers(metadata); | 1673 renderer_->SwapBuffers(metadata); |
| 1679 return true; | 1674 return true; |
| 1680 } | 1675 } |
| 1681 | 1676 |
| 1682 void LayerTreeHostImpl::OnNeedsBeginFramesChange(bool enable) { | |
| 1683 if (output_surface_) | |
| 1684 output_surface_->SetNeedsBeginFrame(enable); | |
| 1685 else | |
| 1686 DCHECK(!enable); | |
| 1687 } | |
| 1688 | |
| 1689 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1677 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 1690 // Sample the frame time now. This time will be used for updating animations | 1678 // Sample the frame time now. This time will be used for updating animations |
| 1691 // when we draw. | 1679 // when we draw. |
| 1692 UpdateCurrentBeginFrameArgs(args); | 1680 UpdateCurrentBeginFrameArgs(args); |
| 1693 // Cache the begin impl frame interval | 1681 // Cache the begin impl frame interval |
| 1694 begin_impl_frame_interval_ = args.interval; | 1682 begin_impl_frame_interval_ = args.interval; |
| 1695 } | 1683 } |
| 1696 | 1684 |
| 1697 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1685 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
| 1698 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1686 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
| (...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3231 // Try to use the current frame time to keep animations non-jittery. But if | 3219 // Try to use the current frame time to keep animations non-jittery. But if |
| 3232 // we're not in a frame (because this is during an input event or a delayed | 3220 // we're not in a frame (because this is during an input event or a delayed |
| 3233 // task), fall back to physical time. This should still be monotonic. | 3221 // task), fall back to physical time. This should still be monotonic. |
| 3234 if (current_begin_frame_args_.IsValid()) | 3222 if (current_begin_frame_args_.IsValid()) |
| 3235 return current_begin_frame_args_; | 3223 return current_begin_frame_args_; |
| 3236 return BeginFrameArgs::Create(gfx::FrameTime::Now(), | 3224 return BeginFrameArgs::Create(gfx::FrameTime::Now(), |
| 3237 base::TimeTicks(), | 3225 base::TimeTicks(), |
| 3238 BeginFrameArgs::DefaultInterval()); | 3226 BeginFrameArgs::DefaultInterval()); |
| 3239 } | 3227 } |
| 3240 | 3228 |
| 3241 void LayerTreeHostImpl::AsValueInto(base::debug::TracedValue* value) const { | |
| 3242 return AsValueWithFrameInto(NULL, value); | |
| 3243 } | |
| 3244 | |
| 3245 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3229 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 3246 LayerTreeHostImpl::AsValue() const { | 3230 LayerTreeHostImpl::AsValue() const { |
| 3247 return AsValueWithFrame(NULL); | 3231 return AsValueWithFrame(NULL); |
| 3248 } | 3232 } |
| 3249 | 3233 |
| 3250 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3234 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 3251 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { | 3235 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { |
| 3252 scoped_refptr<base::debug::TracedValue> state = | 3236 scoped_refptr<base::debug::TracedValue> state = |
| 3253 new base::debug::TracedValue(); | 3237 new base::debug::TracedValue(); |
| 3254 AsValueWithFrameInto(frame, state.get()); | 3238 AsValueWithFrameInto(frame, state.get()); |
| 3255 return state; | 3239 return state; |
| 3256 } | 3240 } |
| 3257 | 3241 |
| 3242 void LayerTreeHostImpl::AsValueInto(base::debug::TracedValue* value) const { |
| 3243 return AsValueWithFrameInto(NULL, value); |
| 3244 } |
| 3245 |
| 3258 void LayerTreeHostImpl::AsValueWithFrameInto( | 3246 void LayerTreeHostImpl::AsValueWithFrameInto( |
| 3259 FrameData* frame, | 3247 FrameData* frame, |
| 3260 base::debug::TracedValue* state) const { | 3248 base::debug::TracedValue* state) const { |
| 3261 if (this->pending_tree_) { | 3249 if (this->pending_tree_) { |
| 3262 state->BeginDictionary("activation_state"); | 3250 state->BeginDictionary("activation_state"); |
| 3263 ActivationStateAsValueInto(state); | 3251 ActivationStateAsValueInto(state); |
| 3264 state->EndDictionary(); | 3252 state->EndDictionary(); |
| 3265 } | 3253 } |
| 3266 state->BeginDictionary("device_viewport_size"); | 3254 state->BeginDictionary("device_viewport_size"); |
| 3267 MathUtil::AddToTracedValue(device_viewport_size_, state); | 3255 MathUtil::AddToTracedValue(device_viewport_size_, state); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3473 } | 3461 } |
| 3474 | 3462 |
| 3475 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3463 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3476 std::vector<PictureLayerImpl*>::iterator it = | 3464 std::vector<PictureLayerImpl*>::iterator it = |
| 3477 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3465 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3478 DCHECK(it != picture_layers_.end()); | 3466 DCHECK(it != picture_layers_.end()); |
| 3479 picture_layers_.erase(it); | 3467 picture_layers_.erase(it); |
| 3480 } | 3468 } |
| 3481 | 3469 |
| 3482 } // namespace cc | 3470 } // namespace cc |
| OLD | NEW |