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 "CCThreadProxy.h" | 7 #include "CCThreadProxy.h" |
8 | 8 |
9 #include "CCDelayBasedTimeSource.h" | 9 #include "CCDelayBasedTimeSource.h" |
10 #include "CCDrawQuad.h" | 10 #include "CCDrawQuad.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 , m_mainThreadProxy(CCScopedThreadProxy::create(CCProxy::mainThread())) | 49 , m_mainThreadProxy(CCScopedThreadProxy::create(CCProxy::mainThread())) |
50 , m_beginFrameCompletionEventOnImplThread(0) | 50 , m_beginFrameCompletionEventOnImplThread(0) |
51 , m_readbackRequestOnImplThread(0) | 51 , m_readbackRequestOnImplThread(0) |
52 , m_commitCompletionEventOnImplThread(0) | 52 , m_commitCompletionEventOnImplThread(0) |
53 , m_textureAcquisitionCompletionEventOnImplThread(0) | 53 , m_textureAcquisitionCompletionEventOnImplThread(0) |
54 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) | 54 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) |
55 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) | 55 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) |
56 , m_totalCommitCount(0) | 56 , m_totalCommitCount(0) |
57 { | 57 { |
58 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy"); | 58 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy"); |
59 ASSERT(isMainThread()); | 59 CC_DCHECK(isMainThread()); |
60 } | 60 } |
61 | 61 |
62 CCThreadProxy::~CCThreadProxy() | 62 CCThreadProxy::~CCThreadProxy() |
63 { | 63 { |
64 TRACE_EVENT0("cc", "CCThreadProxy::~CCThreadProxy"); | 64 TRACE_EVENT0("cc", "CCThreadProxy::~CCThreadProxy"); |
65 ASSERT(isMainThread()); | 65 CC_DCHECK(isMainThread()); |
66 ASSERT(!m_started); | 66 CC_DCHECK(!m_started); |
67 } | 67 } |
68 | 68 |
69 bool CCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) | 69 bool CCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) |
70 { | 70 { |
71 TRACE_EVENT0("cc", "CCThreadPRoxy::compositeAndReadback"); | 71 TRACE_EVENT0("cc", "CCThreadPRoxy::compositeAndReadback"); |
72 ASSERT(isMainThread()); | 72 CC_DCHECK(isMainThread()); |
73 ASSERT(m_layerTreeHost); | 73 CC_DCHECK(m_layerTreeHost); |
74 | 74 |
75 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 75 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
76 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); | 76 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 // Perform a synchronous commit. | 81 // Perform a synchronous commit. |
82 { | 82 { |
83 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 83 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
(...skipping 12 matching lines...) Expand all Loading... |
96 { | 96 { |
97 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 97 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
98 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:requestReadbackOnImplThread, &request)); | 98 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:requestReadbackOnImplThread, &request)); |
99 request.completion.wait(); | 99 request.completion.wait(); |
100 } | 100 } |
101 return request.success; | 101 return request.success; |
102 } | 102 } |
103 | 103 |
104 void CCThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) | 104 void CCThreadProxy::requestReadbackOnImplThread(ReadbackRequest* request) |
105 { | 105 { |
106 ASSERT(CCProxy::isImplThread()); | 106 CC_DCHECK(CCProxy::isImplThread()); |
107 ASSERT(!m_readbackRequestOnImplThread); | 107 CC_DCHECK(!m_readbackRequestOnImplThread); |
108 if (!m_layerTreeHostImpl.get()) { | 108 if (!m_layerTreeHostImpl.get()) { |
109 request->success = false; | 109 request->success = false; |
110 request->completion.signal(); | 110 request->completion.signal(); |
111 return; | 111 return; |
112 } | 112 } |
113 | 113 |
114 m_readbackRequestOnImplThread = request; | 114 m_readbackRequestOnImplThread = request; |
115 m_schedulerOnImplThread->setNeedsRedraw(); | 115 m_schedulerOnImplThread->setNeedsRedraw(); |
116 m_schedulerOnImplThread->setNeedsForcedRedraw(); | 116 m_schedulerOnImplThread->setNeedsForcedRedraw(); |
117 } | 117 } |
118 | 118 |
119 void CCThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool
useAnchor, float scale, double duration) | 119 void CCThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, bool
useAnchor, float scale, double duration) |
120 { | 120 { |
121 ASSERT(CCProxy::isMainThread()); | 121 CC_DCHECK(CCProxy::isMainThread()); |
122 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::req
uestStartPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, durat
ion)); | 122 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::req
uestStartPageScaleAnimationOnImplThread, targetPosition, useAnchor, scale, durat
ion)); |
123 } | 123 } |
124 | 124 |
125 void CCThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPos
ition, bool useAnchor, float scale, double duration) | 125 void CCThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPos
ition, bool useAnchor, float scale, double duration) |
126 { | 126 { |
127 ASSERT(CCProxy::isImplThread()); | 127 CC_DCHECK(CCProxy::isImplThread()); |
128 if (m_layerTreeHostImpl.get()) | 128 if (m_layerTreeHostImpl.get()) |
129 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, monotonicallyIncreasingTime(), duration); | 129 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, monotonicallyIncreasingTime(), duration); |
130 } | 130 } |
131 | 131 |
132 void CCThreadProxy::finishAllRendering() | 132 void CCThreadProxy::finishAllRendering() |
133 { | 133 { |
134 ASSERT(CCProxy::isMainThread()); | 134 CC_DCHECK(CCProxy::isMainThread()); |
135 | 135 |
136 // Make sure all GL drawing is finished on the impl thread. | 136 // Make sure all GL drawing is finished on the impl thread. |
137 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 137 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
138 CCCompletionEvent completion; | 138 CCCompletionEvent completion; |
139 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::fin
ishAllRenderingOnImplThread, &completion)); | 139 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::fin
ishAllRenderingOnImplThread, &completion)); |
140 completion.wait(); | 140 completion.wait(); |
141 } | 141 } |
142 | 142 |
143 bool CCThreadProxy::isStarted() const | 143 bool CCThreadProxy::isStarted() const |
144 { | 144 { |
145 ASSERT(CCProxy::isMainThread()); | 145 CC_DCHECK(CCProxy::isMainThread()); |
146 return m_started; | 146 return m_started; |
147 } | 147 } |
148 | 148 |
149 bool CCThreadProxy::initializeContext() | 149 bool CCThreadProxy::initializeContext() |
150 { | 150 { |
151 TRACE_EVENT0("cc", "CCThreadProxy::initializeContext"); | 151 TRACE_EVENT0("cc", "CCThreadProxy::initializeContext"); |
152 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); | 152 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); |
153 if (!context.get()) | 153 if (!context.get()) |
154 return false; | 154 return false; |
155 | 155 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (initializeSucceeded) { | 205 if (initializeSucceeded) { |
206 m_rendererInitialized = true; | 206 m_rendererInitialized = true; |
207 m_RendererCapabilitiesMainThreadCopy = capabilities; | 207 m_RendererCapabilitiesMainThreadCopy = capabilities; |
208 } | 208 } |
209 return initializeSucceeded; | 209 return initializeSucceeded; |
210 } | 210 } |
211 | 211 |
212 bool CCThreadProxy::recreateContext() | 212 bool CCThreadProxy::recreateContext() |
213 { | 213 { |
214 TRACE_EVENT0("cc", "CCThreadProxy::recreateContext"); | 214 TRACE_EVENT0("cc", "CCThreadProxy::recreateContext"); |
215 ASSERT(isMainThread()); | 215 CC_DCHECK(isMainThread()); |
216 | 216 |
217 // Try to create the context. | 217 // Try to create the context. |
218 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); | 218 scoped_ptr<CCGraphicsContext> context = m_layerTreeHost->createContext(); |
219 if (!context.get()) | 219 if (!context.get()) |
220 return false; | 220 return false; |
221 if (m_layerTreeHost->needsSharedContext()) | 221 if (m_layerTreeHost->needsSharedContext()) |
222 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) | 222 if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) |
223 return false; | 223 return false; |
224 | 224 |
225 // Make a blocking call to recreateContextOnImplThread. The results of that | 225 // Make a blocking call to recreateContextOnImplThread. The results of that |
(...skipping 10 matching lines...) Expand all Loading... |
236 &capabilities)); | 236 &capabilities)); |
237 completion.wait(); | 237 completion.wait(); |
238 | 238 |
239 if (recreateSucceeded) | 239 if (recreateSucceeded) |
240 m_RendererCapabilitiesMainThreadCopy = capabilities; | 240 m_RendererCapabilitiesMainThreadCopy = capabilities; |
241 return recreateSucceeded; | 241 return recreateSucceeded; |
242 } | 242 } |
243 | 243 |
244 void CCThreadProxy::renderingStats(CCRenderingStats* stats) | 244 void CCThreadProxy::renderingStats(CCRenderingStats* stats) |
245 { | 245 { |
246 ASSERT(isMainThread()); | 246 CC_DCHECK(isMainThread()); |
247 | 247 |
248 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 248 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
249 CCCompletionEvent completion; | 249 CCCompletionEvent completion; |
250 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ren
deringStatsOnImplThread, | 250 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ren
deringStatsOnImplThread, |
251 &completion, | 251 &completion, |
252 stats)); | 252 stats)); |
253 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); | 253 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); |
254 stats->totalCommitCount = m_totalCommitCount; | 254 stats->totalCommitCount = m_totalCommitCount; |
255 | 255 |
256 completion.wait(); | 256 completion.wait(); |
257 } | 257 } |
258 | 258 |
259 const RendererCapabilities& CCThreadProxy::rendererCapabilities() const | 259 const RendererCapabilities& CCThreadProxy::rendererCapabilities() const |
260 { | 260 { |
261 ASSERT(m_rendererInitialized); | 261 CC_DCHECK(m_rendererInitialized); |
262 return m_RendererCapabilitiesMainThreadCopy; | 262 return m_RendererCapabilitiesMainThreadCopy; |
263 } | 263 } |
264 | 264 |
265 void CCThreadProxy::loseContext() | 265 void CCThreadProxy::loseContext() |
266 { | 266 { |
267 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::did
LoseContextOnImplThread)); | 267 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::did
LoseContextOnImplThread)); |
268 } | 268 } |
269 | 269 |
270 void CCThreadProxy::setNeedsAnimate() | 270 void CCThreadProxy::setNeedsAnimate() |
271 { | 271 { |
272 ASSERT(isMainThread()); | 272 CC_DCHECK(isMainThread()); |
273 if (m_animateRequested) | 273 if (m_animateRequested) |
274 return; | 274 return; |
275 | 275 |
276 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsAnimate"); | 276 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsAnimate"); |
277 m_animateRequested = true; | 277 m_animateRequested = true; |
278 | 278 |
279 if (m_commitRequestSentToImplThread) | 279 if (m_commitRequestSentToImplThread) |
280 return; | 280 return; |
281 m_commitRequestSentToImplThread = true; | 281 m_commitRequestSentToImplThread = true; |
282 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsCommitOnImplThread)); | 282 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsCommitOnImplThread)); |
283 } | 283 } |
284 | 284 |
285 void CCThreadProxy::setNeedsCommit() | 285 void CCThreadProxy::setNeedsCommit() |
286 { | 286 { |
287 ASSERT(isMainThread()); | 287 CC_DCHECK(isMainThread()); |
288 if (m_commitRequested) | 288 if (m_commitRequested) |
289 return; | 289 return; |
290 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommit"); | 290 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommit"); |
291 m_commitRequested = true; | 291 m_commitRequested = true; |
292 | 292 |
293 if (m_commitRequestSentToImplThread) | 293 if (m_commitRequestSentToImplThread) |
294 return; | 294 return; |
295 m_commitRequestSentToImplThread = true; | 295 m_commitRequestSentToImplThread = true; |
296 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsCommitOnImplThread)); | 296 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsCommitOnImplThread)); |
297 } | 297 } |
298 | 298 |
299 void CCThreadProxy::didLoseContextOnImplThread() | 299 void CCThreadProxy::didLoseContextOnImplThread() |
300 { | 300 { |
301 ASSERT(isImplThread()); | 301 CC_DCHECK(isImplThread()); |
302 TRACE_EVENT0("cc", "CCThreadProxy::didLoseContextOnImplThread"); | 302 TRACE_EVENT0("cc", "CCThreadProxy::didLoseContextOnImplThread"); |
303 m_schedulerOnImplThread->didLoseContext(); | 303 m_schedulerOnImplThread->didLoseContext(); |
304 } | 304 } |
305 | 305 |
306 void CCThreadProxy::onSwapBuffersCompleteOnImplThread() | 306 void CCThreadProxy::onSwapBuffersCompleteOnImplThread() |
307 { | 307 { |
308 ASSERT(isImplThread()); | 308 CC_DCHECK(isImplThread()); |
309 TRACE_EVENT0("cc", "CCThreadProxy::onSwapBuffersCompleteOnImplThread"); | 309 TRACE_EVENT0("cc", "CCThreadProxy::onSwapBuffersCompleteOnImplThread"); |
310 m_schedulerOnImplThread->didSwapBuffersComplete(); | 310 m_schedulerOnImplThread->didSwapBuffersComplete(); |
311 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::didComp
leteSwapBuffers)); | 311 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::didComp
leteSwapBuffers)); |
312 } | 312 } |
313 | 313 |
314 void CCThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double in
tervalInSeconds) | 314 void CCThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double in
tervalInSeconds) |
315 { | 315 { |
316 ASSERT(isImplThread()); | 316 CC_DCHECK(isImplThread()); |
317 TRACE_EVENT2("cc", "CCThreadProxy::onVSyncParametersChanged", "monotonicTime
base", monotonicTimebase, "intervalInSeconds", intervalInSeconds); | 317 TRACE_EVENT2("cc", "CCThreadProxy::onVSyncParametersChanged", "monotonicTime
base", monotonicTimebase, "intervalInSeconds", intervalInSeconds); |
318 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb
ase * base::Time::kMicrosecondsPerSecond); | 318 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb
ase * base::Time::kMicrosecondsPerSecond); |
319 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon
ds * base::Time::kMicrosecondsPerSecond); | 319 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon
ds * base::Time::kMicrosecondsPerSecond); |
320 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); | 320 m_schedulerOnImplThread->setTimebaseAndInterval(timebase, interval); |
321 } | 321 } |
322 | 322 |
323 void CCThreadProxy::onCanDrawStateChanged(bool canDraw) | 323 void CCThreadProxy::onCanDrawStateChanged(bool canDraw) |
324 { | 324 { |
325 ASSERT(isImplThread()); | 325 CC_DCHECK(isImplThread()); |
326 TRACE_EVENT1("cc", "CCThreadProxy::onCanDrawStateChanged", "canDraw", canDra
w); | 326 TRACE_EVENT1("cc", "CCThreadProxy::onCanDrawStateChanged", "canDraw", canDra
w); |
327 m_schedulerOnImplThread->setCanDraw(canDraw); | 327 m_schedulerOnImplThread->setCanDraw(canDraw); |
328 } | 328 } |
329 | 329 |
330 void CCThreadProxy::setNeedsCommitOnImplThread() | 330 void CCThreadProxy::setNeedsCommitOnImplThread() |
331 { | 331 { |
332 ASSERT(isImplThread()); | 332 CC_DCHECK(isImplThread()); |
333 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommitOnImplThread"); | 333 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommitOnImplThread"); |
334 m_schedulerOnImplThread->setNeedsCommit(); | 334 m_schedulerOnImplThread->setNeedsCommit(); |
335 } | 335 } |
336 | 336 |
337 void CCThreadProxy::setNeedsForcedCommitOnImplThread() | 337 void CCThreadProxy::setNeedsForcedCommitOnImplThread() |
338 { | 338 { |
339 ASSERT(isImplThread()); | 339 CC_DCHECK(isImplThread()); |
340 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsForcedCommitOnImplThread"); | 340 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsForcedCommitOnImplThread"); |
341 m_schedulerOnImplThread->setNeedsCommit(); | 341 m_schedulerOnImplThread->setNeedsCommit(); |
342 m_schedulerOnImplThread->setNeedsForcedCommit(); | 342 m_schedulerOnImplThread->setNeedsForcedCommit(); |
343 } | 343 } |
344 | 344 |
345 void CCThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAni
mationEventsVector> events, double wallClockTime) | 345 void CCThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAni
mationEventsVector> events, double wallClockTime) |
346 { | 346 { |
347 ASSERT(isImplThread()); | 347 CC_DCHECK(isImplThread()); |
348 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre
ad"); | 348 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre
ad"); |
349 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim
ationEvents, events.release(), wallClockTime)); | 349 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim
ationEvents, events.release(), wallClockTime)); |
350 } | 350 } |
351 | 351 |
352 void CCThreadProxy::releaseContentsTexturesOnImplThread() | 352 void CCThreadProxy::releaseContentsTexturesOnImplThread() |
353 { | 353 { |
354 ASSERT(isImplThread()); | 354 CC_DCHECK(isImplThread()); |
355 | 355 |
356 if (m_layerTreeHost->contentsTextureManager()) | 356 if (m_layerTreeHost->contentsTextureManager()) |
357 m_layerTreeHost->contentsTextureManager()->reduceMemoryOnImplThread(0, m
_layerTreeHostImpl->resourceProvider()); | 357 m_layerTreeHost->contentsTextureManager()->reduceMemoryOnImplThread(0, m
_layerTreeHostImpl->resourceProvider()); |
358 | 358 |
359 // The texture upload queue may reference textures that were just purged, cl
ear | 359 // The texture upload queue may reference textures that were just purged, cl
ear |
360 // them from the queue. | 360 // them from the queue. |
361 if (m_currentTextureUpdateControllerOnImplThread.get()) | 361 if (m_currentTextureUpdateControllerOnImplThread.get()) |
362 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes
ources(); | 362 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes
ources(); |
363 } | 363 } |
364 | 364 |
365 void CCThreadProxy::setNeedsRedraw() | 365 void CCThreadProxy::setNeedsRedraw() |
366 { | 366 { |
367 ASSERT(isMainThread()); | 367 CC_DCHECK(isMainThread()); |
368 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw"); | 368 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw"); |
369 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
FullRootLayerDamageOnImplThread)); | 369 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
FullRootLayerDamageOnImplThread)); |
370 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsRedrawOnImplThread)); | 370 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsRedrawOnImplThread)); |
371 } | 371 } |
372 | 372 |
373 bool CCThreadProxy::commitRequested() const | 373 bool CCThreadProxy::commitRequested() const |
374 { | 374 { |
375 ASSERT(isMainThread()); | 375 CC_DCHECK(isMainThread()); |
376 return m_commitRequested; | 376 return m_commitRequested; |
377 } | 377 } |
378 | 378 |
379 void CCThreadProxy::setNeedsRedrawOnImplThread() | 379 void CCThreadProxy::setNeedsRedrawOnImplThread() |
380 { | 380 { |
381 ASSERT(isImplThread()); | 381 CC_DCHECK(isImplThread()); |
382 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedrawOnImplThread"); | 382 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedrawOnImplThread"); |
383 m_schedulerOnImplThread->setNeedsRedraw(); | 383 m_schedulerOnImplThread->setNeedsRedraw(); |
384 } | 384 } |
385 | 385 |
386 void CCThreadProxy::start() | 386 void CCThreadProxy::start() |
387 { | 387 { |
388 ASSERT(isMainThread()); | 388 CC_DCHECK(isMainThread()); |
389 ASSERT(CCProxy::implThread()); | 389 CC_DCHECK(CCProxy::implThread()); |
390 // Create LayerTreeHostImpl. | 390 // Create LayerTreeHostImpl. |
391 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 391 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
392 CCCompletionEvent completion; | 392 CCCompletionEvent completion; |
393 scoped_ptr<CCInputHandler> handler = m_layerTreeHost->createInputHandler(); | 393 scoped_ptr<CCInputHandler> handler = m_layerTreeHost->createInputHandler(); |
394 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ini
tializeImplOnImplThread, &completion, handler.release())); | 394 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ini
tializeImplOnImplThread, &completion, handler.release())); |
395 completion.wait(); | 395 completion.wait(); |
396 | 396 |
397 m_started = true; | 397 m_started = true; |
398 } | 398 } |
399 | 399 |
400 void CCThreadProxy::stop() | 400 void CCThreadProxy::stop() |
401 { | 401 { |
402 TRACE_EVENT0("cc", "CCThreadProxy::stop"); | 402 TRACE_EVENT0("cc", "CCThreadProxy::stop"); |
403 ASSERT(isMainThread()); | 403 CC_DCHECK(isMainThread()); |
404 ASSERT(m_started); | 404 CC_DCHECK(m_started); |
405 | 405 |
406 // Synchronously deletes the impl. | 406 // Synchronously deletes the impl. |
407 { | 407 { |
408 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 408 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
409 | 409 |
410 CCCompletionEvent completion; | 410 CCCompletionEvent completion; |
411 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:layerTreeHostClosedOnImplThread, &completion)); | 411 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:layerTreeHostClosedOnImplThread, &completion)); |
412 completion.wait(); | 412 completion.wait(); |
413 } | 413 } |
414 | 414 |
415 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. | 415 m_mainThreadProxy->shutdown(); // Stop running tasks posted to us. |
416 | 416 |
417 ASSERT(!m_layerTreeHostImpl.get()); // verify that the impl deleted. | 417 CC_DCHECK(!m_layerTreeHostImpl.get()); // verify that the impl deleted. |
418 m_layerTreeHost = 0; | 418 m_layerTreeHost = 0; |
419 m_started = false; | 419 m_started = false; |
420 } | 420 } |
421 | 421 |
422 void CCThreadProxy::forceSerializeOnSwapBuffers() | 422 void CCThreadProxy::forceSerializeOnSwapBuffers() |
423 { | 423 { |
424 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 424 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
425 CCCompletionEvent completion; | 425 CCCompletionEvent completion; |
426 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::for
ceSerializeOnSwapBuffersOnImplThread, &completion)); | 426 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::for
ceSerializeOnSwapBuffersOnImplThread, &completion)); |
427 completion.wait(); | 427 completion.wait(); |
428 } | 428 } |
429 | 429 |
430 void CCThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent* c
ompletion) | 430 void CCThreadProxy::forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent* c
ompletion) |
431 { | 431 { |
432 if (m_rendererInitialized) | 432 if (m_rendererInitialized) |
433 m_layerTreeHostImpl->renderer()->doNoOp(); | 433 m_layerTreeHostImpl->renderer()->doNoOp(); |
434 completion->signal(); | 434 completion->signal(); |
435 } | 435 } |
436 | 436 |
437 | 437 |
438 void CCThreadProxy::finishAllRenderingOnImplThread(CCCompletionEvent* completion
) | 438 void CCThreadProxy::finishAllRenderingOnImplThread(CCCompletionEvent* completion
) |
439 { | 439 { |
440 TRACE_EVENT0("cc", "CCThreadProxy::finishAllRenderingOnImplThread"); | 440 TRACE_EVENT0("cc", "CCThreadProxy::finishAllRenderingOnImplThread"); |
441 ASSERT(isImplThread()); | 441 CC_DCHECK(isImplThread()); |
442 m_layerTreeHostImpl->finishAllRendering(); | 442 m_layerTreeHostImpl->finishAllRendering(); |
443 completion->signal(); | 443 completion->signal(); |
444 } | 444 } |
445 | 445 |
446 void CCThreadProxy::forceBeginFrameOnImplThread(CCCompletionEvent* completion) | 446 void CCThreadProxy::forceBeginFrameOnImplThread(CCCompletionEvent* completion) |
447 { | 447 { |
448 TRACE_EVENT0("cc", "CCThreadProxy::forceBeginFrameOnImplThread"); | 448 TRACE_EVENT0("cc", "CCThreadProxy::forceBeginFrameOnImplThread"); |
449 ASSERT(!m_beginFrameCompletionEventOnImplThread); | 449 CC_DCHECK(!m_beginFrameCompletionEventOnImplThread); |
450 | 450 |
451 if (m_schedulerOnImplThread->commitPending()) { | 451 if (m_schedulerOnImplThread->commitPending()) { |
452 completion->signal(); | 452 completion->signal(); |
453 return; | 453 return; |
454 } | 454 } |
455 | 455 |
456 m_beginFrameCompletionEventOnImplThread = completion; | 456 m_beginFrameCompletionEventOnImplThread = completion; |
457 setNeedsForcedCommitOnImplThread(); | 457 setNeedsForcedCommitOnImplThread(); |
458 } | 458 } |
459 | 459 |
460 void CCThreadProxy::scheduledActionBeginFrame() | 460 void CCThreadProxy::scheduledActionBeginFrame() |
461 { | 461 { |
462 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); | 462 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); |
463 ASSERT(!m_pendingBeginFrameRequest); | 463 CC_DCHECK(!m_pendingBeginFrameRequest); |
464 m_pendingBeginFrameRequest = make_scoped_ptr(new BeginFrameAndCommitState())
; | 464 m_pendingBeginFrameRequest = make_scoped_ptr(new BeginFrameAndCommitState())
; |
465 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin
gTime(); | 465 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin
gTime(); |
466 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); | 466 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); |
467 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo
rm(); | 467 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo
rm(); |
468 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); | 468 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); |
469 if (m_layerTreeHost->contentsTextureManager()) | 469 if (m_layerTreeHost->contentsTextureManager()) |
470 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending
BeginFrameRequest->evictedContentsTexturesBackings); | 470 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending
BeginFrameRequest->evictedContentsTexturesBackings); |
471 | 471 |
472 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr
ame)); | 472 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr
ame)); |
473 | 473 |
474 if (m_beginFrameCompletionEventOnImplThread) { | 474 if (m_beginFrameCompletionEventOnImplThread) { |
475 m_beginFrameCompletionEventOnImplThread->signal(); | 475 m_beginFrameCompletionEventOnImplThread->signal(); |
476 m_beginFrameCompletionEventOnImplThread = 0; | 476 m_beginFrameCompletionEventOnImplThread = 0; |
477 } | 477 } |
478 } | 478 } |
479 | 479 |
480 void CCThreadProxy::beginFrame() | 480 void CCThreadProxy::beginFrame() |
481 { | 481 { |
482 TRACE_EVENT0("cc", "CCThreadProxy::beginFrame"); | 482 TRACE_EVENT0("cc", "CCThreadProxy::beginFrame"); |
483 ASSERT(isMainThread()); | 483 CC_DCHECK(isMainThread()); |
484 if (!m_layerTreeHost) | 484 if (!m_layerTreeHost) |
485 return; | 485 return; |
486 | 486 |
487 if (!m_pendingBeginFrameRequest) { | 487 if (!m_pendingBeginFrameRequest) { |
488 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); | 488 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); |
489 return; | 489 return; |
490 } | 490 } |
491 | 491 |
492 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) | 492 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) |
493 WebSharedGraphicsContext3D::createCompositorThreadContext(); | 493 WebSharedGraphicsContext3D::createCompositorThreadContext(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 | 581 |
582 m_layerTreeHost->commitComplete(); | 582 m_layerTreeHost->commitComplete(); |
583 m_layerTreeHost->didBeginFrame(); | 583 m_layerTreeHost->didBeginFrame(); |
584 } | 584 } |
585 | 585 |
586 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion
, CCTextureUpdateQueue* rawQueue) | 586 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion
, CCTextureUpdateQueue* rawQueue) |
587 { | 587 { |
588 scoped_ptr<CCTextureUpdateQueue> queue(rawQueue); | 588 scoped_ptr<CCTextureUpdateQueue> queue(rawQueue); |
589 | 589 |
590 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); | 590 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); |
591 ASSERT(!m_commitCompletionEventOnImplThread); | 591 CC_DCHECK(!m_commitCompletionEventOnImplThread); |
592 ASSERT(isImplThread() && isMainThreadBlocked()); | 592 CC_DCHECK(isImplThread() && isMainThreadBlocked()); |
593 ASSERT(m_schedulerOnImplThread); | 593 CC_DCHECK(m_schedulerOnImplThread); |
594 ASSERT(m_schedulerOnImplThread->commitPending()); | 594 CC_DCHECK(m_schedulerOnImplThread->commitPending()); |
595 | 595 |
596 if (!m_layerTreeHostImpl.get()) { | 596 if (!m_layerTreeHostImpl.get()) { |
597 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); | 597 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); |
598 completion->signal(); | 598 completion->signal(); |
599 return; | 599 return; |
600 } | 600 } |
601 | 601 |
602 if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist())
{ | 602 if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist())
{ |
603 // Clear any uploads we were making to textures linked to evicted | 603 // Clear any uploads we were making to textures linked to evicted |
604 // resources | 604 // resources |
605 queue->clearUploadsToEvictedResources(); | 605 queue->clearUploadsToEvictedResources(); |
606 // Some textures in the layer tree are invalid. Kick off another commit | 606 // Some textures in the layer tree are invalid. Kick off another commit |
607 // to fill them again. | 607 // to fill them again. |
608 setNeedsCommitOnImplThread(); | 608 setNeedsCommitOnImplThread(); |
609 } | 609 } |
610 | 610 |
611 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; | 611 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; |
612 | 612 |
613 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr
eate(this, CCProxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourcePro
vider(), m_layerTreeHostImpl->resourceProvider()->textureUploader()); | 613 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr
eate(this, CCProxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourcePro
vider(), m_layerTreeHostImpl->resourceProvider()->textureUploader()); |
614 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( | 614 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( |
615 m_schedulerOnImplThread->anticipatedDrawTime()); | 615 m_schedulerOnImplThread->anticipatedDrawTime()); |
616 | 616 |
617 m_commitCompletionEventOnImplThread = completion; | 617 m_commitCompletionEventOnImplThread = completion; |
618 } | 618 } |
619 | 619 |
620 void CCThreadProxy::beginFrameAbortedOnImplThread() | 620 void CCThreadProxy::beginFrameAbortedOnImplThread() |
621 { | 621 { |
622 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); | 622 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); |
623 ASSERT(isImplThread()); | 623 CC_DCHECK(isImplThread()); |
624 ASSERT(m_schedulerOnImplThread); | 624 CC_DCHECK(m_schedulerOnImplThread); |
625 ASSERT(m_schedulerOnImplThread->commitPending()); | 625 CC_DCHECK(m_schedulerOnImplThread->commitPending()); |
626 | 626 |
627 m_schedulerOnImplThread->beginFrameAborted(); | 627 m_schedulerOnImplThread->beginFrameAborted(); |
628 } | 628 } |
629 | 629 |
630 void CCThreadProxy::scheduledActionCommit() | 630 void CCThreadProxy::scheduledActionCommit() |
631 { | 631 { |
632 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit"); | 632 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit"); |
633 ASSERT(isImplThread()); | 633 CC_DCHECK(isImplThread()); |
634 ASSERT(m_commitCompletionEventOnImplThread); | 634 CC_DCHECK(m_commitCompletionEventOnImplThread); |
635 ASSERT(m_currentTextureUpdateControllerOnImplThread); | 635 CC_DCHECK(m_currentTextureUpdateControllerOnImplThread); |
636 | 636 |
637 // Complete all remaining texture updates. | 637 // Complete all remaining texture updates. |
638 m_currentTextureUpdateControllerOnImplThread->finalize(); | 638 m_currentTextureUpdateControllerOnImplThread->finalize(); |
639 m_currentTextureUpdateControllerOnImplThread.reset(); | 639 m_currentTextureUpdateControllerOnImplThread.reset(); |
640 | 640 |
641 // If there are linked evicted backings, these backings' resources may be pu
t into the | 641 // If there are linked evicted backings, these backings' resources may be pu
t into the |
642 // impl tree, so we can't draw yet. Determine this before clearing all evict
ed backings. | 642 // impl tree, so we can't draw yet. Determine this before clearing all evict
ed backings. |
643 bool newImplTreeHasNoEvictedResources = !m_layerTreeHost->contentsTextureMan
ager()->linkedEvictedBackingsExist(); | 643 bool newImplTreeHasNoEvictedResources = !m_layerTreeHost->contentsTextureMan
ager()->linkedEvictedBackingsExist(); |
644 | 644 |
645 m_layerTreeHostImpl->beginCommit(); | 645 m_layerTreeHostImpl->beginCommit(); |
(...skipping 11 matching lines...) Expand all Loading... |
657 | 657 |
658 m_commitCompletionEventOnImplThread->signal(); | 658 m_commitCompletionEventOnImplThread->signal(); |
659 m_commitCompletionEventOnImplThread = 0; | 659 m_commitCompletionEventOnImplThread = 0; |
660 | 660 |
661 // SetVisible kicks off the next scheduler action, so this must be last. | 661 // SetVisible kicks off the next scheduler action, so this must be last. |
662 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); | 662 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); |
663 } | 663 } |
664 | 664 |
665 void CCThreadProxy::scheduledActionBeginContextRecreation() | 665 void CCThreadProxy::scheduledActionBeginContextRecreation() |
666 { | 666 { |
667 ASSERT(isImplThread()); | 667 CC_DCHECK(isImplThread()); |
668 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginCo
ntextRecreation)); | 668 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginCo
ntextRecreation)); |
669 } | 669 } |
670 | 670 |
671 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapInte
rnal(bool forcedDraw) | 671 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapInte
rnal(bool forcedDraw) |
672 { | 672 { |
673 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionDrawAndSwap"); | 673 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionDrawAndSwap"); |
674 CCScheduledActionDrawAndSwapResult result; | 674 CCScheduledActionDrawAndSwapResult result; |
675 result.didDraw = false; | 675 result.didDraw = false; |
676 result.didSwap = false; | 676 result.didSwap = false; |
677 ASSERT(isImplThread()); | 677 CC_DCHECK(isImplThread()); |
678 ASSERT(m_layerTreeHostImpl.get()); | 678 CC_DCHECK(m_layerTreeHostImpl.get()); |
679 if (!m_layerTreeHostImpl.get()) | 679 if (!m_layerTreeHostImpl.get()) |
680 return result; | 680 return result; |
681 | 681 |
682 ASSERT(m_layerTreeHostImpl->renderer()); | 682 CC_DCHECK(m_layerTreeHostImpl->renderer()); |
683 if (!m_layerTreeHostImpl->renderer()) | 683 if (!m_layerTreeHostImpl->renderer()) |
684 return result; | 684 return result; |
685 | 685 |
686 // FIXME: compute the frame display time more intelligently | 686 // FIXME: compute the frame display time more intelligently |
687 double monotonicTime = monotonicallyIncreasingTime(); | 687 double monotonicTime = monotonicallyIncreasingTime(); |
688 double wallClockTime = currentTime(); | 688 double wallClockTime = currentTime(); |
689 | 689 |
690 if (m_inputHandlerOnImplThread.get()) | 690 if (m_inputHandlerOnImplThread.get()) |
691 m_inputHandlerOnImplThread->animate(monotonicTime); | 691 m_inputHandlerOnImplThread->animate(monotonicTime); |
692 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); | 692 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 return result; | 729 return result; |
730 } | 730 } |
731 | 731 |
732 void CCThreadProxy::acquireLayerTextures() | 732 void CCThreadProxy::acquireLayerTextures() |
733 { | 733 { |
734 // Called when the main thread needs to modify a layer texture that is used | 734 // Called when the main thread needs to modify a layer texture that is used |
735 // directly by the compositor. | 735 // directly by the compositor. |
736 // This method will block until the next compositor draw if there is a | 736 // This method will block until the next compositor draw if there is a |
737 // previously committed frame that is still undrawn. This is necessary to | 737 // previously committed frame that is still undrawn. This is necessary to |
738 // ensure that the main thread does not monopolize access to the textures. | 738 // ensure that the main thread does not monopolize access to the textures. |
739 ASSERT(isMainThread()); | 739 CC_DCHECK(isMainThread()); |
740 | 740 |
741 if (m_texturesAcquired) | 741 if (m_texturesAcquired) |
742 return; | 742 return; |
743 | 743 |
744 TRACE_EVENT0("cc", "CCThreadProxy::acquireLayerTextures"); | 744 TRACE_EVENT0("cc", "CCThreadProxy::acquireLayerTextures"); |
745 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 745 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
746 CCCompletionEvent completion; | 746 CCCompletionEvent completion; |
747 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::acq
uireLayerTexturesForMainThreadOnImplThread, &completion)); | 747 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::acq
uireLayerTexturesForMainThreadOnImplThread, &completion)); |
748 completion.wait(); // Block until it is safe to write to layer textures from
the main thread. | 748 completion.wait(); // Block until it is safe to write to layer textures from
the main thread. |
749 | 749 |
750 m_texturesAcquired = true; | 750 m_texturesAcquired = true; |
751 } | 751 } |
752 | 752 |
753 void CCThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CCCompletionEv
ent* completion) | 753 void CCThreadProxy::acquireLayerTexturesForMainThreadOnImplThread(CCCompletionEv
ent* completion) |
754 { | 754 { |
755 ASSERT(isImplThread()); | 755 CC_DCHECK(isImplThread()); |
756 ASSERT(!m_textureAcquisitionCompletionEventOnImplThread); | 756 CC_DCHECK(!m_textureAcquisitionCompletionEventOnImplThread); |
757 | 757 |
758 m_textureAcquisitionCompletionEventOnImplThread = completion; | 758 m_textureAcquisitionCompletionEventOnImplThread = completion; |
759 m_schedulerOnImplThread->setMainThreadNeedsLayerTextures(); | 759 m_schedulerOnImplThread->setMainThreadNeedsLayerTextures(); |
760 } | 760 } |
761 | 761 |
762 void CCThreadProxy::scheduledActionAcquireLayerTexturesForMainThread() | 762 void CCThreadProxy::scheduledActionAcquireLayerTexturesForMainThread() |
763 { | 763 { |
764 ASSERT(m_textureAcquisitionCompletionEventOnImplThread); | 764 CC_DCHECK(m_textureAcquisitionCompletionEventOnImplThread); |
765 m_textureAcquisitionCompletionEventOnImplThread->signal(); | 765 m_textureAcquisitionCompletionEventOnImplThread->signal(); |
766 m_textureAcquisitionCompletionEventOnImplThread = 0; | 766 m_textureAcquisitionCompletionEventOnImplThread = 0; |
767 } | 767 } |
768 | 768 |
769 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapIfPo
ssible() | 769 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapIfPo
ssible() |
770 { | 770 { |
771 return scheduledActionDrawAndSwapInternal(false); | 771 return scheduledActionDrawAndSwapInternal(false); |
772 } | 772 } |
773 | 773 |
774 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapForc
ed() | 774 CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapForc
ed() |
775 { | 775 { |
776 return scheduledActionDrawAndSwapInternal(true); | 776 return scheduledActionDrawAndSwapInternal(true); |
777 } | 777 } |
778 | 778 |
779 void CCThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) | 779 void CCThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) |
780 { | 780 { |
781 if (!m_currentTextureUpdateControllerOnImplThread) | 781 if (!m_currentTextureUpdateControllerOnImplThread) |
782 return; | 782 return; |
783 | 783 |
784 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates(time); | 784 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates(time); |
785 } | 785 } |
786 | 786 |
787 void CCThreadProxy::readyToFinalizeTextureUpdates() | 787 void CCThreadProxy::readyToFinalizeTextureUpdates() |
788 { | 788 { |
789 ASSERT(isImplThread()); | 789 CC_DCHECK(isImplThread()); |
790 m_schedulerOnImplThread->beginFrameComplete(); | 790 m_schedulerOnImplThread->beginFrameComplete(); |
791 } | 791 } |
792 | 792 |
793 void CCThreadProxy::didCommitAndDrawFrame() | 793 void CCThreadProxy::didCommitAndDrawFrame() |
794 { | 794 { |
795 ASSERT(isMainThread()); | 795 CC_DCHECK(isMainThread()); |
796 if (!m_layerTreeHost) | 796 if (!m_layerTreeHost) |
797 return; | 797 return; |
798 m_layerTreeHost->didCommitAndDrawFrame(); | 798 m_layerTreeHost->didCommitAndDrawFrame(); |
799 } | 799 } |
800 | 800 |
801 void CCThreadProxy::didCompleteSwapBuffers() | 801 void CCThreadProxy::didCompleteSwapBuffers() |
802 { | 802 { |
803 ASSERT(isMainThread()); | 803 CC_DCHECK(isMainThread()); |
804 if (!m_layerTreeHost) | 804 if (!m_layerTreeHost) |
805 return; | 805 return; |
806 m_layerTreeHost->didCompleteSwapBuffers(); | 806 m_layerTreeHost->didCompleteSwapBuffers(); |
807 } | 807 } |
808 | 808 |
809 void CCThreadProxy::setAnimationEvents(CCAnimationEventsVector* passed_events, d
ouble wallClockTime) | 809 void CCThreadProxy::setAnimationEvents(CCAnimationEventsVector* passed_events, d
ouble wallClockTime) |
810 { | 810 { |
811 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(passed_events)); | 811 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(passed_events)); |
812 | 812 |
813 TRACE_EVENT0("cc", "CCThreadProxy::setAnimationEvents"); | 813 TRACE_EVENT0("cc", "CCThreadProxy::setAnimationEvents"); |
814 ASSERT(isMainThread()); | 814 CC_DCHECK(isMainThread()); |
815 if (!m_layerTreeHost) | 815 if (!m_layerTreeHost) |
816 return; | 816 return; |
817 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); | 817 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); |
818 } | 818 } |
819 | 819 |
820 class CCThreadProxyContextRecreationTimer : public CCTimer, CCTimerClient { | 820 class CCThreadProxyContextRecreationTimer : public CCTimer, CCTimerClient { |
821 public: | 821 public: |
822 static scoped_ptr<CCThreadProxyContextRecreationTimer> create(CCThreadProxy*
proxy) { return make_scoped_ptr(new CCThreadProxyContextRecreationTimer(proxy))
; } | 822 static scoped_ptr<CCThreadProxyContextRecreationTimer> create(CCThreadProxy*
proxy) { return make_scoped_ptr(new CCThreadProxyContextRecreationTimer(proxy))
; } |
823 | 823 |
824 virtual void onTimerFired() OVERRIDE | 824 virtual void onTimerFired() OVERRIDE |
825 { | 825 { |
826 m_proxy->tryToRecreateContext(); | 826 m_proxy->tryToRecreateContext(); |
827 } | 827 } |
828 | 828 |
829 private: | 829 private: |
830 explicit CCThreadProxyContextRecreationTimer(CCThreadProxy* proxy) | 830 explicit CCThreadProxyContextRecreationTimer(CCThreadProxy* proxy) |
831 : CCTimer(CCProxy::mainThread(), this) | 831 : CCTimer(CCProxy::mainThread(), this) |
832 , m_proxy(proxy) | 832 , m_proxy(proxy) |
833 { | 833 { |
834 } | 834 } |
835 | 835 |
836 CCThreadProxy* m_proxy; | 836 CCThreadProxy* m_proxy; |
837 }; | 837 }; |
838 | 838 |
839 void CCThreadProxy::beginContextRecreation() | 839 void CCThreadProxy::beginContextRecreation() |
840 { | 840 { |
841 TRACE_EVENT0("cc", "CCThreadProxy::beginContextRecreation"); | 841 TRACE_EVENT0("cc", "CCThreadProxy::beginContextRecreation"); |
842 ASSERT(isMainThread()); | 842 CC_DCHECK(isMainThread()); |
843 ASSERT(!m_contextRecreationTimer); | 843 CC_DCHECK(!m_contextRecreationTimer); |
844 m_contextRecreationTimer = CCThreadProxyContextRecreationTimer::create(this)
; | 844 m_contextRecreationTimer = CCThreadProxyContextRecreationTimer::create(this)
; |
845 m_layerTreeHost->didLoseContext(); | 845 m_layerTreeHost->didLoseContext(); |
846 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); | 846 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); |
847 } | 847 } |
848 | 848 |
849 void CCThreadProxy::tryToRecreateContext() | 849 void CCThreadProxy::tryToRecreateContext() |
850 { | 850 { |
851 ASSERT(isMainThread()); | 851 CC_DCHECK(isMainThread()); |
852 ASSERT(m_layerTreeHost); | 852 CC_DCHECK(m_layerTreeHost); |
853 CCLayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); | 853 CCLayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); |
854 if (result == CCLayerTreeHost::RecreateFailedButTryAgain) | 854 if (result == CCLayerTreeHost::RecreateFailedButTryAgain) |
855 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); | 855 m_contextRecreationTimer->startOneShot(contextRecreationTickRate); |
856 else if (result == CCLayerTreeHost::RecreateSucceeded) | 856 else if (result == CCLayerTreeHost::RecreateSucceeded) |
857 m_contextRecreationTimer.reset(); | 857 m_contextRecreationTimer.reset(); |
858 } | 858 } |
859 | 859 |
860 void CCThreadProxy::initializeImplOnImplThread(CCCompletionEvent* completion, CC
InputHandler* handler) | 860 void CCThreadProxy::initializeImplOnImplThread(CCCompletionEvent* completion, CC
InputHandler* handler) |
861 { | 861 { |
862 TRACE_EVENT0("cc", "CCThreadProxy::initializeImplOnImplThread"); | 862 TRACE_EVENT0("cc", "CCThreadProxy::initializeImplOnImplThread"); |
863 ASSERT(isImplThread()); | 863 CC_DCHECK(isImplThread()); |
864 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); | 864 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); |
865 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec
onds(base::Time::kMicrosecondsPerSecond / 60); | 865 const base::TimeDelta displayRefreshInterval = base::TimeDelta::FromMicrosec
onds(base::Time::kMicrosecondsPerSecond / 60); |
866 scoped_ptr<CCFrameRateController> frameRateController; | 866 scoped_ptr<CCFrameRateController> frameRateController; |
867 if (m_renderVSyncEnabled) | 867 if (m_renderVSyncEnabled) |
868 frameRateController.reset(new CCFrameRateController(CCDelayBasedTimeSour
ce::create(displayRefreshInterval, CCProxy::implThread()))); | 868 frameRateController.reset(new CCFrameRateController(CCDelayBasedTimeSour
ce::create(displayRefreshInterval, CCProxy::implThread()))); |
869 else | 869 else |
870 frameRateController.reset(new CCFrameRateController(CCProxy::implThread(
))); | 870 frameRateController.reset(new CCFrameRateController(CCProxy::implThread(
))); |
871 m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.Pass
()); | 871 m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.Pass
()); |
872 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); | 872 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); |
873 | 873 |
874 m_inputHandlerOnImplThread = scoped_ptr<CCInputHandler>(handler); | 874 m_inputHandlerOnImplThread = scoped_ptr<CCInputHandler>(handler); |
875 if (m_inputHandlerOnImplThread.get()) | 875 if (m_inputHandlerOnImplThread.get()) |
876 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); | 876 m_inputHandlerOnImplThread->bindToClient(m_layerTreeHostImpl.get()); |
877 | 877 |
878 completion->signal(); | 878 completion->signal(); |
879 } | 879 } |
880 | 880 |
881 void CCThreadProxy::initializeContextOnImplThread(CCGraphicsContext* context) | 881 void CCThreadProxy::initializeContextOnImplThread(CCGraphicsContext* context) |
882 { | 882 { |
883 TRACE_EVENT0("cc", "CCThreadProxy::initializeContextOnImplThread"); | 883 TRACE_EVENT0("cc", "CCThreadProxy::initializeContextOnImplThread"); |
884 ASSERT(isImplThread()); | 884 CC_DCHECK(isImplThread()); |
885 m_contextBeforeInitializationOnImplThread = scoped_ptr<CCGraphicsContext>(co
ntext).Pass(); | 885 m_contextBeforeInitializationOnImplThread = scoped_ptr<CCGraphicsContext>(co
ntext).Pass(); |
886 } | 886 } |
887 | 887 |
888 void CCThreadProxy::initializeRendererOnImplThread(CCCompletionEvent* completion
, bool* initializeSucceeded, RendererCapabilities* capabilities) | 888 void CCThreadProxy::initializeRendererOnImplThread(CCCompletionEvent* completion
, bool* initializeSucceeded, RendererCapabilities* capabilities) |
889 { | 889 { |
890 TRACE_EVENT0("cc", "CCThreadProxy::initializeRendererOnImplThread"); | 890 TRACE_EVENT0("cc", "CCThreadProxy::initializeRendererOnImplThread"); |
891 ASSERT(isImplThread()); | 891 CC_DCHECK(isImplThread()); |
892 ASSERT(m_contextBeforeInitializationOnImplThread.get()); | 892 CC_DCHECK(m_contextBeforeInitializationOnImplThread.get()); |
893 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBefo
reInitializationOnImplThread.Pass()); | 893 *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBefo
reInitializationOnImplThread.Pass()); |
894 if (*initializeSucceeded) { | 894 if (*initializeSucceeded) { |
895 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); | 895 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); |
896 m_schedulerOnImplThread->setSwapBuffersCompleteSupported( | 896 m_schedulerOnImplThread->setSwapBuffersCompleteSupported( |
897 capabilities->usingSwapCompleteCallback); | 897 capabilities->usingSwapCompleteCallback); |
898 } | 898 } |
899 | 899 |
900 completion->signal(); | 900 completion->signal(); |
901 } | 901 } |
902 | 902 |
903 void CCThreadProxy::layerTreeHostClosedOnImplThread(CCCompletionEvent* completio
n) | 903 void CCThreadProxy::layerTreeHostClosedOnImplThread(CCCompletionEvent* completio
n) |
904 { | 904 { |
905 TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread"); | 905 TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread"); |
906 ASSERT(isImplThread()); | 906 CC_DCHECK(isImplThread()); |
907 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 907 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
908 m_inputHandlerOnImplThread.reset(); | 908 m_inputHandlerOnImplThread.reset(); |
909 m_layerTreeHostImpl.reset(); | 909 m_layerTreeHostImpl.reset(); |
910 m_schedulerOnImplThread.reset(); | 910 m_schedulerOnImplThread.reset(); |
911 completion->signal(); | 911 completion->signal(); |
912 } | 912 } |
913 | 913 |
914 void CCThreadProxy::setFullRootLayerDamageOnImplThread() | 914 void CCThreadProxy::setFullRootLayerDamageOnImplThread() |
915 { | 915 { |
916 ASSERT(isImplThread()); | 916 CC_DCHECK(isImplThread()); |
917 m_layerTreeHostImpl->setFullRootLayerDamage(); | 917 m_layerTreeHostImpl->setFullRootLayerDamage(); |
918 } | 918 } |
919 | 919 |
920 size_t CCThreadProxy::maxPartialTextureUpdates() const | 920 size_t CCThreadProxy::maxPartialTextureUpdates() const |
921 { | 921 { |
922 return CCTextureUpdateController::maxPartialTextureUpdates(); | 922 return CCTextureUpdateController::maxPartialTextureUpdates(); |
923 } | 923 } |
924 | 924 |
925 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C
CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap
abilities) | 925 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C
CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap
abilities) |
926 { | 926 { |
927 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); | 927 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); |
928 ASSERT(isImplThread()); | 928 CC_DCHECK(isImplThread()); |
929 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 929 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
930 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(scoped_ptr<CCGr
aphicsContext>(contextPtr).Pass()); | 930 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(scoped_ptr<CCGr
aphicsContext>(contextPtr).Pass()); |
931 if (*recreateSucceeded) { | 931 if (*recreateSucceeded) { |
932 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); | 932 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); |
933 m_schedulerOnImplThread->didRecreateContext(); | 933 m_schedulerOnImplThread->didRecreateContext(); |
934 } | 934 } |
935 completion->signal(); | 935 completion->signal(); |
936 } | 936 } |
937 | 937 |
938 void CCThreadProxy::renderingStatsOnImplThread(CCCompletionEvent* completion, CC
RenderingStats* stats) | 938 void CCThreadProxy::renderingStatsOnImplThread(CCCompletionEvent* completion, CC
RenderingStats* stats) |
939 { | 939 { |
940 ASSERT(isImplThread()); | 940 CC_DCHECK(isImplThread()); |
941 m_layerTreeHostImpl->renderingStats(stats); | 941 m_layerTreeHostImpl->renderingStats(stats); |
942 completion->signal(); | 942 completion->signal(); |
943 } | 943 } |
944 | 944 |
945 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 945 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
946 : monotonicFrameBeginTime(0) | 946 : monotonicFrameBeginTime(0) |
947 { | 947 { |
948 } | 948 } |
949 | 949 |
950 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 950 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
951 { | 951 { |
952 } | 952 } |
953 | 953 |
954 } // namespace cc | 954 } // namespace cc |
OLD | NEW |