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 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 resourceless_software_draw_ = resourceless_software_draw; | 1424 resourceless_software_draw_ = resourceless_software_draw; |
1425 } | 1425 } |
1426 | 1426 |
1427 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 1427 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
1428 if (damage_rect.IsEmpty()) | 1428 if (damage_rect.IsEmpty()) |
1429 return; | 1429 return; |
1430 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1430 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
1431 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1431 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
1432 } | 1432 } |
1433 | 1433 |
1434 void LayerTreeHostImpl::BeginFrame(const BeginFrameArgs& args) { | |
1435 SendBeginFrame(args); | |
1436 } | |
1437 | |
1438 void LayerTreeHostImpl::DidSwapBuffers() { | 1434 void LayerTreeHostImpl::DidSwapBuffers() { |
1439 client_->DidSwapBuffersOnImplThread(); | 1435 client_->DidSwapBuffersOnImplThread(); |
1440 } | 1436 } |
1441 | 1437 |
1442 void LayerTreeHostImpl::DidSwapBuffersComplete() { | 1438 void LayerTreeHostImpl::DidSwapBuffersComplete() { |
1443 client_->DidSwapBuffersCompleteOnImplThread(); | 1439 client_->DidSwapBuffersCompleteOnImplThread(); |
1444 } | 1440 } |
1445 | 1441 |
1446 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { | 1442 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { |
1447 // TODO(piman): We may need to do some validation on this ack before | 1443 // 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( | 1661 TRACE_EVENT_FLOW_STEP0( |
1666 "input", | 1662 "input", |
1667 "LatencyInfo.Flow", | 1663 "LatencyInfo.Flow", |
1668 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), | 1664 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), |
1669 "SwapBuffers"); | 1665 "SwapBuffers"); |
1670 } | 1666 } |
1671 renderer_->SwapBuffers(metadata); | 1667 renderer_->SwapBuffers(metadata); |
1672 return true; | 1668 return true; |
1673 } | 1669 } |
1674 | 1670 |
1675 bool LayerTreeHostImpl::NeedsBeginFrames() const { | |
1676 return needs_begin_frames_; | |
1677 } | |
1678 | |
1679 void LayerTreeHostImpl::SetNeedsBeginFrames(bool enable) { | |
1680 needs_begin_frames_ = enable; | |
1681 if (output_surface_) | |
1682 output_surface_->SetNeedsBeginFrame(enable); | |
1683 else | |
1684 DCHECK(!enable); | |
1685 } | |
1686 | |
1687 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1671 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1688 // Sample the frame time now. This time will be used for updating animations | 1672 // Sample the frame time now. This time will be used for updating animations |
1689 // when we draw. | 1673 // when we draw. |
1690 UpdateCurrentBeginFrameArgs(args); | 1674 UpdateCurrentBeginFrameArgs(args); |
1691 // Cache the begin impl frame interval | 1675 // Cache the begin impl frame interval |
1692 begin_impl_frame_interval_ = args.interval; | 1676 begin_impl_frame_interval_ = args.interval; |
1693 } | 1677 } |
1694 | 1678 |
1695 void LayerTreeHostImpl::UpdateInnerViewportContainerSize() { | 1679 void LayerTreeHostImpl::UpdateInnerViewportContainerSize() { |
1696 LayerImpl* container_layer = active_tree_->InnerViewportContainerLayer(); | 1680 LayerImpl* container_layer = active_tree_->InnerViewportContainerLayer(); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 settings_.use_distance_field_text); | 2080 settings_.use_distance_field_text); |
2097 | 2081 |
2098 if (output_surface_->capabilities().deferred_gl_initialization) | 2082 if (output_surface_->capabilities().deferred_gl_initialization) |
2099 EnforceZeroBudget(true); | 2083 EnforceZeroBudget(true); |
2100 | 2084 |
2101 CreateAndSetRenderer(); | 2085 CreateAndSetRenderer(); |
2102 | 2086 |
2103 if (settings_.impl_side_painting) | 2087 if (settings_.impl_side_painting) |
2104 CreateAndSetTileManager(); | 2088 CreateAndSetTileManager(); |
2105 | 2089 |
2106 // Initialize vsync parameters to sane values. | |
2107 const base::TimeDelta display_refresh_interval = | |
2108 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / | |
2109 settings_.refresh_rate); | |
2110 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); | |
2111 | |
2112 // TODO(brianderson): Don't use a hard-coded parent draw time. | 2090 // TODO(brianderson): Don't use a hard-coded parent draw time. |
2113 base::TimeDelta parent_draw_time = | 2091 base::TimeDelta parent_draw_time = |
2114 (!settings_.begin_frame_scheduling_enabled && | 2092 (!settings_.begin_frame_scheduling_enabled && |
2115 output_surface_->capabilities().adjust_deadline_for_parent) | 2093 output_surface_->capabilities().adjust_deadline_for_parent) |
2116 ? BeginFrameArgs::DefaultEstimatedParentDrawTime() | 2094 ? BeginFrameArgs::DefaultEstimatedParentDrawTime() |
2117 : base::TimeDelta(); | 2095 : base::TimeDelta(); |
2118 client_->SetEstimatedParentDrawTime(parent_draw_time); | 2096 client_->SetEstimatedParentDrawTime(parent_draw_time); |
2119 | 2097 |
2120 int max_frames_pending = output_surface_->capabilities().max_frames_pending; | 2098 int max_frames_pending = output_surface_->capabilities().max_frames_pending; |
2121 if (max_frames_pending <= 0) | 2099 if (max_frames_pending <= 0) |
2122 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 2100 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
2123 client_->SetMaxSwapsPendingOnImplThread(max_frames_pending); | 2101 client_->SetMaxSwapsPendingOnImplThread(max_frames_pending); |
2124 client_->OnCanDrawStateChanged(CanDraw()); | 2102 client_->OnCanDrawStateChanged(CanDraw()); |
2125 | 2103 |
2126 return true; | 2104 return true; |
2127 } | 2105 } |
2128 | 2106 |
2129 void LayerTreeHostImpl::CommitVSyncParameters(base::TimeTicks timebase, | |
2130 base::TimeDelta interval) { | |
2131 client_->CommitVSyncParameters(timebase, interval); | |
2132 } | |
2133 | |
2134 void LayerTreeHostImpl::DeferredInitialize() { | 2107 void LayerTreeHostImpl::DeferredInitialize() { |
2135 DCHECK(output_surface_->capabilities().deferred_gl_initialization); | 2108 DCHECK(output_surface_->capabilities().deferred_gl_initialization); |
2136 DCHECK(settings_.impl_side_painting); | 2109 DCHECK(settings_.impl_side_painting); |
2137 DCHECK(output_surface_->context_provider()); | 2110 DCHECK(output_surface_->context_provider()); |
2138 | 2111 |
2139 ReleaseTreeResources(); | 2112 ReleaseTreeResources(); |
2140 renderer_.reset(); | 2113 renderer_.reset(); |
2141 DestroyTileManager(); | 2114 DestroyTileManager(); |
2142 | 2115 |
2143 resource_provider_->InitializeGL(); | 2116 resource_provider_->InitializeGL(); |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3388 } | 3361 } |
3389 | 3362 |
3390 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3363 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3391 std::vector<PictureLayerImpl*>::iterator it = | 3364 std::vector<PictureLayerImpl*>::iterator it = |
3392 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3365 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3393 DCHECK(it != picture_layers_.end()); | 3366 DCHECK(it != picture_layers_.end()); |
3394 picture_layers_.erase(it); | 3367 picture_layers_.erase(it); |
3395 } | 3368 } |
3396 | 3369 |
3397 } // namespace cc | 3370 } // namespace cc |
OLD | NEW |