| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "web/tests/sim/SimCompositor.h" | 6 #include "web/tests/sim/SimCompositor.h" |
| 7 | 7 |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/layout/compositing/CompositedLayerMapping.h" | 10 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 11 #include "core/paint/PaintLayer.h" | 11 #include "core/paint/PaintLayer.h" |
| 12 #include "platform/graphics/ContentLayerDelegate.h" | 12 #include "platform/graphics/ContentLayerDelegate.h" |
| 13 #include "public/platform/WebRect.h" | 13 #include "public/platform/WebRect.h" |
| 14 #include "web/WebLocalFrameImpl.h" | 14 #include "web/WebLocalFrameImpl.h" |
| 15 #include "web/WebViewImpl.h" | 15 #include "web/WebViewImpl.h" |
| 16 #include "web/tests/sim/SimDisplayItemList.h" | 16 #include "web/tests/sim/SimDisplayItemList.h" |
| 17 #include "web/tests/sim/SimLayerTreeView.h" | 17 #include "web/tests/sim/SimLayerTreeView.h" |
| 18 #include "wtf/CurrentTime.h" | 18 #include "wtf/CurrentTime.h" |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 static void paintLayers(PaintLayer& layer, SimDisplayItemList& displayList) | 22 static void paintLayers(PaintLayer& layer, SimDisplayItemList& displayList) |
| 23 { | 23 { |
| 24 if (layer.compositingState() == PaintsIntoOwnBacking) { | 24 if (layer.isAllowedToQueryCompositingState() && layer.compositingState() ==
PaintsIntoOwnBacking) { |
| 25 CompositedLayerMapping* mapping = layer.compositedLayerMapping(); | 25 CompositedLayerMapping* mapping = layer.compositedLayerMapping(); |
| 26 GraphicsLayer* graphicsLayer = mapping->mainGraphicsLayer(); | 26 GraphicsLayer* graphicsLayer = mapping->mainGraphicsLayer(); |
| 27 if (graphicsLayer->hasTrackedPaintInvalidations()) { | 27 if (graphicsLayer->hasTrackedPaintInvalidations()) { |
| 28 ContentLayerDelegate* delegate = graphicsLayer->contentLayerDelegate
ForTesting(); | 28 ContentLayerDelegate* delegate = graphicsLayer->contentLayerDelegate
ForTesting(); |
| 29 delegate->paintContents(&displayList, WebRect(0, 0, layer.size().wid
th(), layer.size().height())); | 29 delegate->paintContents(&displayList, WebRect(0, 0, layer.size().wid
th(), layer.size().height())); |
| 30 graphicsLayer->resetTrackedPaintInvalidations(); | 30 graphicsLayer->resetTrackedPaintInvalidations(); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 for (PaintLayer* child = layer.firstChild(); child; child = child->nextSibli
ng()) | 33 for (PaintLayer* child = layer.firstChild(); child; child = child->nextSibli
ng()) |
| 34 paintLayers(*child, displayList); | 34 paintLayers(*child, displayList); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 64 void SimCompositor::setWebViewImpl(WebViewImpl& webViewImpl) | 64 void SimCompositor::setWebViewImpl(WebViewImpl& webViewImpl) |
| 65 { | 65 { |
| 66 m_webViewImpl = &webViewImpl; | 66 m_webViewImpl = &webViewImpl; |
| 67 } | 67 } |
| 68 | 68 |
| 69 SimDisplayItemList SimCompositor::beginFrame() | 69 SimDisplayItemList SimCompositor::beginFrame() |
| 70 { | 70 { |
| 71 ASSERT(m_webViewImpl); | 71 ASSERT(m_webViewImpl); |
| 72 ASSERT(!m_layerTreeView->deferCommits()); | 72 ASSERT(!m_layerTreeView->deferCommits()); |
| 73 ASSERT(m_layerTreeView->needsAnimate()); | 73 ASSERT(m_layerTreeView->needsAnimate()); |
| 74 m_layerTreeView->clearNeedsAnimate(); |
| 74 | 75 |
| 75 // Always advance the time as if the compositor was running at 60fps. | 76 // Always advance the time as if the compositor was running at 60fps. |
| 76 m_lastFrameTimeMonotonic = monotonicallyIncreasingTime() + 0.016; | 77 m_lastFrameTimeMonotonic = monotonicallyIncreasingTime() + 0.016; |
| 77 | 78 |
| 78 WebBeginFrameArgs args(m_lastFrameTimeMonotonic, 0, 0); | 79 WebBeginFrameArgs args(m_lastFrameTimeMonotonic, 0, 0); |
| 79 m_webViewImpl->beginFrame(args); | 80 m_webViewImpl->beginFrame(args); |
| 80 m_webViewImpl->layout(); | 81 m_webViewImpl->layout(); |
| 81 | 82 |
| 82 LocalFrame* root = m_webViewImpl->mainFrameImpl()->frame(); | 83 LocalFrame* root = m_webViewImpl->mainFrameImpl()->frame(); |
| 83 | 84 |
| 84 SimDisplayItemList displayList; | 85 SimDisplayItemList displayList; |
| 85 paintFrames(*root, displayList); | 86 paintFrames(*root, displayList); |
| 86 | 87 |
| 87 m_layerTreeView->clearNeedsAnimate(); | |
| 88 | |
| 89 return displayList; | 88 return displayList; |
| 90 } | 89 } |
| 91 | 90 |
| 92 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |