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