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

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 17176012: Remove NULL ResourceProvider, TileManager early outs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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/trees/layer_tree_host_impl.cc ('k') | no next file » | 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/trees/thread_proxy.h" 5 #include "cc/trees/thread_proxy.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 FROM_HERE, 344 FROM_HERE,
345 base::Bind(&ThreadProxy::CheckOutputSurfaceStatusOnImplThread, 345 base::Bind(&ThreadProxy::CheckOutputSurfaceStatusOnImplThread,
346 impl_thread_weak_ptr_)); 346 impl_thread_weak_ptr_));
347 } 347 }
348 348
349 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { 349 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() {
350 DCHECK(IsImplThread()); 350 DCHECK(IsImplThread());
351 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread"); 351 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread");
352 if (!layer_tree_host_impl_->IsContextLost()) 352 if (!layer_tree_host_impl_->IsContextLost())
353 return; 353 return;
354 cc::ContextProvider* offscreen_contexts = 354 if (cc::ContextProvider* offscreen_contexts = layer_tree_host_impl_
355 layer_tree_host_impl_->resource_provider() ? 355 ->resource_provider()->offscreen_context_provider())
356 layer_tree_host_impl_->resource_provider()->
357 offscreen_context_provider() : NULL;
358
359 if (offscreen_contexts)
360 offscreen_contexts->VerifyContexts(); 356 offscreen_contexts->VerifyContexts();
361 scheduler_on_impl_thread_->DidLoseOutputSurface(); 357 scheduler_on_impl_thread_->DidLoseOutputSurface();
362 } 358 }
363 359
364 void ThreadProxy::OnSwapBuffersCompleteOnImplThread() { 360 void ThreadProxy::OnSwapBuffersCompleteOnImplThread() {
365 DCHECK(IsImplThread()); 361 DCHECK(IsImplThread());
366 TRACE_EVENT0("cc", "ThreadProxy::OnSwapBuffersCompleteOnImplThread"); 362 TRACE_EVENT0("cc", "ThreadProxy::OnSwapBuffersCompleteOnImplThread");
367 Proxy::MainThreadTaskRunner()->PostTask( 363 Proxy::MainThreadTaskRunner()->PostTask(
368 FROM_HERE, 364 FROM_HERE,
369 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); 365 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 base::Passed(&events), 413 base::Passed(&events),
418 wall_clock_time)); 414 wall_clock_time));
419 } 415 }
420 416
421 bool ThreadProxy::ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, 417 bool ThreadProxy::ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes,
422 int priority_cutoff) { 418 int priority_cutoff) {
423 DCHECK(IsImplThread()); 419 DCHECK(IsImplThread());
424 420
425 if (!layer_tree_host_->contents_texture_manager()) 421 if (!layer_tree_host_->contents_texture_manager())
426 return false; 422 return false;
427 if (!layer_tree_host_impl_->resource_provider())
428 return false;
429 423
430 bool reduce_result = layer_tree_host_->contents_texture_manager()-> 424 bool reduce_result = layer_tree_host_->contents_texture_manager()->
431 ReduceMemoryOnImplThread(limit_bytes, 425 ReduceMemoryOnImplThread(limit_bytes,
432 priority_cutoff, 426 priority_cutoff,
433 layer_tree_host_impl_->resource_provider()); 427 layer_tree_host_impl_->resource_provider());
434 if (!reduce_result) 428 if (!reduce_result)
435 return false; 429 return false;
436 430
437 // The texture upload queue may reference textures that were just purged, 431 // The texture upload queue may reference textures that were just purged,
438 // clear them from the queue. 432 // clear them from the queue.
439 if (current_resource_update_controller_on_impl_thread_) { 433 if (current_resource_update_controller_on_impl_thread_) {
440 current_resource_update_controller_on_impl_thread_-> 434 current_resource_update_controller_on_impl_thread_->
441 DiscardUploadsToEvictedResources(); 435 DiscardUploadsToEvictedResources();
442 } 436 }
443 return true; 437 return true;
444 } 438 }
445 439
446 void ThreadProxy::ReduceWastedContentsTextureMemoryOnImplThread() { 440 void ThreadProxy::ReduceWastedContentsTextureMemoryOnImplThread() {
447 DCHECK(IsImplThread()); 441 DCHECK(IsImplThread());
448 442
449 if (!layer_tree_host_->contents_texture_manager()) 443 if (!layer_tree_host_->contents_texture_manager())
450 return; 444 return;
451 if (!layer_tree_host_impl_->resource_provider())
452 return;
453 445
454 layer_tree_host_->contents_texture_manager()->ReduceWastedMemoryOnImplThread( 446 layer_tree_host_->contents_texture_manager()->ReduceWastedMemoryOnImplThread(
455 layer_tree_host_impl_->resource_provider()); 447 layer_tree_host_impl_->resource_provider());
456 } 448 }
457 449
458 void ThreadProxy::SendManagedMemoryStats() { 450 void ThreadProxy::SendManagedMemoryStats() {
459 DCHECK(IsImplThread()); 451 DCHECK(IsImplThread());
460 if (!layer_tree_host_impl_) 452 if (!layer_tree_host_impl_)
461 return; 453 return;
462 if (!layer_tree_host_->contents_texture_manager()) 454 if (!layer_tree_host_->contents_texture_manager())
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 DCHECK(scheduler_on_impl_thread_->CommitPending()); 791 DCHECK(scheduler_on_impl_thread_->CommitPending());
800 792
801 if (!layer_tree_host_impl_) { 793 if (!layer_tree_host_impl_) {
802 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); 794 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree");
803 completion->Signal(); 795 completion->Signal();
804 return; 796 return;
805 } 797 }
806 798
807 if (offscreen_context_provider.get()) 799 if (offscreen_context_provider.get())
808 offscreen_context_provider->BindToCurrentThread(); 800 offscreen_context_provider->BindToCurrentThread();
809 if (layer_tree_host_impl_->resource_provider()) { 801 layer_tree_host_impl_->resource_provider()->
810 layer_tree_host_impl_->resource_provider()-> 802 set_offscreen_context_provider(offscreen_context_provider);
811 set_offscreen_context_provider(offscreen_context_provider);
812 }
813 803
814 if (layer_tree_host_->contents_texture_manager()) { 804 if (layer_tree_host_->contents_texture_manager()) {
815 if (layer_tree_host_->contents_texture_manager()-> 805 if (layer_tree_host_->contents_texture_manager()->
816 LinkedEvictedBackingsExist()) { 806 LinkedEvictedBackingsExist()) {
817 // Clear any uploads we were making to textures linked to evicted 807 // Clear any uploads we were making to textures linked to evicted
818 // resources 808 // resources
819 queue->ClearUploadsToEvictedResources(); 809 queue->ClearUploadsToEvictedResources();
820 // Some textures in the layer tree are invalid. Kick off another commit 810 // Some textures in the layer tree are invalid. Kick off another commit
821 // to fill them again. 811 // to fill them again.
822 SetNeedsCommitOnImplThread(); 812 SetNeedsCommitOnImplThread();
823 } 813 }
824 814
825 layer_tree_host_->contents_texture_manager()-> 815 layer_tree_host_->contents_texture_manager()->
826 PushTexturePrioritiesToBackings(); 816 PushTexturePrioritiesToBackings();
827 } 817 }
828 818
829 commit_completion_event_on_impl_thread_ = completion; 819 commit_completion_event_on_impl_thread_ = completion;
830 if (layer_tree_host_impl_->resource_provider()) { 820 current_resource_update_controller_on_impl_thread_ =
831 current_resource_update_controller_on_impl_thread_ = 821 ResourceUpdateController::Create(
832 ResourceUpdateController::Create( 822 this,
833 this, 823 Proxy::ImplThreadTaskRunner(),
834 Proxy::ImplThreadTaskRunner(), 824 queue.Pass(),
835 queue.Pass(), 825 layer_tree_host_impl_->resource_provider());
836 layer_tree_host_impl_->resource_provider()); 826 current_resource_update_controller_on_impl_thread_->PerformMoreUpdates(
837 current_resource_update_controller_on_impl_thread_->PerformMoreUpdates( 827 scheduler_on_impl_thread_->AnticipatedDrawTime());
838 scheduler_on_impl_thread_->AnticipatedDrawTime());
839 } else {
840 // Normally the ResourceUpdateController notifies when commit should
841 // finish, but in tile-free software rendering there is no resource
842 // update step so jump straight to the notification.
843 scheduler_on_impl_thread_->FinishCommit();
844 }
845 } 828 }
846 829
847 void ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread() { 830 void ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread() {
848 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread"); 831 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread");
849 DCHECK(IsImplThread()); 832 DCHECK(IsImplThread());
850 DCHECK(scheduler_on_impl_thread_); 833 DCHECK(scheduler_on_impl_thread_);
851 DCHECK(scheduler_on_impl_thread_->CommitPending()); 834 DCHECK(scheduler_on_impl_thread_->CommitPending());
852 835
853 scheduler_on_impl_thread_->BeginFrameAbortedByMainThread(); 836 scheduler_on_impl_thread_->BeginFrameAbortedByMainThread();
854 } 837 }
855 838
856 void ThreadProxy::ScheduledActionCommit() { 839 void ThreadProxy::ScheduledActionCommit() {
857 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); 840 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit");
858 DCHECK(IsImplThread()); 841 DCHECK(IsImplThread());
859 DCHECK(commit_completion_event_on_impl_thread_); 842 DCHECK(commit_completion_event_on_impl_thread_);
860 if (current_resource_update_controller_on_impl_thread_) { 843 DCHECK(current_resource_update_controller_on_impl_thread_);
861 // Complete all remaining texture updates. 844
862 current_resource_update_controller_on_impl_thread_->Finalize(); 845 // Complete all remaining texture updates.
863 current_resource_update_controller_on_impl_thread_.reset(); 846 current_resource_update_controller_on_impl_thread_->Finalize();
864 } 847 current_resource_update_controller_on_impl_thread_.reset();
865 848
866 layer_tree_host_impl_->BeginCommit(); 849 layer_tree_host_impl_->BeginCommit();
867 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); 850 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get());
868 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); 851 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get());
869 layer_tree_host_impl_->CommitComplete(); 852 layer_tree_host_impl_->CommitComplete();
870 853
871 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( 854 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
872 !scheduler_on_impl_thread_->WillDrawIfNeeded()); 855 !scheduler_on_impl_thread_->WillDrawIfNeeded());
873 856
874 next_frame_is_newly_committed_frame_on_impl_thread_ = true; 857 next_frame_is_newly_committed_frame_on_impl_thread_ = true;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 void ThreadProxy::DidTryInitializeRendererOnImplThread( 1213 void ThreadProxy::DidTryInitializeRendererOnImplThread(
1231 bool success, 1214 bool success,
1232 scoped_refptr<ContextProvider> offscreen_context_provider) { 1215 scoped_refptr<ContextProvider> offscreen_context_provider) {
1233 DCHECK(IsImplThread()); 1216 DCHECK(IsImplThread());
1234 DCHECK(!inside_draw_); 1217 DCHECK(!inside_draw_);
1235 1218
1236 if (offscreen_context_provider.get()) 1219 if (offscreen_context_provider.get())
1237 offscreen_context_provider->BindToCurrentThread(); 1220 offscreen_context_provider->BindToCurrentThread();
1238 1221
1239 if (success) { 1222 if (success) {
1240 if (layer_tree_host_impl_->resource_provider()) { 1223 layer_tree_host_impl_->resource_provider()->
1241 layer_tree_host_impl_->resource_provider()-> 1224 set_offscreen_context_provider(offscreen_context_provider);
1242 set_offscreen_context_provider(offscreen_context_provider);
1243 }
1244 } else if (offscreen_context_provider.get()) { 1225 } else if (offscreen_context_provider.get()) {
1245 offscreen_context_provider->VerifyContexts(); 1226 offscreen_context_provider->VerifyContexts();
1246 } 1227 }
1247 } 1228 }
1248 1229
1249 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { 1230 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) {
1250 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); 1231 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread");
1251 DCHECK(IsImplThread()); 1232 DCHECK(IsImplThread());
1252 if (layer_tree_host_impl_->resource_provider()) 1233 if (layer_tree_host_impl_->resource_provider())
1253 layer_tree_host_impl_->resource_provider()->Finish(); 1234 layer_tree_host_impl_->resource_provider()->Finish();
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 !layer_tree_host_impl_->pending_tree()) { 1437 !layer_tree_host_impl_->pending_tree()) {
1457 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", 1438 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation",
1458 TRACE_EVENT_SCOPE_THREAD); 1439 TRACE_EVENT_SCOPE_THREAD);
1459 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); 1440 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
1460 completion_event_for_commit_held_on_tree_activation_->Signal(); 1441 completion_event_for_commit_held_on_tree_activation_->Signal();
1461 completion_event_for_commit_held_on_tree_activation_ = NULL; 1442 completion_event_for_commit_held_on_tree_activation_ = NULL;
1462 } 1443 }
1463 } 1444 }
1464 1445
1465 } // namespace cc 1446 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698