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

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

Issue 1415143005: Preparation for enabling slimming paint synchronized painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/LayoutObjectDrawingRecorder.h" 6 #include "core/paint/LayoutObjectDrawingRecorder.h"
7 7
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/paint/PaintControllerPaintTest.h" 10 #include "core/paint/PaintControllerPaintTest.h"
11 #include "core/paint/PaintLayer.h" 11 #include "core/paint/PaintLayer.h"
12 #include "platform/graphics/GraphicsContext.h" 12 #include "platform/graphics/GraphicsContext.h"
13 #include "platform/graphics/GraphicsLayer.h" 13 #include "platform/graphics/GraphicsLayer.h"
14 #include "platform/graphics/paint/DrawingDisplayItem.h" 14 #include "platform/graphics/paint/DrawingDisplayItem.h"
15 #include "platform/graphics/paint/PaintController.h" 15 #include "platform/graphics/paint/PaintController.h"
16 #include <gtest/gtest.h> 16 #include <gtest/gtest.h>
17 17
18 namespace blink { 18 namespace blink {
19 19
20 using LayoutObjectDrawingRecorderTest = PaintControllerPaintTest; 20 using LayoutObjectDrawingRecorderTest = PaintControllerPaintTest;
21 using LayoutObjectDrawingRecorderTestForSlimmingPaintV2 = PaintControllerPaintTe stForSlimmingPaintV2;
Xianzhu 2015/10/28 18:10:23 This was not used. We also don't need to test for
22 21
23 namespace { 22 namespace {
24 23
25 void drawNothing(GraphicsContext& context, const LayoutView& layoutView, PaintPh ase phase, const LayoutRect& bound) 24 void drawNothing(GraphicsContext& context, const LayoutView& layoutView, PaintPh ase phase, const LayoutRect& bound)
26 { 25 {
27 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutV iew, phase, LayoutPoint())) 26 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutV iew, phase, LayoutPoint()))
28 return; 27 return;
29 28
30 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun d, LayoutPoint()); 29 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun d, LayoutPoint());
31 } 30 }
32 31
33 void drawRect(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase , const LayoutRect& bound) 32 void drawRect(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase , const LayoutRect& bound)
34 { 33 {
35 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutV iew, phase, LayoutPoint())) 34 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutV iew, phase, LayoutPoint()))
36 return; 35 return;
37 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun d, LayoutPoint()); 36 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun d, LayoutPoint());
38 IntRect rect(0, 0, 10, 10); 37 IntRect rect(0, 0, 10, 10);
39 context.drawRect(rect); 38 context.drawRect(rect);
40 } 39 }
41 40
42 TEST_F(LayoutObjectDrawingRecorderTest, Nothing) 41 TEST_F(LayoutObjectDrawingRecorderTest, Nothing)
43 { 42 {
43 rootPaintController().invalidateAll();
44 GraphicsContext context(rootPaintController()); 44 GraphicsContext context(rootPaintController());
45 LayoutRect bound = layoutView().viewRect(); 45 LayoutRect bound = layoutView().viewRect();
46 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size());
47
48 drawNothing(context, layoutView(), PaintPhaseForeground, bound); 46 drawNothing(context, layoutView(), PaintPhaseForeground, bound);
49 rootPaintController().commitNewDisplayItems(); 47 rootPaintController().commitNewDisplayItems();
50 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1, 48 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1,
51 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground))); 49 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)));
52 EXPECT_FALSE(static_cast<const DrawingDisplayItem&>(rootPaintController().di splayItemList()[0]).picture()); 50 EXPECT_FALSE(static_cast<const DrawingDisplayItem&>(rootPaintController().di splayItemList()[0]).picture());
53 } 51 }
54 52
55 TEST_F(LayoutObjectDrawingRecorderTest, Rect) 53 TEST_F(LayoutObjectDrawingRecorderTest, Rect)
56 { 54 {
55 rootPaintController().invalidateAll();
57 GraphicsContext context(rootPaintController()); 56 GraphicsContext context(rootPaintController());
58 LayoutRect bound = layoutView().viewRect(); 57 LayoutRect bound = layoutView().viewRect();
59 drawRect(context, layoutView(), PaintPhaseForeground, bound); 58 drawRect(context, layoutView(), PaintPhaseForeground, bound);
60 rootPaintController().commitNewDisplayItems(); 59 rootPaintController().commitNewDisplayItems();
61 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1, 60 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1,
62 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground))); 61 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)));
63 } 62 }
64 63
65 TEST_F(LayoutObjectDrawingRecorderTest, Cached) 64 TEST_F(LayoutObjectDrawingRecorderTest, Cached)
66 { 65 {
66 rootPaintController().invalidateAll();
67 GraphicsContext context(rootPaintController()); 67 GraphicsContext context(rootPaintController());
68 LayoutRect bound = layoutView().viewRect(); 68 LayoutRect bound = layoutView().viewRect();
69 drawNothing(context, layoutView(), PaintPhaseBlockBackground, bound); 69 drawNothing(context, layoutView(), PaintPhaseBlockBackground, bound);
70 drawRect(context, layoutView(), PaintPhaseForeground, bound); 70 drawRect(context, layoutView(), PaintPhaseForeground, bound);
71 rootPaintController().commitNewDisplayItems(); 71 rootPaintController().commitNewDisplayItems();
72 72
73 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, 73 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2,
74 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseBlockBackground)), 74 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseBlockBackground)),
75 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground))); 75 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)));
76 76
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 // Ensure the new paint offset can be used. 160 // Ensure the new paint offset can be used.
161 EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground, newPaintOffset)); 161 EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground, newPaintOffset));
162 rootPaintController().commitNewDisplayItems(); 162 rootPaintController().commitNewDisplayItems();
163 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1, 163 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1,
164 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground))); 164 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)));
165 } 165 }
166 166
167 } // namespace 167 } // namespace
168 } // namespace blink 168 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698