[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 5 | #include "cc/trees/single_thread_proxy.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 6 | |
[email protected] | 74d9063c | 2013-01-18 03:14:47 | [diff] [blame] | 7 | #include "base/auto_reset.h" |
[email protected] | 6331a117 | 2012-10-18 11:35:13 | [diff] [blame] | 8 | #include "base/debug/trace_event.h" |
[email protected] | 7f0d825f | 2013-03-18 07:24:30 | [diff] [blame] | 9 | #include "cc/output/context_provider.h" |
| 10 | #include "cc/output/output_surface.h" |
[email protected] | 89e8267 | 2013-03-18 07:50:56 | [diff] [blame] | 11 | #include "cc/quads/draw_quad.h" |
[email protected] | e12dd0e | 2013-03-18 08:24:40 | [diff] [blame] | 12 | #include "cc/resources/prioritized_resource_manager.h" |
| 13 | #include "cc/resources/resource_update_controller.h" |
[email protected] | 9794fb3 | 2013-08-29 09:49:59 | [diff] [blame] | 14 | #include "cc/trees/blocking_task_runner.h" |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 15 | #include "cc/trees/layer_tree_host.h" |
| 16 | #include "cc/trees/layer_tree_impl.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 17 | |
[email protected] | 9c88e56 | 2012-09-14 22:21:30 | [diff] [blame] | 18 | namespace cc { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 19 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 20 | scoped_ptr<Proxy> SingleThreadProxy::Create(LayerTreeHost* layer_tree_host) { |
| 21 | return make_scoped_ptr( |
| 22 | new SingleThreadProxy(layer_tree_host)).PassAs<Proxy>(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 23 | } |
| 24 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 25 | SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host) |
[email protected] | 810d40b7 | 2013-06-20 18:26:15 | [diff] [blame] | 26 | : Proxy(NULL), |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 27 | layer_tree_host_(layer_tree_host), |
[email protected] | e06e112 | 2013-03-15 17:12:38 | [diff] [blame] | 28 | created_offscreen_context_provider_(false), |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 29 | next_frame_is_newly_committed_frame_(false), |
[email protected] | ccd6d9d | 2013-03-30 19:08:58 | [diff] [blame] | 30 | inside_draw_(false) { |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 31 | TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
| 32 | DCHECK(Proxy::IsMainThread()); |
| 33 | DCHECK(layer_tree_host); |
[email protected] | 1e4c352b | 2013-01-10 02:05:23 | [diff] [blame] | 34 | |
[email protected] | 089102b | 2013-03-14 03:54:56 | [diff] [blame] | 35 | // Impl-side painting not supported without threaded compositing. |
[email protected] | d9c086a | 2013-04-17 16:12:48 | [diff] [blame] | 36 | CHECK(!layer_tree_host->settings().impl_side_painting) |
| 37 | << "Threaded compositing must be enabled to use impl-side painting."; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 38 | } |
| 39 | |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 40 | void SingleThreadProxy::Start(scoped_ptr<OutputSurface> first_output_surface) { |
| 41 | DCHECK(first_output_surface); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 42 | DebugScopedSetImplThread impl(this); |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 43 | layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 44 | first_output_surface_ = first_output_surface.Pass(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | SingleThreadProxy::~SingleThreadProxy() { |
| 48 | TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); |
| 49 | DCHECK(Proxy::IsMainThread()); |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 50 | // Make sure Stop() got called or never Started. |
| 51 | DCHECK(!layer_tree_host_impl_); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | bool SingleThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) { |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 55 | TRACE_EVENT0("cc", "SingleThreadProxy::CompositeAndReadback"); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 56 | DCHECK(Proxy::IsMainThread()); |
| 57 | |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 58 | gfx::Rect device_viewport_damage_rect = rect; |
| 59 | |
| 60 | LayerTreeHostImpl::FrameData frame; |
| 61 | if (!CommitAndComposite(base::TimeTicks::Now(), |
| 62 | device_viewport_damage_rect, |
[email protected] | 2921d04 | 2013-05-10 05:01:39 | [diff] [blame] | 63 | true, // for_readback |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 64 | &frame)) |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 65 | return false; |
| 66 | |
| 67 | { |
[email protected] | 61de581 | 2012-11-08 07:03:44 | [diff] [blame] | 68 | DebugScopedSetImplThread impl(this); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 69 | layer_tree_host_impl_->Readback(pixels, rect); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 70 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 71 | if (layer_tree_host_impl_->IsContextLost()) |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 72 | return false; |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 73 | } |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 74 | |
| 75 | return true; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 76 | } |
| 77 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 78 | void SingleThreadProxy::FinishAllRendering() { |
| 79 | DCHECK(Proxy::IsMainThread()); |
| 80 | { |
[email protected] | 61de581 | 2012-11-08 07:03:44 | [diff] [blame] | 81 | DebugScopedSetImplThread impl(this); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 82 | layer_tree_host_impl_->FinishAllRendering(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 83 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 84 | } |
| 85 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 86 | bool SingleThreadProxy::IsStarted() const { |
| 87 | DCHECK(Proxy::IsMainThread()); |
[email protected] | 3209161d | 2013-03-29 19:17:34 | [diff] [blame] | 88 | return layer_tree_host_impl_; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 89 | } |
| 90 | |
[email protected] | 14bd554 | 2013-05-08 21:51:30 | [diff] [blame] | 91 | void SingleThreadProxy::SetLayerTreeHostClientReady() { |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 92 | // Scheduling is controlled by the embedder in the single thread case, so |
| 93 | // nothing to do. |
| 94 | } |
| 95 | |
| 96 | void SingleThreadProxy::SetVisible(bool visible) { |
[email protected] | f7c01c8 | 2013-07-02 22:58:46 | [diff] [blame] | 97 | DebugScopedSetImplThread impl(this); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 98 | layer_tree_host_impl_->SetVisible(visible); |
[email protected] | 8ea875b | 2013-08-07 00:32:12 | [diff] [blame] | 99 | |
| 100 | // Changing visibility could change ShouldComposite(). |
[email protected] | d9fce672 | 2013-08-30 01:10:01 | [diff] [blame] | 101 | UpdateBackgroundAnimateTicking(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 102 | } |
| 103 | |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 104 | void SingleThreadProxy::CreateAndInitializeOutputSurface() { |
| 105 | TRACE_EVENT0( |
| 106 | "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 107 | DCHECK(Proxy::IsMainThread()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 108 | |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 109 | scoped_ptr<OutputSurface> output_surface = first_output_surface_.Pass(); |
[email protected] | 486544b | 2013-04-26 18:46:22 | [diff] [blame] | 110 | if (!output_surface) |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 111 | output_surface = layer_tree_host_->CreateOutputSurface(); |
| 112 | if (!output_surface) { |
| 113 | OnOutputSurfaceInitializeAttempted(false); |
| 114 | return; |
| 115 | } |
| 116 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 117 | scoped_refptr<cc::ContextProvider> offscreen_context_provider; |
[email protected] | e06e112 | 2013-03-15 17:12:38 | [diff] [blame] | 118 | if (created_offscreen_context_provider_) { |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 119 | offscreen_context_provider = |
[email protected] | f10dc47 | 2013-09-27 03:31:59 | [diff] [blame^] | 120 | layer_tree_host_->client()->OffscreenContextProvider(); |
| 121 | if (!offscreen_context_provider.get() || |
| 122 | !offscreen_context_provider->BindToCurrentThread()) { |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 123 | OnOutputSurfaceInitializeAttempted(false); |
| 124 | return; |
| 125 | } |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 126 | } |
| 127 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 128 | { |
[email protected] | 819b9f5 | 2013-09-22 23:29:51 | [diff] [blame] | 129 | DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 130 | DebugScopedSetImplThread impl(this); |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 131 | layer_tree_host_->DeleteContentsTexturesOnImplThread( |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 132 | layer_tree_host_impl_->resource_provider()); |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | bool initialized; |
| 136 | { |
| 137 | DebugScopedSetImplThread impl(this); |
| 138 | |
| 139 | DCHECK(output_surface); |
| 140 | initialized = layer_tree_host_impl_->InitializeRenderer( |
| 141 | output_surface.Pass()); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 142 | if (initialized) { |
| 143 | renderer_capabilities_for_main_thread_ = |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 144 | layer_tree_host_impl_->GetRendererCapabilities(); |
[email protected] | 22898ed | 2013-06-01 04:52:30 | [diff] [blame] | 145 | } else if (offscreen_context_provider.get()) { |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 146 | offscreen_context_provider->VerifyContexts(); |
[email protected] | b5174d71 | 2013-08-28 08:10:43 | [diff] [blame] | 147 | offscreen_context_provider = NULL; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 148 | } |
[email protected] | b5174d71 | 2013-08-28 08:10:43 | [diff] [blame] | 149 | |
| 150 | layer_tree_host_impl_->SetOffscreenContextProvider( |
| 151 | offscreen_context_provider); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 152 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 153 | |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 154 | OnOutputSurfaceInitializeAttempted(initialized); |
| 155 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 156 | |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 157 | void SingleThreadProxy::OnOutputSurfaceInitializeAttempted(bool success) { |
| 158 | LayerTreeHost::CreateResult result = |
| 159 | layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
| 160 | if (result == LayerTreeHost::CreateFailedButTryAgain) { |
| 161 | // Force another recreation attempt to happen by requesting another commit. |
| 162 | SetNeedsCommit(); |
| 163 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 164 | } |
| 165 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 166 | const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 167 | DCHECK(Proxy::IsMainThread()); |
| 168 | DCHECK(!layer_tree_host_->output_surface_lost()); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 169 | return renderer_capabilities_for_main_thread_; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 170 | } |
| 171 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 172 | void SingleThreadProxy::SetNeedsAnimate() { |
| 173 | // Thread-only feature. |
| 174 | NOTREACHED(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 175 | } |
| 176 | |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 177 | void SingleThreadProxy::SetNeedsUpdateLayers() { |
| 178 | DCHECK(Proxy::IsMainThread()); |
| 179 | layer_tree_host_->ScheduleComposite(); |
| 180 | } |
| 181 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 182 | void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { |
| 183 | DCHECK(Proxy::IsMainThread()); |
| 184 | // Commit immediately. |
| 185 | { |
[email protected] | 819b9f5 | 2013-09-22 23:29:51 | [diff] [blame] | 186 | DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
[email protected] | f7c01c8 | 2013-07-02 22:58:46 | [diff] [blame] | 187 | DebugScopedSetImplThread impl(this); |
| 188 | |
[email protected] | 9794fb3 | 2013-08-29 09:49:59 | [diff] [blame] | 189 | // This CapturePostTasks should be destroyed before CommitComplete() is |
| 190 | // called since that goes out to the embedder, and we want the embedder |
| 191 | // to receive its callbacks before that. |
| 192 | BlockingTaskRunner::CapturePostTasks blocked; |
| 193 | |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 194 | RenderingStatsInstrumentation* stats_instrumentation = |
| 195 | layer_tree_host_->rendering_stats_instrumentation(); |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 196 | base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 197 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 198 | layer_tree_host_impl_->BeginCommit(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 199 | |
[email protected] | 6e8c5492 | 2013-06-02 19:17:35 | [diff] [blame] | 200 | if (layer_tree_host_->contents_texture_manager()) { |
| 201 | layer_tree_host_->contents_texture_manager()-> |
| 202 | PushTexturePrioritiesToBackings(); |
| 203 | } |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 204 | layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 205 | |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 206 | scoped_ptr<ResourceUpdateController> update_controller = |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 207 | ResourceUpdateController::Create( |
| 208 | NULL, |
[email protected] | 810d40b7 | 2013-06-20 18:26:15 | [diff] [blame] | 209 | Proxy::MainThreadTaskRunner(), |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 210 | queue.Pass(), |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 211 | layer_tree_host_impl_->resource_provider()); |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 212 | update_controller->Finalize(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 213 | |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 214 | if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
| 215 | layer_tree_host_->RecreateUIResources(); |
| 216 | |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 217 | layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 218 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 219 | layer_tree_host_impl_->CommitComplete(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 220 | |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 221 | #ifndef NDEBUG |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 222 | // In the single-threaded case, the scale and scroll deltas should never be |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 223 | // touched on the impl layer tree. |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 224 | scoped_ptr<ScrollAndScaleSet> scroll_info = |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 225 | layer_tree_host_impl_->ProcessScrollDeltas(); |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 226 | DCHECK(!scroll_info->scrolls.size()); |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 227 | DCHECK_EQ(1.f, scroll_info->page_scale_delta); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 228 | #endif |
[email protected] | 8b9af6b | 2012-09-27 00:36:36 | [diff] [blame] | 229 | |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 230 | base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 231 | stats_instrumentation->AddCommit(duration); |
[email protected] | c1e6cc06 | 2013-08-24 03:35:35 | [diff] [blame] | 232 | stats_instrumentation->IssueTraceEventForMainThreadStats(); |
[email protected] | a9dc0d0f | 2013-08-17 02:43:18 | [diff] [blame] | 233 | stats_instrumentation->AccumulateAndClearMainThreadStats(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 234 | } |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 235 | layer_tree_host_->CommitComplete(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 236 | next_frame_is_newly_committed_frame_ = true; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 237 | } |
| 238 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 239 | void SingleThreadProxy::SetNeedsCommit() { |
| 240 | DCHECK(Proxy::IsMainThread()); |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 241 | layer_tree_host_->ScheduleComposite(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 242 | } |
| 243 | |
[email protected] | b9d4a36 | 2013-04-23 05:36:27 | [diff] [blame] | 244 | void SingleThreadProxy::SetNeedsRedraw(gfx::Rect damage_rect) { |
[email protected] | 1cd9f555 | 2013-04-26 04:22:03 | [diff] [blame] | 245 | SetNeedsRedrawRectOnImplThread(damage_rect); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 246 | } |
| 247 | |
[email protected] | 74b43cc | 2013-08-30 06:29:27 | [diff] [blame] | 248 | void SingleThreadProxy::SetNextCommitWaitsForActivation() { |
| 249 | // There is no activation here other than commit. So do nothing. |
| 250 | } |
| 251 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 252 | void SingleThreadProxy::SetDeferCommits(bool defer_commits) { |
| 253 | // Thread-only feature. |
| 254 | NOTREACHED(); |
[email protected] | 6b16679e | 2012-10-27 00:44:28 | [diff] [blame] | 255 | } |
| 256 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 257 | bool SingleThreadProxy::CommitRequested() const { return false; } |
| 258 | |
| 259 | size_t SingleThreadProxy::MaxPartialTextureUpdates() const { |
| 260 | return std::numeric_limits<size_t>::max(); |
| 261 | } |
| 262 | |
| 263 | void SingleThreadProxy::Stop() { |
| 264 | TRACE_EVENT0("cc", "SingleThreadProxy::stop"); |
| 265 | DCHECK(Proxy::IsMainThread()); |
| 266 | { |
[email protected] | 819b9f5 | 2013-09-22 23:29:51 | [diff] [blame] | 267 | DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 268 | DebugScopedSetImplThread impl(this); |
| 269 | |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 270 | layer_tree_host_->DeleteContentsTexturesOnImplThread( |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 271 | layer_tree_host_impl_->resource_provider()); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 272 | layer_tree_host_impl_.reset(); |
| 273 | } |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 274 | layer_tree_host_ = NULL; |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 275 | } |
| 276 | |
[email protected] | 3d9f743 | 2013-04-06 00:35:18 | [diff] [blame] | 277 | void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
| 278 | DCHECK(Proxy::IsImplThread()); |
[email protected] | d9fce672 | 2013-08-30 01:10:01 | [diff] [blame] | 279 | UpdateBackgroundAnimateTicking(); |
[email protected] | 3d9f743 | 2013-04-06 00:35:18 | [diff] [blame] | 280 | } |
| 281 | |
[email protected] | 4f48f6e | 2013-08-27 06:33:38 | [diff] [blame] | 282 | void SingleThreadProxy::NotifyReadyToActivate() { |
| 283 | // Thread-only feature. |
| 284 | NOTREACHED(); |
| 285 | } |
| 286 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 287 | void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 288 | layer_tree_host_->ScheduleComposite(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 289 | } |
| 290 | |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 291 | void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { |
| 292 | // Thread-only/Impl-side-painting-only feature. |
| 293 | NOTREACHED(); |
| 294 | } |
| 295 | |
[email protected] | 1cd9f555 | 2013-04-26 04:22:03 | [diff] [blame] | 296 | void SingleThreadProxy::SetNeedsRedrawRectOnImplThread(gfx::Rect damage_rect) { |
[email protected] | 27d851ab | 2013-06-28 01:09:50 | [diff] [blame] | 297 | // TODO(brianderson): Once we move render_widget scheduling into this class, |
| 298 | // we can treat redraw requests more efficiently than CommitAndRedraw |
| 299 | // requests. |
[email protected] | 1cd9f555 | 2013-04-26 04:22:03 | [diff] [blame] | 300 | layer_tree_host_impl_->SetViewportDamage(damage_rect); |
| 301 | SetNeedsCommit(); |
| 302 | } |
| 303 | |
[email protected] | 8612679 | 2013-03-16 20:07:54 | [diff] [blame] | 304 | void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 305 | // Impl-side painting only. |
| 306 | NOTREACHED(); |
| 307 | } |
| 308 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 309 | void SingleThreadProxy::SetNeedsCommitOnImplThread() { |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 310 | layer_tree_host_->ScheduleComposite(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 311 | } |
| 312 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 313 | void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 314 | scoped_ptr<AnimationEventsVector> events, |
| 315 | base::Time wall_clock_time) { |
| 316 | DCHECK(Proxy::IsImplThread()); |
| 317 | DebugScopedSetMainThread main(this); |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 318 | layer_tree_host_->SetAnimationEvents(events.Pass(), wall_clock_time); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 319 | } |
| 320 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 321 | bool SingleThreadProxy::ReduceContentsTextureMemoryOnImplThread( |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 322 | size_t limit_bytes, |
| 323 | int priority_cutoff) { |
| 324 | DCHECK(IsImplThread()); |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 325 | if (!layer_tree_host_->contents_texture_manager()) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 326 | return false; |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 327 | |
[email protected] | b56c130 | 2013-03-20 21:17:34 | [diff] [blame] | 328 | return layer_tree_host_->contents_texture_manager()->ReduceMemoryOnImplThread( |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 329 | limit_bytes, priority_cutoff, layer_tree_host_impl_->resource_provider()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 330 | } |
| 331 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 332 | void SingleThreadProxy::ReduceWastedContentsTextureMemoryOnImplThread() { |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 333 | // Impl-side painting only. |
| 334 | NOTREACHED(); |
[email protected] | 49306751 | 2012-09-19 23:34:10 | [diff] [blame] | 335 | } |
| 336 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 337 | void SingleThreadProxy::SendManagedMemoryStats() { |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 338 | DCHECK(Proxy::IsImplThread()); |
[email protected] | 384b2c5e | 2013-04-23 01:02:22 | [diff] [blame] | 339 | if (!layer_tree_host_impl_) |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 340 | return; |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 341 | if (!layer_tree_host_->contents_texture_manager()) |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 342 | return; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 343 | |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 344 | PrioritizedResourceManager* contents_texture_manager = |
| 345 | layer_tree_host_->contents_texture_manager(); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 346 | layer_tree_host_impl_->SendManagedMemoryStats( |
[email protected] | b56c130 | 2013-03-20 21:17:34 | [diff] [blame] | 347 | contents_texture_manager->MemoryVisibleBytes(), |
| 348 | contents_texture_manager->MemoryVisibleAndNearbyBytes(), |
| 349 | contents_texture_manager->MemoryUseBytes()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 350 | } |
| 351 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 352 | bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 353 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 354 | void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 355 | // Cause a commit so we can notice the lost context. |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 356 | SetNeedsCommitOnImplThread(); |
[email protected] | 49306751 | 2012-09-19 23:34:10 | [diff] [blame] | 357 | } |
| 358 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 359 | // Called by the legacy scheduling path (e.g. where render_widget does the |
| 360 | // scheduling) |
[email protected] | f0c2a24 | 2013-03-15 19:34:52 | [diff] [blame] | 361 | void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 362 | gfx::Rect device_viewport_damage_rect; |
| 363 | |
| 364 | LayerTreeHostImpl::FrameData frame; |
| 365 | if (CommitAndComposite(frame_begin_time, |
| 366 | device_viewport_damage_rect, |
[email protected] | 2921d04 | 2013-05-10 05:01:39 | [diff] [blame] | 367 | false, // for_readback |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 368 | &frame)) { |
[email protected] | 819b9f5 | 2013-09-22 23:29:51 | [diff] [blame] | 369 | { |
| 370 | DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 371 | DebugScopedSetImplThread impl(this); |
| 372 | |
| 373 | // This CapturePostTasks should be destroyed before |
| 374 | // DidCommitAndDrawFrame() is called since that goes out to the embedder, |
| 375 | // and we want the embedder to receive its callbacks before that. |
| 376 | // NOTE: This maintains consistent ordering with the ThreadProxy since |
| 377 | // the DidCommitAndDrawFrame() must be post-tasked from the impl thread |
| 378 | // there as the main thread is not blocked, so any posted tasks inside |
| 379 | // the swap buffers will execute first. |
| 380 | BlockingTaskRunner::CapturePostTasks blocked; |
| 381 | |
| 382 | layer_tree_host_impl_->SwapBuffers(frame); |
| 383 | } |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 384 | DidSwapFrame(); |
| 385 | } |
[email protected] | 74d9063c | 2013-01-18 03:14:47 | [diff] [blame] | 386 | } |
| 387 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 388 | scoped_ptr<base::Value> SingleThreadProxy::AsValue() const { |
| 389 | scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 390 | { |
| 391 | // The following line casts away const modifiers because it is just |
| 392 | // setting debug state. We still want the AsValue() function and its |
| 393 | // call chain to be const throughout. |
| 394 | DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); |
| 395 | |
| 396 | state->Set("layer_tree_host_impl", |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 397 | layer_tree_host_impl_->AsValue().release()); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 398 | } |
| 399 | return state.PassAs<base::Value>(); |
[email protected] | 49306751 | 2012-09-19 23:34:10 | [diff] [blame] | 400 | } |
| 401 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 402 | void SingleThreadProxy::ForceSerializeOnSwapBuffers() { |
| 403 | { |
| 404 | DebugScopedSetImplThread impl(this); |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 405 | if (layer_tree_host_impl_->renderer()) { |
| 406 | DCHECK(!layer_tree_host_->output_surface_lost()); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 407 | layer_tree_host_impl_->renderer()->DoNoOp(); |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 408 | } |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 409 | } |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 410 | } |
| 411 | |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 412 | bool SingleThreadProxy::CommitAndComposite( |
| 413 | base::TimeTicks frame_begin_time, |
| 414 | gfx::Rect device_viewport_damage_rect, |
[email protected] | 2921d04 | 2013-05-10 05:01:39 | [diff] [blame] | 415 | bool for_readback, |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 416 | LayerTreeHostImpl::FrameData* frame) { |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 417 | DCHECK(Proxy::IsMainThread()); |
[email protected] | b1969fa | 2012-10-17 20:16:29 | [diff] [blame] | 418 | |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 419 | if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) |
[email protected] | 16288a4 | 2012-12-17 23:31:05 | [diff] [blame] | 420 | return false; |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 421 | |
[email protected] | d776366 | 2013-05-09 18:14:37 | [diff] [blame] | 422 | layer_tree_host_->AnimateLayers(frame_begin_time); |
| 423 | |
[email protected] | 6e8c5492 | 2013-06-02 19:17:35 | [diff] [blame] | 424 | if (layer_tree_host_->contents_texture_manager()) { |
| 425 | layer_tree_host_->contents_texture_manager() |
| 426 | ->UnlinkAndClearEvictedBackings(); |
[email protected] | 990e050a | 2013-09-23 18:50:21 | [diff] [blame] | 427 | layer_tree_host_->contents_texture_manager()->SetMaxMemoryLimitBytes( |
| 428 | layer_tree_host_impl_->memory_allocation_limit_bytes()); |
| 429 | layer_tree_host_->contents_texture_manager()->SetExternalPriorityCutoff( |
| 430 | layer_tree_host_impl_->memory_allocation_priority_cutoff()); |
[email protected] | 6e8c5492 | 2013-06-02 19:17:35 | [diff] [blame] | 431 | } |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 432 | |
| 433 | scoped_ptr<ResourceUpdateQueue> queue = |
| 434 | make_scoped_ptr(new ResourceUpdateQueue); |
[email protected] | 990e050a | 2013-09-23 18:50:21 | [diff] [blame] | 435 | layer_tree_host_->UpdateLayers(queue.get()); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 436 | |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 437 | layer_tree_host_->WillCommit(); |
[email protected] | a024d0e | 2013-09-26 19:20:45 | [diff] [blame] | 438 | |
| 439 | scoped_refptr<cc::ContextProvider> offscreen_context_provider; |
| 440 | if (renderer_capabilities_for_main_thread_.using_offscreen_context3d && |
| 441 | layer_tree_host_->needs_offscreen_context()) { |
| 442 | offscreen_context_provider = |
[email protected] | f10dc47 | 2013-09-27 03:31:59 | [diff] [blame^] | 443 | layer_tree_host_->client()->OffscreenContextProvider(); |
| 444 | if (offscreen_context_provider.get() && |
| 445 | !offscreen_context_provider->BindToCurrentThread()) |
| 446 | offscreen_context_provider = NULL; |
| 447 | |
[email protected] | a024d0e | 2013-09-26 19:20:45 | [diff] [blame] | 448 | if (offscreen_context_provider.get()) |
| 449 | created_offscreen_context_provider_ = true; |
| 450 | } |
| 451 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 452 | DoCommit(queue.Pass()); |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 453 | bool result = DoComposite(offscreen_context_provider, |
| 454 | frame_begin_time, |
| 455 | device_viewport_damage_rect, |
[email protected] | 2921d04 | 2013-05-10 05:01:39 | [diff] [blame] | 456 | for_readback, |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 457 | frame); |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 458 | layer_tree_host_->DidBeginFrame(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 459 | return result; |
[email protected] | 16288a4 | 2012-12-17 23:31:05 | [diff] [blame] | 460 | } |
| 461 | |
[email protected] | 3d9f743 | 2013-04-06 00:35:18 | [diff] [blame] | 462 | bool SingleThreadProxy::ShouldComposite() const { |
| 463 | DCHECK(Proxy::IsImplThread()); |
| 464 | return layer_tree_host_impl_->visible() && |
| 465 | layer_tree_host_impl_->CanDraw(); |
| 466 | } |
| 467 | |
[email protected] | d9fce672 | 2013-08-30 01:10:01 | [diff] [blame] | 468 | void SingleThreadProxy::UpdateBackgroundAnimateTicking() { |
| 469 | DCHECK(Proxy::IsImplThread()); |
| 470 | layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
| 471 | !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); |
| 472 | } |
| 473 | |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 474 | bool SingleThreadProxy::DoComposite( |
[email protected] | f0c2a24 | 2013-03-15 19:34:52 | [diff] [blame] | 475 | scoped_refptr<cc::ContextProvider> offscreen_context_provider, |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 476 | base::TimeTicks frame_begin_time, |
| 477 | gfx::Rect device_viewport_damage_rect, |
[email protected] | 2921d04 | 2013-05-10 05:01:39 | [diff] [blame] | 478 | bool for_readback, |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 479 | LayerTreeHostImpl::FrameData* frame) { |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 480 | DCHECK(!layer_tree_host_->output_surface_lost()); |
| 481 | |
| 482 | bool lost_output_surface = false; |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 483 | { |
| 484 | DebugScopedSetImplThread impl(this); |
| 485 | base::AutoReset<bool> mark_inside(&inside_draw_, true); |
| 486 | |
[email protected] | b5174d71 | 2013-08-28 08:10:43 | [diff] [blame] | 487 | layer_tree_host_impl_->SetOffscreenContextProvider( |
| 488 | offscreen_context_provider); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 489 | |
[email protected] | 2921d04 | 2013-05-10 05:01:39 | [diff] [blame] | 490 | bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); |
| 491 | |
[email protected] | 3d9f743 | 2013-04-06 00:35:18 | [diff] [blame] | 492 | // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
| 493 | // frame, so can only be used when such a frame is possible. Since |
| 494 | // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
| 495 | // CanDraw() as well. |
[email protected] | 2921d04 | 2013-05-10 05:01:39 | [diff] [blame] | 496 | if (!ShouldComposite() || (for_readback && !can_do_readback)) { |
[email protected] | d9fce672 | 2013-08-30 01:10:01 | [diff] [blame] | 497 | UpdateBackgroundAnimateTicking(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 498 | return false; |
[email protected] | 3d9f743 | 2013-04-06 00:35:18 | [diff] [blame] | 499 | } |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 500 | |
[email protected] | fb7425a | 2013-04-22 16:28:55 | [diff] [blame] | 501 | layer_tree_host_impl_->Animate( |
| 502 | layer_tree_host_impl_->CurrentFrameTimeTicks(), |
| 503 | layer_tree_host_impl_->CurrentFrameTime()); |
[email protected] | d9fce672 | 2013-08-30 01:10:01 | [diff] [blame] | 504 | UpdateBackgroundAnimateTicking(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 505 | |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 506 | layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect); |
| 507 | layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); |
| 508 | layer_tree_host_impl_->DidDrawAllLayers(*frame); |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 509 | lost_output_surface = layer_tree_host_impl_->IsContextLost(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 510 | |
[email protected] | 3d9f743 | 2013-04-06 00:35:18 | [diff] [blame] | 511 | bool start_ready_animations = true; |
| 512 | layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
| 513 | |
[email protected] | 8347d69 | 2013-05-17 23:22:38 | [diff] [blame] | 514 | layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 515 | } |
| 516 | |
[email protected] | 04049fc | 2013-05-01 03:13:20 | [diff] [blame] | 517 | if (lost_output_surface) { |
[email protected] | b5174d71 | 2013-08-28 08:10:43 | [diff] [blame] | 518 | cc::ContextProvider* offscreen_contexts = |
| 519 | layer_tree_host_impl_->offscreen_context_provider(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 520 | if (offscreen_contexts) |
| 521 | offscreen_contexts->VerifyContexts(); |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 522 | layer_tree_host_->DidLoseOutputSurface(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 523 | return false; |
| 524 | } |
| 525 | |
| 526 | return true; |
| 527 | } |
| 528 | |
| 529 | void SingleThreadProxy::DidSwapFrame() { |
| 530 | if (next_frame_is_newly_committed_frame_) { |
| 531 | next_frame_is_newly_committed_frame_ = false; |
[email protected] | 804c898 | 2013-03-13 16:32:21 | [diff] [blame] | 532 | layer_tree_host_->DidCommitAndDrawFrame(); |
[email protected] | a8a049c | 2013-03-11 23:27:06 | [diff] [blame] | 533 | } |
| 534 | } |
| 535 | |
| 536 | bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
| 537 | |
[email protected] | bc5e77c | 2012-11-05 20:00:49 | [diff] [blame] | 538 | } // namespace cc |