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