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

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

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 5 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
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/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 10 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 LayoutRect rect(1, 1, 9, 9); 53 LayoutRect rect(1, 1, 9, 9);
54 ClipRect clipRect(rect); 54 ClipRect clipRect(rect);
55 LayerClipRecorder LayerClipRecorder(context, *layoutView.compositor()->rootL ayer()->layoutObject(), DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags()); 55 LayerClipRecorder LayerClipRecorder(context, *layoutView.compositor()->rootL ayer()->layoutObject(), DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags());
56 } 56 }
57 57
58 void drawRectInClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase, const FloatRect& bound) 58 void drawRectInClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase, const FloatRect& bound)
59 { 59 {
60 IntRect rect(1, 1, 9, 9); 60 IntRect rect(1, 1, 9, 9);
61 ClipRect clipRect((LayoutRect(rect))); 61 ClipRect clipRect((LayoutRect(rect)));
62 LayerClipRecorder LayerClipRecorder(context, *layoutView.compositor()->rootL ayer()->layoutObject(), DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags()); 62 LayerClipRecorder LayerClipRecorder(context, *layoutView.compositor()->rootL ayer()->layoutObject(), DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags());
63 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun d); 63 if (!LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layout View, phase)) {
64 if (!drawingRecorder.canUseCachedDrawing()) 64 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, bound);
65 context.drawRect(rect); 65 context.drawRect(rect);
66 }
66 } 67 }
67 68
68 TEST_F(LayerClipRecorderTest, Single) 69 TEST_F(LayerClipRecorderTest, Single)
69 { 70 {
70 GraphicsContext context(&rootDisplayItemList()); 71 GraphicsContext context(&rootDisplayItemList());
71 FloatRect bound = layoutView().viewRect(); 72 FloatRect bound = layoutView().viewRect();
72 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); 73 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size());
73 74
74 drawRectInClip(context, layoutView(), PaintPhaseForeground, bound); 75 drawRectInClip(context, layoutView(), PaintPhaseForeground, bound);
75 rootDisplayItemList().commitNewDisplayItems(); 76 rootDisplayItemList().commitNewDisplayItems();
76 EXPECT_EQ((size_t)3, rootDisplayItemList().displayItems().size()); 77 EXPECT_EQ((size_t)3, rootDisplayItemList().displayItems().size());
77 EXPECT_TRUE(DisplayItem::isClipType(rootDisplayItemList().displayItems().ele mentAt(0)->type())); 78 EXPECT_TRUE(DisplayItem::isClipType(rootDisplayItemList().displayItems().ele mentAt(0)->type()));
78 EXPECT_TRUE(DisplayItem::isDrawingType(rootDisplayItemList().displayItems(). elementAt(1)->type())); 79 EXPECT_TRUE(DisplayItem::isDrawingType(rootDisplayItemList().displayItems(). elementAt(1)->type()));
79 EXPECT_TRUE(DisplayItem::isEndClipType(rootDisplayItemList().displayItems(). elementAt(2)->type())); 80 EXPECT_TRUE(DisplayItem::isEndClipType(rootDisplayItemList().displayItems(). elementAt(2)->type()));
80 } 81 }
81 82
82 TEST_F(LayerClipRecorderTest, Empty) 83 TEST_F(LayerClipRecorderTest, Empty)
83 { 84 {
84 GraphicsContext context(&rootDisplayItemList()); 85 GraphicsContext context(&rootDisplayItemList());
85 FloatRect bound = layoutView().viewRect(); 86 FloatRect bound = layoutView().viewRect();
86 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); 87 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size());
87 88
88 drawEmptyClip(context, layoutView(), PaintPhaseForeground, bound); 89 drawEmptyClip(context, layoutView(), PaintPhaseForeground, bound);
89 rootDisplayItemList().commitNewDisplayItems(); 90 rootDisplayItemList().commitNewDisplayItems();
90 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); 91 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size());
91 } 92 }
92 93
93 } 94 }
94 } 95 }
OLDNEW
« no previous file with comments | « Source/core/paint/InlineTextBoxPainter.cpp ('k') | Source/core/paint/LayoutObjectDrawingRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698