| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 PassOwnPtr<CCLayerTreeHost> CCLayerTreeHost::create(CCLayerTreeHostClient* clien
t, const CCLayerTreeSettings& settings) | 44 PassOwnPtr<CCLayerTreeHost> CCLayerTreeHost::create(CCLayerTreeHostClient* clien
t, const CCLayerTreeSettings& settings) |
| 45 { | 45 { |
| 46 OwnPtr<CCLayerTreeHost> layerTreeHost = adoptPtr(new CCLayerTreeHost(client,
settings)); | 46 OwnPtr<CCLayerTreeHost> layerTreeHost = adoptPtr(new CCLayerTreeHost(client,
settings)); |
| 47 if (!layerTreeHost->initialize()) | 47 if (!layerTreeHost->initialize()) |
| 48 return nullptr; | 48 return nullptr; |
| 49 return layerTreeHost.release(); | 49 return layerTreeHost.release(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCLayerTre
eSettings& settings) | 52 CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCLayerTre
eSettings& settings) |
| 53 : m_compositorIdentifier(-1) | 53 : m_animating(false) |
| 54 , m_animating(false) | |
| 55 , m_needsAnimateLayers(false) | 54 , m_needsAnimateLayers(false) |
| 56 , m_client(client) | 55 , m_client(client) |
| 57 , m_commitNumber(0) | 56 , m_commitNumber(0) |
| 58 , m_renderingStats() | 57 , m_renderingStats() |
| 59 , m_rendererInitialized(false) | 58 , m_rendererInitialized(false) |
| 60 , m_contextLost(false) | 59 , m_contextLost(false) |
| 61 , m_numTimesRecreateShouldFail(0) | 60 , m_numTimesRecreateShouldFail(0) |
| 62 , m_numFailedRecreateAttempts(0) | 61 , m_numFailedRecreateAttempts(0) |
| 63 , m_settings(settings) | 62 , m_settings(settings) |
| 64 , m_deviceScaleFactor(1) | 63 , m_deviceScaleFactor(1) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 78 bool CCLayerTreeHost::initialize() | 77 bool CCLayerTreeHost::initialize() |
| 79 { | 78 { |
| 80 TRACE_EVENT0("cc", "CCLayerTreeHost::initialize"); | 79 TRACE_EVENT0("cc", "CCLayerTreeHost::initialize"); |
| 81 | 80 |
| 82 if (CCProxy::hasImplThread()) | 81 if (CCProxy::hasImplThread()) |
| 83 m_proxy = CCThreadProxy::create(this); | 82 m_proxy = CCThreadProxy::create(this); |
| 84 else | 83 else |
| 85 m_proxy = CCSingleThreadProxy::create(this); | 84 m_proxy = CCSingleThreadProxy::create(this); |
| 86 m_proxy->start(); | 85 m_proxy->start(); |
| 87 | 86 |
| 88 if (!m_proxy->initializeContext()) | 87 return m_proxy->initializeContext(); |
| 89 return false; | |
| 90 | |
| 91 m_compositorIdentifier = m_proxy->compositorIdentifier(); | |
| 92 return true; | |
| 93 } | 88 } |
| 94 | 89 |
| 95 CCLayerTreeHost::~CCLayerTreeHost() | 90 CCLayerTreeHost::~CCLayerTreeHost() |
| 96 { | 91 { |
| 97 if (m_rootLayer) | 92 if (m_rootLayer) |
| 98 m_rootLayer->setLayerTreeHost(0); | 93 m_rootLayer->setLayerTreeHost(0); |
| 99 ASSERT(CCProxy::isMainThread()); | 94 ASSERT(CCProxy::isMainThread()); |
| 100 TRACE_EVENT0("cc", "CCLayerTreeHost::~CCLayerTreeHost"); | 95 TRACE_EVENT0("cc", "CCLayerTreeHost::~CCLayerTreeHost"); |
| 101 ASSERT(m_proxy); | 96 ASSERT(m_proxy); |
| 102 m_proxy->stop(); | 97 m_proxy->stop(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 { | 260 { |
| 266 m_deleteTextureAfterCommitList.clear(); | 261 m_deleteTextureAfterCommitList.clear(); |
| 267 m_client->didCommit(); | 262 m_client->didCommit(); |
| 268 } | 263 } |
| 269 | 264 |
| 270 PassOwnPtr<CCGraphicsContext> CCLayerTreeHost::createContext() | 265 PassOwnPtr<CCGraphicsContext> CCLayerTreeHost::createContext() |
| 271 { | 266 { |
| 272 return m_client->createOutputSurface(); | 267 return m_client->createOutputSurface(); |
| 273 } | 268 } |
| 274 | 269 |
| 270 PassOwnPtr<CCInputHandler> CCLayerTreeHost::createInputHandler() |
| 271 { |
| 272 return m_client->createInputHandler(); |
| 273 } |
| 274 |
| 275 PassOwnPtr<CCLayerTreeHostImpl> CCLayerTreeHost::createLayerTreeHostImpl(CCLayer
TreeHostImplClient* client) | 275 PassOwnPtr<CCLayerTreeHostImpl> CCLayerTreeHost::createLayerTreeHostImpl(CCLayer
TreeHostImplClient* client) |
| 276 { | 276 { |
| 277 return CCLayerTreeHostImpl::create(m_settings, client); | 277 return CCLayerTreeHostImpl::create(m_settings, client); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void CCLayerTreeHost::didLoseContext() | 280 void CCLayerTreeHost::didLoseContext() |
| 281 { | 281 { |
| 282 TRACE_EVENT0("cc", "CCLayerTreeHost::didLoseContext"); | 282 TRACE_EVENT0("cc", "CCLayerTreeHost::didLoseContext"); |
| 283 ASSERT(CCProxy::isMainThread()); | 283 ASSERT(CCProxy::isMainThread()); |
| 284 m_contextLost = true; | 284 m_contextLost = true; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 if (!m_rendererInitialized) | 437 if (!m_rendererInitialized) |
| 438 return false; | 438 return false; |
| 439 } | 439 } |
| 440 if (m_contextLost) { | 440 if (m_contextLost) { |
| 441 if (recreateContext() != RecreateSucceeded) | 441 if (recreateContext() != RecreateSucceeded) |
| 442 return false; | 442 return false; |
| 443 } | 443 } |
| 444 return true; | 444 return true; |
| 445 } | 445 } |
| 446 | 446 |
| 447 | |
| 448 void CCLayerTreeHost::updateLayers(CCTextureUpdateQueue& queue, size_t memoryAll
ocationLimitBytes) | 447 void CCLayerTreeHost::updateLayers(CCTextureUpdateQueue& queue, size_t memoryAll
ocationLimitBytes) |
| 449 { | 448 { |
| 450 ASSERT(m_rendererInitialized); | 449 ASSERT(m_rendererInitialized); |
| 451 ASSERT(memoryAllocationLimitBytes); | 450 ASSERT(memoryAllocationLimitBytes); |
| 452 | 451 |
| 453 if (!rootLayer()) | 452 if (!rootLayer()) |
| 454 return; | 453 return; |
| 455 | 454 |
| 456 if (layoutViewportSize().isEmpty()) | 455 if (layoutViewportSize().isEmpty()) |
| 457 return; | 456 return; |
| 458 | 457 |
| 459 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes)
; | 458 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes)
; |
| 460 | 459 |
| 461 updateLayers(rootLayer(), queue); | 460 updateLayers(rootLayer(), queue); |
| 462 } | 461 } |
| 463 | 462 |
| 463 static void setScale(LayerChromium* layer, float deviceScaleFactor, float pageSc
aleFactor) |
| 464 { |
| 465 if (layer->boundsContainPageScale()) |
| 466 layer->setContentsScale(deviceScaleFactor); |
| 467 else |
| 468 layer->setContentsScale(deviceScaleFactor * pageScaleFactor); |
| 469 } |
| 470 |
| 471 static void updateLayerScale(LayerChromium* layer, float deviceScaleFactor, floa
t pageScaleFactor) |
| 472 { |
| 473 setScale(layer, deviceScaleFactor, pageScaleFactor); |
| 474 |
| 475 LayerChromium* maskLayer = layer->maskLayer(); |
| 476 if (maskLayer) |
| 477 setScale(maskLayer, deviceScaleFactor, pageScaleFactor); |
| 478 |
| 479 LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLaye
r()->maskLayer() : 0; |
| 480 if (replicaMaskLayer) |
| 481 setScale(replicaMaskLayer, deviceScaleFactor, pageScaleFactor); |
| 482 |
| 483 const Vector<RefPtr<LayerChromium> >& children = layer->children(); |
| 484 for (unsigned int i = 0; i < children.size(); ++i) |
| 485 updateLayerScale(children[i].get(), deviceScaleFactor, pageScaleFactor); |
| 486 } |
| 487 |
| 464 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueu
e& queue) | 488 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueu
e& queue) |
| 465 { | 489 { |
| 466 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers"); | 490 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers"); |
| 467 | 491 |
| 492 updateLayerScale(rootLayer, m_deviceScaleFactor, m_pageScaleFactor); |
| 493 |
| 468 LayerList updateList; | 494 LayerList updateList; |
| 469 | 495 |
| 470 { | 496 { |
| 471 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc"); | 497 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc"); |
| 472 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewport
Size(), m_deviceScaleFactor, rendererCapabilities().maxTextureSize, updateList); | 498 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewport
Size(), m_deviceScaleFactor, rendererCapabilities().maxTextureSize, updateList); |
| 473 CCLayerTreeHostCommon::calculateVisibleRects(updateList); | 499 CCLayerTreeHostCommon::calculateVisibleRects(updateList); |
| 474 } | 500 } |
| 475 | 501 |
| 476 // Reset partial texture update requests. | 502 // Reset partial texture update requests. |
| 477 m_partialTextureUpdateRequests = 0; | 503 m_partialTextureUpdateRequests = 0; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 else | 772 else |
| 747 layer->notifyAnimationFinished(wallClockTime); | 773 layer->notifyAnimationFinished(wallClockTime); |
| 748 } | 774 } |
| 749 } | 775 } |
| 750 | 776 |
| 751 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 777 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
| 752 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 778 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
| 753 } | 779 } |
| 754 | 780 |
| 755 } // namespace WebCore | 781 } // namespace WebCore |
| OLD | NEW |