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

Side by Side Diff: cc/thread_proxy.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month 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
« no previous file with comments | « cc/thread_proxy.h ('k') | cc/tiled_layer_impl_unittest.cc » ('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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/thread_proxy.h" 7 #include "cc/thread_proxy.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "cc/delay_based_time_source.h" 11 #include "cc/delay_based_time_source.h"
12 #include "cc/draw_quad.h" 12 #include "cc/draw_quad.h"
13 #include "cc/frame_rate_controller.h" 13 #include "cc/frame_rate_controller.h"
14 #include "cc/graphics_context.h" 14 #include "cc/graphics_context.h"
15 #include "cc/input_handler.h" 15 #include "cc/input_handler.h"
16 #include "cc/layer_tree_host.h" 16 #include "cc/layer_tree_host.h"
17 #include "cc/scheduler.h" 17 #include "cc/scheduler.h"
18 #include "cc/scoped_thread_proxy.h" 18 #include "cc/scoped_thread_proxy.h"
19 #include "cc/thread.h"
19 #include <public/WebSharedGraphicsContext3D.h> 20 #include <public/WebSharedGraphicsContext3D.h>
20 21
21 using WebKit::WebSharedGraphicsContext3D; 22 using WebKit::WebSharedGraphicsContext3D;
22 23
23 namespace { 24 namespace {
24 25
25 // Measured in seconds. 26 // Measured in seconds.
26 const double contextRecreationTickRate = 0.03; 27 const double contextRecreationTickRate = 0.03;
27 28
28 } // namespace 29 } // namespace
29 30
30 namespace cc { 31 namespace cc {
31 32
32 scoped_ptr<Proxy> ThreadProxy::create(LayerTreeHost* layerTreeHost) 33 scoped_ptr<Proxy> ThreadProxy::create(LayerTreeHost* layerTreeHost, scoped_ptr<T hread> implThread)
33 { 34 {
34 return make_scoped_ptr(new ThreadProxy(layerTreeHost)).PassAs<Proxy>(); 35 return make_scoped_ptr(new ThreadProxy(layerTreeHost, implThread.Pass())).Pa ssAs<Proxy>();
35 } 36 }
36 37
37 ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost) 38 ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implTh read)
38 : m_animateRequested(false) 39 : Proxy(implThread.Pass())
40 , m_animateRequested(false)
39 , m_commitRequested(false) 41 , m_commitRequested(false)
40 , m_commitRequestSentToImplThread(false) 42 , m_commitRequestSentToImplThread(false)
41 , m_forcedCommitRequested(false) 43 , m_forcedCommitRequested(false)
42 , m_layerTreeHost(layerTreeHost) 44 , m_layerTreeHost(layerTreeHost)
43 , m_rendererInitialized(false) 45 , m_rendererInitialized(false)
44 , m_started(false) 46 , m_started(false)
45 , m_texturesAcquired(true) 47 , m_texturesAcquired(true)
46 , m_inCompositeAndReadback(false) 48 , m_inCompositeAndReadback(false)
47 , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread())) 49 , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread()))
48 , m_beginFrameCompletionEventOnImplThread(0) 50 , m_beginFrameCompletionEventOnImplThread(0)
(...skipping 25 matching lines...) Expand all
74 DCHECK(!m_deferCommits); 76 DCHECK(!m_deferCommits);
75 77
76 if (!m_layerTreeHost->initializeRendererIfNeeded()) { 78 if (!m_layerTreeHost->initializeRendererIfNeeded()) {
77 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); 79 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized");
78 return false; 80 return false;
79 } 81 }
80 82
81 83
82 // Perform a synchronous commit. 84 // Perform a synchronous commit.
83 { 85 {
84 DebugScopedSetMainThreadBlocked mainThreadBlocked; 86 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
85 CompletionEvent beginFrameCompletion; 87 CompletionEvent beginFrameCompletion;
86 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::forceBeginFrameOn ImplThread, base::Unretained(this), &beginFrameCompletion)); 88 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::forceBeginFrameOn ImplThread, base::Unretained(this), &beginFrameCompletion));
87 beginFrameCompletion.wait(); 89 beginFrameCompletion.wait();
88 } 90 }
89 m_inCompositeAndReadback = true; 91 m_inCompositeAndReadback = true;
90 beginFrame(); 92 beginFrame();
91 m_inCompositeAndReadback = false; 93 m_inCompositeAndReadback = false;
92 94
93 // Perform a synchronous readback. 95 // Perform a synchronous readback.
94 ReadbackRequest request; 96 ReadbackRequest request;
95 request.rect = rect; 97 request.rect = rect;
96 request.pixels = pixels; 98 request.pixels = pixels;
97 { 99 {
98 DebugScopedSetMainThreadBlocked mainThreadBlocked; 100 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
99 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestReadbackOn ImplThread, base::Unretained(this), &request)); 101 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::requestReadbackOn ImplThread, base::Unretained(this), &request));
100 request.completion.wait(); 102 request.completion.wait();
101 } 103 }
102 return request.success; 104 return request.success;
103 } 105 }
104 106
105 void ThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) 107 void ThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request)
106 { 108 {
107 DCHECK(Proxy::isImplThread()); 109 DCHECK(Proxy::isImplThread());
108 DCHECK(!m_readbackRequestOnImplThread); 110 DCHECK(!m_readbackRequestOnImplThread);
(...skipping 20 matching lines...) Expand all
129 if (m_layerTreeHostImpl.get()) 131 if (m_layerTreeHostImpl.get())
130 m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, sc ale, base::TimeTicks::Now(), duration); 132 m_layerTreeHostImpl->startPageScaleAnimation(targetOffset, useAnchor, sc ale, base::TimeTicks::Now(), duration);
131 } 133 }
132 134
133 void ThreadProxy::finishAllRendering() 135 void ThreadProxy::finishAllRendering()
134 { 136 {
135 DCHECK(Proxy::isMainThread()); 137 DCHECK(Proxy::isMainThread());
136 DCHECK(!m_deferCommits); 138 DCHECK(!m_deferCommits);
137 139
138 // Make sure all GL drawing is finished on the impl thread. 140 // Make sure all GL drawing is finished on the impl thread.
139 DebugScopedSetMainThreadBlocked mainThreadBlocked; 141 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
140 CompletionEvent completion; 142 CompletionEvent completion;
141 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::finishAllRenderingOnI mplThread, base::Unretained(this), &completion)); 143 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::finishAllRenderingOnI mplThread, base::Unretained(this), &completion));
142 completion.wait(); 144 completion.wait();
143 } 145 }
144 146
145 bool ThreadProxy::isStarted() const 147 bool ThreadProxy::isStarted() const
146 { 148 {
147 DCHECK(Proxy::isMainThread()); 149 DCHECK(Proxy::isMainThread());
148 return m_started; 150 return m_started;
149 } 151 }
(...skipping 17 matching lines...) Expand all
167 169
168 void ThreadProxy::setSurfaceReadyOnImplThread() 170 void ThreadProxy::setSurfaceReadyOnImplThread()
169 { 171 {
170 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReadyOnImplThread"); 172 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReadyOnImplThread");
171 m_schedulerOnImplThread->setCanBeginFrame(true); 173 m_schedulerOnImplThread->setCanBeginFrame(true);
172 } 174 }
173 175
174 void ThreadProxy::setVisible(bool visible) 176 void ThreadProxy::setVisible(bool visible)
175 { 177 {
176 TRACE_EVENT0("cc", "ThreadProxy::setVisible"); 178 TRACE_EVENT0("cc", "ThreadProxy::setVisible");
177 DebugScopedSetMainThreadBlocked mainThreadBlocked; 179 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
178 CompletionEvent completion; 180 CompletionEvent completion;
179 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setVisibleOnImplThrea d, base::Unretained(this), &completion, visible)); 181 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setVisibleOnImplThrea d, base::Unretained(this), &completion, visible));
180 completion.wait(); 182 completion.wait();
181 } 183 }
182 184
183 void ThreadProxy::setVisibleOnImplThread(CompletionEvent* completion, bool visib le) 185 void ThreadProxy::setVisibleOnImplThread(CompletionEvent* completion, bool visib le)
184 { 186 {
185 TRACE_EVENT0("cc", "ThreadProxy::setVisibleOnImplThread"); 187 TRACE_EVENT0("cc", "ThreadProxy::setVisibleOnImplThread");
186 m_layerTreeHostImpl->setVisible(visible); 188 m_layerTreeHostImpl->setVisible(visible);
187 m_schedulerOnImplThread->setVisible(visible); 189 m_schedulerOnImplThread->setVisible(visible);
188 completion->signal(); 190 completion->signal();
189 } 191 }
190 192
191 bool ThreadProxy::initializeRenderer() 193 bool ThreadProxy::initializeRenderer()
192 { 194 {
193 TRACE_EVENT0("cc", "ThreadProxy::initializeRenderer"); 195 TRACE_EVENT0("cc", "ThreadProxy::initializeRenderer");
194 // Make a blocking call to initializeRendererOnImplThread. The results of th at call 196 // Make a blocking call to initializeRendererOnImplThread. The results of th at call
195 // are pushed into the initializeSucceeded and capabilities local variables. 197 // are pushed into the initializeSucceeded and capabilities local variables.
196 CompletionEvent completion; 198 CompletionEvent completion;
197 bool initializeSucceeded = false; 199 bool initializeSucceeded = false;
198 RendererCapabilities capabilities; 200 RendererCapabilities capabilities;
199 DebugScopedSetMainThreadBlocked mainThreadBlocked; 201 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
200 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeRendererOnI mplThread, 202 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeRendererOnI mplThread,
201 base::Unretained(this), 203 base::Unretained(this),
202 &completion, 204 &completion,
203 &initializeSucceeded, 205 &initializeSucceeded,
204 &capabilities)); 206 &capabilities));
205 completion.wait(); 207 completion.wait();
206 208
207 if (initializeSucceeded) { 209 if (initializeSucceeded) {
208 m_rendererInitialized = true; 210 m_rendererInitialized = true;
209 m_RendererCapabilitiesMainThreadCopy = capabilities; 211 m_RendererCapabilitiesMainThreadCopy = capabilities;
(...skipping 13 matching lines...) Expand all
223 if (m_layerTreeHost->needsSharedContext()) 225 if (m_layerTreeHost->needsSharedContext())
224 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) 226 if (!WebSharedGraphicsContext3D::createCompositorThreadContext())
225 return false; 227 return false;
226 228
227 // Make a blocking call to recreateContextOnImplThread. The results of that 229 // Make a blocking call to recreateContextOnImplThread. The results of that
228 // call are pushed into the recreateSucceeded and capabilities local 230 // call are pushed into the recreateSucceeded and capabilities local
229 // variables. 231 // variables.
230 CompletionEvent completion; 232 CompletionEvent completion;
231 bool recreateSucceeded = false; 233 bool recreateSucceeded = false;
232 RendererCapabilities capabilities; 234 RendererCapabilities capabilities;
233 DebugScopedSetMainThreadBlocked mainThreadBlocked; 235 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
234 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateContextOnImpl Thread, 236 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateContextOnImpl Thread,
235 base::Unretained(this), 237 base::Unretained(this),
236 &completion, 238 &completion,
237 base::Passed(context.Pass()), 239 base::Passed(context.Pass()),
238 &recreateSucceeded, 240 &recreateSucceeded,
239 &capabilities)); 241 &capabilities));
240 completion.wait(); 242 completion.wait();
241 243
242 if (recreateSucceeded) 244 if (recreateSucceeded)
243 m_RendererCapabilitiesMainThreadCopy = capabilities; 245 m_RendererCapabilitiesMainThreadCopy = capabilities;
244 return recreateSucceeded; 246 return recreateSucceeded;
245 } 247 }
246 248
247 void ThreadProxy::renderingStats(RenderingStats* stats) 249 void ThreadProxy::renderingStats(RenderingStats* stats)
248 { 250 {
249 DCHECK(isMainThread()); 251 DCHECK(isMainThread());
250 252
251 DebugScopedSetMainThreadBlocked mainThreadBlocked; 253 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
252 CompletionEvent completion; 254 CompletionEvent completion;
253 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::renderingStatsOnImplT hread, 255 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::renderingStatsOnImplT hread,
254 base::Unretained(this), &completio n, stats)); 256 base::Unretained(this), &completio n, stats));
255 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); 257 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF();
256 stats->totalCommitCount = m_totalCommitCount; 258 stats->totalCommitCount = m_totalCommitCount;
257 259
258 completion.wait(); 260 completion.wait();
259 } 261 }
260 262
261 const RendererCapabilities& ThreadProxy::rendererCapabilities() const 263 const RendererCapabilities& ThreadProxy::rendererCapabilities() const
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 DCHECK(isImplThread()); 423 DCHECK(isImplThread());
422 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); 424 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread");
423 m_schedulerOnImplThread->setNeedsRedraw(); 425 m_schedulerOnImplThread->setNeedsRedraw();
424 } 426 }
425 427
426 void ThreadProxy::start() 428 void ThreadProxy::start()
427 { 429 {
428 DCHECK(isMainThread()); 430 DCHECK(isMainThread());
429 DCHECK(Proxy::implThread()); 431 DCHECK(Proxy::implThread());
430 // Create LayerTreeHostImpl. 432 // Create LayerTreeHostImpl.
431 DebugScopedSetMainThreadBlocked mainThreadBlocked; 433 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
432 CompletionEvent completion; 434 CompletionEvent completion;
433 scoped_ptr<InputHandler> handler = m_layerTreeHost->createInputHandler(); 435 scoped_ptr<InputHandler> handler = m_layerTreeHost->createInputHandler();
434 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeImplOnImplT hread, base::Unretained(this), &completion, handler.release())); 436 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeImplOnImplT hread, base::Unretained(this), &completion, handler.release()));
435 completion.wait(); 437 completion.wait();
436 438
437 m_started = true; 439 m_started = true;
438 } 440 }
439 441
440 void ThreadProxy::stop() 442 void ThreadProxy::stop()
441 { 443 {
442 TRACE_EVENT0("cc", "ThreadProxy::stop"); 444 TRACE_EVENT0("cc", "ThreadProxy::stop");
443 DCHECK(isMainThread()); 445 DCHECK(isMainThread());
444 DCHECK(m_started); 446 DCHECK(m_started);
445 447
446 // Synchronously deletes the impl. 448 // Synchronously deletes the impl.
447 { 449 {
448 DebugScopedSetMainThreadBlocked mainThreadBlocked; 450 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
449 451
450 CompletionEvent completion; 452 CompletionEvent completion;
451 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::layerTreeHostClos edOnImplThread, base::Unretained(this), &completion)); 453 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::layerTreeHostClos edOnImplThread, base::Unretained(this), &completion));
452 completion.wait(); 454 completion.wait();
453 } 455 }
454 456
455 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. 457 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us.
456 458
457 DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted. 459 DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted.
458 m_layerTreeHost = 0; 460 m_layerTreeHost = 0;
459 m_started = false; 461 m_started = false;
460 } 462 }
461 463
462 void ThreadProxy::forceSerializeOnSwapBuffers() 464 void ThreadProxy::forceSerializeOnSwapBuffers()
463 { 465 {
464 DebugScopedSetMainThreadBlocked mainThreadBlocked; 466 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
465 CompletionEvent completion; 467 CompletionEvent completion;
466 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::forceSerializeOnSwapB uffersOnImplThread, base::Unretained(this), &completion)); 468 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::forceSerializeOnSwapB uffersOnImplThread, base::Unretained(this), &completion));
467 completion.wait(); 469 completion.wait();
468 } 470 }
469 471
470 void ThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CompletionEvent* compl etion) 472 void ThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CompletionEvent* compl etion)
471 { 473 {
472 if (m_rendererInitialized) 474 if (m_rendererInitialized)
473 m_layerTreeHostImpl->renderer()->doNoOp(); 475 m_layerTreeHostImpl->renderer()->doNoOp();
474 completion->signal(); 476 completion->signal();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 setNeedsAnimate(); 609 setNeedsAnimate();
608 } 610 }
609 611
610 // Notify the impl thread that the beginFrame has completed. This will 612 // Notify the impl thread that the beginFrame has completed. This will
611 // begin the commit process, which is blocking from the main thread's 613 // begin the commit process, which is blocking from the main thread's
612 // point of view, but asynchronously performed on the impl thread, 614 // point of view, but asynchronously performed on the impl thread,
613 // coordinated by the Scheduler. 615 // coordinated by the Scheduler.
614 { 616 {
615 TRACE_EVENT0("cc", "commit"); 617 TRACE_EVENT0("cc", "commit");
616 618
617 DebugScopedSetMainThreadBlocked mainThreadBlocked; 619 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
618 620
619 base::TimeTicks startTime = base::TimeTicks::HighResNow(); 621 base::TimeTicks startTime = base::TimeTicks::HighResNow();
620 CompletionEvent completion; 622 CompletionEvent completion;
621 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::beginFrameComplet eOnImplThread, base::Unretained(this), &completion, queue.release())); 623 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::beginFrameComplet eOnImplThread, base::Unretained(this), &completion, queue.release()));
622 completion.wait(); 624 completion.wait();
623 base::TimeTicks endTime = base::TimeTicks::HighResNow(); 625 base::TimeTicks endTime = base::TimeTicks::HighResNow();
624 626
625 m_totalCommitTime += endTime - startTime; 627 m_totalCommitTime += endTime - startTime;
626 m_totalCommitCount++; 628 m_totalCommitCount++;
627 } 629 }
(...skipping 22 matching lines...) Expand all
650 // Clear any uploads we were making to textures linked to evicted 652 // Clear any uploads we were making to textures linked to evicted
651 // resources 653 // resources
652 queue->clearUploadsToEvictedResources(); 654 queue->clearUploadsToEvictedResources();
653 // Some textures in the layer tree are invalid. Kick off another commit 655 // Some textures in the layer tree are invalid. Kick off another commit
654 // to fill them again. 656 // to fill them again.
655 setNeedsCommitOnImplThread(); 657 setNeedsCommitOnImplThread();
656 } 658 }
657 659
658 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings() ; 660 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings() ;
659 661
660 m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::cr eate(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvi der()); 662 m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::cr eate(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvi der(), hasImplThread());
661 ResourceProvider::debugNotifyEnterZone(0x2000000); 663 ResourceProvider::debugNotifyEnterZone(0x2000000);
662 m_currentResourceUpdateControllerOnImplThread->performMoreUpdates( 664 m_currentResourceUpdateControllerOnImplThread->performMoreUpdates(
663 m_schedulerOnImplThread->anticipatedDrawTime()); 665 m_schedulerOnImplThread->anticipatedDrawTime());
664 ResourceProvider::debugNotifyLeaveZone(); 666 ResourceProvider::debugNotifyLeaveZone();
665 667
666 m_commitCompletionEventOnImplThread = completion; 668 m_commitCompletionEventOnImplThread = completion;
667 } 669 }
668 670
669 void ThreadProxy::beginFrameAbortedOnImplThread() 671 void ThreadProxy::beginFrameAbortedOnImplThread()
670 { 672 {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 // directly by the compositor. 790 // directly by the compositor.
789 // This method will block until the next compositor draw if there is a 791 // This method will block until the next compositor draw if there is a
790 // previously committed frame that is still undrawn. This is necessary to 792 // previously committed frame that is still undrawn. This is necessary to
791 // ensure that the main thread does not monopolize access to the textures. 793 // ensure that the main thread does not monopolize access to the textures.
792 DCHECK(isMainThread()); 794 DCHECK(isMainThread());
793 795
794 if (m_texturesAcquired) 796 if (m_texturesAcquired)
795 return; 797 return;
796 798
797 TRACE_EVENT0("cc", "ThreadProxy::acquireLayerTextures"); 799 TRACE_EVENT0("cc", "ThreadProxy::acquireLayerTextures");
798 DebugScopedSetMainThreadBlocked mainThreadBlocked; 800 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
799 CompletionEvent completion; 801 CompletionEvent completion;
800 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::acquireLayerTexturesF orMainThreadOnImplThread, base::Unretained(this), &completion)); 802 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::acquireLayerTexturesF orMainThreadOnImplThread, base::Unretained(this), &completion));
801 completion.wait(); // Block until it is safe to write to layer textures from the main thread. 803 completion.wait(); // Block until it is safe to write to layer textures from the main thread.
802 804
803 m_texturesAcquired = true; 805 m_texturesAcquired = true;
804 } 806 }
805 807
806 void ThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent* completion) 808 void ThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent* completion)
807 { 809 {
808 DCHECK(isImplThread()); 810 DCHECK(isImplThread());
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 983
982 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 984 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
983 { 985 {
984 } 986 }
985 987
986 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() 988 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState()
987 { 989 {
988 } 990 }
989 991
990 } // namespace cc 992 } // namespace cc
OLDNEW
« no previous file with comments | « cc/thread_proxy.h ('k') | cc/tiled_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698