| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void CCLayerTreeHost::layout() | 192 void CCLayerTreeHost::layout() |
| 193 { | 193 { |
| 194 m_client->layout(); | 194 m_client->layout(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void CCLayerTreeHost::beginCommitOnImplThread(CCLayerTreeHostImpl* hostImpl) | 197 void CCLayerTreeHost::beginCommitOnImplThread(CCLayerTreeHostImpl* hostImpl) |
| 198 { | 198 { |
| 199 ASSERT(CCProxy::isImplThread()); | 199 ASSERT(CCProxy::isImplThread()); |
| 200 TRACE_EVENT("CCLayerTreeHost::commitTo", this, 0); | 200 TRACE_EVENT("CCLayerTreeHost::commitTo", this, 0); |
| 201 | 201 |
| 202 m_contentsTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBy
tes(viewportSize())); | 202 m_contentsTextureManager->reduceMemoryToLimit(m_contentsTextureManager->pref
erredMemoryLimitBytes()); |
| 203 m_contentsTextureManager->deleteEvictedTextures(hostImpl->contentsTextureAll
ocator()); | 203 m_contentsTextureManager->deleteEvictedTextures(hostImpl->contentsTextureAll
ocator()); |
| 204 } | 204 } |
| 205 | 205 |
| 206 // This function commits the CCLayerTreeHost to an impl tree. When modifying | 206 // This function commits the CCLayerTreeHost to an impl tree. When modifying |
| 207 // this function, keep in mind that the function *runs* on the impl thread! Any | 207 // this function, keep in mind that the function *runs* on the impl thread! Any |
| 208 // code that is logically a main thread operation, e.g. deletion of a LayerChrom
ium, | 208 // code that is logically a main thread operation, e.g. deletion of a LayerChrom
ium, |
| 209 // should be delayed until the CCLayerTreeHost::commitComplete, which will run | 209 // should be delayed until the CCLayerTreeHost::commitComplete, which will run |
| 210 // after the commit, but on the main thread. | 210 // after the commit, but on the main thread. |
| 211 void CCLayerTreeHost::finishCommitOnImplThread(CCLayerTreeHostImpl* hostImpl) | 211 void CCLayerTreeHost::finishCommitOnImplThread(CCLayerTreeHostImpl* hostImpl) |
| 212 { | 212 { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 360 } |
| 361 | 361 |
| 362 void CCLayerTreeHost::setVisible(bool visible) | 362 void CCLayerTreeHost::setVisible(bool visible) |
| 363 { | 363 { |
| 364 if (m_visible == visible) | 364 if (m_visible == visible) |
| 365 return; | 365 return; |
| 366 | 366 |
| 367 m_visible = visible; | 367 m_visible = visible; |
| 368 | 368 |
| 369 if (!visible && m_layerRendererInitialized) { | 369 if (!visible && m_layerRendererInitialized) { |
| 370 m_contentsTextureManager->reduceMemoryToLimit(TextureManager::lowLimitBy
tes(viewportSize())); | 370 // Drop all unprotected textures. |
| 371 m_contentsTextureManager->reduceMemoryToLimit(0); |
| 371 m_contentsTextureManager->unprotectAllTextures(); | 372 m_contentsTextureManager->unprotectAllTextures(); |
| 372 } | 373 } |
| 373 | 374 |
| 374 // Tells the proxy that visibility state has changed. This will in turn call | 375 // Tells the proxy that visibility state has changed. This will in turn call |
| 375 // CCLayerTreeHost::didBecomeInvisibleOnImplThread on the appropriate thread
, for | 376 // CCLayerTreeHost::didBecomeInvisibleOnImplThread on the appropriate thread
, for |
| 376 // the case where !visible. | 377 // the case where !visible. |
| 377 m_proxy->setVisible(visible); | 378 m_proxy->setVisible(visible); |
| 378 } | 379 } |
| 379 | 380 |
| 380 void CCLayerTreeHost::didBecomeInvisibleOnImplThread(CCLayerTreeHostImpl* hostIm
pl) | 381 void CCLayerTreeHost::didBecomeInvisibleOnImplThread(CCLayerTreeHostImpl* hostIm
pl) |
| 381 { | 382 { |
| 382 ASSERT(CCProxy::isImplThread()); | 383 ASSERT(CCProxy::isImplThread()); |
| 383 if (!m_layerRendererInitialized) | 384 if (!m_layerRendererInitialized) |
| 384 return; | 385 return; |
| 385 | 386 |
| 386 if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer) | 387 if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer) |
| 387 contentsTextureManager()->evictAndDeleteAllTextures(hostImpl->contentsTe
xtureAllocator()); | 388 contentsTextureManager()->evictAndDeleteAllTextures(hostImpl->contentsTe
xtureAllocator()); |
| 388 else { | 389 else { |
| 389 contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLim
itBytes(viewportSize())); | 390 contentsTextureManager()->reduceMemoryToLimit(m_contentsTextureManager->
preferredMemoryLimitBytes()); |
| 390 contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextur
eAllocator()); | 391 contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextur
eAllocator()); |
| 391 } | 392 } |
| 392 | 393 |
| 393 // Ensure that the dropped tiles are propagated to the impl tree. | 394 // Ensure that the dropped tiles are propagated to the impl tree. |
| 394 // If the frontbuffer is cached, then clobber the impl tree. Otherwise, | 395 // If the frontbuffer is cached, then clobber the impl tree. Otherwise, |
| 395 // push over the tree changes. | 396 // push over the tree changes. |
| 396 if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer) { | 397 if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer) { |
| 397 hostImpl->setRootLayer(nullptr); | 398 hostImpl->setRootLayer(nullptr); |
| 398 return; | 399 return; |
| 399 } | 400 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 482 |
| 482 // Reset partial texture update requests. | 483 // Reset partial texture update requests. |
| 483 m_partialTextureUpdateRequests = 0; | 484 m_partialTextureUpdateRequests = 0; |
| 484 | 485 |
| 485 reserveTextures(); | 486 reserveTextures(); |
| 486 | 487 |
| 487 paintLayerContents(m_updateList, PaintVisible); | 488 paintLayerContents(m_updateList, PaintVisible); |
| 488 if (!m_triggerIdlePaints) | 489 if (!m_triggerIdlePaints) |
| 489 return; | 490 return; |
| 490 | 491 |
| 491 size_t preferredLimitBytes = TextureManager::reclaimLimitBytes(m_viewportSiz
e); | 492 size_t preferredLimitBytes = m_contentsTextureManager->preferredMemoryLimitB
ytes(); |
| 492 size_t maxLimitBytes = TextureManager::highLimitBytes(m_viewportSize); | 493 size_t maxLimitBytes = m_contentsTextureManager->maxMemoryLimitBytes(); |
| 493 m_contentsTextureManager->reduceMemoryToLimit(preferredLimitBytes); | 494 m_contentsTextureManager->reduceMemoryToLimit(preferredLimitBytes); |
| 494 if (m_contentsTextureManager->currentMemoryUseBytes() >= preferredLimitBytes
) | 495 if (m_contentsTextureManager->currentMemoryUseBytes() >= preferredLimitBytes
) |
| 495 return; | 496 return; |
| 496 | 497 |
| 497 // Idle painting should fail when we hit the preferred memory limit, | 498 // Idle painting should fail when we hit the preferred memory limit, |
| 498 // otherwise it will always push us towards the maximum limit. | 499 // otherwise it will always push us towards the maximum limit. |
| 499 m_contentsTextureManager->setMaxMemoryLimitBytes(preferredLimitBytes); | 500 m_contentsTextureManager->setMaxMemoryLimitBytes(preferredLimitBytes); |
| 500 // The second (idle) paint will be a no-op in layers where painting already
occured above. | 501 // The second (idle) paint will be a no-op in layers where painting already
occured above. |
| 501 paintLayerContents(m_updateList, PaintIdle); | 502 paintLayerContents(m_updateList, PaintIdle); |
| 502 m_contentsTextureManager->setMaxMemoryLimitBytes(maxLimitBytes); | 503 m_contentsTextureManager->setMaxMemoryLimitBytes(maxLimitBytes); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { | 693 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { |
| 693 if (layer->id() == events[eventIndex].layerId) | 694 if (layer->id() == events[eventIndex].layerId) |
| 694 layer->notifyAnimationStarted(events[eventIndex], wallClockTime); | 695 layer->notifyAnimationStarted(events[eventIndex], wallClockTime); |
| 695 } | 696 } |
| 696 | 697 |
| 697 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 698 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
| 698 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 699 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
| 699 } | 700 } |
| 700 | 701 |
| 701 } // namespace WebCore | 702 } // namespace WebCore |
| OLD | NEW |