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

Side by Side Diff: cc/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/thread_proxy.h ('k') | cc/tiled_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/thread_proxy.h" 5 #include "cc/thread_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/context_provider.h" 10 #include "cc/context_provider.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 void ThreadProxy::StartPageScaleAnimation(gfx::Vector2d targetOffset, bool useAn chor, float scale, base::TimeDelta duration) 127 void ThreadProxy::StartPageScaleAnimation(gfx::Vector2d targetOffset, bool useAn chor, float scale, base::TimeDelta duration)
128 { 128 {
129 DCHECK(Proxy::IsMainThread()); 129 DCHECK(Proxy::IsMainThread());
130 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::requestStartPageScale AnimationOnImplThread, m_implThreadWeakPtr, targetOffset, useAnchor, scale, dura tion)); 130 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::requestStartPageScale AnimationOnImplThread, m_implThreadWeakPtr, targetOffset, useAnchor, scale, dura tion));
131 } 131 }
132 132
133 void ThreadProxy::requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targe tOffset, bool useAnchor, float scale, base::TimeDelta duration) 133 void ThreadProxy::requestStartPageScaleAnimationOnImplThread(gfx::Vector2d targe tOffset, bool useAnchor, float scale, base::TimeDelta duration)
134 { 134 {
135 DCHECK(Proxy::IsImplThread()); 135 DCHECK(Proxy::IsImplThread());
136 if (m_layerTreeHostImpl.get()) 136 if (m_layerTreeHostImpl.get())
137 m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, sc ale, base::TimeTicks::Now(), duration); 137 m_layerTreeHostImpl->StartPageScaleAnimation(targetOffset, useAnchor, sc ale, base::TimeTicks::Now(), duration);
138 } 138 }
139 139
140 void ThreadProxy::FinishAllRendering() 140 void ThreadProxy::FinishAllRendering()
141 { 141 {
142 DCHECK(Proxy::IsMainThread()); 142 DCHECK(Proxy::IsMainThread());
143 DCHECK(!m_deferCommits); 143 DCHECK(!m_deferCommits);
144 144
145 // Make sure all GL drawing is finished on the impl thread. 145 // Make sure all GL drawing is finished on the impl thread.
146 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 146 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
147 CompletionEvent completion; 147 CompletionEvent completion;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 TRACE_EVENT0("cc", "ThreadProxy::setVisible"); 183 TRACE_EVENT0("cc", "ThreadProxy::setVisible");
184 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 184 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
185 CompletionEvent completion; 185 CompletionEvent completion;
186 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::setVisibleOnImplThrea d, m_implThreadWeakPtr, &completion, visible)); 186 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::setVisibleOnImplThrea d, m_implThreadWeakPtr, &completion, visible));
187 completion.wait(); 187 completion.wait();
188 } 188 }
189 189
190 void ThreadProxy::setVisibleOnImplThread(CompletionEvent* completion, bool visib le) 190 void ThreadProxy::setVisibleOnImplThread(CompletionEvent* completion, bool visib le)
191 { 191 {
192 TRACE_EVENT0("cc", "ThreadProxy::setVisibleOnImplThread"); 192 TRACE_EVENT0("cc", "ThreadProxy::setVisibleOnImplThread");
193 m_layerTreeHostImpl->setVisible(visible); 193 m_layerTreeHostImpl->SetVisible(visible);
194 m_schedulerOnImplThread->setVisible(visible); 194 m_schedulerOnImplThread->setVisible(visible);
195 completion->signal(); 195 completion->signal();
196 } 196 }
197 197
198 bool ThreadProxy::InitializeRenderer() 198 bool ThreadProxy::InitializeRenderer()
199 { 199 {
200 TRACE_EVENT0("cc", "ThreadProxy::initializeRenderer"); 200 TRACE_EVENT0("cc", "ThreadProxy::initializeRenderer");
201 // Make a blocking call to initializeRendererOnImplThread. The results of th at call 201 // Make a blocking call to initializeRendererOnImplThread. The results of th at call
202 // are pushed into the initializeSucceeded and capabilities local variables. 202 // are pushed into the initializeSucceeded and capabilities local variables.
203 CompletionEvent completion; 203 CompletionEvent completion;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 DCHECK(IsMainThread()); 280 DCHECK(IsMainThread());
281 if (m_animateRequested) 281 if (m_animateRequested)
282 return; 282 return;
283 283
284 TRACE_EVENT0("cc", "ThreadProxy::setNeedsAnimate"); 284 TRACE_EVENT0("cc", "ThreadProxy::setNeedsAnimate");
285 m_animateRequested = true; 285 m_animateRequested = true;
286 286
287 if (m_commitRequestSentToImplThread) 287 if (m_commitRequestSentToImplThread)
288 return; 288 return;
289 m_commitRequestSentToImplThread = true; 289 m_commitRequestSentToImplThread = true;
290 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplT hread, m_implThreadWeakPtr)); 290 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::SetNeedsCommitOnImplT hread, m_implThreadWeakPtr));
291 } 291 }
292 292
293 void ThreadProxy::SetNeedsCommit() 293 void ThreadProxy::SetNeedsCommit()
294 { 294 {
295 DCHECK(IsMainThread()); 295 DCHECK(IsMainThread());
296 if (m_commitRequested) 296 if (m_commitRequested)
297 return; 297 return;
298 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommit"); 298 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommit");
299 m_commitRequested = true; 299 m_commitRequested = true;
300 300
301 if (m_commitRequestSentToImplThread) 301 if (m_commitRequestSentToImplThread)
302 return; 302 return;
303 m_commitRequestSentToImplThread = true; 303 m_commitRequestSentToImplThread = true;
304 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplT hread, m_implThreadWeakPtr)); 304 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::SetNeedsCommitOnImplT hread, m_implThreadWeakPtr));
305 } 305 }
306 306
307 void ThreadProxy::didLoseOutputSurfaceOnImplThread() 307 void ThreadProxy::DidLoseOutputSurfaceOnImplThread()
308 { 308 {
309 DCHECK(IsImplThread()); 309 DCHECK(IsImplThread());
310 TRACE_EVENT0("cc", "ThreadProxy::didLoseOutputSurfaceOnImplThread"); 310 TRACE_EVENT0("cc", "ThreadProxy::didLoseOutputSurfaceOnImplThread");
311 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::checkOutputSurfaceSta tusOnImplThread, m_implThreadWeakPtr)); 311 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::checkOutputSurfaceSta tusOnImplThread, m_implThreadWeakPtr));
312 } 312 }
313 313
314 void ThreadProxy::checkOutputSurfaceStatusOnImplThread() 314 void ThreadProxy::checkOutputSurfaceStatusOnImplThread()
315 { 315 {
316 DCHECK(IsImplThread()); 316 DCHECK(IsImplThread());
317 TRACE_EVENT0("cc", "ThreadProxy::checkOutputSurfaceStatusOnImplThread"); 317 TRACE_EVENT0("cc", "ThreadProxy::checkOutputSurfaceStatusOnImplThread");
318 if (!m_layerTreeHostImpl->isContextLost()) 318 if (!m_layerTreeHostImpl->IsContextLost())
319 return; 319 return;
320 if (cc::ContextProvider* offscreenContexts = m_layerTreeHostImpl->resourcePr ovider()->offscreen_context_provider()) 320 if (cc::ContextProvider* offscreenContexts = m_layerTreeHostImpl->resource_p rovider()->offscreen_context_provider())
321 offscreenContexts->VerifyContexts(); 321 offscreenContexts->VerifyContexts();
322 m_schedulerOnImplThread->didLoseOutputSurface(); 322 m_schedulerOnImplThread->didLoseOutputSurface();
323 } 323 }
324 324
325 void ThreadProxy::onSwapBuffersCompleteOnImplThread() 325 void ThreadProxy::OnSwapBuffersCompleteOnImplThread()
326 { 326 {
327 DCHECK(IsImplThread()); 327 DCHECK(IsImplThread());
328 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread"); 328 TRACE_EVENT0("cc", "ThreadProxy::onSwapBuffersCompleteOnImplThread");
329 m_schedulerOnImplThread->didSwapBuffersComplete(); 329 m_schedulerOnImplThread->didSwapBuffersComplete();
330 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::didCompleteSwapBuffer s, m_mainThreadWeakPtr)); 330 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::didCompleteSwapBuffer s, m_mainThreadWeakPtr));
331 } 331 }
332 332
333 void ThreadProxy::onVSyncParametersChanged(base::TimeTicks timebase, base::TimeD elta interval) 333 void ThreadProxy::OnVSyncParametersChanged(base::TimeTicks timebase, base::TimeD elta interval)
334 { 334 {
335 DCHECK(IsImplThread()); 335 DCHECK(IsImplThread());
336 TRACE_EVENT2("cc", "ThreadProxy::onVSyncParametersChanged", "timebase", (tim ebase - base::TimeTicks()).InMilliseconds(), "interval", interval.InMilliseconds ()); 336 TRACE_EVENT2("cc", "ThreadProxy::onVSyncParametersChanged", "timebase", (tim ebase - base::TimeTicks()).InMilliseconds(), "interval", interval.InMilliseconds ());
337 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); 337 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval);
338 } 338 }
339 339
340 void ThreadProxy::onCanDrawStateChanged(bool canDraw) 340 void ThreadProxy::OnCanDrawStateChanged(bool canDraw)
341 { 341 {
342 DCHECK(IsImplThread()); 342 DCHECK(IsImplThread());
343 TRACE_EVENT1("cc", "ThreadProxy::onCanDrawStateChanged", "canDraw", canDraw) ; 343 TRACE_EVENT1("cc", "ThreadProxy::onCanDrawStateChanged", "canDraw", canDraw) ;
344 m_schedulerOnImplThread->setCanDraw(canDraw); 344 m_schedulerOnImplThread->setCanDraw(canDraw);
345 } 345 }
346 346
347 void ThreadProxy::onHasPendingTreeStateChanged(bool hasPendingTree) 347 void ThreadProxy::OnHasPendingTreeStateChanged(bool hasPendingTree)
348 { 348 {
349 DCHECK(IsImplThread()); 349 DCHECK(IsImplThread());
350 TRACE_EVENT1("cc", "ThreadProxy::onHasPendingTreeStateChanged", "hasPendingT ree", hasPendingTree); 350 TRACE_EVENT1("cc", "ThreadProxy::onHasPendingTreeStateChanged", "hasPendingT ree", hasPendingTree);
351 m_schedulerOnImplThread->setHasPendingTree(hasPendingTree); 351 m_schedulerOnImplThread->setHasPendingTree(hasPendingTree);
352 } 352 }
353 353
354 void ThreadProxy::setNeedsCommitOnImplThread() 354 void ThreadProxy::SetNeedsCommitOnImplThread()
355 { 355 {
356 DCHECK(IsImplThread()); 356 DCHECK(IsImplThread());
357 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommitOnImplThread"); 357 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommitOnImplThread");
358 m_schedulerOnImplThread->setNeedsCommit(); 358 m_schedulerOnImplThread->setNeedsCommit();
359 } 359 }
360 360
361 void ThreadProxy::setNeedsManageTilesOnImplThread() 361 void ThreadProxy::SetNeedsManageTilesOnImplThread()
362 { 362 {
363 if (m_manageTilesPending) 363 if (m_manageTilesPending)
364 return; 364 return;
365 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::manageTilesOnImplThre ad, m_implThreadWeakPtr)); 365 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::manageTilesOnImplThre ad, m_implThreadWeakPtr));
366 m_manageTilesPending = true; 366 m_manageTilesPending = true;
367 } 367 }
368 368
369 void ThreadProxy::manageTilesOnImplThread() 369 void ThreadProxy::manageTilesOnImplThread()
370 { 370 {
371 // TODO(nduca): If needed, move this into CCSchedulerStateMachine. 371 // TODO(nduca): If needed, move this into CCSchedulerStateMachine.
372 m_manageTilesPending = false; 372 m_manageTilesPending = false;
373 if (m_layerTreeHostImpl) 373 if (m_layerTreeHostImpl)
374 m_layerTreeHostImpl->manageTiles(); 374 m_layerTreeHostImpl->ManageTiles();
375 } 375 }
376 376
377 void ThreadProxy::setNeedsForcedCommitOnImplThread() 377 void ThreadProxy::setNeedsForcedCommitOnImplThread()
378 { 378 {
379 DCHECK(IsImplThread()); 379 DCHECK(IsImplThread());
380 TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread"); 380 TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread");
381 m_schedulerOnImplThread->setNeedsForcedCommit(); 381 m_schedulerOnImplThread->setNeedsForcedCommit();
382 } 382 }
383 383
384 void ThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati onEventsVector> events, base::Time wallClockTime) 384 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati onEventsVector> events, base::Time wallClockTime)
385 { 385 {
386 DCHECK(IsImplThread()); 386 DCHECK(IsImplThread());
387 TRACE_EVENT0("cc", "ThreadProxy::postAnimationEventsToMainThreadOnImplThread "); 387 TRACE_EVENT0("cc", "ThreadProxy::postAnimationEventsToMainThreadOnImplThread ");
388 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::setAnimationEvents, m _mainThreadWeakPtr, base::Passed(&events), wallClockTime)); 388 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::setAnimationEvents, m _mainThreadWeakPtr, base::Passed(&events), wallClockTime));
389 } 389 }
390 390
391 bool ThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) 391 bool ThreadProxy::ReduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff)
392 { 392 {
393 DCHECK(IsImplThread()); 393 DCHECK(IsImplThread());
394 394
395 if (!m_layerTreeHost->contents_texture_manager()) 395 if (!m_layerTreeHost->contents_texture_manager())
396 return false; 396 return false;
397 397
398 bool reduceResult = m_layerTreeHost->contents_texture_manager()->reduceMemor yOnImplThread(limitBytes, priorityCutoff, m_layerTreeHostImpl->resourceProvider( )); 398 bool reduceResult = m_layerTreeHost->contents_texture_manager()->reduceMemor yOnImplThread(limitBytes, priorityCutoff, m_layerTreeHostImpl->resource_provider ());
399 if (!reduceResult) 399 if (!reduceResult)
400 return false; 400 return false;
401 401
402 // The texture upload queue may reference textures that were just purged, cl ear 402 // The texture upload queue may reference textures that were just purged, cl ear
403 // them from the queue. 403 // them from the queue.
404 if (m_currentResourceUpdateControllerOnImplThread.get()) 404 if (m_currentResourceUpdateControllerOnImplThread.get())
405 m_currentResourceUpdateControllerOnImplThread->DiscardUploadsToEvictedRe sources(); 405 m_currentResourceUpdateControllerOnImplThread->DiscardUploadsToEvictedRe sources();
406 return true; 406 return true;
407 } 407 }
408 408
409 void ThreadProxy::reduceWastedContentsTextureMemoryOnImplThread() 409 void ThreadProxy::ReduceWastedContentsTextureMemoryOnImplThread()
410 { 410 {
411 DCHECK(IsImplThread()); 411 DCHECK(IsImplThread());
412 412
413 if (!m_layerTreeHost->contents_texture_manager()) 413 if (!m_layerTreeHost->contents_texture_manager())
414 return; 414 return;
415 415
416 m_layerTreeHost->contents_texture_manager()->reduceWastedMemoryOnImplThread( m_layerTreeHostImpl->resourceProvider()); 416 m_layerTreeHost->contents_texture_manager()->reduceWastedMemoryOnImplThread( m_layerTreeHostImpl->resource_provider());
417 } 417 }
418 418
419 void ThreadProxy::sendManagedMemoryStats() 419 void ThreadProxy::SendManagedMemoryStats()
420 { 420 {
421 DCHECK(IsImplThread()); 421 DCHECK(IsImplThread());
422 if (!m_layerTreeHostImpl.get()) 422 if (!m_layerTreeHostImpl.get())
423 return; 423 return;
424 if (!m_layerTreeHost->contents_texture_manager()) 424 if (!m_layerTreeHost->contents_texture_manager())
425 return; 425 return;
426 426
427 // If we are using impl-side painting, then sendManagedMemoryStats is called 427 // If we are using impl-side painting, then sendManagedMemoryStats is called
428 // directly after the tile manager's manage function, and doesn't need to 428 // directly after the tile manager's manage function, and doesn't need to
429 // interact with main thread's layer tree. 429 // interact with main thread's layer tree.
430 if (m_layerTreeHost->settings().implSidePainting) 430 if (m_layerTreeHost->settings().implSidePainting)
431 return; 431 return;
432 432
433 m_layerTreeHostImpl->sendManagedMemoryStats( 433 m_layerTreeHostImpl->SendManagedMemoryStats(
434 m_layerTreeHost->contents_texture_manager()->memoryVisibleBytes(), 434 m_layerTreeHost->contents_texture_manager()->memoryVisibleBytes(),
435 m_layerTreeHost->contents_texture_manager()->memoryVisibleAndNearbyBytes (), 435 m_layerTreeHost->contents_texture_manager()->memoryVisibleAndNearbyBytes (),
436 m_layerTreeHost->contents_texture_manager()->memoryUseBytes()); 436 m_layerTreeHost->contents_texture_manager()->memoryUseBytes());
437 } 437 }
438 438
439 bool ThreadProxy::isInsideDraw() 439 bool ThreadProxy::IsInsideDraw()
440 { 440 {
441 return m_insideDraw; 441 return m_insideDraw;
442 } 442 }
443 443
444 void ThreadProxy::SetNeedsRedraw() 444 void ThreadProxy::SetNeedsRedraw()
445 { 445 {
446 DCHECK(IsMainThread()); 446 DCHECK(IsMainThread());
447 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); 447 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw");
448 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::setFullRootLayerDamag eOnImplThread, m_implThreadWeakPtr)); 448 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::setFullRootLayerDamag eOnImplThread, m_implThreadWeakPtr));
449 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::setNeedsRedrawOnImplT hread, m_implThreadWeakPtr)); 449 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::SetNeedsRedrawOnImplT hread, m_implThreadWeakPtr));
450 } 450 }
451 451
452 void ThreadProxy::SetDeferCommits(bool deferCommits) 452 void ThreadProxy::SetDeferCommits(bool deferCommits)
453 { 453 {
454 DCHECK(IsMainThread()); 454 DCHECK(IsMainThread());
455 DCHECK_NE(m_deferCommits, deferCommits); 455 DCHECK_NE(m_deferCommits, deferCommits);
456 m_deferCommits = deferCommits; 456 m_deferCommits = deferCommits;
457 457
458 if (m_deferCommits) 458 if (m_deferCommits)
459 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::setDeferCommits", this); 459 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::setDeferCommits", this);
460 else 460 else
461 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::setDeferCommits", this); 461 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::setDeferCommits", this);
462 462
463 if (!m_deferCommits && m_pendingDeferredCommit) 463 if (!m_deferCommits && m_pendingDeferredCommit)
464 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::beginFrame, m_mai nThreadWeakPtr, base::Passed(&m_pendingDeferredCommit))); 464 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::beginFrame, m_mai nThreadWeakPtr, base::Passed(&m_pendingDeferredCommit)));
465 } 465 }
466 466
467 bool ThreadProxy::CommitRequested() const 467 bool ThreadProxy::CommitRequested() const
468 { 468 {
469 DCHECK(IsMainThread()); 469 DCHECK(IsMainThread());
470 return m_commitRequested; 470 return m_commitRequested;
471 } 471 }
472 472
473 void ThreadProxy::setNeedsRedrawOnImplThread() 473 void ThreadProxy::SetNeedsRedrawOnImplThread()
474 { 474 {
475 DCHECK(IsImplThread()); 475 DCHECK(IsImplThread());
476 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); 476 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread");
477 m_schedulerOnImplThread->setNeedsRedraw(); 477 m_schedulerOnImplThread->setNeedsRedraw();
478 } 478 }
479 479
480 void ThreadProxy::didSwapUseIncompleteTileOnImplThread() 480 void ThreadProxy::didSwapUseIncompleteTileOnImplThread()
481 { 481 {
482 DCHECK(IsImplThread()); 482 DCHECK(IsImplThread());
483 TRACE_EVENT0("cc", "ThreadProxy::didSwapUseIncompleteTileOnImplThread"); 483 TRACE_EVENT0("cc", "ThreadProxy::didSwapUseIncompleteTileOnImplThread");
484 m_schedulerOnImplThread->didSwapUseIncompleteTile(); 484 m_schedulerOnImplThread->didSwapUseIncompleteTile();
485 } 485 }
486 486
487 void ThreadProxy::didUploadVisibleHighResolutionTileOnImplThread() 487 void ThreadProxy::DidUploadVisibleHighResolutionTileOnImplThread()
488 { 488 {
489 DCHECK(IsImplThread()); 489 DCHECK(IsImplThread());
490 TRACE_EVENT0("cc", "ThreadProxy::didUploadVisibleHighResolutionTileOnImplThre ad"); 490 TRACE_EVENT0("cc", "ThreadProxy::didUploadVisibleHighResolutionTileOnImplThre ad");
491 m_schedulerOnImplThread->setNeedsRedraw(); 491 m_schedulerOnImplThread->setNeedsRedraw();
492 } 492 }
493 493
494 void ThreadProxy::MainThreadHasStoppedFlinging() 494 void ThreadProxy::MainThreadHasStoppedFlinging()
495 { 495 {
496 if (m_inputHandlerOnImplThread) 496 if (m_inputHandlerOnImplThread)
497 m_inputHandlerOnImplThread->mainThreadHasStoppedFlinging(); 497 m_inputHandlerOnImplThread->MainThreadHasStoppedFlinging();
498 } 498 }
499 499
500 void ThreadProxy::Start() 500 void ThreadProxy::Start()
501 { 501 {
502 DCHECK(IsMainThread()); 502 DCHECK(IsMainThread());
503 DCHECK(Proxy::ImplThread()); 503 DCHECK(Proxy::ImplThread());
504 // Create LayerTreeHostImpl. 504 // Create LayerTreeHostImpl.
505 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 505 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
506 CompletionEvent completion; 506 CompletionEvent completion;
507 scoped_ptr<InputHandler> handler = m_layerTreeHost->CreateInputHandler(); 507 scoped_ptr<InputHandler> handler = m_layerTreeHost->CreateInputHandler();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 if (m_rendererInitialized) 548 if (m_rendererInitialized)
549 m_layerTreeHostImpl->renderer()->DoNoOp(); 549 m_layerTreeHostImpl->renderer()->DoNoOp();
550 completion->signal(); 550 completion->signal();
551 } 551 }
552 552
553 553
554 void ThreadProxy::finishAllRenderingOnImplThread(CompletionEvent* completion) 554 void ThreadProxy::finishAllRenderingOnImplThread(CompletionEvent* completion)
555 { 555 {
556 TRACE_EVENT0("cc", "ThreadProxy::finishAllRenderingOnImplThread"); 556 TRACE_EVENT0("cc", "ThreadProxy::finishAllRenderingOnImplThread");
557 DCHECK(IsImplThread()); 557 DCHECK(IsImplThread());
558 m_layerTreeHostImpl->finishAllRendering(); 558 m_layerTreeHostImpl->FinishAllRendering();
559 completion->signal(); 559 completion->signal();
560 } 560 }
561 561
562 void ThreadProxy::forceBeginFrameOnImplThread(CompletionEvent* completion) 562 void ThreadProxy::forceBeginFrameOnImplThread(CompletionEvent* completion)
563 { 563 {
564 TRACE_EVENT0("cc", "ThreadProxy::forceBeginFrameOnImplThread"); 564 TRACE_EVENT0("cc", "ThreadProxy::forceBeginFrameOnImplThread");
565 DCHECK(!m_beginFrameCompletionEventOnImplThread); 565 DCHECK(!m_beginFrameCompletionEventOnImplThread);
566 566
567 setNeedsForcedCommitOnImplThread(); 567 setNeedsForcedCommitOnImplThread();
568 if (m_schedulerOnImplThread->commitPending()) { 568 if (m_schedulerOnImplThread->commitPending()) {
569 completion->signal(); 569 completion->signal();
570 return; 570 return;
571 } 571 }
572 572
573 m_beginFrameCompletionEventOnImplThread = completion; 573 m_beginFrameCompletionEventOnImplThread = completion;
574 } 574 }
575 575
576 void ThreadProxy::scheduledActionBeginFrame() 576 void ThreadProxy::scheduledActionBeginFrame()
577 { 577 {
578 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame"); 578 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame");
579 scoped_ptr<BeginFrameAndCommitState> beginFrameState(new BeginFrameAndCommit State); 579 scoped_ptr<BeginFrameAndCommitState> beginFrameState(new BeginFrameAndCommit State);
580 beginFrameState->monotonicFrameBeginTime = base::TimeTicks::Now(); 580 beginFrameState->monotonicFrameBeginTime = base::TimeTicks::Now();
581 beginFrameState->scrollInfo = m_layerTreeHostImpl->processScrollDeltas(); 581 beginFrameState->scrollInfo = m_layerTreeHostImpl->ProcessScrollDeltas();
582 beginFrameState->implTransform = m_layerTreeHostImpl->activeTree()->ImplTran sform(); 582 beginFrameState->implTransform = m_layerTreeHostImpl->active_tree()->ImplTra nsform();
583 DCHECK_GT(m_layerTreeHostImpl->memoryAllocationLimitBytes(), 0u); 583 DCHECK_GT(m_layerTreeHostImpl->memory_allocation_limit_bytes(), 0u);
584 beginFrameState->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAll ocationLimitBytes(); 584 beginFrameState->memoryAllocationLimitBytes = m_layerTreeHostImpl->memory_al location_limit_bytes();
585 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::beginFrame, m_mainThr eadWeakPtr, base::Passed(&beginFrameState))); 585 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::beginFrame, m_mainThr eadWeakPtr, base::Passed(&beginFrameState)));
586 586
587 if (m_beginFrameCompletionEventOnImplThread) { 587 if (m_beginFrameCompletionEventOnImplThread) {
588 m_beginFrameCompletionEventOnImplThread->signal(); 588 m_beginFrameCompletionEventOnImplThread->signal();
589 m_beginFrameCompletionEventOnImplThread = 0; 589 m_beginFrameCompletionEventOnImplThread = 0;
590 } 590 }
591 } 591 }
592 592
593 void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat e) 593 void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat e)
594 { 594 {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 DCHECK(IsImplThread() && IsMainThreadBlocked()); 714 DCHECK(IsImplThread() && IsMainThreadBlocked());
715 DCHECK(m_schedulerOnImplThread); 715 DCHECK(m_schedulerOnImplThread);
716 DCHECK(m_schedulerOnImplThread->commitPending()); 716 DCHECK(m_schedulerOnImplThread->commitPending());
717 717
718 if (!m_layerTreeHostImpl.get()) { 718 if (!m_layerTreeHostImpl.get()) {
719 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); 719 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree");
720 completion->signal(); 720 completion->signal();
721 return; 721 return;
722 } 722 }
723 723
724 m_layerTreeHostImpl->resourceProvider()->SetOffscreenContextProvider(offscre enContextProvider); 724 m_layerTreeHostImpl->resource_provider()->SetOffscreenContextProvider(offscr eenContextProvider);
725 725
726 if (m_layerTreeHost->contents_texture_manager()->linkedEvictedBackingsExist( )) { 726 if (m_layerTreeHost->contents_texture_manager()->linkedEvictedBackingsExist( )) {
727 // Clear any uploads we were making to textures linked to evicted 727 // Clear any uploads we were making to textures linked to evicted
728 // resources 728 // resources
729 queue->clearUploadsToEvictedResources(); 729 queue->clearUploadsToEvictedResources();
730 // Some textures in the layer tree are invalid. Kick off another commit 730 // Some textures in the layer tree are invalid. Kick off another commit
731 // to fill them again. 731 // to fill them again.
732 setNeedsCommitOnImplThread(); 732 SetNeedsCommitOnImplThread();
733 } 733 }
734 734
735 m_layerTreeHost->contents_texture_manager()->pushTexturePrioritiesToBackings (); 735 m_layerTreeHost->contents_texture_manager()->pushTexturePrioritiesToBackings ();
736 736
737 m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::Cr eate(this, Proxy::ImplThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvi der()); 737 m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::Cr eate(this, Proxy::ImplThread(), queue.Pass(), m_layerTreeHostImpl->resource_prov ider());
738 m_currentResourceUpdateControllerOnImplThread->PerformMoreUpdates( 738 m_currentResourceUpdateControllerOnImplThread->PerformMoreUpdates(
739 m_schedulerOnImplThread->anticipatedDrawTime()); 739 m_schedulerOnImplThread->anticipatedDrawTime());
740 740
741 m_commitCompletionEventOnImplThread = completion; 741 m_commitCompletionEventOnImplThread = completion;
742 } 742 }
743 743
744 void ThreadProxy::beginFrameAbortedOnImplThread() 744 void ThreadProxy::beginFrameAbortedOnImplThread()
745 { 745 {
746 TRACE_EVENT0("cc", "ThreadProxy::beginFrameAbortedOnImplThread"); 746 TRACE_EVENT0("cc", "ThreadProxy::beginFrameAbortedOnImplThread");
747 DCHECK(IsImplThread()); 747 DCHECK(IsImplThread());
748 DCHECK(m_schedulerOnImplThread); 748 DCHECK(m_schedulerOnImplThread);
749 DCHECK(m_schedulerOnImplThread->commitPending()); 749 DCHECK(m_schedulerOnImplThread->commitPending());
750 750
751 m_schedulerOnImplThread->beginFrameAborted(); 751 m_schedulerOnImplThread->beginFrameAborted();
752 } 752 }
753 753
754 void ThreadProxy::scheduledActionCommit() 754 void ThreadProxy::scheduledActionCommit()
755 { 755 {
756 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionCommit"); 756 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionCommit");
757 DCHECK(IsImplThread()); 757 DCHECK(IsImplThread());
758 DCHECK(m_commitCompletionEventOnImplThread); 758 DCHECK(m_commitCompletionEventOnImplThread);
759 DCHECK(m_currentResourceUpdateControllerOnImplThread); 759 DCHECK(m_currentResourceUpdateControllerOnImplThread);
760 760
761 // Complete all remaining texture updates. 761 // Complete all remaining texture updates.
762 m_currentResourceUpdateControllerOnImplThread->Finalize(); 762 m_currentResourceUpdateControllerOnImplThread->Finalize();
763 m_currentResourceUpdateControllerOnImplThread.reset(); 763 m_currentResourceUpdateControllerOnImplThread.reset();
764 764
765 m_layerTreeHostImpl->beginCommit(); 765 m_layerTreeHostImpl->BeginCommit();
766 m_layerTreeHost->BeginCommitOnImplThread(m_layerTreeHostImpl.get()); 766 m_layerTreeHost->BeginCommitOnImplThread(m_layerTreeHostImpl.get());
767 m_layerTreeHost->FinishCommitOnImplThread(m_layerTreeHostImpl.get()); 767 m_layerTreeHost->FinishCommitOnImplThread(m_layerTreeHostImpl.get());
768 m_layerTreeHostImpl->commitComplete(); 768 m_layerTreeHostImpl->CommitComplete();
769 769
770 m_nextFrameIsNewlyCommittedFrameOnImplThread = true; 770 m_nextFrameIsNewlyCommittedFrameOnImplThread = true;
771 771
772 if (m_layerTreeHost->settings().implSidePainting && m_layerTreeHost->BlocksP endingCommit()) 772 if (m_layerTreeHost->settings().implSidePainting && m_layerTreeHost->BlocksP endingCommit())
773 { 773 {
774 // For some layer types in impl-side painting, the commit is held until 774 // For some layer types in impl-side painting, the commit is held until
775 // the pending tree is activated. 775 // the pending tree is activated.
776 TRACE_EVENT_INSTANT0("cc", "HoldCommit"); 776 TRACE_EVENT_INSTANT0("cc", "HoldCommit");
777 m_completionEventForCommitHeldOnTreeActivation = m_commitCompletionEvent OnImplThread; 777 m_completionEventForCommitHeldOnTreeActivation = m_commitCompletionEvent OnImplThread;
778 m_commitCompletionEventOnImplThread = 0; 778 m_commitCompletionEventOnImplThread = 0;
779 } 779 }
780 else 780 else
781 { 781 {
782 m_commitCompletionEventOnImplThread->signal(); 782 m_commitCompletionEventOnImplThread->signal();
783 m_commitCompletionEventOnImplThread = 0; 783 m_commitCompletionEventOnImplThread = 0;
784 } 784 }
785 785
786 // SetVisible kicks off the next scheduler action, so this must be last. 786 // SetVisible kicks off the next scheduler action, so this must be last.
787 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); 787 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
788 } 788 }
789 789
790 void ThreadProxy::scheduledActionCheckForCompletedTileUploads() 790 void ThreadProxy::scheduledActionCheckForCompletedTileUploads()
791 { 791 {
792 DCHECK(IsImplThread()); 792 DCHECK(IsImplThread());
793 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionCheckForCompletedTileUploads "); 793 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionCheckForCompletedTileUploads ");
794 m_layerTreeHostImpl->checkForCompletedTileUploads(); 794 m_layerTreeHostImpl->CheckForCompletedTileUploads();
795 } 795 }
796 796
797 void ThreadProxy::scheduledActionActivatePendingTreeIfNeeded() 797 void ThreadProxy::scheduledActionActivatePendingTreeIfNeeded()
798 { 798 {
799 DCHECK(IsImplThread()); 799 DCHECK(IsImplThread());
800 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionActivatePendingTreeIfNeeded" ); 800 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionActivatePendingTreeIfNeeded" );
801 m_layerTreeHostImpl->activatePendingTreeIfNeeded(); 801 m_layerTreeHostImpl->ActivatePendingTreeIfNeeded();
802 } 802 }
803 803
804 void ThreadProxy::scheduledActionBeginContextRecreation() 804 void ThreadProxy::scheduledActionBeginContextRecreation()
805 { 805 {
806 DCHECK(IsImplThread()); 806 DCHECK(IsImplThread());
807 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::beginContextRecreatio n, m_mainThreadWeakPtr)); 807 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::beginContextRecreatio n, m_mainThreadWeakPtr));
808 } 808 }
809 809
810 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapInternal (bool forcedDraw) 810 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapInternal (bool forcedDraw)
811 { 811 {
(...skipping 11 matching lines...) Expand all
823 823
824 DCHECK(m_layerTreeHostImpl->renderer()); 824 DCHECK(m_layerTreeHostImpl->renderer());
825 if (!m_layerTreeHostImpl->renderer()) 825 if (!m_layerTreeHostImpl->renderer())
826 return result; 826 return result;
827 827
828 // FIXME: compute the frame display time more intelligently 828 // FIXME: compute the frame display time more intelligently
829 base::TimeTicks monotonicTime = base::TimeTicks::Now(); 829 base::TimeTicks monotonicTime = base::TimeTicks::Now();
830 base::Time wallClockTime = base::Time::Now(); 830 base::Time wallClockTime = base::Time::Now();
831 831
832 if (m_inputHandlerOnImplThread.get()) 832 if (m_inputHandlerOnImplThread.get())
833 m_inputHandlerOnImplThread->animate(monotonicTime); 833 m_inputHandlerOnImplThread->Animate(monotonicTime);
834 834
835 m_layerTreeHostImpl->activatePendingTreeIfNeeded(); 835 m_layerTreeHostImpl->ActivatePendingTreeIfNeeded();
836 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); 836 m_layerTreeHostImpl->Animate(monotonicTime, wallClockTime);
837 837
838 // This method is called on a forced draw, regardless of whether we are able to produce a frame, 838 // This method is called on a forced draw, regardless of whether we are able to produce a frame,
839 // as the calling site on main thread is blocked until its request completes , and we signal 839 // as the calling site on main thread is blocked until its request completes , and we signal
840 // completion here. If canDraw() is false, we will indicate success=false to the caller, but we 840 // completion here. If canDraw() is false, we will indicate success=false to the caller, but we
841 // must still signal completion to avoid deadlock. 841 // must still signal completion to avoid deadlock.
842 842
843 // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only 843 // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only
844 // be used when such a frame is possible. Since drawLayers() depends on the result of 844 // be used when such a frame is possible. Since drawLayers() depends on the result of
845 // prepareToDraw(), it is guarded on canDraw() as well. 845 // prepareToDraw(), it is guarded on canDraw() as well.
846 846
847 LayerTreeHostImpl::FrameData frame; 847 LayerTreeHostImpl::FrameData frame;
848 bool drawFrame = m_layerTreeHostImpl->canDraw() && (m_layerTreeHostImpl->pre pareToDraw(frame) || forcedDraw); 848 bool drawFrame = m_layerTreeHostImpl->CanDraw() && (m_layerTreeHostImpl->Pre pareToDraw(&frame) || forcedDraw);
849 if (drawFrame) { 849 if (drawFrame) {
850 m_layerTreeHostImpl->drawLayers(frame); 850 m_layerTreeHostImpl->DrawLayers(&frame);
851 result.didDraw = true; 851 result.didDraw = true;
852 } 852 }
853 m_layerTreeHostImpl->didDrawAllLayers(frame); 853 m_layerTreeHostImpl->DidDrawAllLayers(frame);
854 854
855 // Check for tree activation. 855 // Check for tree activation.
856 if (m_completionEventForCommitHeldOnTreeActivation && !m_layerTreeHostImpl-> pendingTree()) 856 if (m_completionEventForCommitHeldOnTreeActivation && !m_layerTreeHostImpl-> pending_tree())
857 { 857 {
858 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation"); 858 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation");
859 DCHECK(m_layerTreeHostImpl->Settings().implSidePainting); 859 DCHECK(m_layerTreeHostImpl->settings().implSidePainting);
860 m_completionEventForCommitHeldOnTreeActivation->signal(); 860 m_completionEventForCommitHeldOnTreeActivation->signal();
861 m_completionEventForCommitHeldOnTreeActivation = 0; 861 m_completionEventForCommitHeldOnTreeActivation = 0;
862 } 862 }
863 863
864 // Check for a pending compositeAndReadback. 864 // Check for a pending compositeAndReadback.
865 if (m_readbackRequestOnImplThread) { 865 if (m_readbackRequestOnImplThread) {
866 m_readbackRequestOnImplThread->success = false; 866 m_readbackRequestOnImplThread->success = false;
867 if (drawFrame) { 867 if (drawFrame) {
868 m_layerTreeHostImpl->readback(m_readbackRequestOnImplThread->pixels, m_readbackRequestOnImplThread->rect); 868 m_layerTreeHostImpl->Readback(m_readbackRequestOnImplThread->pixels, m_readbackRequestOnImplThread->rect);
869 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isCon textLost(); 869 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->IsCon textLost();
870 } 870 }
871 m_readbackRequestOnImplThread->completion.signal(); 871 m_readbackRequestOnImplThread->completion.signal();
872 m_readbackRequestOnImplThread = 0; 872 m_readbackRequestOnImplThread = 0;
873 } else if (drawFrame) { 873 } else if (drawFrame) {
874 result.didSwap = m_layerTreeHostImpl->swapBuffers(); 874 result.didSwap = m_layerTreeHostImpl->SwapBuffers();
875 875
876 if (frame.containsIncompleteTile) 876 if (frame.contains_incomplete_tile)
877 didSwapUseIncompleteTileOnImplThread(); 877 didSwapUseIncompleteTileOnImplThread();
878 } 878 }
879 879
880 // Tell the main thread that the the newly-commited frame was drawn. 880 // Tell the main thread that the the newly-commited frame was drawn.
881 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) { 881 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) {
882 m_nextFrameIsNewlyCommittedFrameOnImplThread = false; 882 m_nextFrameIsNewlyCommittedFrameOnImplThread = false;
883 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::didCommitAndDrawF rame, m_mainThreadWeakPtr)); 883 Proxy::MainThread()->postTask(base::Bind(&ThreadProxy::didCommitAndDrawF rame, m_mainThreadWeakPtr));
884 } 884 }
885 885
886 if (drawFrame) 886 if (drawFrame)
887 checkOutputSurfaceStatusOnImplThread(); 887 checkOutputSurfaceStatusOnImplThread();
888 888
889 m_layerTreeHostImpl->beginNextFrame(); 889 m_layerTreeHostImpl->BeginNextFrame();
890 890
891 return result; 891 return result;
892 } 892 }
893 893
894 void ThreadProxy::AcquireLayerTextures() 894 void ThreadProxy::AcquireLayerTextures()
895 { 895 {
896 // Called when the main thread needs to modify a layer texture that is used 896 // Called when the main thread needs to modify a layer texture that is used
897 // directly by the compositor. 897 // directly by the compositor.
898 // This method will block until the next compositor draw if there is a 898 // This method will block until the next compositor draw if there is a
899 // previously committed frame that is still undrawn. This is necessary to 899 // previously committed frame that is still undrawn. This is necessary to
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 else 1009 else
1010 frameRateController.reset(new FrameRateController(Proxy::ImplThread())); 1010 frameRateController.reset(new FrameRateController(Proxy::ImplThread()));
1011 SchedulerSettings schedulerSettings; 1011 SchedulerSettings schedulerSettings;
1012 schedulerSettings.implSidePainting = m_layerTreeHost->settings().implSidePai nting; 1012 schedulerSettings.implSidePainting = m_layerTreeHost->settings().implSidePai nting;
1013 m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass() , 1013 m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass() ,
1014 schedulerSettings); 1014 schedulerSettings);
1015 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); 1015 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
1016 1016
1017 m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler); 1017 m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler);
1018 if (m_inputHandlerOnImplThread.get()) 1018 if (m_inputHandlerOnImplThread.get())
1019 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); 1019 m_inputHandlerOnImplThread->BindToClient(m_layerTreeHostImpl.get());
1020 1020
1021 m_implThreadWeakPtr = m_weakFactoryOnImplThread.GetWeakPtr(); 1021 m_implThreadWeakPtr = m_weakFactoryOnImplThread.GetWeakPtr();
1022 completion->signal(); 1022 completion->signal();
1023 } 1023 }
1024 1024
1025 void ThreadProxy::initializeOutputSurfaceOnImplThread(scoped_ptr<OutputSurface> outputSurface) 1025 void ThreadProxy::initializeOutputSurfaceOnImplThread(scoped_ptr<OutputSurface> outputSurface)
1026 { 1026 {
1027 TRACE_EVENT0("cc", "ThreadProxy::initializeContextOnImplThread"); 1027 TRACE_EVENT0("cc", "ThreadProxy::initializeContextOnImplThread");
1028 DCHECK(IsImplThread()); 1028 DCHECK(IsImplThread());
1029 m_outputSurfaceBeforeInitializationOnImplThread = outputSurface.Pass(); 1029 m_outputSurfaceBeforeInitializationOnImplThread = outputSurface.Pass();
1030 } 1030 }
1031 1031
1032 void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bo ol* initializeSucceeded, RendererCapabilities* capabilities) 1032 void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bo ol* initializeSucceeded, RendererCapabilities* capabilities)
1033 { 1033 {
1034 TRACE_EVENT0("cc", "ThreadProxy::initializeRendererOnImplThread"); 1034 TRACE_EVENT0("cc", "ThreadProxy::initializeRendererOnImplThread");
1035 DCHECK(IsImplThread()); 1035 DCHECK(IsImplThread());
1036 DCHECK(m_outputSurfaceBeforeInitializationOnImplThread.get()); 1036 DCHECK(m_outputSurfaceBeforeInitializationOnImplThread.get());
1037 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_outputSurfa ceBeforeInitializationOnImplThread.Pass()); 1037 *initializeSucceeded = m_layerTreeHostImpl->InitializeRenderer(m_outputSurfa ceBeforeInitializationOnImplThread.Pass());
1038 if (*initializeSucceeded) { 1038 if (*initializeSucceeded) {
1039 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); 1039 *capabilities = m_layerTreeHostImpl->GetRendererCapabilities();
1040 m_schedulerOnImplThread->setSwapBuffersCompleteSupported( 1040 m_schedulerOnImplThread->setSwapBuffersCompleteSupported(
1041 capabilities->using_swap_complete_callback); 1041 capabilities->using_swap_complete_callback);
1042 1042
1043 int maxFramesPending = FrameRateController::kDefaultMaxFramesPending; 1043 int maxFramesPending = FrameRateController::kDefaultMaxFramesPending;
1044 if (m_layerTreeHostImpl->outputSurface()->capabilities().has_parent_comp ositor) 1044 if (m_layerTreeHostImpl->output_surface()->capabilities().has_parent_com positor)
1045 maxFramesPending = 1; 1045 maxFramesPending = 1;
1046 m_schedulerOnImplThread->setMaxFramesPending(maxFramesPending); 1046 m_schedulerOnImplThread->setMaxFramesPending(maxFramesPending);
1047 } 1047 }
1048 1048
1049 completion->signal(); 1049 completion->signal();
1050 } 1050 }
1051 1051
1052 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion) 1052 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion)
1053 { 1053 {
1054 TRACE_EVENT0("cc", "ThreadProxy::layerTreeHostClosedOnImplThread"); 1054 TRACE_EVENT0("cc", "ThreadProxy::layerTreeHostClosedOnImplThread");
1055 DCHECK(IsImplThread()); 1055 DCHECK(IsImplThread());
1056 m_layerTreeHost->DeleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider()); 1056 m_layerTreeHost->DeleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ource_provider());
1057 m_inputHandlerOnImplThread.reset(); 1057 m_inputHandlerOnImplThread.reset();
1058 m_layerTreeHostImpl.reset(); 1058 m_layerTreeHostImpl.reset();
1059 m_schedulerOnImplThread.reset(); 1059 m_schedulerOnImplThread.reset();
1060 m_weakFactoryOnImplThread.InvalidateWeakPtrs(); 1060 m_weakFactoryOnImplThread.InvalidateWeakPtrs();
1061 completion->signal(); 1061 completion->signal();
1062 } 1062 }
1063 1063
1064 void ThreadProxy::setFullRootLayerDamageOnImplThread() 1064 void ThreadProxy::setFullRootLayerDamageOnImplThread()
1065 { 1065 {
1066 DCHECK(IsImplThread()); 1066 DCHECK(IsImplThread());
1067 m_layerTreeHostImpl->SetFullRootLayerDamage(); 1067 m_layerTreeHostImpl->SetFullRootLayerDamage();
1068 } 1068 }
1069 1069
1070 size_t ThreadProxy::MaxPartialTextureUpdates() const 1070 size_t ThreadProxy::MaxPartialTextureUpdates() const
1071 { 1071 {
1072 return ResourceUpdateController::MaxPartialTextureUpdates(); 1072 return ResourceUpdateController::MaxPartialTextureUpdates();
1073 } 1073 }
1074 1074
1075 void ThreadProxy::recreateOutputSurfaceOnImplThread(CompletionEvent* completion, scoped_ptr<OutputSurface> outputSurface, scoped_refptr<cc::ContextProvider> off screenContextProvider, bool* recreateSucceeded, RendererCapabilities* capabiliti es) 1075 void ThreadProxy::recreateOutputSurfaceOnImplThread(CompletionEvent* completion, scoped_ptr<OutputSurface> outputSurface, scoped_refptr<cc::ContextProvider> off screenContextProvider, bool* recreateSucceeded, RendererCapabilities* capabiliti es)
1076 { 1076 {
1077 TRACE_EVENT0("cc", "ThreadProxy::recreateOutputSurfaceOnImplThread"); 1077 TRACE_EVENT0("cc", "ThreadProxy::recreateOutputSurfaceOnImplThread");
1078 DCHECK(IsImplThread()); 1078 DCHECK(IsImplThread());
1079 m_layerTreeHost->DeleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider()); 1079 m_layerTreeHost->DeleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ource_provider());
1080 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(outputSurface.P ass()); 1080 *recreateSucceeded = m_layerTreeHostImpl->InitializeRenderer(outputSurface.P ass());
1081 if (*recreateSucceeded) { 1081 if (*recreateSucceeded) {
1082 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); 1082 *capabilities = m_layerTreeHostImpl->GetRendererCapabilities();
1083 m_layerTreeHostImpl->resourceProvider()->SetOffscreenContextProvider(off screenContextProvider); 1083 m_layerTreeHostImpl->resource_provider()->SetOffscreenContextProvider(of fscreenContextProvider);
1084 m_schedulerOnImplThread->didRecreateOutputSurface(); 1084 m_schedulerOnImplThread->didRecreateOutputSurface();
1085 } else if (offscreenContextProvider) { 1085 } else if (offscreenContextProvider) {
1086 offscreenContextProvider->VerifyContexts(); 1086 offscreenContextProvider->VerifyContexts();
1087 } 1087 }
1088 completion->signal(); 1088 completion->signal();
1089 } 1089 }
1090 1090
1091 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render ingStats* stats) 1091 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render ingStats* stats)
1092 { 1092 {
1093 DCHECK(IsImplThread()); 1093 DCHECK(IsImplThread());
1094 m_layerTreeHostImpl->renderingStats(stats); 1094 m_layerTreeHostImpl->CollectRenderingStats(stats);
1095 completion->signal(); 1095 completion->signal();
1096 } 1096 }
1097 1097
1098 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 1098 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
1099 : memoryAllocationLimitBytes(0) 1099 : memoryAllocationLimitBytes(0)
1100 { 1100 {
1101 } 1101 }
1102 1102
1103 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() 1103 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState()
1104 { 1104 {
(...skipping 11 matching lines...) Expand all
1116 m_implThreadWeakPtr, 1116 m_implThreadWeakPtr,
1117 &completion, 1117 &completion,
1118 state.get())); 1118 state.get()));
1119 completion.wait(); 1119 completion.wait();
1120 } 1120 }
1121 return state.PassAs<base::Value>(); 1121 return state.PassAs<base::Value>();
1122 } 1122 }
1123 1123
1124 void ThreadProxy::asValueOnImplThread(CompletionEvent* completion, base::Diction aryValue* state) const 1124 void ThreadProxy::asValueOnImplThread(CompletionEvent* completion, base::Diction aryValue* state) const
1125 { 1125 {
1126 state->Set("layer_tree_host_impl", m_layerTreeHostImpl->asValue().release()) ; 1126 state->Set("layer_tree_host_impl", m_layerTreeHostImpl->AsValue().release()) ;
1127 completion->signal(); 1127 completion->signal();
1128 } 1128 }
1129 1129
1130 bool ThreadProxy::CommitPendingForTesting() 1130 bool ThreadProxy::CommitPendingForTesting()
1131 { 1131 {
1132 DCHECK(IsMainThread()); 1132 DCHECK(IsMainThread());
1133 CommitPendingRequest commitPendingRequest; 1133 CommitPendingRequest commitPendingRequest;
1134 { 1134 {
1135 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 1135 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
1136 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::commitPendingOnIm plThreadForTesting, m_implThreadWeakPtr, &commitPendingRequest)); 1136 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::commitPendingOnIm plThreadForTesting, m_implThreadWeakPtr, &commitPendingRequest));
1137 commitPendingRequest.completion.wait(); 1137 commitPendingRequest.completion.wait();
1138 } 1138 }
1139 return commitPendingRequest.commitPending; 1139 return commitPendingRequest.commitPending;
1140 } 1140 }
1141 1141
1142 void ThreadProxy::commitPendingOnImplThreadForTesting(CommitPendingRequest* requ est) 1142 void ThreadProxy::commitPendingOnImplThreadForTesting(CommitPendingRequest* requ est)
1143 { 1143 {
1144 DCHECK(IsImplThread()); 1144 DCHECK(IsImplThread());
1145 if (m_layerTreeHostImpl->outputSurface()) 1145 if (m_layerTreeHostImpl->output_surface())
1146 request->commitPending = m_schedulerOnImplThread->commitPending(); 1146 request->commitPending = m_schedulerOnImplThread->commitPending();
1147 else 1147 else
1148 request->commitPending = false; 1148 request->commitPending = false;
1149 request->completion.signal(); 1149 request->completion.signal();
1150 } 1150 }
1151 1151
1152 skia::RefPtr<SkPicture> ThreadProxy::CapturePicture() 1152 skia::RefPtr<SkPicture> ThreadProxy::CapturePicture()
1153 { 1153 {
1154 DCHECK(IsMainThread()); 1154 DCHECK(IsMainThread());
1155 CompletionEvent completion; 1155 CompletionEvent completion;
1156 skia::RefPtr<SkPicture> picture; 1156 skia::RefPtr<SkPicture> picture;
1157 { 1157 {
1158 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 1158 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
1159 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::capturePictureOnI mplThread, 1159 Proxy::ImplThread()->postTask(base::Bind(&ThreadProxy::capturePictureOnI mplThread,
1160 m_implThreadWeakPtr, 1160 m_implThreadWeakPtr,
1161 &completion, 1161 &completion,
1162 &picture)); 1162 &picture));
1163 completion.wait(); 1163 completion.wait();
1164 } 1164 }
1165 return picture; 1165 return picture;
1166 } 1166 }
1167 1167
1168 void ThreadProxy::capturePictureOnImplThread(CompletionEvent* completion, skia:: RefPtr<SkPicture>* picture) 1168 void ThreadProxy::capturePictureOnImplThread(CompletionEvent* completion, skia:: RefPtr<SkPicture>* picture)
1169 { 1169 {
1170 DCHECK(IsImplThread()); 1170 DCHECK(IsImplThread());
1171 *picture = m_layerTreeHostImpl->capturePicture(); 1171 *picture = m_layerTreeHostImpl->CapturePicture();
1172 completion->signal(); 1172 completion->signal();
1173 } 1173 }
1174 1174
1175 void ThreadProxy::renewTreePriority() 1175 void ThreadProxy::RenewTreePriority()
1176 { 1176 {
1177 bool smoothnessTakesPriority = 1177 bool smoothnessTakesPriority =
1178 m_layerTreeHostImpl->pinchGestureActive() || 1178 m_layerTreeHostImpl->pinch_gesture_active() ||
1179 m_layerTreeHostImpl->currentlyScrollingLayer() || 1179 m_layerTreeHostImpl->CurrentlyScrollingLayer() ||
1180 m_layerTreeHostImpl->pageScaleAnimationActive(); 1180 m_layerTreeHostImpl->page_scale_animation_active();
1181 1181
1182 // Update expiration time if smoothness currently takes priority. 1182 // Update expiration time if smoothness currently takes priority.
1183 if (smoothnessTakesPriority) { 1183 if (smoothnessTakesPriority) {
1184 m_smoothnessTakesPriorityExpirationTime = base::TimeTicks::Now() + 1184 m_smoothnessTakesPriorityExpirationTime = base::TimeTicks::Now() +
1185 base::TimeDelta::FromMilliseconds( 1185 base::TimeDelta::FromMilliseconds(
1186 smoothnessTakesPriorityExpirationDelay * 1000); 1186 smoothnessTakesPriorityExpirationDelay * 1000);
1187 } 1187 }
1188 1188
1189 // We use the same priority for both trees by default. 1189 // We use the same priority for both trees by default.
1190 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; 1190 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES;
1191 1191
1192 // Smoothness takes priority if expiration time is in the future. 1192 // Smoothness takes priority if expiration time is in the future.
1193 if (m_smoothnessTakesPriorityExpirationTime > base::TimeTicks::Now()) 1193 if (m_smoothnessTakesPriorityExpirationTime > base::TimeTicks::Now())
1194 priority = SMOOTHNESS_TAKES_PRIORITY; 1194 priority = SMOOTHNESS_TAKES_PRIORITY;
1195 1195
1196 // New content always takes priority when the active tree has 1196 // New content always takes priority when the active tree has
1197 // evicted resources or there is an invalid viewport size. 1197 // evicted resources or there is an invalid viewport size.
1198 if (m_layerTreeHostImpl->activeTree()->ContentsTexturesPurged() || 1198 if (m_layerTreeHostImpl->active_tree()->ContentsTexturesPurged() ||
1199 m_layerTreeHostImpl->activeTree()->ViewportSizeInvalid()) 1199 m_layerTreeHostImpl->active_tree()->ViewportSizeInvalid())
1200 priority = NEW_CONTENT_TAKES_PRIORITY; 1200 priority = NEW_CONTENT_TAKES_PRIORITY;
1201 1201
1202 m_layerTreeHostImpl->setTreePriority(priority); 1202 m_layerTreeHostImpl->SetTreePriority(priority);
1203 1203
1204 // Notify the the client of this compositor via the output surface. 1204 // Notify the the client of this compositor via the output surface.
1205 // TODO(epenner): Route this to compositor-thread instead of output-surface 1205 // TODO(epenner): Route this to compositor-thread instead of output-surface
1206 // after GTFO refactor of compositor-thread (http://crbug/170828). 1206 // after GTFO refactor of compositor-thread (http://crbug/170828).
1207 if (m_layerTreeHostImpl->outputSurface()) { 1207 if (m_layerTreeHostImpl->output_surface()) {
1208 m_layerTreeHostImpl->outputSurface()->UpdateSmoothnessTakesPriority( 1208 m_layerTreeHostImpl->output_surface()->UpdateSmoothnessTakesPriority(
1209 priority == SMOOTHNESS_TAKES_PRIORITY); 1209 priority == SMOOTHNESS_TAKES_PRIORITY);
1210 } 1210 }
1211 1211
1212 base::TimeDelta delay = m_smoothnessTakesPriorityExpirationTime - 1212 base::TimeDelta delay = m_smoothnessTakesPriorityExpirationTime -
1213 base::TimeTicks::Now(); 1213 base::TimeTicks::Now();
1214 1214
1215 // Need to make sure a delayed task is posted when we have smoothness 1215 // Need to make sure a delayed task is posted when we have smoothness
1216 // takes priority expiration time in the future. 1216 // takes priority expiration time in the future.
1217 if (delay <= base::TimeDelta()) 1217 if (delay <= base::TimeDelta())
1218 return; 1218 return;
1219 if (m_renewTreePriorityOnImplThreadPending) 1219 if (m_renewTreePriorityOnImplThreadPending)
1220 return; 1220 return;
1221 1221
1222 Proxy::ImplThread()->postDelayedTask( 1222 Proxy::ImplThread()->postDelayedTask(
1223 base::Bind(&ThreadProxy::renewTreePriorityOnImplThread, 1223 base::Bind(&ThreadProxy::renewTreePriorityOnImplThread,
1224 m_weakFactoryOnImplThread.GetWeakPtr()), 1224 m_weakFactoryOnImplThread.GetWeakPtr()),
1225 delay.InMilliseconds()); 1225 delay.InMilliseconds());
1226 1226
1227 m_renewTreePriorityOnImplThreadPending = true; 1227 m_renewTreePriorityOnImplThreadPending = true;
1228 } 1228 }
1229 1229
1230 void ThreadProxy::renewTreePriorityOnImplThread() 1230 void ThreadProxy::renewTreePriorityOnImplThread()
1231 { 1231 {
1232 DCHECK(m_renewTreePriorityOnImplThreadPending); 1232 DCHECK(m_renewTreePriorityOnImplThreadPending);
1233 m_renewTreePriorityOnImplThreadPending = false; 1233 m_renewTreePriorityOnImplThreadPending = false;
1234 1234
1235 renewTreePriority(); 1235 RenewTreePriority();
1236 } 1236 }
1237 1237
1238 } // namespace cc 1238 } // namespace cc
OLDNEW
« no previous file with comments | « cc/thread_proxy.h ('k') | cc/tiled_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698