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/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "cc/base/thread.h" | 9 #include "cc/base/thread.h" |
10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 SingleThreadProxy::~SingleThreadProxy() { | 47 SingleThreadProxy::~SingleThreadProxy() { |
48 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); | 48 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); |
49 DCHECK(Proxy::IsMainThread()); | 49 DCHECK(Proxy::IsMainThread()); |
50 DCHECK(!layer_tree_host_impl_.get() && | 50 DCHECK(!layer_tree_host_impl_.get() && |
51 !layer_tree_host_); // make sure Stop() got called. | 51 !layer_tree_host_); // make sure Stop() got called. |
52 } | 52 } |
53 | 53 |
54 bool SingleThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) { | 54 bool SingleThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) { |
55 TRACE_EVENT0("cc", "SingleThreadProxy::compositeAndReadback"); | 55 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeAndReadback"); |
56 DCHECK(Proxy::IsMainThread()); | 56 DCHECK(Proxy::IsMainThread()); |
57 | 57 |
58 if (!CommitAndComposite(base::TimeTicks::Now())) | 58 if (!CommitAndComposite(base::TimeTicks::Now())) |
59 return false; | 59 return false; |
60 | 60 |
61 { | 61 { |
62 DebugScopedSetImplThread impl(this); | 62 DebugScopedSetImplThread impl(this); |
63 layer_tree_host_impl_->Readback(pixels, rect); | 63 layer_tree_host_impl_->Readback(pixels, rect); |
64 | 64 |
65 if (layer_tree_host_impl_->IsContextLost()) | 65 if (layer_tree_host_impl_->IsContextLost()) |
(...skipping 22 matching lines...) Expand all Loading... |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 bool SingleThreadProxy::IsStarted() const { | 91 bool SingleThreadProxy::IsStarted() const { |
92 DCHECK(Proxy::IsMainThread()); | 92 DCHECK(Proxy::IsMainThread()); |
93 return layer_tree_host_impl_.get(); | 93 return layer_tree_host_impl_.get(); |
94 } | 94 } |
95 | 95 |
96 bool SingleThreadProxy::InitializeOutputSurface() { | 96 bool SingleThreadProxy::InitializeOutputSurface() { |
97 DCHECK(Proxy::IsMainThread()); | 97 DCHECK(Proxy::IsMainThread()); |
98 scoped_ptr<OutputSurface> outputSurface = | 98 scoped_ptr<OutputSurface> output_surface = |
99 layer_tree_host_->CreateOutputSurface(); | 99 layer_tree_host_->CreateOutputSurface(); |
100 if (!outputSurface.get()) | 100 if (!output_surface.get()) |
101 return false; | 101 return false; |
102 output_surface_before_initialization_ = outputSurface.Pass(); | 102 output_surface_before_initialization_ = output_surface.Pass(); |
103 return true; | 103 return true; |
104 } | 104 } |
105 | 105 |
106 void SingleThreadProxy::SetSurfaceReady() { | 106 void SingleThreadProxy::SetSurfaceReady() { |
107 // Scheduling is controlled by the embedder in the single thread case, so | 107 // Scheduling is controlled by the embedder in the single thread case, so |
108 // nothing to do. | 108 // nothing to do. |
109 } | 109 } |
110 | 110 |
111 void SingleThreadProxy::SetVisible(bool visible) { | 111 void SingleThreadProxy::SetVisible(bool visible) { |
112 DebugScopedSetImplThread impl(this); | 112 DebugScopedSetImplThread impl(this); |
(...skipping 11 matching lines...) Expand all Loading... |
124 renderer_initialized_ = true; | 124 renderer_initialized_ = true; |
125 renderer_capabilities_for_main_thread_ = | 125 renderer_capabilities_for_main_thread_ = |
126 layer_tree_host_impl_->GetRendererCapabilities(); | 126 layer_tree_host_impl_->GetRendererCapabilities(); |
127 } | 127 } |
128 | 128 |
129 return ok; | 129 return ok; |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 bool SingleThreadProxy::RecreateOutputSurface() { | 133 bool SingleThreadProxy::RecreateOutputSurface() { |
134 TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext"); | 134 TRACE_EVENT0("cc", "SingleThreadProxy::RecreateContext"); |
135 DCHECK(Proxy::IsMainThread()); | 135 DCHECK(Proxy::IsMainThread()); |
136 DCHECK(output_surface_lost_); | 136 DCHECK(output_surface_lost_); |
137 | 137 |
138 scoped_ptr<OutputSurface> outputSurface = | 138 scoped_ptr<OutputSurface> output_surface = |
139 layer_tree_host_->CreateOutputSurface(); | 139 layer_tree_host_->CreateOutputSurface(); |
140 if (!outputSurface.get()) | 140 if (!output_surface.get()) |
141 return false; | 141 return false; |
142 scoped_refptr<cc::ContextProvider> offscreen_context_provider; | 142 scoped_refptr<cc::ContextProvider> offscreen_context_provider; |
143 if (created_offscreen_context_provider_) { | 143 if (created_offscreen_context_provider_) { |
144 offscreen_context_provider = | 144 offscreen_context_provider = |
145 layer_tree_host_->client()->OffscreenContextProviderForMainThread(); | 145 layer_tree_host_->client()->OffscreenContextProviderForMainThread(); |
146 if (!offscreen_context_provider) | 146 if (!offscreen_context_provider) |
147 return false; | 147 return false; |
148 } | 148 } |
149 | 149 |
150 bool initialized; | 150 bool initialized; |
151 { | 151 { |
152 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); | 152 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
153 DebugScopedSetImplThread impl(this); | 153 DebugScopedSetImplThread impl(this); |
154 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 154 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
155 layer_tree_host_impl_->resource_provider()); | 155 layer_tree_host_impl_->resource_provider()); |
156 initialized = | 156 initialized = |
157 layer_tree_host_impl_->InitializeRenderer(outputSurface.Pass()); | 157 layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); |
158 if (initialized) { | 158 if (initialized) { |
159 renderer_capabilities_for_main_thread_ = | 159 renderer_capabilities_for_main_thread_ = |
160 layer_tree_host_impl_->GetRendererCapabilities(); | 160 layer_tree_host_impl_->GetRendererCapabilities(); |
161 layer_tree_host_impl_->resource_provider()-> | 161 layer_tree_host_impl_->resource_provider()-> |
162 set_offscreen_context_provider(offscreen_context_provider); | 162 set_offscreen_context_provider(offscreen_context_provider); |
163 } else if (offscreen_context_provider) { | 163 } else if (offscreen_context_provider) { |
164 offscreen_context_provider->VerifyContexts(); | 164 offscreen_context_provider->VerifyContexts(); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
(...skipping 16 matching lines...) Expand all Loading... |
184 | 184 |
185 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { | 185 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { |
186 DCHECK(Proxy::IsMainThread()); | 186 DCHECK(Proxy::IsMainThread()); |
187 // Commit immediately. | 187 // Commit immediately. |
188 { | 188 { |
189 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); | 189 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
190 DebugScopedSetImplThread impl(this); | 190 DebugScopedSetImplThread impl(this); |
191 | 191 |
192 RenderingStatsInstrumentation* stats_instrumentation = | 192 RenderingStatsInstrumentation* stats_instrumentation = |
193 layer_tree_host_->rendering_stats_instrumentation(); | 193 layer_tree_host_->rendering_stats_instrumentation(); |
194 base::TimeTicks startTime = stats_instrumentation->StartRecording(); | 194 base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
195 | 195 |
196 layer_tree_host_impl_->BeginCommit(); | 196 layer_tree_host_impl_->BeginCommit(); |
197 | 197 |
198 layer_tree_host_->contents_texture_manager()-> | 198 layer_tree_host_->contents_texture_manager()-> |
199 PushTexturePrioritiesToBackings(); | 199 PushTexturePrioritiesToBackings(); |
200 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); | 200 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); |
201 | 201 |
202 scoped_ptr<ResourceUpdateController> updateController = | 202 scoped_ptr<ResourceUpdateController> update_controller = |
203 ResourceUpdateController::Create( | 203 ResourceUpdateController::Create( |
204 NULL, | 204 NULL, |
205 Proxy::MainThread(), | 205 Proxy::MainThread(), |
206 queue.Pass(), | 206 queue.Pass(), |
207 layer_tree_host_impl_->resource_provider()); | 207 layer_tree_host_impl_->resource_provider()); |
208 updateController->Finalize(); | 208 update_controller->Finalize(); |
209 | 209 |
210 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 210 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
211 | 211 |
212 layer_tree_host_impl_->CommitComplete(); | 212 layer_tree_host_impl_->CommitComplete(); |
213 | 213 |
214 #ifndef NDEBUG | 214 #ifndef NDEBUG |
215 // In the single-threaded case, the scroll deltas should never be | 215 // In the single-threaded case, the scroll deltas should never be |
216 // touched on the impl layer tree. | 216 // touched on the impl layer tree. |
217 scoped_ptr<ScrollAndScaleSet> scrollInfo = | 217 scoped_ptr<ScrollAndScaleSet> scroll_info = |
218 layer_tree_host_impl_->ProcessScrollDeltas(); | 218 layer_tree_host_impl_->ProcessScrollDeltas(); |
219 DCHECK(!scrollInfo->scrolls.size()); | 219 DCHECK(!scroll_info->scrolls.size()); |
220 #endif | 220 #endif |
221 | 221 |
222 base::TimeDelta duration = stats_instrumentation->EndRecording(startTime); | 222 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); |
223 stats_instrumentation->AddCommit(duration); | 223 stats_instrumentation->AddCommit(duration); |
224 } | 224 } |
225 layer_tree_host_->CommitComplete(); | 225 layer_tree_host_->CommitComplete(); |
226 next_frame_is_newly_committed_frame_ = true; | 226 next_frame_is_newly_committed_frame_ = true; |
227 } | 227 } |
228 | 228 |
229 void SingleThreadProxy::SetNeedsCommit() { | 229 void SingleThreadProxy::SetNeedsCommit() { |
230 DCHECK(Proxy::IsMainThread()); | 230 DCHECK(Proxy::IsMainThread()); |
231 layer_tree_host_->ScheduleComposite(); | 231 layer_tree_host_->ScheduleComposite(); |
232 } | 232 } |
233 | 233 |
234 void SingleThreadProxy::SetNeedsRedraw() { | 234 void SingleThreadProxy::SetNeedsRedraw() { |
235 // FIXME: Once we move render_widget scheduling into this class, we can | 235 // FIXME: Once we move render_widget scheduling into this class, we can |
236 // treat redraw requests more efficiently than commitAndRedraw requests. | 236 // treat redraw requests more efficiently than CommitAndRedraw requests. |
237 layer_tree_host_impl_->SetFullRootLayerDamage(); | 237 layer_tree_host_impl_->SetFullRootLayerDamage(); |
238 SetNeedsCommit(); | 238 SetNeedsCommit(); |
239 } | 239 } |
240 | 240 |
241 void SingleThreadProxy::OnHasPendingTreeStateChanged(bool have_pending_tree) { | 241 void SingleThreadProxy::OnHasPendingTreeStateChanged(bool have_pending_tree) { |
242 // Thread-only feature. | 242 // Thread-only feature. |
243 NOTREACHED(); | 243 NOTREACHED(); |
244 } | 244 } |
245 | 245 |
246 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { | 246 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 446 |
447 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 447 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
448 | 448 |
449 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { | 449 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { |
450 // Impl-side painting only. | 450 // Impl-side painting only. |
451 NOTREACHED(); | 451 NOTREACHED(); |
452 return skia::RefPtr<SkPicture>(); | 452 return skia::RefPtr<SkPicture>(); |
453 } | 453 } |
454 | 454 |
455 } // namespace cc | 455 } // namespace cc |
OLD | NEW |