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

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

Issue 23548022: [cc] Evict UIResources when the renderer is not visible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typos Created 7 years, 3 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
« cc/trees/layer_tree_impl.cc ('K') | « cc/trees/thread_proxy.h ('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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 begin_frame_state->monotonic_frame_begin_time = 684 begin_frame_state->monotonic_frame_begin_time =
685 layer_tree_host_impl_->CurrentPhysicalTimeTicks(); 685 layer_tree_host_impl_->CurrentPhysicalTimeTicks();
686 begin_frame_state->scroll_info = 686 begin_frame_state->scroll_info =
687 layer_tree_host_impl_->ProcessScrollDeltas(); 687 layer_tree_host_impl_->ProcessScrollDeltas();
688 688
689 if (!layer_tree_host_impl_->settings().impl_side_painting) { 689 if (!layer_tree_host_impl_->settings().impl_side_painting) {
690 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); 690 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u);
691 } 691 }
692 begin_frame_state->memory_allocation_limit_bytes = 692 begin_frame_state->memory_allocation_limit_bytes =
693 layer_tree_host_impl_->memory_allocation_limit_bytes(); 693 layer_tree_host_impl_->memory_allocation_limit_bytes();
694 begin_frame_state->evicted_ui_resources =
695 layer_tree_host_impl_->EvictedUIResourcesExist();
694 Proxy::MainThreadTaskRunner()->PostTask( 696 Proxy::MainThreadTaskRunner()->PostTask(
695 FROM_HERE, 697 FROM_HERE,
696 base::Bind(&ThreadProxy::BeginFrameOnMainThread, 698 base::Bind(&ThreadProxy::BeginFrameOnMainThread,
697 main_thread_weak_ptr_, 699 main_thread_weak_ptr_,
698 base::Passed(&begin_frame_state))); 700 base::Passed(&begin_frame_state)));
699 701
700 if (begin_frame_sent_to_main_thread_completion_event_on_impl_thread_) { 702 if (begin_frame_sent_to_main_thread_completion_event_on_impl_thread_) {
701 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_->Signal(); 703 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_->Signal();
702 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_ = NULL; 704 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_ = NULL;
703 } 705 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 begin_frame_state->monotonic_frame_begin_time); 760 begin_frame_state->monotonic_frame_begin_time);
759 } 761 }
760 762
761 // Unlink any backings that the impl thread has evicted, so that we know to 763 // Unlink any backings that the impl thread has evicted, so that we know to
762 // re-paint them in UpdateLayers. 764 // re-paint them in UpdateLayers.
763 if (layer_tree_host_->contents_texture_manager()) { 765 if (layer_tree_host_->contents_texture_manager()) {
764 layer_tree_host_->contents_texture_manager()-> 766 layer_tree_host_->contents_texture_manager()->
765 UnlinkAndClearEvictedBackings(); 767 UnlinkAndClearEvictedBackings();
766 } 768 }
767 769
770 // Recreate all UI resources if there were evicted UI resources when the impl
aelias_OOO_until_Jul13 2013/09/10 20:02:33 Hmm, I don't know of anything that guarantees no c
ccameron 2013/09/10 21:27:49 Only forced commits will happen, which I'm told is
771 // thread initiated the commit.
772 bool evicted_ui_resources =
773 begin_frame_state ? begin_frame_state->evicted_ui_resources : false;
774 if (evicted_ui_resources)
775 layer_tree_host_->RecreateUIResources();
776
768 layer_tree_host_->Layout(); 777 layer_tree_host_->Layout();
769 778
770 // Clear the commit flag after updating animations and layout here --- objects 779 // Clear the commit flag after updating animations and layout here --- objects
771 // that only layout when painted will trigger another SetNeedsCommit inside 780 // that only layout when painted will trigger another SetNeedsCommit inside
772 // UpdateLayers. 781 // UpdateLayers.
773 commit_requested_ = false; 782 commit_requested_ = false;
774 commit_request_sent_to_impl_thread_ = false; 783 commit_request_sent_to_impl_thread_ = false;
775 bool can_cancel_this_commit = 784 bool can_cancel_this_commit =
776 can_cancel_commit_ && !in_composite_and_readback_; 785 can_cancel_commit_ &&
786 !in_composite_and_readback_ &&
787 !evicted_ui_resources;
777 can_cancel_commit_ = true; 788 can_cancel_commit_ = true;
778 789
779 scoped_ptr<ResourceUpdateQueue> queue = 790 scoped_ptr<ResourceUpdateQueue> queue =
780 make_scoped_ptr(new ResourceUpdateQueue); 791 make_scoped_ptr(new ResourceUpdateQueue);
781 bool updated = layer_tree_host_->UpdateLayers( 792 bool updated = layer_tree_host_->UpdateLayers(
782 queue.get(), 793 queue.get(),
783 begin_frame_state ? begin_frame_state->memory_allocation_limit_bytes 794 begin_frame_state ? begin_frame_state->memory_allocation_limit_bytes
784 : 0u); 795 : 0u);
785 796
786 // Once single buffered layers are committed, they cannot be modified until 797 // Once single buffered layers are committed, they cannot be modified until
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 layer_tree_host_impl_.reset(); 1357 layer_tree_host_impl_.reset();
1347 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); 1358 weak_factory_on_impl_thread_.InvalidateWeakPtrs();
1348 completion->Signal(); 1359 completion->Signal();
1349 } 1360 }
1350 1361
1351 size_t ThreadProxy::MaxPartialTextureUpdates() const { 1362 size_t ThreadProxy::MaxPartialTextureUpdates() const {
1352 return ResourceUpdateController::MaxPartialTextureUpdates(); 1363 return ResourceUpdateController::MaxPartialTextureUpdates();
1353 } 1364 }
1354 1365
1355 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 1366 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
1356 : memory_allocation_limit_bytes(0) {} 1367 : memory_allocation_limit_bytes(0), evicted_ui_resources(false) {}
1357 1368
1358 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() {} 1369 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() {}
1359 1370
1360 scoped_ptr<base::Value> ThreadProxy::AsValue() const { 1371 scoped_ptr<base::Value> ThreadProxy::AsValue() const {
1361 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1372 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1362 1373
1363 CompletionEvent completion; 1374 CompletionEvent completion;
1364 { 1375 {
1365 DebugScopedSetMainThreadBlocked main_thread_blocked( 1376 DebugScopedSetMainThreadBlocked main_thread_blocked(
1366 const_cast<ThreadProxy*>(this)); 1377 const_cast<ThreadProxy*>(this));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; 1462 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES;
1452 1463
1453 // Smoothness takes priority if expiration time is in the future. 1464 // Smoothness takes priority if expiration time is in the future.
1454 if (smoothness_takes_priority_expiration_time_ > now) 1465 if (smoothness_takes_priority_expiration_time_ > now)
1455 priority = SMOOTHNESS_TAKES_PRIORITY; 1466 priority = SMOOTHNESS_TAKES_PRIORITY;
1456 1467
1457 // New content always takes priority when the active tree has 1468 // New content always takes priority when the active tree has
1458 // evicted resources or there is an invalid viewport size. 1469 // evicted resources or there is an invalid viewport size.
1459 if (layer_tree_host_impl_->active_tree()->ContentsTexturesPurged() || 1470 if (layer_tree_host_impl_->active_tree()->ContentsTexturesPurged() ||
1460 layer_tree_host_impl_->active_tree()->ViewportSizeInvalid() || 1471 layer_tree_host_impl_->active_tree()->ViewportSizeInvalid() ||
1472 layer_tree_host_impl_->EvictedUIResourcesExist() ||
1461 input_throttled_until_commit_) 1473 input_throttled_until_commit_)
1462 priority = NEW_CONTENT_TAKES_PRIORITY; 1474 priority = NEW_CONTENT_TAKES_PRIORITY;
1463 1475
1464 layer_tree_host_impl_->SetTreePriority(priority); 1476 layer_tree_host_impl_->SetTreePriority(priority);
1465 1477
1466 // Notify the the client of this compositor via the output surface. 1478 // Notify the the client of this compositor via the output surface.
1467 // TODO(epenner): Route this to compositor-thread instead of output-surface 1479 // TODO(epenner): Route this to compositor-thread instead of output-surface
1468 // after GTFO refactor of compositor-thread (http://crbug/170828). 1480 // after GTFO refactor of compositor-thread (http://crbug/170828).
1469 if (layer_tree_host_impl_->output_surface()) { 1481 if (layer_tree_host_impl_->output_surface()) {
1470 layer_tree_host_impl_->output_surface()-> 1482 layer_tree_host_impl_->output_surface()->
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 completion_event_for_commit_held_on_tree_activation_ = NULL; 1533 completion_event_for_commit_held_on_tree_activation_ = NULL;
1522 } 1534 }
1523 1535
1524 UpdateBackgroundAnimateTicking(); 1536 UpdateBackgroundAnimateTicking();
1525 1537
1526 commit_to_activate_duration_history_.InsertSample( 1538 commit_to_activate_duration_history_.InsertSample(
1527 base::TimeTicks::HighResNow() - commit_complete_time_); 1539 base::TimeTicks::HighResNow() - commit_complete_time_);
1528 } 1540 }
1529 1541
1530 } // namespace cc 1542 } // namespace cc
OLDNEW
« cc/trees/layer_tree_impl.cc ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698