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

Side by Side Diff: Source/web/PageOverlayTest.cpp

Issue 1264483002: PageOverlays: Remove PageOverlayList (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "web/PageOverlay.h" 6 #include "web/PageOverlay.h"
7 7
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "platform/graphics/Color.h" 10 #include "platform/graphics/Color.h"
11 #include "platform/graphics/GraphicsContext.h" 11 #include "platform/graphics/GraphicsContext.h"
12 #include "platform/graphics/paint/DisplayItemList.h" 12 #include "platform/graphics/paint/DisplayItemList.h"
13 #include "platform/graphics/paint/DrawingRecorder.h" 13 #include "platform/graphics/paint/DrawingRecorder.h"
14 #include "public/platform/Platform.h" 14 #include "public/platform/Platform.h"
15 #include "public/platform/WebCanvas.h" 15 #include "public/platform/WebCanvas.h"
16 #include "public/platform/WebThread.h" 16 #include "public/platform/WebThread.h"
17 #include "public/web/WebPageOverlay.h"
18 #include "public/web/WebSettings.h" 17 #include "public/web/WebSettings.h"
19 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
20 #include "third_party/skia/include/core/SkCanvas.h" 19 #include "third_party/skia/include/core/SkCanvas.h"
21 #include "third_party/skia/include/core/SkColor.h" 20 #include "third_party/skia/include/core/SkColor.h"
22 #include "third_party/skia/include/core/SkPaint.h" 21 #include "third_party/skia/include/core/SkPaint.h"
23 #include "web/WebGraphicsContextImpl.h" 22 #include "web/WebGraphicsContextImpl.h"
24 #include "web/WebLocalFrameImpl.h" 23 #include "web/WebLocalFrameImpl.h"
24 #include "web/WebPageOverlay.h"
25 #include "web/WebViewImpl.h" 25 #include "web/WebViewImpl.h"
26 #include "web/tests/FrameTestHelpers.h" 26 #include "web/tests/FrameTestHelpers.h"
27 #include <gmock/gmock.h> 27 #include <gmock/gmock.h>
28 #include <gtest/gtest.h> 28 #include <gtest/gtest.h>
29 29
30 using testing::_; 30 using testing::_;
31 using testing::AtLeast; 31 using testing::AtLeast;
32 using testing::Property; 32 using testing::Property;
33 33
34 namespace blink { 34 namespace blink {
(...skipping 19 matching lines...) Expand all
54 enum CompositingMode { AcceleratedCompositing, UnacceleratedCompositing }; 54 enum CompositingMode { AcceleratedCompositing, UnacceleratedCompositing };
55 55
56 void initialize(CompositingMode compositingMode) 56 void initialize(CompositingMode compositingMode)
57 { 57 {
58 m_helper.initialize( 58 m_helper.initialize(
59 false /* enableJavascript */, nullptr /* webFrameClient */, nullptr /* webViewClient */, 59 false /* enableJavascript */, nullptr /* webFrameClient */, nullptr /* webViewClient */,
60 compositingMode == AcceleratedCompositing ? enableAcceleratedComposi ting : disableAcceleratedCompositing); 60 compositingMode == AcceleratedCompositing ? enableAcceleratedComposi ting : disableAcceleratedCompositing);
61 webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); 61 webViewImpl()->resize(WebSize(viewportWidth, viewportHeight));
62 webViewImpl()->layout(); 62 webViewImpl()->layout();
63 ASSERT_EQ(compositingMode == AcceleratedCompositing, webViewImpl()->isAc celeratedCompositingActive()); 63 ASSERT_EQ(compositingMode == AcceleratedCompositing, webViewImpl()->isAc celeratedCompositingActive());
64 ASSERT_TRUE(!webViewImpl()->pageOverlays() || webViewImpl()->pageOverlay s()->empty()); 64 ASSERT_TRUE(!webViewImpl()->pageOverlay());
65 } 65 }
66 66
67 WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); } 67 WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); }
68 68
69 template <typename OverlayType> 69 template <typename OverlayType>
70 void runPageOverlayTestWithUnacceleratedCompositing(); 70 void runPageOverlayTestWithUnacceleratedCompositing();
71 71
72 template <typename OverlayType> 72 template <typename OverlayType>
73 void runPageOverlayTestWithAcceleratedCompositing(); 73 void runPageOverlayTestWithAcceleratedCompositing();
74 74
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 MOCK_METHOD2(onDrawRect, void(const SkRect&, const SkPaint&)); 135 MOCK_METHOD2(onDrawRect, void(const SkRect&, const SkPaint&));
136 }; 136 };
137 137
138 template <typename OverlayType> 138 template <typename OverlayType>
139 void PageOverlayTest::runPageOverlayTestWithUnacceleratedCompositing() 139 void PageOverlayTest::runPageOverlayTestWithUnacceleratedCompositing()
140 { 140 {
141 initialize(UnacceleratedCompositing); 141 initialize(UnacceleratedCompositing);
142 142
143 OverlayType overlay(SK_ColorYELLOW); 143 OverlayType overlay(SK_ColorYELLOW);
144 webViewImpl()->addPageOverlay(&overlay, 0 /* zOrder */); 144 webViewImpl()->addPageOverlay(&overlay, 0 /* zOrder */);
145 EXPECT_TRUE(webViewImpl()->pageOverlays() && !webViewImpl()->pageOverlays()- >empty()); 145 EXPECT_TRUE(webViewImpl()->pageOverlay());
146 webViewImpl()->layout(); 146 webViewImpl()->layout();
147 147
148 MockCanvas canvas(viewportWidth, viewportHeight); 148 MockCanvas canvas(viewportWidth, viewportHeight);
149 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(1)); 149 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(1));
150 EXPECT_CALL(canvas, onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight) , Property(&SkPaint::getColor, SK_ColorYELLOW))); 150 EXPECT_CALL(canvas, onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight) , Property(&SkPaint::getColor, SK_ColorYELLOW)));
151 webViewImpl()->paint(&canvas, WebRect(0, 0, viewportWidth, viewportHeight)); 151 webViewImpl()->paint(&canvas, WebRect(0, 0, viewportWidth, viewportHeight));
152 } 152 }
153 153
154 TEST_F(PageOverlayTest, SimpleCanvasOverlay_UnacceleratedCompositing_NoSlimmingP aint) 154 TEST_F(PageOverlayTest, SimpleCanvasOverlay_UnacceleratedCompositing_NoSlimmingP aint)
155 { 155 {
(...skipping 20 matching lines...) Expand all
176 } 176 }
177 177
178 template <typename OverlayType> 178 template <typename OverlayType>
179 void PageOverlayTest::runPageOverlayTestWithAcceleratedCompositing() 179 void PageOverlayTest::runPageOverlayTestWithAcceleratedCompositing()
180 { 180 {
181 initialize(AcceleratedCompositing); 181 initialize(AcceleratedCompositing);
182 webViewImpl()->layerTreeView()->setViewportSize(WebSize(viewportWidth, viewp ortHeight)); 182 webViewImpl()->layerTreeView()->setViewportSize(WebSize(viewportWidth, viewp ortHeight));
183 183
184 OverlayType overlay(SK_ColorYELLOW); 184 OverlayType overlay(SK_ColorYELLOW);
185 webViewImpl()->addPageOverlay(&overlay, 0 /* zOrder */); 185 webViewImpl()->addPageOverlay(&overlay, 0 /* zOrder */);
186 EXPECT_TRUE(webViewImpl()->pageOverlays() && !webViewImpl()->pageOverlays()- >empty()); 186 EXPECT_TRUE(webViewImpl()->pageOverlay());
187 webViewImpl()->layout(); 187 webViewImpl()->layout();
188 188
189 // Ideally, we would get results from the compositor that showed that this 189 // Ideally, we would get results from the compositor that showed that this
190 // page overlay actually winds up getting drawn on top of the rest. 190 // page overlay actually winds up getting drawn on top of the rest.
191 // For now, we just check that the GraphicsLayer will draw the right thing. 191 // For now, we just check that the GraphicsLayer will draw the right thing.
192 192
193 MockCanvas canvas(viewportWidth, viewportHeight); 193 MockCanvas canvas(viewportWidth, viewportHeight);
194 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(0)); 194 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(0));
195 EXPECT_CALL(canvas, onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight) , Property(&SkPaint::getColor, SK_ColorYELLOW))); 195 EXPECT_CALL(canvas, onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight) , Property(&SkPaint::getColor, SK_ColorYELLOW)));
196 196
197 GraphicsLayer* graphicsLayer = webViewImpl()->pageOverlays()->graphicsLayerF orTesting(); 197 GraphicsLayer* graphicsLayer = webViewImpl()->pageOverlay()->graphicsLayer() ;
198 WebRect rect(0, 0, viewportWidth, viewportHeight); 198 WebRect rect(0, 0, viewportWidth, viewportHeight);
199 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 199 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
200 // If slimming paint is on, we paint the layer with a null canvas to get 200 // If slimming paint is on, we paint the layer with a null canvas to get
201 // a display list, and then replay that onto the mock canvas for 201 // a display list, and then replay that onto the mock canvas for
202 // examination. This is about as close to the real path as we can easily 202 // examination. This is about as close to the real path as we can easily
203 // get. 203 // get.
204 GraphicsContext graphicsContext(graphicsLayer->displayItemList()); 204 GraphicsContext graphicsContext(graphicsLayer->displayItemList());
205 graphicsLayer->paint(graphicsContext, rect); 205 graphicsLayer->paint(graphicsContext, rect);
206 206
207 graphicsContext.beginRecording(IntRect(rect)); 207 graphicsContext.beginRecording(IntRect(rect));
(...skipping 24 matching lines...) Expand all
232 } 232 }
233 233
234 TEST_F(PageOverlayTest, PrivateGraphicsContextOverlay_AcceleratedCompositing_Sli mmingPaint) 234 TEST_F(PageOverlayTest, PrivateGraphicsContextOverlay_AcceleratedCompositing_Sli mmingPaint)
235 { 235 {
236 SlimmingPaintScope slimmingPaintEnabled(true); 236 SlimmingPaintScope slimmingPaintEnabled(true);
237 runPageOverlayTestWithAcceleratedCompositing<PrivateGraphicsContextOverlay>( ); 237 runPageOverlayTestWithAcceleratedCompositing<PrivateGraphicsContextOverlay>( );
238 } 238 }
239 239
240 } // namespace 240 } // namespace
241 } // namespace blink 241 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698