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

Unified Diff: third_party/WebKit/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp

Issue 1391753005: (WIP) Invalidation during painting (for synchronized painting) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/LayoutObjectDrawingRecorderTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp b/third_party/WebKit/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp
index 9e4285f8eb9d4f3b1f6e1777e85fc8869d60b7ae..ac06fd814d374384d8010d45d85b30ce866f9f53 100644
--- a/third_party/WebKit/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp
+++ b/third_party/WebKit/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp
@@ -7,6 +7,7 @@
#include "core/layout/LayoutTestHelper.h"
#include "core/layout/LayoutView.h"
#include "core/paint/PaintControllerPaintTest.h"
+#include "core/paint/PaintInfo.h"
#include "core/paint/PaintLayer.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
@@ -22,17 +23,17 @@ namespace {
void drawNothing(GraphicsContext& context, const LayoutView& layoutView, PaintPhase phase, const LayoutRect& bound)
{
- if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView, phase, LayoutPoint()))
+ if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView, phase))
return;
- LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, bound, LayoutPoint());
+ LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, bound);
}
void drawRect(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase, const LayoutRect& bound)
{
- if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView, phase, LayoutPoint()))
+ if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView, phase))
return;
- LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, bound, LayoutPoint());
+ LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, bound);
IntRect rect(0, 0, 10, 10);
context.drawRect(rect);
}
@@ -94,8 +95,7 @@ FloatRect drawAndGetCullRect(PaintController& controller, const LayoutObject& la
{
// Draw some things which will produce a non-null picture.
GraphicsContext context(controller);
- LayoutObjectDrawingRecorder recorder(
- context, layoutObject, DisplayItem::BoxDecorationBackground, bounds, LayoutPoint());
+ LayoutObjectDrawingRecorder recorder(context, layoutObject, DisplayItem::BoxDecorationBackground, bounds);
context.drawRect(enclosedIntRect(FloatRect(bounds)));
}
controller.commitNewDisplayItems();
@@ -120,45 +120,53 @@ TEST_F(LayoutObjectDrawingRecorderTest, CullRectMatchesProvidedClip)
TEST_F(LayoutObjectDrawingRecorderTest, PaintOffsetCache)
{
- RuntimeEnabledFeatures::setSlimmingPaintOffsetCachingEnabled(true);
+ layoutView().document().lifecycle().advanceTo(DocumentLifecycle::InCompositingUpdate);
+ layoutView().document().lifecycle().advanceTo(DocumentLifecycle::CompositingClean);
+
+ RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true);
+ layoutView().document().lifecycle().advanceTo(DocumentLifecycle::InPaint);
GraphicsContext context(rootPaintController());
LayoutRect bounds = layoutView().viewRect();
LayoutPoint paintOffset(1, 2);
+ layoutView().setPreviousPaintOffset(paintOffset);
+ PaintInvalidationState paintInvalidationState(layoutView(), LayoutRect(), 0);
+ PaintInfo paintInfo(&context, IntRect(0, 0, 100, 100), PaintPhaseForeground, 0, 0);
+ paintInfo.paintInvalidationState = &paintInvalidationState;
rootPaintController().invalidateAll();
- EXPECT_FALSE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground, paintOffset));
+ EXPECT_FALSE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground));
{
- LayoutObjectDrawingRecorder drawingRecorder(context, layoutView(), PaintPhaseForeground, bounds, paintOffset);
+ LayoutObjectDrawingRecorder drawingRecorder(context, layoutView(), PaintPhaseForeground, bounds);
IntRect rect(0, 0, 10, 10);
context.drawRect(rect);
}
- rootPaintController().commitNewDisplayItems();
+ GraphicsLayer* graphicsLayer = layoutView().layer()->graphicsLayerBacking();
+ rootPaintController().commitNewDisplayItems(graphicsLayer);
EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1,
TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)));
// Ensure we cannot use the cache with a new paint offset.
LayoutPoint newPaintOffset(2, 3);
- EXPECT_FALSE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground, newPaintOffset));
+ layoutView().mutableForPainting().invalidatePaintIfNeeded(paintInfo, newPaintOffset);
+ EXPECT_FALSE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground));
// Test that a new paint offset is recorded.
{
- LayoutObjectDrawingRecorder drawingRecorder(context, layoutView(), PaintPhaseForeground, bounds, newPaintOffset);
+ LayoutObjectDrawingRecorder drawingRecorder(context, layoutView(), PaintPhaseForeground, bounds);
IntRect rect(0, 0, 10, 10);
context.drawRect(rect);
}
- rootPaintController().commitNewDisplayItems();
+ rootPaintController().commitNewDisplayItems(graphicsLayer);
EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1,
TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)));
- // Ensure the old paint offset cannot be used.
- EXPECT_FALSE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground, paintOffset));
-
// Ensure the new paint offset can be used.
- EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground, newPaintOffset));
- rootPaintController().commitNewDisplayItems();
+ layoutView().mutableForPainting().invalidatePaintIfNeeded(paintInfo, newPaintOffset);
+ EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground));
+ rootPaintController().commitNewDisplayItems(graphicsLayer);
EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1,
TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)));
}

Powered by Google App Engine
This is Rietveld 408576698