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

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 typo 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
« no previous file with comments | « 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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 begin_frame_state->monotonic_frame_begin_time = 686 begin_frame_state->monotonic_frame_begin_time =
687 layer_tree_host_impl_->CurrentPhysicalTimeTicks(); 687 layer_tree_host_impl_->CurrentPhysicalTimeTicks();
688 begin_frame_state->scroll_info = 688 begin_frame_state->scroll_info =
689 layer_tree_host_impl_->ProcessScrollDeltas(); 689 layer_tree_host_impl_->ProcessScrollDeltas();
690 690
691 if (!layer_tree_host_impl_->settings().impl_side_painting) { 691 if (!layer_tree_host_impl_->settings().impl_side_painting) {
692 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); 692 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u);
693 } 693 }
694 begin_frame_state->memory_allocation_limit_bytes = 694 begin_frame_state->memory_allocation_limit_bytes =
695 layer_tree_host_impl_->memory_allocation_limit_bytes(); 695 layer_tree_host_impl_->memory_allocation_limit_bytes();
696 begin_frame_state->evicted_ui_resources =
697 layer_tree_host_impl_->EvictedUIResourcesExist();
696 Proxy::MainThreadTaskRunner()->PostTask( 698 Proxy::MainThreadTaskRunner()->PostTask(
697 FROM_HERE, 699 FROM_HERE,
698 base::Bind(&ThreadProxy::BeginFrameOnMainThread, 700 base::Bind(&ThreadProxy::BeginFrameOnMainThread,
699 main_thread_weak_ptr_, 701 main_thread_weak_ptr_,
700 base::Passed(&begin_frame_state))); 702 base::Passed(&begin_frame_state)));
701 703
702 if (begin_frame_sent_to_main_thread_completion_event_on_impl_thread_) { 704 if (begin_frame_sent_to_main_thread_completion_event_on_impl_thread_) {
703 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_->Signal(); 705 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_->Signal();
704 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_ = NULL; 706 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_ = NULL;
705 } 707 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 begin_frame_state->monotonic_frame_begin_time); 762 begin_frame_state->monotonic_frame_begin_time);
761 } 763 }
762 764
763 // Unlink any backings that the impl thread has evicted, so that we know to 765 // Unlink any backings that the impl thread has evicted, so that we know to
764 // re-paint them in UpdateLayers. 766 // re-paint them in UpdateLayers.
765 if (layer_tree_host_->contents_texture_manager()) { 767 if (layer_tree_host_->contents_texture_manager()) {
766 layer_tree_host_->contents_texture_manager()-> 768 layer_tree_host_->contents_texture_manager()->
767 UnlinkAndClearEvictedBackings(); 769 UnlinkAndClearEvictedBackings();
768 } 770 }
769 771
772 // Recreate all UI resources if there were evicted UI resources when the impl
773 // thread initiated the commit.
774 bool evicted_ui_resources =
775 begin_frame_state ? begin_frame_state->evicted_ui_resources : false;
776 if (evicted_ui_resources)
777 layer_tree_host_->RecreateUIResources();
778
770 layer_tree_host_->Layout(); 779 layer_tree_host_->Layout();
771 780
772 // Clear the commit flag after updating animations and layout here --- objects 781 // Clear the commit flag after updating animations and layout here --- objects
773 // that only layout when painted will trigger another SetNeedsCommit inside 782 // that only layout when painted will trigger another SetNeedsCommit inside
774 // UpdateLayers. 783 // UpdateLayers.
775 commit_requested_ = false; 784 commit_requested_ = false;
776 commit_request_sent_to_impl_thread_ = false; 785 commit_request_sent_to_impl_thread_ = false;
777 bool can_cancel_this_commit = 786 bool can_cancel_this_commit =
778 can_cancel_commit_ && !in_composite_and_readback_; 787 can_cancel_commit_ &&
788 !in_composite_and_readback_ &&
789 !evicted_ui_resources;
779 can_cancel_commit_ = true; 790 can_cancel_commit_ = true;
780 791
781 scoped_ptr<ResourceUpdateQueue> queue = 792 scoped_ptr<ResourceUpdateQueue> queue =
782 make_scoped_ptr(new ResourceUpdateQueue); 793 make_scoped_ptr(new ResourceUpdateQueue);
783 bool updated = layer_tree_host_->UpdateLayers( 794 bool updated = layer_tree_host_->UpdateLayers(
784 queue.get(), 795 queue.get(),
785 begin_frame_state ? begin_frame_state->memory_allocation_limit_bytes 796 begin_frame_state ? begin_frame_state->memory_allocation_limit_bytes
786 : 0u); 797 : 0u);
787 798
788 // Once single buffered layers are committed, they cannot be modified until 799 // Once single buffered layers are committed, they cannot be modified until
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 layer_tree_host_impl_.reset(); 1386 layer_tree_host_impl_.reset();
1376 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); 1387 weak_factory_on_impl_thread_.InvalidateWeakPtrs();
1377 completion->Signal(); 1388 completion->Signal();
1378 } 1389 }
1379 1390
1380 size_t ThreadProxy::MaxPartialTextureUpdates() const { 1391 size_t ThreadProxy::MaxPartialTextureUpdates() const {
1381 return ResourceUpdateController::MaxPartialTextureUpdates(); 1392 return ResourceUpdateController::MaxPartialTextureUpdates();
1382 } 1393 }
1383 1394
1384 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 1395 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
1385 : memory_allocation_limit_bytes(0) {} 1396 : memory_allocation_limit_bytes(0), evicted_ui_resources(false) {}
1386 1397
1387 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() {} 1398 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() {}
1388 1399
1389 scoped_ptr<base::Value> ThreadProxy::AsValue() const { 1400 scoped_ptr<base::Value> ThreadProxy::AsValue() const {
1390 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1401 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1391 1402
1392 CompletionEvent completion; 1403 CompletionEvent completion;
1393 { 1404 {
1394 DebugScopedSetMainThreadBlocked main_thread_blocked( 1405 DebugScopedSetMainThreadBlocked main_thread_blocked(
1395 const_cast<ThreadProxy*>(this)); 1406 const_cast<ThreadProxy*>(this));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; 1491 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES;
1481 1492
1482 // Smoothness takes priority if expiration time is in the future. 1493 // Smoothness takes priority if expiration time is in the future.
1483 if (smoothness_takes_priority_expiration_time_ > now) 1494 if (smoothness_takes_priority_expiration_time_ > now)
1484 priority = SMOOTHNESS_TAKES_PRIORITY; 1495 priority = SMOOTHNESS_TAKES_PRIORITY;
1485 1496
1486 // New content always takes priority when the active tree has 1497 // New content always takes priority when the active tree has
1487 // evicted resources or there is an invalid viewport size. 1498 // evicted resources or there is an invalid viewport size.
1488 if (layer_tree_host_impl_->active_tree()->ContentsTexturesPurged() || 1499 if (layer_tree_host_impl_->active_tree()->ContentsTexturesPurged() ||
1489 layer_tree_host_impl_->active_tree()->ViewportSizeInvalid() || 1500 layer_tree_host_impl_->active_tree()->ViewportSizeInvalid() ||
1501 layer_tree_host_impl_->EvictedUIResourcesExist() ||
1490 input_throttled_until_commit_) 1502 input_throttled_until_commit_)
1491 priority = NEW_CONTENT_TAKES_PRIORITY; 1503 priority = NEW_CONTENT_TAKES_PRIORITY;
1492 1504
1493 layer_tree_host_impl_->SetTreePriority(priority); 1505 layer_tree_host_impl_->SetTreePriority(priority);
1494 1506
1495 // Notify the the client of this compositor via the output surface. 1507 // Notify the the client of this compositor via the output surface.
1496 // TODO(epenner): Route this to compositor-thread instead of output-surface 1508 // TODO(epenner): Route this to compositor-thread instead of output-surface
1497 // after GTFO refactor of compositor-thread (http://crbug/170828). 1509 // after GTFO refactor of compositor-thread (http://crbug/170828).
1498 if (layer_tree_host_impl_->output_surface()) { 1510 if (layer_tree_host_impl_->output_surface()) {
1499 layer_tree_host_impl_->output_surface()-> 1511 layer_tree_host_impl_->output_surface()->
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 completion_event_for_commit_held_on_tree_activation_ = NULL; 1562 completion_event_for_commit_held_on_tree_activation_ = NULL;
1551 } 1563 }
1552 1564
1553 UpdateBackgroundAnimateTicking(); 1565 UpdateBackgroundAnimateTicking();
1554 1566
1555 commit_to_activate_duration_history_.InsertSample( 1567 commit_to_activate_duration_history_.InsertSample(
1556 base::TimeTicks::HighResNow() - commit_complete_time_); 1568 base::TimeTicks::HighResNow() - commit_complete_time_);
1557 } 1569 }
1558 1570
1559 } // namespace cc 1571 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698