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