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 "CCLayerTreeHost.h" | 7 #include "CCLayerTreeHost.h" |
8 | 8 |
9 #include "CCFontAtlas.h" | 9 #include "CCFontAtlas.h" |
10 #include "CCGraphicsContext.h" | 10 #include "CCGraphicsContext.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 , m_numFailedRecreateAttempts(0) | 61 , m_numFailedRecreateAttempts(0) |
62 , m_settings(settings) | 62 , m_settings(settings) |
63 , m_deviceScaleFactor(1) | 63 , m_deviceScaleFactor(1) |
64 , m_visible(true) | 64 , m_visible(true) |
65 , m_pageScaleFactor(1) | 65 , m_pageScaleFactor(1) |
66 , m_minPageScaleFactor(1) | 66 , m_minPageScaleFactor(1) |
67 , m_maxPageScaleFactor(1) | 67 , m_maxPageScaleFactor(1) |
68 , m_triggerIdleUpdates(true) | 68 , m_triggerIdleUpdates(true) |
69 , m_backgroundColor(SK_ColorWHITE) | 69 , m_backgroundColor(SK_ColorWHITE) |
70 , m_hasTransparentBackground(false) | 70 , m_hasTransparentBackground(false) |
| 71 , m_maxPartialTextureUpdates(0) |
71 , m_partialTextureUpdateRequests(0) | 72 , m_partialTextureUpdateRequests(0) |
72 { | 73 { |
73 ASSERT(CCProxy::isMainThread()); | 74 ASSERT(CCProxy::isMainThread()); |
74 numLayerTreeInstances++; | 75 numLayerTreeInstances++; |
75 } | 76 } |
76 | 77 |
77 bool CCLayerTreeHost::initialize() | 78 bool CCLayerTreeHost::initialize() |
78 { | 79 { |
79 TRACE_EVENT0("cc", "CCLayerTreeHost::initialize"); | 80 TRACE_EVENT0("cc", "CCLayerTreeHost::initialize"); |
80 | 81 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 TRACE_EVENT0("cc", "CCLayerTreeHost::initializeRenderer"); | 113 TRACE_EVENT0("cc", "CCLayerTreeHost::initializeRenderer"); |
113 if (!m_proxy->initializeRenderer()) { | 114 if (!m_proxy->initializeRenderer()) { |
114 // Uh oh, better tell the client that we can't do anything with this con
text. | 115 // Uh oh, better tell the client that we can't do anything with this con
text. |
115 m_client->didRecreateOutputSurface(false); | 116 m_client->didRecreateOutputSurface(false); |
116 return; | 117 return; |
117 } | 118 } |
118 | 119 |
119 // Update m_settings based on capabilities that we got back from the rendere
r. | 120 // Update m_settings based on capabilities that we got back from the rendere
r. |
120 m_settings.acceleratePainting = m_proxy->rendererCapabilities().usingAcceler
atedPainting; | 121 m_settings.acceleratePainting = m_proxy->rendererCapabilities().usingAcceler
atedPainting; |
121 | 122 |
122 // Update m_settings based on partial update capability. | |
123 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdate
s, m_proxy->maxPartialTextureUpdates()); | |
124 | |
125 m_contentsTextureManager = CCPrioritizedTextureManager::create(0, m_proxy->r
endererCapabilities().maxTextureSize, CCRenderer::ContentPool); | 123 m_contentsTextureManager = CCPrioritizedTextureManager::create(0, m_proxy->r
endererCapabilities().maxTextureSize, CCRenderer::ContentPool); |
126 m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(IntSize
(), GraphicsContext3D::RGBA); | 124 m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(IntSize
(), GraphicsContext3D::RGBA); |
127 | 125 |
128 m_rendererInitialized = true; | 126 m_rendererInitialized = true; |
129 | 127 |
130 m_settings.defaultTileSize = IntSize(min(m_settings.defaultTileSize.width(),
m_proxy->rendererCapabilities().maxTextureSize), | 128 m_settings.defaultTileSize = IntSize(min(m_settings.defaultTileSize.width(),
m_proxy->rendererCapabilities().maxTextureSize), |
131 min(m_settings.defaultTileSize.height()
, m_proxy->rendererCapabilities().maxTextureSize)); | 129 min(m_settings.defaultTileSize.height()
, m_proxy->rendererCapabilities().maxTextureSize)); |
132 m_settings.maxUntiledLayerSize = IntSize(min(m_settings.maxUntiledLayerSize.
width(), m_proxy->rendererCapabilities().maxTextureSize), | 130 m_settings.maxUntiledLayerSize = IntSize(min(m_settings.maxUntiledLayerSize.
width(), m_proxy->rendererCapabilities().maxTextureSize), |
133 min(m_settings.maxUntiledLayerSize.
height(), m_proxy->rendererCapabilities().maxTextureSize)); | 131 min(m_settings.maxUntiledLayerSize.
height(), m_proxy->rendererCapabilities().maxTextureSize)); |
134 } | 132 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 if (!m_rendererInitialized) | 442 if (!m_rendererInitialized) |
445 return false; | 443 return false; |
446 } | 444 } |
447 if (m_contextLost) { | 445 if (m_contextLost) { |
448 if (recreateContext() != RecreateSucceeded) | 446 if (recreateContext() != RecreateSucceeded) |
449 return false; | 447 return false; |
450 } | 448 } |
451 return true; | 449 return true; |
452 } | 450 } |
453 | 451 |
454 void CCLayerTreeHost::updateLayers(CCTextureUpdateQueue& queue, size_t memoryAll
ocationLimitBytes) | 452 void CCLayerTreeHost::updateLayers(CCTextureUpdateQueue& queue, size_t memoryAll
ocationLimitBytes, size_t maxTextureUpdates) |
455 { | 453 { |
456 ASSERT(m_rendererInitialized); | 454 ASSERT(m_rendererInitialized); |
457 ASSERT(memoryAllocationLimitBytes); | 455 ASSERT(memoryAllocationLimitBytes); |
458 | 456 |
459 if (!rootLayer()) | 457 if (!rootLayer()) |
460 return; | 458 return; |
461 | 459 |
462 if (layoutViewportSize().isEmpty()) | 460 if (layoutViewportSize().isEmpty()) |
463 return; | 461 return; |
464 | 462 |
465 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes)
; | 463 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes)
; |
466 | 464 |
467 updateLayers(rootLayer(), queue); | 465 updateLayers(rootLayer(), queue, maxTextureUpdates); |
468 } | 466 } |
469 | 467 |
470 static void setScale(LayerChromium* layer, float deviceScaleFactor, float pageSc
aleFactor) | 468 static void setScale(LayerChromium* layer, float deviceScaleFactor, float pageSc
aleFactor) |
471 { | 469 { |
472 if (layer->boundsContainPageScale()) | 470 if (layer->boundsContainPageScale()) |
473 layer->setContentsScale(deviceScaleFactor); | 471 layer->setContentsScale(deviceScaleFactor); |
474 else | 472 else |
475 layer->setContentsScale(deviceScaleFactor * pageScaleFactor); | 473 layer->setContentsScale(deviceScaleFactor * pageScaleFactor); |
476 } | 474 } |
477 | 475 |
478 static void updateLayerScale(LayerChromium* layer, float deviceScaleFactor, floa
t pageScaleFactor) | 476 static void updateLayerScale(LayerChromium* layer, float deviceScaleFactor, floa
t pageScaleFactor) |
479 { | 477 { |
480 setScale(layer, deviceScaleFactor, pageScaleFactor); | 478 setScale(layer, deviceScaleFactor, pageScaleFactor); |
481 | 479 |
482 LayerChromium* maskLayer = layer->maskLayer(); | 480 LayerChromium* maskLayer = layer->maskLayer(); |
483 if (maskLayer) | 481 if (maskLayer) |
484 setScale(maskLayer, deviceScaleFactor, pageScaleFactor); | 482 setScale(maskLayer, deviceScaleFactor, pageScaleFactor); |
485 | 483 |
486 LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLaye
r()->maskLayer() : 0; | 484 LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLaye
r()->maskLayer() : 0; |
487 if (replicaMaskLayer) | 485 if (replicaMaskLayer) |
488 setScale(replicaMaskLayer, deviceScaleFactor, pageScaleFactor); | 486 setScale(replicaMaskLayer, deviceScaleFactor, pageScaleFactor); |
489 | 487 |
490 const Vector<RefPtr<LayerChromium> >& children = layer->children(); | 488 const Vector<RefPtr<LayerChromium> >& children = layer->children(); |
491 for (unsigned int i = 0; i < children.size(); ++i) | 489 for (unsigned int i = 0; i < children.size(); ++i) |
492 updateLayerScale(children[i].get(), deviceScaleFactor, pageScaleFactor); | 490 updateLayerScale(children[i].get(), deviceScaleFactor, pageScaleFactor); |
493 } | 491 } |
494 | 492 |
495 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueu
e& queue) | 493 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueu
e& queue, size_t maxTextureUpdates) |
496 { | 494 { |
497 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers"); | 495 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers"); |
498 | 496 |
499 updateLayerScale(rootLayer, m_deviceScaleFactor, m_pageScaleFactor); | 497 updateLayerScale(rootLayer, m_deviceScaleFactor, m_pageScaleFactor); |
500 | 498 |
501 LayerList updateList; | 499 LayerList updateList; |
502 | 500 |
503 { | 501 { |
504 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc"); | 502 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc"); |
505 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewport
Size(), m_deviceScaleFactor, rendererCapabilities().maxTextureSize, updateList); | 503 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewport
Size(), m_deviceScaleFactor, rendererCapabilities().maxTextureSize, updateList); |
506 CCLayerTreeHostCommon::calculateVisibleRects(updateList); | 504 CCLayerTreeHostCommon::calculateVisibleRects(updateList); |
507 } | 505 } |
508 | 506 |
509 // Reset partial texture update requests. | 507 // Reset partial texture update requests. |
510 m_partialTextureUpdateRequests = 0; | 508 m_partialTextureUpdateRequests = 0; |
| 509 m_maxPartialTextureUpdates = std::min(m_settings.maxPartialTextureUpdates, m
axTextureUpdates); |
511 | 510 |
512 bool needMoreUpdates = paintLayerContents(updateList, queue); | 511 bool needMoreUpdates = paintLayerContents(updateList, queue); |
513 if (m_triggerIdleUpdates && needMoreUpdates) | 512 if (m_triggerIdleUpdates && needMoreUpdates) |
514 setNeedsCommit(); | 513 setNeedsCommit(); |
515 | 514 |
516 for (size_t i = 0; i < updateList.size(); ++i) | 515 for (size_t i = 0; i < updateList.size(); ++i) |
517 updateList[i]->clearRenderSurface(); | 516 updateList[i]->clearRenderSurface(); |
518 } | 517 } |
519 | 518 |
520 void CCLayerTreeHost::setPrioritiesForSurfaces(size_t surfaceMemoryBytes) | 519 void CCLayerTreeHost::setPrioritiesForSurfaces(size_t surfaceMemoryBytes) |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 m_proxy->forceSerializeOnSwapBuffers(); | 708 m_proxy->forceSerializeOnSwapBuffers(); |
710 } | 709 } |
711 | 710 |
712 bool CCLayerTreeHost::bufferedUpdates() | 711 bool CCLayerTreeHost::bufferedUpdates() |
713 { | 712 { |
714 return m_settings.maxPartialTextureUpdates != numeric_limits<size_t>::max(); | 713 return m_settings.maxPartialTextureUpdates != numeric_limits<size_t>::max(); |
715 } | 714 } |
716 | 715 |
717 bool CCLayerTreeHost::requestPartialTextureUpdate() | 716 bool CCLayerTreeHost::requestPartialTextureUpdate() |
718 { | 717 { |
719 if (m_partialTextureUpdateRequests >= m_settings.maxPartialTextureUpdates) | 718 if (m_partialTextureUpdateRequests >= m_maxPartialTextureUpdates) |
720 return false; | 719 return false; |
721 | 720 |
722 m_partialTextureUpdateRequests++; | 721 m_partialTextureUpdateRequests++; |
723 return true; | 722 return true; |
724 } | 723 } |
725 | 724 |
726 void CCLayerTreeHost::deleteTextureAfterCommit(PassOwnPtr<CCPrioritizedTexture>
texture) | 725 void CCLayerTreeHost::deleteTextureAfterCommit(PassOwnPtr<CCPrioritizedTexture>
texture) |
727 { | 726 { |
728 m_deleteTextureAfterCommitList.append(texture); | 727 m_deleteTextureAfterCommitList.append(texture); |
729 } | 728 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 else | 778 else |
780 layer->notifyAnimationFinished(wallClockTime); | 779 layer->notifyAnimationFinished(wallClockTime); |
781 } | 780 } |
782 } | 781 } |
783 | 782 |
784 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 783 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
785 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 784 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
786 } | 785 } |
787 | 786 |
788 } // namespace WebCore | 787 } // namespace WebCore |
OLD | NEW |