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