Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2218)

Unified Diff: Source/web/tests/sim/SimCompositor.cpp

Issue 1329553004: Add a FOUC painting test. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Clean up. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/web/tests/sim/SimCompositor.cpp
diff --git a/Source/web/tests/sim/SimCompositor.cpp b/Source/web/tests/sim/SimCompositor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ee857d770ea09c88d7ee098b8fcc441997092c49
--- /dev/null
+++ b/Source/web/tests/sim/SimCompositor.cpp
@@ -0,0 +1,92 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "web/tests/sim/SimCompositor.h"
+
+#include "core/frame/FrameView.h"
+#include "core/layout/LayoutView.h"
+#include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h"
+#include "core/paint/DeprecatedPaintLayer.h"
+#include "platform/graphics/ContentLayerDelegate.h"
+#include "public/platform/WebRect.h"
+#include "web/WebLocalFrameImpl.h"
+#include "web/WebViewImpl.h"
+#include "web/tests/sim/SimDisplayItemList.h"
+#include "web/tests/sim/SimLayerTreeView.h"
+#include "wtf/CurrentTime.h"
+
+namespace blink {
+
+static void paintLayers(DeprecatedPaintLayer& layer, SimDisplayItemList& displayList)
+{
+ if (layer.compositingState() == PaintsIntoOwnBacking) {
+ CompositedDeprecatedPaintLayerMapping* mapping = layer.compositedDeprecatedPaintLayerMapping();
+ GraphicsLayer* graphicsLayer = mapping->mainGraphicsLayer();
+ if (graphicsLayer->hasTrackedPaintInvalidations()) {
+ ContentLayerDelegate* delegate = graphicsLayer->contentLayerDelegateForTesting();
+ delegate->paintContents(&displayList, WebRect(0, 0, layer.size().width(), layer.size().height()));
+ graphicsLayer->resetTrackedPaintInvalidations();
+ }
+ }
+ for (DeprecatedPaintLayer* child = layer.firstChild(); child; child = child->nextSibling())
+ paintLayers(*child, displayList);
+}
+
+static void paintFrames(LocalFrame& root, SimDisplayItemList& displayList)
+{
+ for (Frame* frame = &root; frame; frame = frame->tree().traverseNext(&root)) {
+ if (!frame->isLocalFrame())
+ continue;
+ DeprecatedPaintLayer* layer = toLocalFrame(frame)->view()->layoutView()->layer();
+ paintLayers(*layer, displayList);
+ }
+}
+
+SimCompositor::SimCompositor(SimLayerTreeView& layerTreeView)
+ : m_layerTreeView(&layerTreeView)
+ , m_webViewImpl(0)
+ , m_lastFrameTimeMonotonic(0)
+{
+ FrameView::setInitialTracksPaintInvalidationsForUnitTestsOnly(true);
+}
+
+SimCompositor::~SimCompositor()
+{
+ FrameView::setInitialTracksPaintInvalidationsForUnitTestsOnly(false);
+}
+
+void SimCompositor::setWebViewImpl(WebViewImpl& webViewImpl)
+{
+ m_webViewImpl = &webViewImpl;
+}
+
+SimCompositor::BeginFrameResult SimCompositor::beginFrame()
+{
+ ASSERT(m_webViewImpl);
+ ASSERT(!m_layerTreeView->deferCommits());
+ ASSERT(m_layerTreeView->needsAnimate());
+
+ // Always advance the time as if the compositor was running at 60fps.
+ m_lastFrameTimeMonotonic = monotonicallyIncreasingTime() + 0.016;
+
+ WebBeginFrameArgs args(m_lastFrameTimeMonotonic, 0, 0);
+ m_webViewImpl->beginFrame(args);
+ m_webViewImpl->layout();
+
+ LocalFrame* root = m_webViewImpl->mainFrameImpl()->frame();
+
+ SimDisplayItemList displayList;
+ paintFrames(*root, displayList);
+
+ BeginFrameResult result;
+ result.didDrawText = displayList.didDrawText();
+ result.drawCount = displayList.drawCount();
+
+ m_layerTreeView->resetNeedsAnimate();
+
+ return result;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698