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

Unified Diff: Source/core/paint/LayerClipRecorderTest.cpp

Issue 900653003: Avoid empty display item pairs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix try bot breakage Created 5 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
« no previous file with comments | « Source/core/paint/CompositingRecorder.cpp ('k') | Source/core/paint/LayerPainter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/LayerClipRecorderTest.cpp
diff --git a/Source/core/paint/LayerClipRecorderTest.cpp b/Source/core/paint/LayerClipRecorderTest.cpp
index e7d3da30d6ffd53cba0d80f2062656d2d752e1dd..7051146225cf5de2df115665afa7d841e513f692 100644
--- a/Source/core/paint/LayerClipRecorderTest.cpp
+++ b/Source/core/paint/LayerClipRecorderTest.cpp
@@ -6,6 +6,7 @@
#include "core/paint/LayerClipRecorder.h"
#include "core/layout/compositing/LayerCompositor.h"
+#include "core/paint/RenderDrawingRecorder.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/RenderingTestHelper.h"
#include "platform/graphics/GraphicsContext.h"
@@ -39,22 +40,46 @@ private:
RenderView* m_renderView;
};
-void drawClip(GraphicsContext* context, RenderView* renderer, PaintPhase phase, const FloatRect& bound)
+void drawEmptyClip(GraphicsContext* context, RenderView* renderer, PaintPhase phase, const FloatRect& bound)
{
IntRect rect(1, 1, 9, 9);
ClipRect clipRect(rect);
LayerClipRecorder LayerClipRecorder(renderer->compositor()->rootLayer()->renderer(), context, DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags());
}
-TEST_F(LayerClipRecorderTest, LayerClipRecorderTest_Single)
+void drawRectInClip(GraphicsContext* context, RenderView* renderer, PaintPhase phase, const FloatRect& bound)
+{
+ IntRect rect(1, 1, 9, 9);
+ ClipRect clipRect(rect);
+ LayerClipRecorder LayerClipRecorder(renderer->compositor()->rootLayer()->renderer(), context, DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags());
+ RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound);
+ if (!drawingRecorder.canUseCachedDrawing())
+ context->drawRect(rect);
+}
+
+TEST_F(LayerClipRecorderTest, Single)
{
GraphicsContext context(nullptr, &rootDisplayItemList());
FloatRect bound = renderView()->viewRect();
EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
- drawClip(&context, renderView(), PaintPhaseForeground, bound);
+ drawRectInClip(&context, renderView(), PaintPhaseForeground, bound);
rootDisplayItemList().endNewPaints();
- EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size());
+ EXPECT_EQ((size_t)3, rootDisplayItemList().paintList().size());
+ EXPECT_TRUE(rootDisplayItemList().paintList()[0]->isClip());
+ EXPECT_TRUE(rootDisplayItemList().paintList()[1]->isDrawing());
+ EXPECT_TRUE(rootDisplayItemList().paintList()[2]->isEndClip());
+}
+
+TEST_F(LayerClipRecorderTest, Empty)
+{
+ GraphicsContext context(nullptr, &rootDisplayItemList());
+ FloatRect bound = renderView()->viewRect();
+ EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
+
+ drawEmptyClip(&context, renderView(), PaintPhaseForeground, bound);
+ rootDisplayItemList().endNewPaints();
+ EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
}
}
« no previous file with comments | « Source/core/paint/CompositingRecorder.cpp ('k') | Source/core/paint/LayerPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698