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

Side by Side Diff: third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp

Issue 2423513002: Simplify incremental paint invalidation (Closed)
Patch Set: Update test and rebaseline layout tests Created 4 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/HTMLNames.h"
6 #include "core/frame/FrameView.h"
7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/LayoutView.h"
9 #include "core/paint/PaintLayer.h"
10 #include "platform/graphics/GraphicsLayer.h"
11 #include "platform/graphics/paint/RasterInvalidationTracking.h"
12
13 namespace blink {
14
15 class BoxPaintInvalidatorTest : public RenderingTest {
16 protected:
17 const RasterInvalidationTracking* getRasterInvalidationTracking() const {
18 // TODO(wangxianzhu): Test SPv2.
19 return layoutView()
20 .layer()
21 ->graphicsLayerBacking()
22 ->getRasterInvalidationTracking();
23 }
24
25 private:
26 void SetUp() override {
27 RenderingTest::SetUp();
28 enableCompositing();
29 setBodyInnerHTML(
30 "<style>"
31 " body { margin: 0 }"
32 " #target {"
33 " width: 50px;"
34 " height: 100px;"
35 " border-width: 20px 10px;"
36 " border-style: solid;"
37 " border-color: red;"
38 " }"
39 "</style>"
40 "<div id='target'></div>");
41 }
42 };
43
44 TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationExpand) {
45 document().view()->setTracksPaintInvalidations(true);
46 Element* target = document().getElementById("target");
47 target->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 200px");
48 document().view()->updateAllLifecyclePhases();
49 const auto* rasterInvalidations =
50 &getRasterInvalidationTracking()->trackedRasterInvalidations;
51 EXPECT_EQ(2u, rasterInvalidations->size());
52 EXPECT_EQ(IntRect(60, 0, 60, 240), (*rasterInvalidations)[0].rect);
53 EXPECT_EQ(PaintInvalidationIncremental, (*rasterInvalidations)[0].reason);
54 EXPECT_EQ(IntRect(0, 120, 120, 120), (*rasterInvalidations)[1].rect);
55 EXPECT_EQ(PaintInvalidationIncremental, (*rasterInvalidations)[1].reason);
56 document().view()->setTracksPaintInvalidations(false);
57 }
58
59 TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationShrink) {
60 document().view()->setTracksPaintInvalidations(true);
61 Element* target = document().getElementById("target");
62 target->setAttribute(HTMLNames::styleAttr, "width: 20px; height: 80px");
63 document().view()->updateAllLifecyclePhases();
64 const auto* rasterInvalidations =
65 &getRasterInvalidationTracking()->trackedRasterInvalidations;
66 EXPECT_EQ(2u, rasterInvalidations->size());
67 EXPECT_EQ(IntRect(30, 0, 40, 140), (*rasterInvalidations)[0].rect);
68 EXPECT_EQ(PaintInvalidationIncremental, (*rasterInvalidations)[0].reason);
69 EXPECT_EQ(IntRect(0, 100, 70, 40), (*rasterInvalidations)[1].rect);
70 EXPECT_EQ(PaintInvalidationIncremental, (*rasterInvalidations)[1].reason);
71 document().view()->setTracksPaintInvalidations(false);
72 }
73
74 TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationMixed) {
75 document().view()->setTracksPaintInvalidations(true);
76 Element* target = document().getElementById("target");
77 target->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 80px");
78 document().view()->updateAllLifecyclePhases();
79 const auto* rasterInvalidations =
80 &getRasterInvalidationTracking()->trackedRasterInvalidations;
81 EXPECT_EQ(2u, rasterInvalidations->size());
82 EXPECT_EQ(IntRect(60, 0, 60, 120), (*rasterInvalidations)[0].rect);
83 EXPECT_EQ(PaintInvalidationIncremental, (*rasterInvalidations)[0].reason);
84 EXPECT_EQ(IntRect(0, 100, 70, 40), (*rasterInvalidations)[1].rect);
85 EXPECT_EQ(PaintInvalidationIncremental, (*rasterInvalidations)[1].reason);
86 document().view()->setTracksPaintInvalidations(false);
87 }
88
89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698