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

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: 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
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 Proxy::ImplThread()->PostTask( 331 Proxy::ImplThread()->PostTask(
332 base::Bind(&ThreadProxy::CheckOutputSurfaceStatusOnImplThread, 332 base::Bind(&ThreadProxy::CheckOutputSurfaceStatusOnImplThread,
333 impl_thread_weak_ptr_)); 333 impl_thread_weak_ptr_));
334 } 334 }
335 335
336 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { 336 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() {
337 DCHECK(IsImplThread()); 337 DCHECK(IsImplThread());
338 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread"); 338 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread");
339 if (!layer_tree_host_impl_->IsContextLost()) 339 if (!layer_tree_host_impl_->IsContextLost())
340 return; 340 return;
341 cc::ContextProvider* offscreen_contexts = 341 if (cc::ContextProvider* offscreen_contexts = layer_tree_host_impl_
342 layer_tree_host_impl_->resource_provider() ? 342 ->resource_provider()->offscreen_context_provider())
343 layer_tree_host_impl_->resource_provider()->
344 offscreen_context_provider() : NULL;
345
346 if (offscreen_contexts)
347 offscreen_contexts->VerifyContexts(); 343 offscreen_contexts->VerifyContexts();
348 scheduler_on_impl_thread_->DidLoseOutputSurface(); 344 scheduler_on_impl_thread_->DidLoseOutputSurface();
349 } 345 }
350 346
351 void ThreadProxy::OnSwapBuffersCompleteOnImplThread() { 347 void ThreadProxy::OnSwapBuffersCompleteOnImplThread() {
352 DCHECK(IsImplThread()); 348 DCHECK(IsImplThread());
353 TRACE_EVENT0("cc", "ThreadProxy::OnSwapBuffersCompleteOnImplThread"); 349 TRACE_EVENT0("cc", "ThreadProxy::OnSwapBuffersCompleteOnImplThread");
354 Proxy::MainThread()->PostTask( 350 Proxy::MainThread()->PostTask(
355 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); 351 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_));
356 } 352 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 base::Passed(&events), 397 base::Passed(&events),
402 wall_clock_time)); 398 wall_clock_time));
403 } 399 }
404 400
405 bool ThreadProxy::ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, 401 bool ThreadProxy::ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes,
406 int priority_cutoff) { 402 int priority_cutoff) {
407 DCHECK(IsImplThread()); 403 DCHECK(IsImplThread());
408 404
409 if (!layer_tree_host_->contents_texture_manager()) 405 if (!layer_tree_host_->contents_texture_manager())
410 return false; 406 return false;
411 if (!layer_tree_host_impl_->resource_provider())
412 return false;
413 407
414 bool reduce_result = layer_tree_host_->contents_texture_manager()-> 408 bool reduce_result = layer_tree_host_->contents_texture_manager()->
415 ReduceMemoryOnImplThread(limit_bytes, 409 ReduceMemoryOnImplThread(limit_bytes,
416 priority_cutoff, 410 priority_cutoff,
417 layer_tree_host_impl_->resource_provider()); 411 layer_tree_host_impl_->resource_provider());
418 if (!reduce_result) 412 if (!reduce_result)
419 return false; 413 return false;
420 414
421 // The texture upload queue may reference textures that were just purged, 415 // The texture upload queue may reference textures that were just purged,
422 // clear them from the queue. 416 // clear them from the queue.
423 if (current_resource_update_controller_on_impl_thread_) { 417 if (current_resource_update_controller_on_impl_thread_) {
424 current_resource_update_controller_on_impl_thread_-> 418 current_resource_update_controller_on_impl_thread_->
425 DiscardUploadsToEvictedResources(); 419 DiscardUploadsToEvictedResources();
426 } 420 }
427 return true; 421 return true;
428 } 422 }
429 423
430 void ThreadProxy::ReduceWastedContentsTextureMemoryOnImplThread() { 424 void ThreadProxy::ReduceWastedContentsTextureMemoryOnImplThread() {
431 DCHECK(IsImplThread()); 425 DCHECK(IsImplThread());
432 426
433 if (!layer_tree_host_->contents_texture_manager()) 427 if (!layer_tree_host_->contents_texture_manager())
434 return; 428 return;
435 if (!layer_tree_host_impl_->resource_provider())
436 return;
437 429
438 layer_tree_host_->contents_texture_manager()->ReduceWastedMemoryOnImplThread( 430 layer_tree_host_->contents_texture_manager()->ReduceWastedMemoryOnImplThread(
439 layer_tree_host_impl_->resource_provider()); 431 layer_tree_host_impl_->resource_provider());
440 } 432 }
441 433
442 void ThreadProxy::SendManagedMemoryStats() { 434 void ThreadProxy::SendManagedMemoryStats() {
443 DCHECK(IsImplThread()); 435 DCHECK(IsImplThread());
444 if (!layer_tree_host_impl_) 436 if (!layer_tree_host_impl_)
445 return; 437 return;
446 if (!layer_tree_host_->contents_texture_manager()) 438 if (!layer_tree_host_->contents_texture_manager())
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 DCHECK(scheduler_on_impl_thread_->CommitPending()); 764 DCHECK(scheduler_on_impl_thread_->CommitPending());
773 765
774 if (!layer_tree_host_impl_) { 766 if (!layer_tree_host_impl_) {
775 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); 767 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree");
776 completion->Signal(); 768 completion->Signal();
777 return; 769 return;
778 } 770 }
779 771
780 if (offscreen_context_provider.get()) 772 if (offscreen_context_provider.get())
781 offscreen_context_provider->BindToCurrentThread(); 773 offscreen_context_provider->BindToCurrentThread();
782 if (layer_tree_host_impl_->resource_provider()) { 774 layer_tree_host_impl_->resource_provider()->
783 layer_tree_host_impl_->resource_provider()-> 775 set_offscreen_context_provider(offscreen_context_provider);
784 set_offscreen_context_provider(offscreen_context_provider);
785 }
786 776
787 if (layer_tree_host_->contents_texture_manager()) { 777 if (layer_tree_host_->contents_texture_manager()) {
788 if (layer_tree_host_->contents_texture_manager()-> 778 if (layer_tree_host_->contents_texture_manager()->
789 LinkedEvictedBackingsExist()) { 779 LinkedEvictedBackingsExist()) {
790 // Clear any uploads we were making to textures linked to evicted 780 // Clear any uploads we were making to textures linked to evicted
791 // resources 781 // resources
792 queue->ClearUploadsToEvictedResources(); 782 queue->ClearUploadsToEvictedResources();
793 // Some textures in the layer tree are invalid. Kick off another commit 783 // Some textures in the layer tree are invalid. Kick off another commit
794 // to fill them again. 784 // to fill them again.
795 SetNeedsCommitOnImplThread(); 785 SetNeedsCommitOnImplThread();
796 } 786 }
797 787
798 layer_tree_host_->contents_texture_manager()-> 788 layer_tree_host_->contents_texture_manager()->
799 PushTexturePrioritiesToBackings(); 789 PushTexturePrioritiesToBackings();
800 } 790 }
801 791
802 commit_completion_event_on_impl_thread_ = completion; 792 commit_completion_event_on_impl_thread_ = completion;
803 if (layer_tree_host_impl_->resource_provider()) { 793 current_resource_update_controller_on_impl_thread_ =
804 current_resource_update_controller_on_impl_thread_ = 794 ResourceUpdateController::Create(
805 ResourceUpdateController::Create( 795 this,
806 this, 796 Proxy::ImplThread()->TaskRunner(),
807 Proxy::ImplThread()->TaskRunner(), 797 queue.Pass(),
808 queue.Pass(), 798 layer_tree_host_impl_->resource_provider());
809 layer_tree_host_impl_->resource_provider()); 799 current_resource_update_controller_on_impl_thread_->PerformMoreUpdates(
810 current_resource_update_controller_on_impl_thread_->PerformMoreUpdates( 800 scheduler_on_impl_thread_->AnticipatedDrawTime());
811 scheduler_on_impl_thread_->AnticipatedDrawTime());
812 } else {
813 // Normally the ResourceUpdateController notifies when commit should
814 // finish, but in tile-free software rendering there is no resource
815 // update step so jump straight to the notification.
816 scheduler_on_impl_thread_->FinishCommit();
817 }
818 } 801 }
819 802
820 void ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread() { 803 void ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread() {
821 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread"); 804 TRACE_EVENT0("cc", "ThreadProxy::BeginFrameAbortedByMainThreadOnImplThread");
822 DCHECK(IsImplThread()); 805 DCHECK(IsImplThread());
823 DCHECK(scheduler_on_impl_thread_); 806 DCHECK(scheduler_on_impl_thread_);
824 DCHECK(scheduler_on_impl_thread_->CommitPending()); 807 DCHECK(scheduler_on_impl_thread_->CommitPending());
825 808
826 scheduler_on_impl_thread_->BeginFrameAbortedByMainThread(); 809 scheduler_on_impl_thread_->BeginFrameAbortedByMainThread();
827 } 810 }
828 811
829 void ThreadProxy::ScheduledActionCommit() { 812 void ThreadProxy::ScheduledActionCommit() {
830 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); 813 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit");
831 DCHECK(IsImplThread()); 814 DCHECK(IsImplThread());
832 DCHECK(commit_completion_event_on_impl_thread_); 815 DCHECK(commit_completion_event_on_impl_thread_);
833 if (current_resource_update_controller_on_impl_thread_) { 816 DCHECK(current_resource_update_controller_on_impl_thread_);
834 // Complete all remaining texture updates. 817
835 current_resource_update_controller_on_impl_thread_->Finalize(); 818 // Complete all remaining texture updates.
836 current_resource_update_controller_on_impl_thread_.reset(); 819 current_resource_update_controller_on_impl_thread_->Finalize();
837 } 820 current_resource_update_controller_on_impl_thread_.reset();
838 821
839 layer_tree_host_impl_->BeginCommit(); 822 layer_tree_host_impl_->BeginCommit();
840 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); 823 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get());
841 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); 824 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get());
842 layer_tree_host_impl_->CommitComplete(); 825 layer_tree_host_impl_->CommitComplete();
843 826
844 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( 827 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
845 !scheduler_on_impl_thread_->WillDrawIfNeeded()); 828 !scheduler_on_impl_thread_->WillDrawIfNeeded());
846 829
847 next_frame_is_newly_committed_frame_on_impl_thread_ = true; 830 next_frame_is_newly_committed_frame_on_impl_thread_ = true;
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 void ThreadProxy::DidTryInitializeRendererOnImplThread( 1182 void ThreadProxy::DidTryInitializeRendererOnImplThread(
1200 bool success, 1183 bool success,
1201 scoped_refptr<ContextProvider> offscreen_context_provider) { 1184 scoped_refptr<ContextProvider> offscreen_context_provider) {
1202 DCHECK(IsImplThread()); 1185 DCHECK(IsImplThread());
1203 DCHECK(!inside_draw_); 1186 DCHECK(!inside_draw_);
1204 1187
1205 if (offscreen_context_provider.get()) 1188 if (offscreen_context_provider.get())
1206 offscreen_context_provider->BindToCurrentThread(); 1189 offscreen_context_provider->BindToCurrentThread();
1207 1190
1208 if (success) { 1191 if (success) {
1209 if (layer_tree_host_impl_->resource_provider()) { 1192 layer_tree_host_impl_->resource_provider()->
1210 layer_tree_host_impl_->resource_provider()-> 1193 set_offscreen_context_provider(offscreen_context_provider);
1211 set_offscreen_context_provider(offscreen_context_provider);
1212 }
1213 } else if (offscreen_context_provider.get()) { 1194 } else if (offscreen_context_provider.get()) {
1214 offscreen_context_provider->VerifyContexts(); 1195 offscreen_context_provider->VerifyContexts();
1215 } 1196 }
1216 } 1197 }
1217 1198
1218 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { 1199 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) {
1219 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); 1200 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread");
1220 DCHECK(IsImplThread()); 1201 DCHECK(IsImplThread());
1221 if (layer_tree_host_impl_->resource_provider()) 1202 if (layer_tree_host_impl_->resource_provider())
1222 layer_tree_host_impl_->resource_provider()->Finish(); 1203 layer_tree_host_impl_->resource_provider()->Finish();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 !layer_tree_host_impl_->pending_tree()) { 1399 !layer_tree_host_impl_->pending_tree()) {
1419 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", 1400 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation",
1420 TRACE_EVENT_SCOPE_THREAD); 1401 TRACE_EVENT_SCOPE_THREAD);
1421 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); 1402 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
1422 completion_event_for_commit_held_on_tree_activation_->Signal(); 1403 completion_event_for_commit_held_on_tree_activation_->Signal();
1423 completion_event_for_commit_held_on_tree_activation_ = NULL; 1404 completion_event_for_commit_held_on_tree_activation_ = NULL;
1424 } 1405 }
1425 } 1406 }
1426 1407
1427 } // namespace cc 1408 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_impl.cc ('K') | « 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