| 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 "cc/layer_tree_host.h" | 7 #include "cc/layer_tree_host.h" |
| 8 | 8 |
| 9 #include "Region.h" | 9 #include "Region.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 , showPlatformLayerTree(false) | 43 , showPlatformLayerTree(false) |
| 44 , showPaintRects(false) | 44 , showPaintRects(false) |
| 45 , showPropertyChangedRects(false) | 45 , showPropertyChangedRects(false) |
| 46 , showSurfaceDamageRects(false) | 46 , showSurfaceDamageRects(false) |
| 47 , showScreenSpaceRects(false) | 47 , showScreenSpaceRects(false) |
| 48 , showReplicaScreenSpaceRects(false) | 48 , showReplicaScreenSpaceRects(false) |
| 49 , showOccludingRects(false) | 49 , showOccludingRects(false) |
| 50 , renderVSyncEnabled(true) | 50 , renderVSyncEnabled(true) |
| 51 , refreshRate(0) | 51 , refreshRate(0) |
| 52 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) | 52 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) |
| 53 , defaultTileSize(IntSize(256, 256)) | 53 , defaultTileSize(gfx::Size(256, 256)) |
| 54 , maxUntiledLayerSize(IntSize(512, 512)) | 54 , maxUntiledLayerSize(gfx::Size(512, 512)) |
| 55 , minimumOcclusionTrackingSize(IntSize(160, 160)) | 55 , minimumOcclusionTrackingSize(gfx::Size(160, 160)) |
| 56 { | 56 { |
| 57 } | 57 } |
| 58 | 58 |
| 59 LayerTreeSettings::~LayerTreeSettings() | 59 LayerTreeSettings::~LayerTreeSettings() |
| 60 { | 60 { |
| 61 } | 61 } |
| 62 | 62 |
| 63 RendererCapabilities::RendererCapabilities() | 63 RendererCapabilities::RendererCapabilities() |
| 64 : bestTextureFormat(0) | 64 : bestTextureFormat(0) |
| 65 , contextHasCachedFrontBuffer(false) | 65 , contextHasCachedFrontBuffer(false) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return; | 158 return; |
| 159 } | 159 } |
| 160 | 160 |
| 161 // Update m_settings based on capabilities that we got back from the rendere
r. | 161 // Update m_settings based on capabilities that we got back from the rendere
r. |
| 162 m_settings.acceleratePainting = m_proxy->rendererCapabilities().usingAcceler
atedPainting; | 162 m_settings.acceleratePainting = m_proxy->rendererCapabilities().usingAcceler
atedPainting; |
| 163 | 163 |
| 164 // Update m_settings based on partial update capability. | 164 // Update m_settings based on partial update capability. |
| 165 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdate
s, m_proxy->maxPartialTextureUpdates()); | 165 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdate
s, m_proxy->maxPartialTextureUpdates()); |
| 166 | 166 |
| 167 m_contentsTextureManager = PrioritizedTextureManager::create(0, m_proxy->ren
dererCapabilities().maxTextureSize, Renderer::ContentPool); | 167 m_contentsTextureManager = PrioritizedTextureManager::create(0, m_proxy->ren
dererCapabilities().maxTextureSize, Renderer::ContentPool); |
| 168 m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(IntSize
(), GL_RGBA); | 168 m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(gfx::Si
ze(), GL_RGBA); |
| 169 | 169 |
| 170 m_rendererInitialized = true; | 170 m_rendererInitialized = true; |
| 171 | 171 |
| 172 m_settings.defaultTileSize = IntSize(min(m_settings.defaultTileSize.width(),
m_proxy->rendererCapabilities().maxTextureSize), | 172 m_settings.defaultTileSize = gfx::Size(min(m_settings.defaultTileSize.width(
), m_proxy->rendererCapabilities().maxTextureSize), |
| 173 min(m_settings.defaultTileSize.height()
, m_proxy->rendererCapabilities().maxTextureSize)); | 173 min(m_settings.defaultTileSize.height
(), m_proxy->rendererCapabilities().maxTextureSize)); |
| 174 m_settings.maxUntiledLayerSize = IntSize(min(m_settings.maxUntiledLayerSize.
width(), m_proxy->rendererCapabilities().maxTextureSize), | 174 m_settings.maxUntiledLayerSize = gfx::Size(min(m_settings.maxUntiledLayerSiz
e.width(), m_proxy->rendererCapabilities().maxTextureSize), |
| 175 min(m_settings.maxUntiledLayerSize.
height(), m_proxy->rendererCapabilities().maxTextureSize)); | 175 min(m_settings.maxUntiledLayerSiz
e.height(), m_proxy->rendererCapabilities().maxTextureSize)); |
| 176 } | 176 } |
| 177 | 177 |
| 178 LayerTreeHost::RecreateResult LayerTreeHost::recreateContext() | 178 LayerTreeHost::RecreateResult LayerTreeHost::recreateContext() |
| 179 { | 179 { |
| 180 TRACE_EVENT0("cc", "LayerTreeHost::recreateContext"); | 180 TRACE_EVENT0("cc", "LayerTreeHost::recreateContext"); |
| 181 DCHECK(m_contextLost); | 181 DCHECK(m_contextLost); |
| 182 | 182 |
| 183 bool recreated = false; | 183 bool recreated = false; |
| 184 if (!m_numTimesRecreateShouldFail) | 184 if (!m_numTimesRecreateShouldFail) |
| 185 recreated = m_proxy->recreateContext(); | 185 recreated = m_proxy->recreateContext(); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 m_rootLayer = rootLayer; | 414 m_rootLayer = rootLayer; |
| 415 if (m_rootLayer) | 415 if (m_rootLayer) |
| 416 m_rootLayer->setLayerTreeHost(this); | 416 m_rootLayer->setLayerTreeHost(this); |
| 417 | 417 |
| 418 if (m_hudLayer) | 418 if (m_hudLayer) |
| 419 m_hudLayer->removeFromParent(); | 419 m_hudLayer->removeFromParent(); |
| 420 | 420 |
| 421 setNeedsCommit(); | 421 setNeedsCommit(); |
| 422 } | 422 } |
| 423 | 423 |
| 424 void LayerTreeHost::setViewportSize(const IntSize& layoutViewportSize, const Int
Size& deviceViewportSize) | 424 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g
fx::Size& deviceViewportSize) |
| 425 { | 425 { |
| 426 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de
viceViewportSize) | 426 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de
viceViewportSize) |
| 427 return; | 427 return; |
| 428 | 428 |
| 429 m_layoutViewportSize = layoutViewportSize; | 429 m_layoutViewportSize = layoutViewportSize; |
| 430 m_deviceViewportSize = deviceViewportSize; | 430 m_deviceViewportSize = deviceViewportSize; |
| 431 | 431 |
| 432 setNeedsCommit(); | 432 setNeedsCommit(); |
| 433 } | 433 } |
| 434 | 434 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 } | 495 } |
| 496 | 496 |
| 497 void LayerTreeHost::updateLayers(ResourceUpdateQueue& queue, size_t memoryAlloca
tionLimitBytes) | 497 void LayerTreeHost::updateLayers(ResourceUpdateQueue& queue, size_t memoryAlloca
tionLimitBytes) |
| 498 { | 498 { |
| 499 DCHECK(m_rendererInitialized); | 499 DCHECK(m_rendererInitialized); |
| 500 DCHECK(memoryAllocationLimitBytes); | 500 DCHECK(memoryAllocationLimitBytes); |
| 501 | 501 |
| 502 if (!rootLayer()) | 502 if (!rootLayer()) |
| 503 return; | 503 return; |
| 504 | 504 |
| 505 if (layoutViewportSize().isEmpty()) | 505 if (layoutViewportSize().IsEmpty()) |
| 506 return; | 506 return; |
| 507 | 507 |
| 508 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes)
; | 508 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes)
; |
| 509 | 509 |
| 510 updateLayers(rootLayer(), queue); | 510 updateLayers(rootLayer(), queue); |
| 511 } | 511 } |
| 512 | 512 |
| 513 static Layer* findFirstScrollableLayer(Layer* layer) | 513 static Layer* findFirstScrollableLayer(Layer* layer) |
| 514 { | 514 { |
| 515 if (!layer) | 515 if (!layer) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 prioritizeTextures(renderSurfaceLayerList, occlusionTracker.overdrawMetrics(
)); | 668 prioritizeTextures(renderSurfaceLayerList, occlusionTracker.overdrawMetrics(
)); |
| 669 | 669 |
| 670 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); | 670 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); |
| 671 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList
); it != end; ++it) { | 671 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList
); it != end; ++it) { |
| 672 occlusionTracker.enterLayer(it); | 672 occlusionTracker.enterLayer(it); |
| 673 | 673 |
| 674 if (it.representsTargetRenderSurface()) { | 674 if (it.representsTargetRenderSurface()) { |
| 675 DCHECK(it->renderSurface()->drawOpacity() || it->renderSurface()->dr
awOpacityIsAnimating()); | 675 DCHECK(it->renderSurface()->drawOpacity() || it->renderSurface()->dr
awOpacityIsAnimating()); |
| 676 needMoreUpdates |= paintMasksForRenderSurface(*it, queue); | 676 needMoreUpdates |= paintMasksForRenderSurface(*it, queue); |
| 677 } else if (it.representsItself()) { | 677 } else if (it.representsItself()) { |
| 678 DCHECK(!it->bounds().isEmpty()); | 678 DCHECK(!it->bounds().IsEmpty()); |
| 679 it->update(queue, &occlusionTracker, m_renderingStats); | 679 it->update(queue, &occlusionTracker, m_renderingStats); |
| 680 needMoreUpdates |= it->needMoreUpdates(); | 680 needMoreUpdates |= it->needMoreUpdates(); |
| 681 } | 681 } |
| 682 | 682 |
| 683 occlusionTracker.leaveLayer(it); | 683 occlusionTracker.leaveLayer(it); |
| 684 } | 684 } |
| 685 | 685 |
| 686 occlusionTracker.overdrawMetrics().recordMetrics(this); | 686 occlusionTracker.overdrawMetrics().recordMetrics(this); |
| 687 | 687 |
| 688 return needMoreUpdates; | 688 return needMoreUpdates; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 702 continue; | 702 continue; |
| 703 if (layer == rootScrollLayer) | 703 if (layer == rootScrollLayer) |
| 704 rootScrollDelta += info.scrolls[i].scrollDelta; | 704 rootScrollDelta += info.scrolls[i].scrollDelta; |
| 705 else | 705 else |
| 706 layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].s
crollDelta); | 706 layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].s
crollDelta); |
| 707 } | 707 } |
| 708 if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1) | 708 if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1) |
| 709 m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta); | 709 m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta); |
| 710 } | 710 } |
| 711 | 711 |
| 712 FloatPoint LayerTreeHost::adjustEventPointForPinchZoom(const FloatPoint& point) | 712 gfx::PointF LayerTreeHost::adjustEventPointForPinchZoom(const gfx::PointF& point
) |
| 713 const | 713 const |
| 714 { | 714 { |
| 715 WebKit::WebTransformationMatrix inverseImplTransform = m_implTransform; | 715 WebKit::WebTransformationMatrix inverseImplTransform = m_implTransform; |
| 716 // TODO(wjmaclean) Need to determine why the next two lines are | 716 // TODO(wjmaclean) Need to determine why the next two lines are |
| 717 // necessary for this to work ... it seems like just inverting | 717 // necessary for this to work ... it seems like just inverting |
| 718 // m_implTransform should be sufficient. | 718 // m_implTransform should be sufficient. |
| 719 DCHECK(inverseImplTransform.m11()); | 719 DCHECK(inverseImplTransform.m11()); |
| 720 DCHECK(inverseImplTransform.m22()); | 720 DCHECK(inverseImplTransform.m22()); |
| 721 inverseImplTransform.setM41(inverseImplTransform.m41() | 721 inverseImplTransform.setM41(inverseImplTransform.m41() |
| 722 / inverseImplTransform.m11()); | 722 / inverseImplTransform.m11()); |
| 723 inverseImplTransform.setM42(inverseImplTransform.m42() | 723 inverseImplTransform.setM42(inverseImplTransform.m42() |
| 724 / inverseImplTransform.m22()); | 724 / inverseImplTransform.m22()); |
| 725 inverseImplTransform = inverseImplTransform.inverse(); | 725 inverseImplTransform = inverseImplTransform.inverse(); |
| 726 bool wasClipped = false; | 726 bool wasClipped = false; |
| 727 FloatPoint adjustedPoint = MathUtil::projectPoint(inverseImplTransform, poin
t, wasClipped); | 727 gfx::PointF adjustedPoint = MathUtil::projectPoint(inverseImplTransform, poi
nt, wasClipped); |
| 728 DCHECK(!wasClipped); | 728 DCHECK(!wasClipped); |
| 729 | 729 |
| 730 return adjustedPoint; | 730 return adjustedPoint; |
| 731 } | 731 } |
| 732 | 732 |
| 733 void LayerTreeHost::setImplTransform(const WebKit::WebTransformationMatrix& tran
sform) | 733 void LayerTreeHost::setImplTransform(const WebKit::WebTransformationMatrix& tran
sform) |
| 734 { | 734 { |
| 735 m_implTransform = transform; | 735 m_implTransform = transform; |
| 736 } | 736 } |
| 737 | 737 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 else | 833 else |
| 834 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 834 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
| 835 } | 835 } |
| 836 } | 836 } |
| 837 | 837 |
| 838 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 838 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
| 839 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 839 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
| 840 } | 840 } |
| 841 | 841 |
| 842 } // namespace cc | 842 } // namespace cc |
| OLD | NEW |