OLD | NEW |
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 "CCDelayBasedTimeSource.h" | 9 #include "CCDelayBasedTimeSource.h" |
10 #include "CCDrawQuad.h" | 10 #include "CCDrawQuad.h" |
11 #include "CCFrameRateController.h" | 11 #include "CCFrameRateController.h" |
12 #include "CCGraphicsContext.h" | 12 #include "CCGraphicsContext.h" |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "cc/input_handler.h" | 14 #include "cc/input_handler.h" |
15 #include "cc/layer_tree_host.h" | 15 #include "cc/layer_tree_host.h" |
16 #include "cc/scheduler.h" | 16 #include "cc/scheduler.h" |
17 #include "cc/scoped_thread_proxy.h" | 17 #include "cc/scoped_thread_proxy.h" |
| 18 #include "cc/thread.h" |
18 #include "cc/thread_task.h" | 19 #include "cc/thread_task.h" |
19 #include <public/WebSharedGraphicsContext3D.h> | 20 #include <public/WebSharedGraphicsContext3D.h> |
20 #include <wtf/CurrentTime.h> | 21 #include <wtf/CurrentTime.h> |
21 | 22 |
22 using WebKit::WebSharedGraphicsContext3D; | 23 using WebKit::WebSharedGraphicsContext3D; |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 // Measured in seconds. | 27 // Measured in seconds. |
27 const double contextRecreationTickRate = 0.03; | 28 const double contextRecreationTickRate = 0.03; |
28 | 29 |
29 } // namespace | 30 } // namespace |
30 | 31 |
31 namespace cc { | 32 namespace cc { |
32 | 33 |
33 scoped_ptr<Proxy> ThreadProxy::create(LayerTreeHost* layerTreeHost) | 34 scoped_ptr<Proxy> ThreadProxy::create(LayerTreeHost* layerTreeHost, Thread* impl
Thread) |
34 { | 35 { |
35 return make_scoped_ptr(new ThreadProxy(layerTreeHost)).PassAs<Proxy>(); | 36 return make_scoped_ptr(new ThreadProxy(layerTreeHost, implThread)).PassAs<Pr
oxy>(); |
36 } | 37 } |
37 | 38 |
38 ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost) | 39 ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, Thread* implThread) |
39 : m_animateRequested(false) | 40 : Proxy(implThread) |
| 41 , m_animateRequested(false) |
40 , m_commitRequested(false) | 42 , m_commitRequested(false) |
41 , m_commitRequestSentToImplThread(false) | 43 , m_commitRequestSentToImplThread(false) |
42 , m_forcedCommitRequested(false) | 44 , m_forcedCommitRequested(false) |
43 , m_layerTreeHost(layerTreeHost) | 45 , m_layerTreeHost(layerTreeHost) |
44 , m_rendererInitialized(false) | 46 , m_rendererInitialized(false) |
45 , m_started(false) | 47 , m_started(false) |
46 , m_texturesAcquired(true) | 48 , m_texturesAcquired(true) |
47 , m_inCompositeAndReadback(false) | 49 , m_inCompositeAndReadback(false) |
48 , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread())) | 50 , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread())) |
49 , m_beginFrameCompletionEventOnImplThread(0) | 51 , m_beginFrameCompletionEventOnImplThread(0) |
(...skipping 22 matching lines...) Expand all Loading... |
72 DCHECK(m_layerTreeHost); | 74 DCHECK(m_layerTreeHost); |
73 | 75 |
74 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 76 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
75 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); | 77 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); |
76 return false; | 78 return false; |
77 } | 79 } |
78 | 80 |
79 | 81 |
80 // Perform a synchronous commit. | 82 // Perform a synchronous commit. |
81 { | 83 { |
82 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 84 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
83 CompletionEvent beginFrameCompletion; | 85 CompletionEvent beginFrameCompletion; |
84 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::force
BeginFrameOnImplThread, &beginFrameCompletion)); | 86 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::force
BeginFrameOnImplThread, &beginFrameCompletion)); |
85 beginFrameCompletion.wait(); | 87 beginFrameCompletion.wait(); |
86 } | 88 } |
87 m_inCompositeAndReadback = true; | 89 m_inCompositeAndReadback = true; |
88 beginFrame(); | 90 beginFrame(); |
89 m_inCompositeAndReadback = false; | 91 m_inCompositeAndReadback = false; |
90 | 92 |
91 // Perform a synchronous readback. | 93 // Perform a synchronous readback. |
92 ReadbackRequest request; | 94 ReadbackRequest request; |
93 request.rect = rect; | 95 request.rect = rect; |
94 request.pixels = pixels; | 96 request.pixels = pixels; |
95 { | 97 { |
96 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 98 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
97 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::reque
stReadbackOnImplThread, &request)); | 99 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::reque
stReadbackOnImplThread, &request)); |
98 request.completion.wait(); | 100 request.completion.wait(); |
99 } | 101 } |
100 return request.success; | 102 return request.success; |
101 } | 103 } |
102 | 104 |
103 void ThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) | 105 void ThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) |
104 { | 106 { |
105 DCHECK(Proxy::isImplThread()); | 107 DCHECK(Proxy::isImplThread()); |
106 DCHECK(!m_readbackRequestOnImplThread); | 108 DCHECK(!m_readbackRequestOnImplThread); |
(...skipping 19 matching lines...) Expand all Loading... |
126 DCHECK(Proxy::isImplThread()); | 128 DCHECK(Proxy::isImplThread()); |
127 if (m_layerTreeHostImpl.get()) | 129 if (m_layerTreeHostImpl.get()) |
128 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, monotonicallyIncreasingTime(), duration); | 130 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, monotonicallyIncreasingTime(), duration); |
129 } | 131 } |
130 | 132 |
131 void ThreadProxy::finishAllRendering() | 133 void ThreadProxy::finishAllRendering() |
132 { | 134 { |
133 DCHECK(Proxy::isMainThread()); | 135 DCHECK(Proxy::isMainThread()); |
134 | 136 |
135 // Make sure all GL drawing is finished on the impl thread. | 137 // Make sure all GL drawing is finished on the impl thread. |
136 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 138 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
137 CompletionEvent completion; | 139 CompletionEvent completion; |
138 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::finishAll
RenderingOnImplThread, &completion)); | 140 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::finishAll
RenderingOnImplThread, &completion)); |
139 completion.wait(); | 141 completion.wait(); |
140 } | 142 } |
141 | 143 |
142 bool ThreadProxy::isStarted() const | 144 bool ThreadProxy::isStarted() const |
143 { | 145 { |
144 DCHECK(Proxy::isMainThread()); | 146 DCHECK(Proxy::isMainThread()); |
145 return m_started; | 147 return m_started; |
146 } | 148 } |
(...skipping 18 matching lines...) Expand all Loading... |
165 | 167 |
166 void ThreadProxy::setSurfaceReadyOnImplThread() | 168 void ThreadProxy::setSurfaceReadyOnImplThread() |
167 { | 169 { |
168 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReadyOnImplThread"); | 170 TRACE_EVENT0("cc", "ThreadProxy::setSurfaceReadyOnImplThread"); |
169 m_schedulerOnImplThread->setCanBeginFrame(true); | 171 m_schedulerOnImplThread->setCanBeginFrame(true); |
170 } | 172 } |
171 | 173 |
172 void ThreadProxy::setVisible(bool visible) | 174 void ThreadProxy::setVisible(bool visible) |
173 { | 175 { |
174 TRACE_EVENT0("cc", "ThreadProxy::setVisible"); | 176 TRACE_EVENT0("cc", "ThreadProxy::setVisible"); |
175 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 177 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
176 CompletionEvent completion; | 178 CompletionEvent completion; |
177 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setVisibl
eOnImplThread, &completion, visible)); | 179 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setVisibl
eOnImplThread, &completion, visible)); |
178 completion.wait(); | 180 completion.wait(); |
179 } | 181 } |
180 | 182 |
181 void ThreadProxy::setVisibleOnImplThread(CompletionEvent* completion, bool visib
le) | 183 void ThreadProxy::setVisibleOnImplThread(CompletionEvent* completion, bool visib
le) |
182 { | 184 { |
183 TRACE_EVENT0("cc", "ThreadProxy::setVisibleOnImplThread"); | 185 TRACE_EVENT0("cc", "ThreadProxy::setVisibleOnImplThread"); |
184 m_layerTreeHostImpl->setVisible(visible); | 186 m_layerTreeHostImpl->setVisible(visible); |
185 m_schedulerOnImplThread->setVisible(visible); | 187 m_schedulerOnImplThread->setVisible(visible); |
186 completion->signal(); | 188 completion->signal(); |
187 } | 189 } |
188 | 190 |
189 bool ThreadProxy::initializeRenderer() | 191 bool ThreadProxy::initializeRenderer() |
190 { | 192 { |
191 TRACE_EVENT0("cc", "ThreadProxy::initializeRenderer"); | 193 TRACE_EVENT0("cc", "ThreadProxy::initializeRenderer"); |
192 // Make a blocking call to initializeRendererOnImplThread. The results of th
at call | 194 // Make a blocking call to initializeRendererOnImplThread. The results of th
at call |
193 // are pushed into the initializeSucceeded and capabilities local variables. | 195 // are pushed into the initializeSucceeded and capabilities local variables. |
194 CompletionEvent completion; | 196 CompletionEvent completion; |
195 bool initializeSucceeded = false; | 197 bool initializeSucceeded = false; |
196 RendererCapabilities capabilities; | 198 RendererCapabilities capabilities; |
197 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 199 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
198 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::initializ
eRendererOnImplThread, | 200 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::initializ
eRendererOnImplThread, |
199 &completion, | 201 &completion, |
200 &initializeSucceeded, | 202 &initializeSucceeded, |
201 &capabilities)); | 203 &capabilities)); |
202 completion.wait(); | 204 completion.wait(); |
203 | 205 |
204 if (initializeSucceeded) { | 206 if (initializeSucceeded) { |
205 m_rendererInitialized = true; | 207 m_rendererInitialized = true; |
206 m_RendererCapabilitiesMainThreadCopy = capabilities; | 208 m_RendererCapabilitiesMainThreadCopy = capabilities; |
207 } | 209 } |
(...skipping 12 matching lines...) Expand all Loading... |
220 if (m_layerTreeHost->needsSharedContext()) | 222 if (m_layerTreeHost->needsSharedContext()) |
221 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) | 223 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) |
222 return false; | 224 return false; |
223 | 225 |
224 // Make a blocking call to recreateContextOnImplThread. The results of that | 226 // Make a blocking call to recreateContextOnImplThread. The results of that |
225 // call are pushed into the recreateSucceeded and capabilities local | 227 // call are pushed into the recreateSucceeded and capabilities local |
226 // variables. | 228 // variables. |
227 CompletionEvent completion; | 229 CompletionEvent completion; |
228 bool recreateSucceeded = false; | 230 bool recreateSucceeded = false; |
229 RendererCapabilities capabilities; | 231 RendererCapabilities capabilities; |
230 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 232 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
231 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::recreateC
ontextOnImplThread, | 233 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::recreateC
ontextOnImplThread, |
232 &completion, | 234 &completion, |
233 context.release(), | 235 context.release(), |
234 &recreateSucceeded, | 236 &recreateSucceeded, |
235 &capabilities)); | 237 &capabilities)); |
236 completion.wait(); | 238 completion.wait(); |
237 | 239 |
238 if (recreateSucceeded) | 240 if (recreateSucceeded) |
239 m_RendererCapabilitiesMainThreadCopy = capabilities; | 241 m_RendererCapabilitiesMainThreadCopy = capabilities; |
240 return recreateSucceeded; | 242 return recreateSucceeded; |
241 } | 243 } |
242 | 244 |
243 void ThreadProxy::renderingStats(RenderingStats* stats) | 245 void ThreadProxy::renderingStats(RenderingStats* stats) |
244 { | 246 { |
245 DCHECK(isMainThread()); | 247 DCHECK(isMainThread()); |
246 | 248 |
247 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 249 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
248 CompletionEvent completion; | 250 CompletionEvent completion; |
249 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::rendering
StatsOnImplThread, | 251 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::rendering
StatsOnImplThread, |
250 &completion, | 252 &completion, |
251 stats)); | 253 stats)); |
252 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); | 254 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); |
253 stats->totalCommitCount = m_totalCommitCount; | 255 stats->totalCommitCount = m_totalCommitCount; |
254 | 256 |
255 completion.wait(); | 257 completion.wait(); |
256 } | 258 } |
257 | 259 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 DCHECK(isImplThread()); | 386 DCHECK(isImplThread()); |
385 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); | 387 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); |
386 m_schedulerOnImplThread->setNeedsRedraw(); | 388 m_schedulerOnImplThread->setNeedsRedraw(); |
387 } | 389 } |
388 | 390 |
389 void ThreadProxy::start() | 391 void ThreadProxy::start() |
390 { | 392 { |
391 DCHECK(isMainThread()); | 393 DCHECK(isMainThread()); |
392 DCHECK(Proxy::implThread()); | 394 DCHECK(Proxy::implThread()); |
393 // Create LayerTreeHostImpl. | 395 // Create LayerTreeHostImpl. |
394 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 396 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
395 CompletionEvent completion; | 397 CompletionEvent completion; |
396 scoped_ptr<InputHandler> handler = m_layerTreeHost->createInputHandler(); | 398 scoped_ptr<InputHandler> handler = m_layerTreeHost->createInputHandler(); |
397 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::initializ
eImplOnImplThread, &completion, handler.release())); | 399 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::initializ
eImplOnImplThread, &completion, handler.release())); |
398 completion.wait(); | 400 completion.wait(); |
399 | 401 |
400 m_started = true; | 402 m_started = true; |
401 } | 403 } |
402 | 404 |
403 void ThreadProxy::stop() | 405 void ThreadProxy::stop() |
404 { | 406 { |
405 TRACE_EVENT0("cc", "ThreadProxy::stop"); | 407 TRACE_EVENT0("cc", "ThreadProxy::stop"); |
406 DCHECK(isMainThread()); | 408 DCHECK(isMainThread()); |
407 DCHECK(m_started); | 409 DCHECK(m_started); |
408 | 410 |
409 // Synchronously deletes the impl. | 411 // Synchronously deletes the impl. |
410 { | 412 { |
411 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 413 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
412 | 414 |
413 CompletionEvent completion; | 415 CompletionEvent completion; |
414 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::layer
TreeHostClosedOnImplThread, &completion)); | 416 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::layer
TreeHostClosedOnImplThread, &completion)); |
415 completion.wait(); | 417 completion.wait(); |
416 } | 418 } |
417 | 419 |
418 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. | 420 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. |
419 | 421 |
420 DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted. | 422 DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted. |
421 m_layerTreeHost = 0; | 423 m_layerTreeHost = 0; |
422 m_started = false; | 424 m_started = false; |
423 } | 425 } |
424 | 426 |
425 void ThreadProxy::forceSerializeOnSwapBuffers() | 427 void ThreadProxy::forceSerializeOnSwapBuffers() |
426 { | 428 { |
427 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 429 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
428 CompletionEvent completion; | 430 CompletionEvent completion; |
429 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::forceSeri
alizeOnSwapBuffersOnImplThread, &completion)); | 431 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::forceSeri
alizeOnSwapBuffersOnImplThread, &completion)); |
430 completion.wait(); | 432 completion.wait(); |
431 } | 433 } |
432 | 434 |
433 void ThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CompletionEvent* compl
etion) | 435 void ThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CompletionEvent* compl
etion) |
434 { | 436 { |
435 if (m_rendererInitialized) | 437 if (m_rendererInitialized) |
436 m_layerTreeHostImpl->renderer()->doNoOp(); | 438 m_layerTreeHostImpl->renderer()->doNoOp(); |
437 completion->signal(); | 439 completion->signal(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 setNeedsAnimate(); | 565 setNeedsAnimate(); |
564 } | 566 } |
565 | 567 |
566 // Notify the impl thread that the beginFrame has completed. This will | 568 // Notify the impl thread that the beginFrame has completed. This will |
567 // begin the commit process, which is blocking from the main thread's | 569 // begin the commit process, which is blocking from the main thread's |
568 // point of view, but asynchronously performed on the impl thread, | 570 // point of view, but asynchronously performed on the impl thread, |
569 // coordinated by the Scheduler. | 571 // coordinated by the Scheduler. |
570 { | 572 { |
571 TRACE_EVENT0("cc", "commit"); | 573 TRACE_EVENT0("cc", "commit"); |
572 | 574 |
573 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 575 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
574 | 576 |
575 base::TimeTicks startTime = base::TimeTicks::HighResNow(); | 577 base::TimeTicks startTime = base::TimeTicks::HighResNow(); |
576 CompletionEvent completion; | 578 CompletionEvent completion; |
577 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::begin
FrameCompleteOnImplThread, &completion, queue.release())); | 579 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::begin
FrameCompleteOnImplThread, &completion, queue.release())); |
578 completion.wait(); | 580 completion.wait(); |
579 base::TimeTicks endTime = base::TimeTicks::HighResNow(); | 581 base::TimeTicks endTime = base::TimeTicks::HighResNow(); |
580 | 582 |
581 m_totalCommitTime += endTime - startTime; | 583 m_totalCommitTime += endTime - startTime; |
582 m_totalCommitCount++; | 584 m_totalCommitCount++; |
583 } | 585 } |
(...skipping 22 matching lines...) Expand all Loading... |
606 // Clear any uploads we were making to textures linked to evicted | 608 // Clear any uploads we were making to textures linked to evicted |
607 // resources | 609 // resources |
608 queue->clearUploadsToEvictedResources(); | 610 queue->clearUploadsToEvictedResources(); |
609 // Some textures in the layer tree are invalid. Kick off another commit | 611 // Some textures in the layer tree are invalid. Kick off another commit |
610 // to fill them again. | 612 // to fill them again. |
611 setNeedsCommitOnImplThread(); | 613 setNeedsCommitOnImplThread(); |
612 } | 614 } |
613 | 615 |
614 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; | 616 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; |
615 | 617 |
616 m_currentTextureUpdateControllerOnImplThread = TextureUpdateController::crea
te(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvide
r()); | 618 m_currentTextureUpdateControllerOnImplThread = TextureUpdateController::crea
te(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvide
r(), hasImplThread()); |
617 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( | 619 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( |
618 m_schedulerOnImplThread->anticipatedDrawTime()); | 620 m_schedulerOnImplThread->anticipatedDrawTime()); |
619 | 621 |
620 m_commitCompletionEventOnImplThread = completion; | 622 m_commitCompletionEventOnImplThread = completion; |
621 } | 623 } |
622 | 624 |
623 void ThreadProxy::beginFrameAbortedOnImplThread() | 625 void ThreadProxy::beginFrameAbortedOnImplThread() |
624 { | 626 { |
625 TRACE_EVENT0("cc", "ThreadProxy::beginFrameAbortedOnImplThread"); | 627 TRACE_EVENT0("cc", "ThreadProxy::beginFrameAbortedOnImplThread"); |
626 DCHECK(isImplThread()); | 628 DCHECK(isImplThread()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 // directly by the compositor. | 740 // directly by the compositor. |
739 // This method will block until the next compositor draw if there is a | 741 // This method will block until the next compositor draw if there is a |
740 // previously committed frame that is still undrawn. This is necessary to | 742 // previously committed frame that is still undrawn. This is necessary to |
741 // ensure that the main thread does not monopolize access to the textures. | 743 // ensure that the main thread does not monopolize access to the textures. |
742 DCHECK(isMainThread()); | 744 DCHECK(isMainThread()); |
743 | 745 |
744 if (m_texturesAcquired) | 746 if (m_texturesAcquired) |
745 return; | 747 return; |
746 | 748 |
747 TRACE_EVENT0("cc", "ThreadProxy::acquireLayerTextures"); | 749 TRACE_EVENT0("cc", "ThreadProxy::acquireLayerTextures"); |
748 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 750 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); |
749 CompletionEvent completion; | 751 CompletionEvent completion; |
750 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::acquireLa
yerTexturesForMainThreadOnImplThread, &completion)); | 752 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::acquireLa
yerTexturesForMainThreadOnImplThread, &completion)); |
751 completion.wait(); // Block until it is safe to write to layer textures from
the main thread. | 753 completion.wait(); // Block until it is safe to write to layer textures from
the main thread. |
752 | 754 |
753 m_texturesAcquired = true; | 755 m_texturesAcquired = true; |
754 } | 756 } |
755 | 757 |
756 void ThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*
completion) | 758 void ThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*
completion) |
757 { | 759 { |
758 DCHECK(isImplThread()); | 760 DCHECK(isImplThread()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 public: | 826 public: |
825 static scoped_ptr<ThreadProxyContextRecreationTimer> create(ThreadProxy* pro
xy) { return make_scoped_ptr(new ThreadProxyContextRecreationTimer(proxy)); } | 827 static scoped_ptr<ThreadProxyContextRecreationTimer> create(ThreadProxy* pro
xy) { return make_scoped_ptr(new ThreadProxyContextRecreationTimer(proxy)); } |
826 | 828 |
827 virtual void onTimerFired() OVERRIDE | 829 virtual void onTimerFired() OVERRIDE |
828 { | 830 { |
829 m_proxy->tryToRecreateContext(); | 831 m_proxy->tryToRecreateContext(); |
830 } | 832 } |
831 | 833 |
832 private: | 834 private: |
833 explicit ThreadProxyContextRecreationTimer(ThreadProxy* proxy) | 835 explicit ThreadProxyContextRecreationTimer(ThreadProxy* proxy) |
834 : Timer(Proxy::mainThread(), this) | 836 : Timer(proxy->mainThread(), this) |
835 , m_proxy(proxy) | 837 , m_proxy(proxy) |
836 { | 838 { |
837 } | 839 } |
838 | 840 |
839 ThreadProxy* m_proxy; | 841 ThreadProxy* m_proxy; |
840 }; | 842 }; |
841 | 843 |
842 void ThreadProxy::beginContextRecreation() | 844 void ThreadProxy::beginContextRecreation() |
843 { | 845 { |
844 TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation"); | 846 TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation"); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 950 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
949 : monotonicFrameBeginTime(0) | 951 : monotonicFrameBeginTime(0) |
950 { | 952 { |
951 } | 953 } |
952 | 954 |
953 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 955 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
954 { | 956 { |
955 } | 957 } |
956 | 958 |
957 } // namespace cc | 959 } // namespace cc |
OLD | NEW |