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

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

Issue 2423513002: Simplify incremental paint invalidation (Closed)
Patch Set: Test Created 4 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 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);
chrishtr 2016/10/21 17:18:27 Check that the paint invalidation reason matches a
Xianzhu 2016/10/21 17:53:38 Done.
53 EXPECT_EQ(IntRect(0, 120, 120, 120), (*rasterInvalidations)[1].rect);
54 document().view()->setTracksPaintInvalidations(false);
55 }
56
57 TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationShrink) {
58 document().view()->setTracksPaintInvalidations(true);
59 Element* target = document().getElementById("target");
60 target->setAttribute(HTMLNames::styleAttr, "width: 20px; height: 80px");
61 document().view()->updateAllLifecyclePhases();
62 const auto* rasterInvalidations =
63 &getRasterInvalidationTracking()->trackedRasterInvalidations;
64 EXPECT_EQ(2u, rasterInvalidations->size());
65 EXPECT_EQ(IntRect(30, 0, 40, 140), (*rasterInvalidations)[0].rect);
66 EXPECT_EQ(IntRect(0, 100, 70, 40), (*rasterInvalidations)[1].rect);
67 document().view()->setTracksPaintInvalidations(false);
68 }
69
70 TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationMixed) {
71 document().view()->setTracksPaintInvalidations(true);
72 Element* target = document().getElementById("target");
73 target->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 80px");
74 document().view()->updateAllLifecyclePhases();
75 const auto* rasterInvalidations =
76 &getRasterInvalidationTracking()->trackedRasterInvalidations;
77 EXPECT_EQ(2u, rasterInvalidations->size());
78 EXPECT_EQ(IntRect(60, 0, 60, 120), (*rasterInvalidations)[0].rect);
79 EXPECT_EQ(IntRect(0, 100, 70, 40), (*rasterInvalidations)[1].rect);
80 document().view()->setTracksPaintInvalidations(false);
81 }
82
83 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698