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

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

Issue 227413011: Remove old texture path in TextureLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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') | content/renderer/pepper/pepper_plugin_instance_impl.h » ('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/trees/thread_proxy.h" 5 #include "cc/trees/thread_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, 89 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy,
90 int layer_tree_host_id) 90 int layer_tree_host_id)
91 : layer_tree_host_id(layer_tree_host_id), 91 : layer_tree_host_id(layer_tree_host_id),
92 animate_requested(false), 92 animate_requested(false),
93 commit_requested(false), 93 commit_requested(false),
94 commit_request_sent_to_impl_thread(false), 94 commit_request_sent_to_impl_thread(false),
95 created_offscreen_context_provider(false), 95 created_offscreen_context_provider(false),
96 started(false), 96 started(false),
97 textures_acquired(true),
98 in_composite_and_readback(false), 97 in_composite_and_readback(false),
99 manage_tiles_pending(false), 98 manage_tiles_pending(false),
100 can_cancel_commit(true), 99 can_cancel_commit(true),
101 defer_commits(false), 100 defer_commits(false),
102 weak_factory(proxy) {} 101 weak_factory(proxy) {}
103 102
104 ThreadProxy::MainThreadOnly::~MainThreadOnly() {} 103 ThreadProxy::MainThreadOnly::~MainThreadOnly() {}
105 104
106 ThreadProxy::MainThreadOrBlockedMainThread::MainThreadOrBlockedMainThread( 105 ThreadProxy::MainThreadOrBlockedMainThread::MainThreadOrBlockedMainThread(
107 LayerTreeHost* host) 106 LayerTreeHost* host)
108 : layer_tree_host(host), 107 : layer_tree_host(host),
109 commit_waits_for_activation(false), 108 commit_waits_for_activation(false),
110 main_thread_inside_commit(false) {} 109 main_thread_inside_commit(false) {}
111 110
112 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} 111 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {}
113 112
114 PrioritizedResourceManager* 113 PrioritizedResourceManager*
115 ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() { 114 ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() {
116 return layer_tree_host->contents_texture_manager(); 115 return layer_tree_host->contents_texture_manager();
117 } 116 }
118 117
119 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy, 118 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy,
120 int layer_tree_host_id) 119 int layer_tree_host_id)
121 : layer_tree_host_id(layer_tree_host_id), 120 : layer_tree_host_id(layer_tree_host_id),
122 contents_texture_manager(NULL), 121 contents_texture_manager(NULL),
123 begin_main_frame_sent_completion_event(NULL), 122 begin_main_frame_sent_completion_event(NULL),
124 readback_request(NULL), 123 readback_request(NULL),
125 commit_completion_event(NULL), 124 commit_completion_event(NULL),
126 completion_event_for_commit_held_on_tree_activation(NULL), 125 completion_event_for_commit_held_on_tree_activation(NULL),
127 texture_acquisition_completion_event(NULL),
128 next_frame_is_newly_committed_frame(false), 126 next_frame_is_newly_committed_frame(false),
129 inside_draw(false), 127 inside_draw(false),
130 input_throttled_until_commit(false), 128 input_throttled_until_commit(false),
131 animations_frozen_until_next_draw(false), 129 animations_frozen_until_next_draw(false),
132 renew_tree_priority_pending(false), 130 renew_tree_priority_pending(false),
133 weak_factory(proxy) {} 131 weak_factory(proxy) {}
134 132
135 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} 133 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {}
136 134
137 ThreadProxy::~ThreadProxy() { 135 ThreadProxy::~ThreadProxy() {
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 bool can_cancel_this_commit = main().can_cancel_commit && 907 bool can_cancel_this_commit = main().can_cancel_commit &&
910 !main().in_composite_and_readback && 908 !main().in_composite_and_readback &&
911 !evicted_ui_resources; 909 !evicted_ui_resources;
912 main().can_cancel_commit = true; 910 main().can_cancel_commit = true;
913 911
914 scoped_ptr<ResourceUpdateQueue> queue = 912 scoped_ptr<ResourceUpdateQueue> queue =
915 make_scoped_ptr(new ResourceUpdateQueue); 913 make_scoped_ptr(new ResourceUpdateQueue);
916 914
917 bool updated = layer_tree_host()->UpdateLayers(queue.get()); 915 bool updated = layer_tree_host()->UpdateLayers(queue.get());
918 916
919 // Once single buffered layers are committed, they cannot be modified until
920 // they are drawn by the impl thread.
921 main().textures_acquired = false;
922
923 layer_tree_host()->WillCommit(); 917 layer_tree_host()->WillCommit();
924 918
925 // Before calling animate, we set main().animate_requested to false. If it is 919 // Before calling animate, we set main().animate_requested to false. If it is
926 // true now, it means SetNeedAnimate was called again, but during a state when 920 // true now, it means SetNeedAnimate was called again, but during a state when
927 // main().commit_request_sent_to_impl_thread = true. We need to force that 921 // main().commit_request_sent_to_impl_thread = true. We need to force that
928 // call to happen again now so that the commit request is sent to the impl 922 // call to happen again now so that the commit request is sent to the impl
929 // thread. 923 // thread.
930 if (main().animate_requested) { 924 if (main().animate_requested) {
931 // Forces SetNeedsAnimate to consider posting a commit task. 925 // Forces SetNeedsAnimate to consider posting a commit task.
932 main().animate_requested = false; 926 main().animate_requested = false;
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 draw_duration_overestimate, 1287 draw_duration_overestimate,
1294 base::TimeDelta::FromMilliseconds(1), 1288 base::TimeDelta::FromMilliseconds(1),
1295 base::TimeDelta::FromMilliseconds(100), 1289 base::TimeDelta::FromMilliseconds(100),
1296 50); 1290 50);
1297 } 1291 }
1298 1292
1299 DCHECK_NE(DrawSwapReadbackResult::INVALID_RESULT, result.draw_result); 1293 DCHECK_NE(DrawSwapReadbackResult::INVALID_RESULT, result.draw_result);
1300 return result; 1294 return result;
1301 } 1295 }
1302 1296
1303 void ThreadProxy::AcquireLayerTextures() {
1304 // Called when the main thread needs to modify a layer texture that is used
1305 // directly by the compositor.
1306 // This method will block until the next compositor draw if there is a
1307 // previously committed frame that is still undrawn. This is necessary to
1308 // ensure that the main thread does not monopolize access to the textures.
1309 DCHECK(IsMainThread());
1310
1311 if (main().textures_acquired)
1312 return;
1313
1314 TRACE_EVENT0("cc", "ThreadProxy::AcquireLayerTextures");
1315 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
1316 CompletionEvent completion;
1317 Proxy::ImplThreadTaskRunner()->PostTask(
1318 FROM_HERE,
1319 base::Bind(&ThreadProxy::AcquireLayerTexturesForMainThreadOnImplThread,
1320 impl_thread_weak_ptr_,
1321 &completion));
1322 // Block until it is safe to write to layer textures from the main thread.
1323 completion.Wait();
1324
1325 main().textures_acquired = true;
1326 main().can_cancel_commit = false;
1327 }
1328
1329 void ThreadProxy::AcquireLayerTexturesForMainThreadOnImplThread(
1330 CompletionEvent* completion) {
1331 DCHECK(IsImplThread());
1332 DCHECK(!impl().texture_acquisition_completion_event);
1333
1334 impl().texture_acquisition_completion_event = completion;
1335 impl().scheduler->SetMainThreadNeedsLayerTextures();
1336 }
1337
1338 void ThreadProxy::ScheduledActionAcquireLayerTexturesForMainThread() {
1339 DCHECK(impl().texture_acquisition_completion_event);
1340 impl().texture_acquisition_completion_event->Signal();
1341 impl().texture_acquisition_completion_event = NULL;
1342 }
1343
1344 void ThreadProxy::ScheduledActionManageTiles() { 1297 void ThreadProxy::ScheduledActionManageTiles() {
1345 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionManageTiles"); 1298 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionManageTiles");
1346 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); 1299 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting);
1347 impl().layer_tree_host_impl->ManageTiles(); 1300 impl().layer_tree_host_impl->ManageTiles();
1348 } 1301 }
1349 1302
1350 DrawSwapReadbackResult ThreadProxy::ScheduledActionDrawAndSwapIfPossible() { 1303 DrawSwapReadbackResult ThreadProxy::ScheduledActionDrawAndSwapIfPossible() {
1351 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionDrawAndSwap"); 1304 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionDrawAndSwap");
1352 1305
1353 // SchedulerStateMachine::DidDrawIfPossibleCompleted isn't set up to 1306 // SchedulerStateMachine::DidDrawIfPossibleCompleted isn't set up to
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 1694
1742 impl().timing_history.DidActivatePendingTree(); 1695 impl().timing_history.DidActivatePendingTree();
1743 } 1696 }
1744 1697
1745 void ThreadProxy::DidManageTiles() { 1698 void ThreadProxy::DidManageTiles() {
1746 DCHECK(IsImplThread()); 1699 DCHECK(IsImplThread());
1747 impl().scheduler->DidManageTiles(); 1700 impl().scheduler->DidManageTiles();
1748 } 1701 }
1749 1702
1750 } // namespace cc 1703 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | content/renderer/pepper/pepper_plugin_instance_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698