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

Side by Side Diff: Source/core/paint/LayerClipRecorderTest.cpp

Issue 892293002: First version of new merge algorithm (not enabled yet) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove scope-related code (accidentally mixed in this CL) 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "core/paint/LayerClipRecorder.h" 6 #include "core/paint/LayerClipRecorder.h"
7 7
8 #include "core/layout/compositing/RenderLayerCompositor.h" 8 #include "core/layout/compositing/RenderLayerCompositor.h"
9 #include "core/paint/RenderDrawingRecorder.h"
9 #include "core/rendering/RenderView.h" 10 #include "core/rendering/RenderView.h"
10 #include "core/rendering/RenderingTestHelper.h" 11 #include "core/rendering/RenderingTestHelper.h"
11 #include "platform/graphics/GraphicsContext.h" 12 #include "platform/graphics/GraphicsContext.h"
12 #include "platform/graphics/GraphicsLayer.h" 13 #include "platform/graphics/GraphicsLayer.h"
13 #include "platform/graphics/paint/DisplayItemList.h" 14 #include "platform/graphics/paint/DisplayItemList.h"
14 #include <gtest/gtest.h> 15 #include <gtest/gtest.h>
15 16
16 namespace blink { 17 namespace blink {
17 namespace { 18 namespace {
18 19
(...skipping 13 matching lines...) Expand all
32 RenderingTest::SetUp(); 33 RenderingTest::SetUp();
33 enableCompositing(); 34 enableCompositing();
34 35
35 m_renderView = document().view()->renderView(); 36 m_renderView = document().view()->renderView();
36 ASSERT_TRUE(m_renderView); 37 ASSERT_TRUE(m_renderView);
37 } 38 }
38 39
39 RenderView* m_renderView; 40 RenderView* m_renderView;
40 }; 41 };
41 42
42 void drawClip(GraphicsContext* context, RenderView* renderer, PaintPhase phase, const FloatRect& bound) 43 void drawEmptyClip(GraphicsContext* context, RenderView* renderer, PaintPhase ph ase, const FloatRect& bound)
43 { 44 {
44 IntRect rect(1, 1, 9, 9); 45 IntRect rect(1, 1, 9, 9);
45 ClipRect clipRect(rect); 46 ClipRect clipRect(rect);
46 LayerClipRecorder LayerClipRecorder(renderer->compositor()->rootRenderLayer( )->renderer(), context, DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags()); 47 LayerClipRecorder LayerClipRecorder(renderer->compositor()->rootRenderLayer( )->renderer(), context, DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags());
47 } 48 }
48 49
49 TEST_F(LayerClipRecorderTest, LayerClipRecorderTest_Single) 50 void drawRectInClip(GraphicsContext* context, RenderView* renderer, PaintPhase p hase, const FloatRect& bound)
51 {
52 IntRect rect(1, 1, 9, 9);
53 ClipRect clipRect(rect);
54 LayerClipRecorder LayerClipRecorder(renderer->compositor()->rootRenderLayer( )->renderer(), context, DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags());
55 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound);
56 if (!drawingRecorder.canUseCachedDrawing())
57 context->drawRect(rect);
58 }
59
60 TEST_F(LayerClipRecorderTest, Single)
50 { 61 {
51 GraphicsContext context(nullptr, &rootDisplayItemList()); 62 GraphicsContext context(nullptr, &rootDisplayItemList());
52 FloatRect bound = renderView()->viewRect(); 63 FloatRect bound = renderView()->viewRect();
53 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); 64 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
54 65
55 drawClip(&context, renderView(), PaintPhaseForeground, bound); 66 drawRectInClip(&context, renderView(), PaintPhaseForeground, bound);
56 rootDisplayItemList().endNewPaints(); 67 rootDisplayItemList().endNewPaints();
57 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); 68 EXPECT_EQ((size_t)3, rootDisplayItemList().paintList().size());
69 EXPECT_TRUE(rootDisplayItemList().paintList()[0]->isClip());
70 EXPECT_TRUE(rootDisplayItemList().paintList()[1]->isDrawing());
71 EXPECT_TRUE(rootDisplayItemList().paintList()[2]->isEndClip());
72 }
73
74 TEST_F(LayerClipRecorderTest, Empty)
75 {
76 GraphicsContext context(nullptr, &rootDisplayItemList());
77 FloatRect bound = renderView()->viewRect();
78 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
79
80 drawEmptyClip(&context, renderView(), PaintPhaseForeground, bound);
81 rootDisplayItemList().endNewPaints();
82 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
58 } 83 }
59 84
60 } 85 }
61 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698