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

Unified Diff: third_party/WebKit/Source/core/paint/PaintControllerPaintTest.h

Issue 1428643004: Repaint on interest rect change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@EnableSyncPaint
Patch Set: Created 5 years, 2 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: third_party/WebKit/Source/core/paint/PaintControllerPaintTest.h
diff --git a/third_party/WebKit/Source/core/paint/PaintControllerPaintTest.h b/third_party/WebKit/Source/core/paint/PaintControllerPaintTest.h
index 43952c11c50d41f15e3b24237f58e062421407cd..fe1b5ea0f338ff4337a3816f8755a0ccceb08d2d 100644
--- a/third_party/WebKit/Source/core/paint/PaintControllerPaintTest.h
+++ b/third_party/WebKit/Source/core/paint/PaintControllerPaintTest.h
@@ -9,78 +9,107 @@
#include "core/layout/LayoutTestHelper.h"
#include "core/layout/LayoutView.h"
#include "core/paint/PaintLayer.h"
+#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
#include <gtest/gtest.h>
namespace blink {
-class PaintControllerPaintTest : public RenderingTest {
+class PaintControllerPaintTestBase : public RenderingTest {
public:
- PaintControllerPaintTest()
+ PaintControllerPaintTestBase(bool enableSlimmingPaintV2)
: m_originalSlimmingPaintSynchronizedPaintingEnabled(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled())
, m_originalSlimmingPaintOffsetCachingEnabled(RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled())
- { }
+ , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaintV2Enabled())
+ , m_enableSlimmingPaintV2(enableSlimmingPaintV2)
+ { }
protected:
LayoutView& layoutView() { return *document().layoutView(); }
PaintController& rootPaintController() { return *layoutView().layer()->graphicsLayerBacking()->paintController(); }
-private:
void SetUp() override
{
RenderingTest::SetUp();
enableCompositing();
GraphicsLayer::setDrawDebugRedFillForTesting(false);
+ RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_enableSlimmingPaintV2);
}
void TearDown() override
{
RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(m_originalSlimmingPaintSynchronizedPaintingEnabled);
RuntimeEnabledFeatures::setSlimmingPaintOffsetCachingEnabled(m_originalSlimmingPaintOffsetCachingEnabled);
+ RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPaintV2Enabled);
GraphicsLayer::setDrawDebugRedFillForTesting(true);
}
- bool m_originalSlimmingPaintSynchronizedPaintingEnabled;
- bool m_originalSlimmingPaintOffsetCachingEnabled;
-};
-
-// Slimming paint v2 has subtly different behavior on some paint tests. This
-// class is used to test only v2 behavior while maintaining v1 test coverage.
-class PaintControllerPaintTestForSlimmingPaintV2 : public RenderingTest {
-public:
- PaintControllerPaintTestForSlimmingPaintV2()
- : m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { }
-
-protected:
- LayoutView& layoutView() { return *document().layoutView(); }
- PaintController& rootPaintController() { return *layoutView().layer()->graphicsLayerBacking()->paintController(); }
-
// Expose some document lifecycle steps for checking new display items before commiting.
- void updateLifecyclePhasesToPaintClean(const LayoutRect* interestRect = nullptr)
+ void updateLifecyclePhasesBeforePaint()
{
- document().view()->updateLifecyclePhasesInternal(FrameView::OnlyUpToCompositingCleanPlusScrolling, nullptr);
- document().view()->invalidateTreeIfNeededRecursive();
- document().view()->updatePaintProperties();
- document().view()->synchronizedPaint(interestRect);
+ // This doesn't do all steps that FrameView does, but is enough for current tests.
+ FrameView* frameView = document().view();
+ frameView->updateLifecyclePhasesInternal(FrameView::OnlyUpToCompositingCleanPlusScrolling);
+ frameView->invalidateTreeIfNeededRecursive();
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
+ document().view()->updatePaintProperties();
}
- void compositeForSlimmingPaintV2() { document().view()->compositeForSlimmingPaintV2(); }
-private:
- void SetUp() override
+ void updateLifecyclePhasesToPaintClean()
{
- RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled());
+ updateLifecyclePhasesBeforePaint();
+ document().view()->synchronizedPaint();
+ }
- RenderingTest::SetUp();
- enableCompositing();
- GraphicsLayer::setDrawDebugRedFillForTesting(false);
+ void paint(const IntRect* interestRect = nullptr)
+ {
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled());
+ // For v1, only root graphics layer is supported.
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !interestRect) {
+ document().view()->synchronizedPaint();
+ } else {
+ document().view()->lifecycle().advanceTo(DocumentLifecycle::InPaint);
+ GraphicsContext context(rootPaintController());
+ layoutView().layer()->graphicsLayerBacking()->paint(context, interestRect);
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
+ document().view()->lifecycle().advanceTo(DocumentLifecycle::PaintClean);
+ }
}
- void TearDown() override
+ // TODO(who removes pre-v2 code): rename to composite().
+ void commit()
{
- GraphicsLayer::setDrawDebugRedFillForTesting(true);
- RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPaintV2Enabled);
+ // For v1, only root graphics layer is supported.
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
+ document().view()->compositeForSlimmingPaintV2();
+ } else {
+ rootPaintController().commitNewDisplayItems();
+ document().view()->lifecycle().advanceTo(DocumentLifecycle::PaintClean);
+ }
}
+private:
+ bool m_originalSlimmingPaintSynchronizedPaintingEnabled;
+ bool m_originalSlimmingPaintOffsetCachingEnabled;
bool m_originalSlimmingPaintV2Enabled;
+ bool m_enableSlimmingPaintV2;
+};
+
+class PaintControllerPaintTest : public PaintControllerPaintTestBase {
+public:
+ PaintControllerPaintTest() : PaintControllerPaintTestBase(false) { }
+};
+
+class PaintControllerPaintTestForSlimmingPaintV2 : public PaintControllerPaintTestBase {
+public:
+ PaintControllerPaintTestForSlimmingPaintV2() : PaintControllerPaintTestBase(true) { }
+};
+
+class PaintControllerPaintTestForSlimmingPaintV1AndV2
+ : public PaintControllerPaintTestBase
+ , public testing::WithParamInterface<bool> {
+public:
+ PaintControllerPaintTestForSlimmingPaintV1AndV2() : PaintControllerPaintTestBase(GetParam()) { }
};
class TestDisplayItem final : public DisplayItem {

Powered by Google App Engine
This is Rietveld 408576698