Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: cc/single_thread_proxy.cc

Issue 12648005: cc: Chromify the LayerTreeHostImpl class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compl Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/single_thread_proxy.h ('k') | cc/solid_color_layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/single_thread_proxy.h" 5 #include "cc/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/context_provider.h" 9 #include "cc/context_provider.h"
10 #include "cc/draw_quad.h" 10 #include "cc/draw_quad.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()) 58 if (!CommitAndComposite())
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())
66 return false; 66 return false;
67 67
68 layer_tree_host_impl_->swapBuffers(); 68 layer_tree_host_impl_->SwapBuffers();
69 } 69 }
70 DidSwapFrame(); 70 DidSwapFrame();
71 71
72 return true; 72 return true;
73 } 73 }
74 74
75 void SingleThreadProxy::StartPageScaleAnimation(gfx::Vector2d target_offset, 75 void SingleThreadProxy::StartPageScaleAnimation(gfx::Vector2d target_offset,
76 bool use_anchor, 76 bool use_anchor,
77 float scale, 77 float scale,
78 base::TimeDelta duration) { 78 base::TimeDelta duration) {
79 layer_tree_host_impl_->startPageScaleAnimation( 79 layer_tree_host_impl_->StartPageScaleAnimation(
80 target_offset, use_anchor, scale, base::TimeTicks::Now(), duration); 80 target_offset, use_anchor, scale, base::TimeTicks::Now(), duration);
81 } 81 }
82 82
83 void SingleThreadProxy::FinishAllRendering() { 83 void SingleThreadProxy::FinishAllRendering() {
84 DCHECK(Proxy::IsMainThread()); 84 DCHECK(Proxy::IsMainThread());
85 { 85 {
86 DebugScopedSetImplThread impl(this); 86 DebugScopedSetImplThread impl(this);
87 layer_tree_host_impl_->finishAllRendering(); 87 layer_tree_host_impl_->FinishAllRendering();
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> outputSurface =
99 layer_tree_host_->CreateOutputSurface(); 99 layer_tree_host_->CreateOutputSurface();
100 if (!outputSurface.get()) 100 if (!outputSurface.get())
101 return false; 101 return false;
102 output_surface_before_initialization_ = outputSurface.Pass(); 102 output_surface_before_initialization_ = outputSurface.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);
113 layer_tree_host_impl_->setVisible(visible); 113 layer_tree_host_impl_->SetVisible(visible);
114 } 114 }
115 115
116 bool SingleThreadProxy::InitializeRenderer() { 116 bool SingleThreadProxy::InitializeRenderer() {
117 DCHECK(Proxy::IsMainThread()); 117 DCHECK(Proxy::IsMainThread());
118 DCHECK(output_surface_before_initialization_.get()); 118 DCHECK(output_surface_before_initialization_.get());
119 { 119 {
120 DebugScopedSetImplThread impl(this); 120 DebugScopedSetImplThread impl(this);
121 bool ok = layer_tree_host_impl_->initializeRenderer( 121 bool ok = layer_tree_host_impl_->InitializeRenderer(
122 output_surface_before_initialization_.Pass()); 122 output_surface_before_initialization_.Pass());
123 if (ok) { 123 if (ok) {
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_->rendererCapabilities(); 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> outputSurface =
139 layer_tree_host_->CreateOutputSurface(); 139 layer_tree_host_->CreateOutputSurface();
140 if (!outputSurface.get()) 140 if (!outputSurface.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->InitializeOnMainThread()) 146 if (!offscreen_context_provider->InitializeOnMainThread())
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_->resourceProvider()); 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(outputSurface.Pass());
158 if (initialized) { 158 if (initialized) {
159 renderer_capabilities_for_main_thread_ = 159 renderer_capabilities_for_main_thread_ =
160 layer_tree_host_impl_->rendererCapabilities(); 160 layer_tree_host_impl_->GetRendererCapabilities();
161 layer_tree_host_impl_->resourceProvider() 161 layer_tree_host_impl_->resource_provider()
162 ->SetOffscreenContextProvider(offscreen_context_provider); 162 ->SetOffscreenContextProvider(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
168 if (initialized) 168 if (initialized)
169 output_surface_lost_ = false; 169 output_surface_lost_ = false;
170 170
171 return initialized; 171 return initialized;
172 } 172 }
173 173
174 void SingleThreadProxy::CollectRenderingStats(RenderingStats* stats) { 174 void SingleThreadProxy::CollectRenderingStats(RenderingStats* stats) {
175 stats->totalCommitTime = total_commit_time_; 175 stats->totalCommitTime = total_commit_time_;
176 stats->totalCommitCount = total_commit_count_; 176 stats->totalCommitCount = total_commit_count_;
177 layer_tree_host_impl_->renderingStats(stats); 177 layer_tree_host_impl_->CollectRenderingStats(stats);
178 } 178 }
179 179
180 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { 180 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const {
181 DCHECK(renderer_initialized_); 181 DCHECK(renderer_initialized_);
182 // Note: this gets called during the commit by the "impl" thread. 182 // Note: this gets called during the commit by the "impl" thread.
183 return renderer_capabilities_for_main_thread_; 183 return renderer_capabilities_for_main_thread_;
184 } 184 }
185 185
186 void SingleThreadProxy::SetNeedsAnimate() { 186 void SingleThreadProxy::SetNeedsAnimate() {
187 // Thread-only feature. 187 // Thread-only feature.
188 NOTREACHED(); 188 NOTREACHED();
189 } 189 }
190 190
191 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { 191 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) {
192 DCHECK(Proxy::IsMainThread()); 192 DCHECK(Proxy::IsMainThread());
193 // Commit immediately. 193 // Commit immediately.
194 { 194 {
195 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 195 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
196 DebugScopedSetImplThread impl(this); 196 DebugScopedSetImplThread impl(this);
197 197
198 base::TimeTicks startTime = base::TimeTicks::HighResNow(); 198 base::TimeTicks startTime = base::TimeTicks::HighResNow();
199 layer_tree_host_impl_->beginCommit(); 199 layer_tree_host_impl_->BeginCommit();
200 200
201 layer_tree_host_->contents_texture_manager()-> 201 layer_tree_host_->contents_texture_manager()->
202 pushTexturePrioritiesToBackings(); 202 pushTexturePrioritiesToBackings();
203 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); 203 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get());
204 204
205 scoped_ptr<ResourceUpdateController> updateController = 205 scoped_ptr<ResourceUpdateController> updateController =
206 ResourceUpdateController::Create( 206 ResourceUpdateController::Create(
207 NULL, 207 NULL,
208 Proxy::MainThread(), 208 Proxy::MainThread(),
209 queue.Pass(), 209 queue.Pass(),
210 layer_tree_host_impl_->resourceProvider()); 210 layer_tree_host_impl_->resource_provider());
211 updateController->Finalize(); 211 updateController->Finalize();
212 212
213 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); 213 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get());
214 214
215 layer_tree_host_impl_->commitComplete(); 215 layer_tree_host_impl_->CommitComplete();
216 216
217 #ifndef NDEBUG 217 #ifndef NDEBUG
218 // In the single-threaded case, the scroll deltas should never be 218 // In the single-threaded case, the scroll deltas should never be
219 // touched on the impl layer tree. 219 // touched on the impl layer tree.
220 scoped_ptr<ScrollAndScaleSet> scrollInfo = 220 scoped_ptr<ScrollAndScaleSet> scrollInfo =
221 layer_tree_host_impl_->processScrollDeltas(); 221 layer_tree_host_impl_->ProcessScrollDeltas();
222 DCHECK(!scrollInfo->scrolls.size()); 222 DCHECK(!scrollInfo->scrolls.size());
223 #endif 223 #endif
224 224
225 base::TimeTicks endTime = base::TimeTicks::HighResNow(); 225 base::TimeTicks endTime = base::TimeTicks::HighResNow();
226 total_commit_time_ += endTime - startTime; 226 total_commit_time_ += endTime - startTime;
227 total_commit_count_++; 227 total_commit_count_++;
228 } 228 }
229 layer_tree_host_->CommitComplete(); 229 layer_tree_host_->CommitComplete();
230 next_frame_is_newly_committed_frame_ = true; 230 next_frame_is_newly_committed_frame_ = true;
231 } 231 }
232 232
233 void SingleThreadProxy::SetNeedsCommit() { 233 void SingleThreadProxy::SetNeedsCommit() {
234 DCHECK(Proxy::IsMainThread()); 234 DCHECK(Proxy::IsMainThread());
235 layer_tree_host_->ScheduleComposite(); 235 layer_tree_host_->ScheduleComposite();
236 } 236 }
237 237
238 void SingleThreadProxy::SetNeedsRedraw() { 238 void SingleThreadProxy::SetNeedsRedraw() {
239 // FIXME: Once we move render_widget scheduling into this class, we can 239 // FIXME: Once we move render_widget scheduling into this class, we can
240 // treat redraw requests more efficiently than commitAndRedraw requests. 240 // treat redraw requests more efficiently than commitAndRedraw requests.
241 layer_tree_host_impl_->SetFullRootLayerDamage(); 241 layer_tree_host_impl_->SetFullRootLayerDamage();
242 SetNeedsCommit(); 242 SetNeedsCommit();
243 } 243 }
244 244
245 void SingleThreadProxy::onHasPendingTreeStateChanged(bool have_pending_tree) { 245 void SingleThreadProxy::OnHasPendingTreeStateChanged(bool have_pending_tree) {
246 // Thread-only feature. 246 // Thread-only feature.
247 NOTREACHED(); 247 NOTREACHED();
248 } 248 }
249 249
250 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { 250 void SingleThreadProxy::SetDeferCommits(bool defer_commits) {
251 // Thread-only feature. 251 // Thread-only feature.
252 NOTREACHED(); 252 NOTREACHED();
253 } 253 }
254 254
255 bool SingleThreadProxy::CommitRequested() const { return false; } 255 bool SingleThreadProxy::CommitRequested() const { return false; }
256 256
257 size_t SingleThreadProxy::MaxPartialTextureUpdates() const { 257 size_t SingleThreadProxy::MaxPartialTextureUpdates() const {
258 return std::numeric_limits<size_t>::max(); 258 return std::numeric_limits<size_t>::max();
259 } 259 }
260 260
261 void SingleThreadProxy::Stop() { 261 void SingleThreadProxy::Stop() {
262 TRACE_EVENT0("cc", "SingleThreadProxy::stop"); 262 TRACE_EVENT0("cc", "SingleThreadProxy::stop");
263 DCHECK(Proxy::IsMainThread()); 263 DCHECK(Proxy::IsMainThread());
264 { 264 {
265 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 265 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
266 DebugScopedSetImplThread impl(this); 266 DebugScopedSetImplThread impl(this);
267 267
268 layer_tree_host_->DeleteContentsTexturesOnImplThread( 268 layer_tree_host_->DeleteContentsTexturesOnImplThread(
269 layer_tree_host_impl_->resourceProvider()); 269 layer_tree_host_impl_->resource_provider());
270 layer_tree_host_impl_.reset(); 270 layer_tree_host_impl_.reset();
271 } 271 }
272 layer_tree_host_ = NULL; 272 layer_tree_host_ = NULL;
273 } 273 }
274 274
275 void SingleThreadProxy::setNeedsRedrawOnImplThread() { 275 void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
276 layer_tree_host_->ScheduleComposite(); 276 layer_tree_host_->ScheduleComposite();
277 } 277 }
278 278
279 void SingleThreadProxy::didUploadVisibleHighResolutionTileOnImplThread() { 279 void SingleThreadProxy::DidUploadVisibleHighResolutionTileOnImplThread() {
280 // Impl-side painting only. 280 // Impl-side painting only.
281 NOTREACHED(); 281 NOTREACHED();
282 } 282 }
283 283
284 void SingleThreadProxy::setNeedsCommitOnImplThread() { 284 void SingleThreadProxy::SetNeedsCommitOnImplThread() {
285 layer_tree_host_->ScheduleComposite(); 285 layer_tree_host_->ScheduleComposite();
286 } 286 }
287 287
288 void SingleThreadProxy::setNeedsManageTilesOnImplThread() { 288 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() {
289 layer_tree_host_->ScheduleComposite(); 289 layer_tree_host_->ScheduleComposite();
290 } 290 }
291 291
292 void SingleThreadProxy::postAnimationEventsToMainThreadOnImplThread( 292 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
293 scoped_ptr<AnimationEventsVector> events, 293 scoped_ptr<AnimationEventsVector> events,
294 base::Time wall_clock_time) { 294 base::Time wall_clock_time) {
295 DCHECK(Proxy::IsImplThread()); 295 DCHECK(Proxy::IsImplThread());
296 DebugScopedSetMainThread main(this); 296 DebugScopedSetMainThread main(this);
297 layer_tree_host_->SetAnimationEvents(events.Pass(), wall_clock_time); 297 layer_tree_host_->SetAnimationEvents(events.Pass(), wall_clock_time);
298 } 298 }
299 299
300 bool SingleThreadProxy::reduceContentsTextureMemoryOnImplThread( 300 bool SingleThreadProxy::ReduceContentsTextureMemoryOnImplThread(
301 size_t limit_bytes, 301 size_t limit_bytes,
302 int priority_cutoff) { 302 int priority_cutoff) {
303 DCHECK(IsImplThread()); 303 DCHECK(IsImplThread());
304 if (!layer_tree_host_->contents_texture_manager()) 304 if (!layer_tree_host_->contents_texture_manager())
305 return false; 305 return false;
306 306
307 return layer_tree_host_->contents_texture_manager()->reduceMemoryOnImplThread( 307 return layer_tree_host_->contents_texture_manager()->reduceMemoryOnImplThread(
308 limit_bytes, priority_cutoff, layer_tree_host_impl_->resourceProvider()); 308 limit_bytes, priority_cutoff, layer_tree_host_impl_->resource_provider());
309 } 309 }
310 310
311 void SingleThreadProxy::reduceWastedContentsTextureMemoryOnImplThread() { 311 void SingleThreadProxy::ReduceWastedContentsTextureMemoryOnImplThread() {
312 // Impl-side painting only. 312 // Impl-side painting only.
313 NOTREACHED(); 313 NOTREACHED();
314 } 314 }
315 315
316 void SingleThreadProxy::sendManagedMemoryStats() { 316 void SingleThreadProxy::SendManagedMemoryStats() {
317 DCHECK(Proxy::IsImplThread()); 317 DCHECK(Proxy::IsImplThread());
318 if (!layer_tree_host_impl_.get()) 318 if (!layer_tree_host_impl_.get())
319 return; 319 return;
320 if (!layer_tree_host_->contents_texture_manager()) 320 if (!layer_tree_host_->contents_texture_manager())
321 return; 321 return;
322 322
323 PrioritizedResourceManager* contents_texture_manager = 323 PrioritizedResourceManager* contents_texture_manager =
324 layer_tree_host_->contents_texture_manager(); 324 layer_tree_host_->contents_texture_manager();
325 layer_tree_host_impl_->sendManagedMemoryStats( 325 layer_tree_host_impl_->SendManagedMemoryStats(
326 contents_texture_manager->memoryVisibleBytes(), 326 contents_texture_manager->memoryVisibleBytes(),
327 contents_texture_manager->memoryVisibleAndNearbyBytes(), 327 contents_texture_manager->memoryVisibleAndNearbyBytes(),
328 contents_texture_manager->memoryUseBytes()); 328 contents_texture_manager->memoryUseBytes());
329 } 329 }
330 330
331 bool SingleThreadProxy::isInsideDraw() { return inside_draw_; } 331 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; }
332 332
333 void SingleThreadProxy::didLoseOutputSurfaceOnImplThread() { 333 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() {
334 // Cause a commit so we can notice the lost context. 334 // Cause a commit so we can notice the lost context.
335 setNeedsCommitOnImplThread(); 335 SetNeedsCommitOnImplThread();
336 } 336 }
337 337
338 // Called by the legacy scheduling path (e.g. where render_widget does the 338 // Called by the legacy scheduling path (e.g. where render_widget does the
339 // scheduling) 339 // scheduling)
340 void SingleThreadProxy::CompositeImmediately() { 340 void SingleThreadProxy::CompositeImmediately() {
341 if (CommitAndComposite()) { 341 if (CommitAndComposite()) {
342 layer_tree_host_impl_->swapBuffers(); 342 layer_tree_host_impl_->SwapBuffers();
343 DidSwapFrame(); 343 DidSwapFrame();
344 } 344 }
345 } 345 }
346 346
347 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const { 347 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const {
348 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 348 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
349 { 349 {
350 // The following line casts away const modifiers because it is just 350 // The following line casts away const modifiers because it is just
351 // setting debug state. We still want the AsValue() function and its 351 // setting debug state. We still want the AsValue() function and its
352 // call chain to be const throughout. 352 // call chain to be const throughout.
353 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); 353 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this));
354 354
355 state->Set("layer_tree_host_impl", 355 state->Set("layer_tree_host_impl",
356 layer_tree_host_impl_->asValue().release()); 356 layer_tree_host_impl_->AsValue().release());
357 } 357 }
358 return state.PassAs<base::Value>(); 358 return state.PassAs<base::Value>();
359 } 359 }
360 360
361 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { 361 void SingleThreadProxy::ForceSerializeOnSwapBuffers() {
362 { 362 {
363 DebugScopedSetImplThread impl(this); 363 DebugScopedSetImplThread impl(this);
364 if (renderer_initialized_) 364 if (renderer_initialized_)
365 layer_tree_host_impl_->renderer()->DoNoOp(); 365 layer_tree_host_impl_->renderer()->DoNoOp();
366 } 366 }
367 } 367 }
368 368
369 void SingleThreadProxy::onSwapBuffersCompleteOnImplThread() { NOTREACHED(); } 369 void SingleThreadProxy::OnSwapBuffersCompleteOnImplThread() { NOTREACHED(); }
370 370
371 bool SingleThreadProxy::CommitAndComposite() { 371 bool SingleThreadProxy::CommitAndComposite() {
372 DCHECK(Proxy::IsMainThread()); 372 DCHECK(Proxy::IsMainThread());
373 373
374 if (!layer_tree_host_->InitializeRendererIfNeeded()) 374 if (!layer_tree_host_->InitializeRendererIfNeeded())
375 return false; 375 return false;
376 376
377 scoped_refptr<cc::ContextProvider> offscreen_context_provider; 377 scoped_refptr<cc::ContextProvider> offscreen_context_provider;
378 if (renderer_capabilities_for_main_thread_.using_offscreen_context3d && 378 if (renderer_capabilities_for_main_thread_.using_offscreen_context3d &&
379 layer_tree_host_->needs_offscreen_context()) { 379 layer_tree_host_->needs_offscreen_context()) {
380 offscreen_context_provider = 380 offscreen_context_provider =
381 layer_tree_host_->client()->OffscreenContextProviderForMainThread(); 381 layer_tree_host_->client()->OffscreenContextProviderForMainThread();
382 if (offscreen_context_provider->InitializeOnMainThread()) 382 if (offscreen_context_provider->InitializeOnMainThread())
383 created_offscreen_context_provider = true; 383 created_offscreen_context_provider = true;
384 else 384 else
385 offscreen_context_provider = NULL; 385 offscreen_context_provider = NULL;
386 } 386 }
387 387
388 layer_tree_host_->contents_texture_manager()->unlinkAndClearEvictedBackings(); 388 layer_tree_host_->contents_texture_manager()->unlinkAndClearEvictedBackings();
389 389
390 scoped_ptr<ResourceUpdateQueue> queue = 390 scoped_ptr<ResourceUpdateQueue> queue =
391 make_scoped_ptr(new ResourceUpdateQueue); 391 make_scoped_ptr(new ResourceUpdateQueue);
392 layer_tree_host_->UpdateLayers( 392 layer_tree_host_->UpdateLayers(
393 queue.get(), layer_tree_host_impl_->memoryAllocationLimitBytes()); 393 queue.get(), layer_tree_host_impl_->memory_allocation_limit_bytes());
394 394
395 layer_tree_host_->WillCommit(); 395 layer_tree_host_->WillCommit();
396 DoCommit(queue.Pass()); 396 DoCommit(queue.Pass());
397 bool result = DoComposite(offscreen_context_provider); 397 bool result = DoComposite(offscreen_context_provider);
398 layer_tree_host_->DidBeginFrame(); 398 layer_tree_host_->DidBeginFrame();
399 return result; 399 return result;
400 } 400 }
401 401
402 bool SingleThreadProxy::DoComposite( 402 bool SingleThreadProxy::DoComposite(
403 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { 403 scoped_refptr<cc::ContextProvider> offscreen_context_provider) {
404 DCHECK(!output_surface_lost_); 404 DCHECK(!output_surface_lost_);
405 { 405 {
406 DebugScopedSetImplThread impl(this); 406 DebugScopedSetImplThread impl(this);
407 base::AutoReset<bool> mark_inside(&inside_draw_, true); 407 base::AutoReset<bool> mark_inside(&inside_draw_, true);
408 408
409 layer_tree_host_impl_->resourceProvider()-> 409 layer_tree_host_impl_->resource_provider()->
410 SetOffscreenContextProvider(offscreen_context_provider); 410 SetOffscreenContextProvider(offscreen_context_provider);
411 411
412 if (!layer_tree_host_impl_->visible()) 412 if (!layer_tree_host_impl_->visible())
413 return false; 413 return false;
414 414
415 layer_tree_host_impl_->animate(base::TimeTicks::Now(), base::Time::Now()); 415 layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now());
416 416
417 // We guard prepareToDraw() with canDraw() because it always returns a valid 417 // We guard prepareToDraw() with canDraw() because it always returns a valid
418 // frame, so can only be used when such a frame is possible. Since 418 // frame, so can only be used when such a frame is possible. Since
419 // drawLayers() depends on the result of prepareToDraw(), it is guarded on 419 // drawLayers() depends on the result of prepareToDraw(), it is guarded on
420 // canDraw() as well. 420 // canDraw() as well.
421 if (!layer_tree_host_impl_->canDraw()) 421 if (!layer_tree_host_impl_->CanDraw())
422 return false; 422 return false;
423 423
424 LayerTreeHostImpl::FrameData frame; 424 LayerTreeHostImpl::FrameData frame;
425 layer_tree_host_impl_->prepareToDraw(frame); 425 layer_tree_host_impl_->PrepareToDraw(&frame);
426 layer_tree_host_impl_->drawLayers(frame); 426 layer_tree_host_impl_->DrawLayers(&frame);
427 layer_tree_host_impl_->didDrawAllLayers(frame); 427 layer_tree_host_impl_->DidDrawAllLayers(frame);
428 output_surface_lost_ = layer_tree_host_impl_->isContextLost(); 428 output_surface_lost_ = layer_tree_host_impl_->IsContextLost();
429 429
430 layer_tree_host_impl_->beginNextFrame(); 430 layer_tree_host_impl_->BeginNextFrame();
431 } 431 }
432 432
433 if (output_surface_lost_) { 433 if (output_surface_lost_) {
434 cc::ContextProvider* offscreen_contexts = layer_tree_host_impl_-> 434 cc::ContextProvider* offscreen_contexts = layer_tree_host_impl_->
435 resourceProvider()->offscreen_context_provider(); 435 resource_provider()->offscreen_context_provider();
436 if (offscreen_contexts) 436 if (offscreen_contexts)
437 offscreen_contexts->VerifyContexts(); 437 offscreen_contexts->VerifyContexts();
438 layer_tree_host_->DidLoseOutputSurface(); 438 layer_tree_host_->DidLoseOutputSurface();
439 return false; 439 return false;
440 } 440 }
441 441
442 return true; 442 return true;
443 } 443 }
444 444
445 void SingleThreadProxy::DidSwapFrame() { 445 void SingleThreadProxy::DidSwapFrame() {
446 if (next_frame_is_newly_committed_frame_) { 446 if (next_frame_is_newly_committed_frame_) {
447 next_frame_is_newly_committed_frame_ = false; 447 next_frame_is_newly_committed_frame_ = false;
448 layer_tree_host_->DidCommitAndDrawFrame(); 448 layer_tree_host_->DidCommitAndDrawFrame();
449 } 449 }
450 } 450 }
451 451
452 bool SingleThreadProxy::CommitPendingForTesting() { return false; } 452 bool SingleThreadProxy::CommitPendingForTesting() { return false; }
453 453
454 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { 454 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() {
455 // Impl-side painting only. 455 // Impl-side painting only.
456 NOTREACHED(); 456 NOTREACHED();
457 return skia::RefPtr<SkPicture>(); 457 return skia::RefPtr<SkPicture>();
458 } 458 }
459 459
460 } // namespace cc 460 } // namespace cc
OLDNEW
« no previous file with comments | « cc/single_thread_proxy.h ('k') | cc/solid_color_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698