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 1491 matching lines...) Loading... |
1502 gfx::SizeF dip_size = | 1502 gfx::SizeF dip_size = |
1503 gfx::ScaleSize(device_viewport_size_, 1.f / device_scale_factor()); | 1503 gfx::ScaleSize(device_viewport_size_, 1.f / device_scale_factor()); |
1504 | 1504 |
1505 float top_offset = | 1505 float top_offset = |
1506 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; | 1506 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; |
1507 return gfx::SizeF(dip_size.width(), | 1507 return gfx::SizeF(dip_size.width(), |
1508 dip_size.height() - top_offset - overdraw_bottom_height_); | 1508 dip_size.height() - top_offset - overdraw_bottom_height_); |
1509 } | 1509 } |
1510 | 1510 |
1511 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1511 void LayerTreeHostImpl::DidLoseOutputSurface() { |
| 1512 #ifndef NDEBUG |
| 1513 // This must be set before calling the below functions as they may |
| 1514 // synchronously try to recreate the output surface. |
| 1515 did_lose_called_ = true; |
| 1516 #endif |
1512 if (resource_provider_) | 1517 if (resource_provider_) |
1513 resource_provider_->DidLoseOutputSurface(); | 1518 resource_provider_->DidLoseOutputSurface(); |
1514 // TODO(jamesr): The renderer_ check is needed to make some of the | 1519 // TODO(jamesr): The renderer_ check is needed to make some of the |
1515 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | 1520 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or |
1516 // important) in production. We should adjust the test to not need this. | 1521 // important) in production. We should adjust the test to not need this. |
1517 if (renderer_) | 1522 if (renderer_) |
1518 client_->DidLoseOutputSurfaceOnImplThread(); | 1523 client_->DidLoseOutputSurfaceOnImplThread(); |
1519 #ifndef NDEBUG | |
1520 did_lose_called_ = true; | |
1521 #endif | |
1522 } | 1524 } |
1523 | 1525 |
1524 void LayerTreeHostImpl::Readback(void* pixels, | 1526 void LayerTreeHostImpl::Readback(void* pixels, |
1525 const gfx::Rect& rect_in_device_viewport) { | 1527 const gfx::Rect& rect_in_device_viewport) { |
1526 DCHECK(renderer_); | 1528 DCHECK(renderer_); |
1527 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); | 1529 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); |
1528 } | 1530 } |
1529 | 1531 |
1530 bool LayerTreeHostImpl::HaveRootScrollLayer() const { | 1532 bool LayerTreeHostImpl::HaveRootScrollLayer() const { |
1531 return !!InnerViewportScrollLayer(); | 1533 return !!InnerViewportScrollLayer(); |
(...skipping 287 matching lines...) Loading... |
1819 GetRendererCapabilities().using_map_image, | 1821 GetRendererCapabilities().using_map_image, |
1820 GetRendererCapabilities().allow_rasterize_on_demand); | 1822 GetRendererCapabilities().allow_rasterize_on_demand); |
1821 } | 1823 } |
1822 | 1824 |
1823 // Setup BeginImplFrameEmulation if it's not supported natively | 1825 // Setup BeginImplFrameEmulation if it's not supported natively |
1824 if (!settings_.begin_impl_frame_scheduling_enabled) { | 1826 if (!settings_.begin_impl_frame_scheduling_enabled) { |
1825 const base::TimeDelta display_refresh_interval = | 1827 const base::TimeDelta display_refresh_interval = |
1826 base::TimeDelta::FromMicroseconds( | 1828 base::TimeDelta::FromMicroseconds( |
1827 base::Time::kMicrosecondsPerSecond / | 1829 base::Time::kMicrosecondsPerSecond / |
1828 settings_.refresh_rate); | 1830 settings_.refresh_rate); |
1829 | 1831 // If no compositor thread, then begin impl frame messages should just |
| 1832 // go back to the main thread. |
| 1833 base::SingleThreadTaskRunner* task_runner = |
| 1834 proxy_->ImplThreadTaskRunner() ? proxy_->ImplThreadTaskRunner() |
| 1835 : proxy_->MainThreadTaskRunner(); |
1830 output_surface->InitializeBeginImplFrameEmulation( | 1836 output_surface->InitializeBeginImplFrameEmulation( |
1831 proxy_->ImplThreadTaskRunner(), | 1837 task_runner, |
1832 settings_.throttle_frame_production, | 1838 settings_.throttle_frame_production, |
1833 display_refresh_interval); | 1839 display_refresh_interval); |
1834 } | 1840 } |
1835 | 1841 |
1836 int max_frames_pending = | 1842 int max_frames_pending = |
1837 output_surface->capabilities().max_frames_pending; | 1843 output_surface->capabilities().max_frames_pending; |
1838 if (max_frames_pending <= 0) | 1844 if (max_frames_pending <= 0) |
1839 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 1845 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
1840 output_surface->SetMaxFramesPending(max_frames_pending); | 1846 output_surface->SetMaxFramesPending(max_frames_pending); |
1841 | 1847 |
(...skipping 1156 matching lines...) Loading... |
2998 swap_promise_monitor_.erase(monitor); | 3004 swap_promise_monitor_.erase(monitor); |
2999 } | 3005 } |
3000 | 3006 |
3001 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3007 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3002 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3008 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3003 for (; it != swap_promise_monitor_.end(); it++) | 3009 for (; it != swap_promise_monitor_.end(); it++) |
3004 (*it)->OnSetNeedsRedrawOnImpl(); | 3010 (*it)->OnSetNeedsRedrawOnImpl(); |
3005 } | 3011 } |
3006 | 3012 |
3007 } // namespace cc | 3013 } // namespace cc |
OLD | NEW |