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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 11264056: cc: Use gfx:: Geometry types for positions, bounds, and related things. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some missed intstuff Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 6
7 #include "cc/layer_tree_host_impl.h" 7 #include "cc/layer_tree_host_impl.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 18 matching lines...) Expand all
29 #include "cc/test/layer_test_common.h" 29 #include "cc/test/layer_test_common.h"
30 #include "cc/test/render_pass_test_common.h" 30 #include "cc/test/render_pass_test_common.h"
31 #include "cc/test/test_common.h" 31 #include "cc/test/test_common.h"
32 #include "cc/texture_draw_quad.h" 32 #include "cc/texture_draw_quad.h"
33 #include "cc/texture_layer_impl.h" 33 #include "cc/texture_layer_impl.h"
34 #include "cc/tile_draw_quad.h" 34 #include "cc/tile_draw_quad.h"
35 #include "cc/tiled_layer_impl.h" 35 #include "cc/tiled_layer_impl.h"
36 #include "cc/video_layer_impl.h" 36 #include "cc/video_layer_impl.h"
37 #include "testing/gmock/include/gmock/gmock.h" 37 #include "testing/gmock/include/gmock/gmock.h"
38 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
39 #include "ui/gfx/size_conversions.h"
39 #include <public/WebVideoFrame.h> 40 #include <public/WebVideoFrame.h>
40 #include <public/WebVideoFrameProvider.h> 41 #include <public/WebVideoFrameProvider.h>
41 42
42 using namespace cc; 43 using namespace cc;
43 using namespace LayerTestCommon; 44 using namespace LayerTestCommon;
44 using namespace WebKit; 45 using namespace WebKit;
45 using namespace WebKitTests; 46 using namespace WebKitTests;
46 47
47 using ::testing::Mock; 48 using ::testing::Mock;
48 using ::testing::Return; 49 using ::testing::Return;
(...skipping 13 matching lines...) Expand all
62 , m_didRequestCommit(false) 63 , m_didRequestCommit(false)
63 , m_didRequestRedraw(false) 64 , m_didRequestRedraw(false)
64 , m_reduceMemoryResult(true) 65 , m_reduceMemoryResult(true)
65 { 66 {
66 } 67 }
67 68
68 virtual void SetUp() 69 virtual void SetUp()
69 { 70 {
70 Settings::setPageScalePinchZoomEnabled(GetParam()); 71 Settings::setPageScalePinchZoomEnabled(GetParam());
71 LayerTreeSettings settings; 72 LayerTreeSettings settings;
72 settings.minimumOcclusionTrackingSize = IntSize(); 73 settings.minimumOcclusionTrackingSize = gfx::Size();
73 74
74 m_hostImpl = LayerTreeHostImpl::create(settings, this); 75 m_hostImpl = LayerTreeHostImpl::create(settings, this);
75 m_hostImpl->initializeRenderer(createContext()); 76 m_hostImpl->initializeRenderer(createContext());
76 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 77 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
77 } 78 }
78 79
79 virtual void TearDown() 80 virtual void TearDown()
80 { 81 {
81 } 82 }
82 83
83 virtual void didLoseContextOnImplThread() OVERRIDE { } 84 virtual void didLoseContextOnImplThread() OVERRIDE { }
84 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } 85 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
85 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } 86 virtual void onVSyncParametersChanged(double, double) OVERRIDE { }
86 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; } 87 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; }
87 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; } 88 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; }
88 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; } 89 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; }
89 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio nEventsVector>, double wallClockTime) OVERRIDE { } 90 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio nEventsVector>, double wallClockTime) OVERRIDE { }
90 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } 91 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE { return m_reduceMemoryResult; }
91 92
92 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; } 93 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; }
93 94
94 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) 95 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root)
95 { 96 {
96 Settings::setPartialSwapEnabled(partialSwap); 97 Settings::setPartialSwapEnabled(partialSwap);
97 98
98 LayerTreeSettings settings; 99 LayerTreeSettings settings;
99 settings.minimumOcclusionTrackingSize = IntSize(); 100 settings.minimumOcclusionTrackingSize = gfx::Size();
100 101
101 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set tings, this); 102 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set tings, this);
102 103
103 myHostImpl->initializeRenderer(graphicsContext.Pass()); 104 myHostImpl->initializeRenderer(graphicsContext.Pass());
104 myHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 105 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
105 106
106 root->setAnchorPoint(FloatPoint(0, 0)); 107 root->setAnchorPoint(gfx::PointF(0, 0));
107 root->setPosition(FloatPoint(0, 0)); 108 root->setPosition(gfx::PointF(0, 0));
108 root->setBounds(IntSize(10, 10)); 109 root->setBounds(gfx::Size(10, 10));
109 root->setContentBounds(IntSize(10, 10)); 110 root->setContentBounds(gfx::Size(10, 10));
110 root->setVisibleContentRect(IntRect(0, 0, 10, 10)); 111 root->setVisibleContentRect(gfx::Rect(0, 0, 10, 10));
111 root->setDrawsContent(true); 112 root->setDrawsContent(true);
112 myHostImpl->setRootLayer(root.Pass()); 113 myHostImpl->setRootLayer(root.Pass());
113 return myHostImpl.Pass(); 114 return myHostImpl.Pass();
114 } 115 }
115 116
116 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) 117 static void expectClearedScrollDeltasRecursive(LayerImpl* layer)
117 { 118 {
118 ASSERT_EQ(layer->scrollDelta(), IntSize()); 119 ASSERT_EQ(layer->scrollDelta(), IntSize());
119 for (size_t i = 0; i < layer->children().size(); ++i) 120 for (size_t i = 0; i < layer->children().size(); ++i)
120 expectClearedScrollDeltasRecursive(layer->children()[i]); 121 expectClearedScrollDeltasRecursive(layer->children()[i]);
121 } 122 }
122 123
123 static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, cons t IntSize& scrollDelta) 124 static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, cons t IntSize& scrollDelta)
124 { 125 {
125 int timesEncountered = 0; 126 int timesEncountered = 0;
126 127
127 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { 128 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) {
128 if (scrollInfo.scrolls[i].layerId != id) 129 if (scrollInfo.scrolls[i].layerId != id)
129 continue; 130 continue;
130 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid th()); 131 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid th());
131 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he ight()); 132 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he ight());
132 timesEncountered++; 133 timesEncountered++;
133 } 134 }
134 135
135 ASSERT_EQ(timesEncountered, 1); 136 ASSERT_EQ(timesEncountered, 1);
136 } 137 }
137 138
138 void setupScrollAndContentsLayers(const IntSize& contentSize) 139 void setupScrollAndContentsLayers(const gfx::Size& contentSize)
139 { 140 {
140 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 141 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
141 root->setScrollable(true); 142 root->setScrollable(true);
142 root->setScrollPosition(IntPoint(0, 0)); 143 root->setScrollPosition(IntPoint(0, 0));
143 root->setMaxScrollPosition(contentSize); 144 root->setMaxScrollPosition(cc::IntSize(contentSize));
144 root->setBounds(contentSize); 145 root->setBounds(contentSize);
145 root->setContentBounds(contentSize); 146 root->setContentBounds(contentSize);
146 root->setPosition(FloatPoint(0, 0)); 147 root->setPosition(gfx::PointF(0, 0));
147 root->setAnchorPoint(FloatPoint(0, 0)); 148 root->setAnchorPoint(gfx::PointF(0, 0));
148 149
149 scoped_ptr<LayerImpl> contents = LayerImpl::create(2); 150 scoped_ptr<LayerImpl> contents = LayerImpl::create(2);
150 contents->setDrawsContent(true); 151 contents->setDrawsContent(true);
151 contents->setBounds(contentSize); 152 contents->setBounds(contentSize);
152 contents->setContentBounds(contentSize); 153 contents->setContentBounds(contentSize);
153 contents->setPosition(FloatPoint(0, 0)); 154 contents->setPosition(gfx::PointF(0, 0));
154 contents->setAnchorPoint(FloatPoint(0, 0)); 155 contents->setAnchorPoint(gfx::PointF(0, 0));
155 root->addChild(contents.Pass()); 156 root->addChild(contents.Pass());
156 m_hostImpl->setRootLayer(root.Pass()); 157 m_hostImpl->setRootLayer(root.Pass());
157 } 158 }
158 159
159 static scoped_ptr<LayerImpl> createScrollableLayer(int id, const IntSize& si ze) 160 static scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size)
160 { 161 {
161 scoped_ptr<LayerImpl> layer = LayerImpl::create(id); 162 scoped_ptr<LayerImpl> layer = LayerImpl::create(id);
162 layer->setScrollable(true); 163 layer->setScrollable(true);
163 layer->setDrawsContent(true); 164 layer->setDrawsContent(true);
164 layer->setBounds(size); 165 layer->setBounds(size);
165 layer->setContentBounds(size); 166 layer->setContentBounds(size);
166 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2) ); 167 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2) );
167 return layer.Pass(); 168 return layer.Pass();
168 } 169 }
169 170
(...skipping 29 matching lines...) Expand all
199 }; 200 };
200 201
201 TEST_P(LayerTreeHostImplTest, notifyIfCanDrawChanged) 202 TEST_P(LayerTreeHostImplTest, notifyIfCanDrawChanged)
202 { 203 {
203 // Note: It is not possible to disable the renderer once it has been set, 204 // Note: It is not possible to disable the renderer once it has been set,
204 // so we do not need to test that disabling the renderer notifies us 205 // so we do not need to test that disabling the renderer notifies us
205 // that canDraw changed. 206 // that canDraw changed.
206 EXPECT_FALSE(m_hostImpl->canDraw()); 207 EXPECT_FALSE(m_hostImpl->canDraw());
207 m_onCanDrawStateChangedCalled = false; 208 m_onCanDrawStateChangedCalled = false;
208 209
209 setupScrollAndContentsLayers(IntSize(100, 100)); 210 setupScrollAndContentsLayers(gfx::Size(100, 100));
210 EXPECT_TRUE(m_hostImpl->canDraw()); 211 EXPECT_TRUE(m_hostImpl->canDraw());
211 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 212 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
212 m_onCanDrawStateChangedCalled = false; 213 m_onCanDrawStateChangedCalled = false;
213 214
214 // Toggle the root layer to make sure it toggles canDraw 215 // Toggle the root layer to make sure it toggles canDraw
215 m_hostImpl->setRootLayer(scoped_ptr<LayerImpl>()); 216 m_hostImpl->setRootLayer(scoped_ptr<LayerImpl>());
216 EXPECT_FALSE(m_hostImpl->canDraw()); 217 EXPECT_FALSE(m_hostImpl->canDraw());
217 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 218 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
218 m_onCanDrawStateChangedCalled = false; 219 m_onCanDrawStateChangedCalled = false;
219 220
220 setupScrollAndContentsLayers(IntSize(100, 100)); 221 setupScrollAndContentsLayers(gfx::Size(100, 100));
221 EXPECT_TRUE(m_hostImpl->canDraw()); 222 EXPECT_TRUE(m_hostImpl->canDraw());
222 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 223 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
223 m_onCanDrawStateChangedCalled = false; 224 m_onCanDrawStateChangedCalled = false;
224 225
225 // Toggle the device viewport size to make sure it toggles canDraw. 226 // Toggle the device viewport size to make sure it toggles canDraw.
226 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(0, 0)); 227 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(0, 0));
227 EXPECT_FALSE(m_hostImpl->canDraw()); 228 EXPECT_FALSE(m_hostImpl->canDraw());
228 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 229 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
229 m_onCanDrawStateChangedCalled = false; 230 m_onCanDrawStateChangedCalled = false;
230 231
231 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); 232 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
232 EXPECT_TRUE(m_hostImpl->canDraw()); 233 EXPECT_TRUE(m_hostImpl->canDraw());
233 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 234 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
234 m_onCanDrawStateChangedCalled = false; 235 m_onCanDrawStateChangedCalled = false;
235 236
236 // Toggle contents textures purged without causing any evictions, 237 // Toggle contents textures purged without causing any evictions,
237 // and make sure that it does not change canDraw. 238 // and make sure that it does not change canDraw.
238 setReduceMemoryResult(false); 239 setReduceMemoryResult(false);
239 m_hostImpl->setManagedMemoryPolicy(ManagedMemoryPolicy( 240 m_hostImpl->setManagedMemoryPolicy(ManagedMemoryPolicy(
240 m_hostImpl->memoryAllocationLimitBytes() - 1)); 241 m_hostImpl->memoryAllocationLimitBytes() - 1));
241 EXPECT_TRUE(m_hostImpl->canDraw()); 242 EXPECT_TRUE(m_hostImpl->canDraw());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); 319 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
319 expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2); 320 expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2);
320 321
321 root->scrollBy(IntSize()); 322 root->scrollBy(IntSize());
322 scrollInfo = m_hostImpl->processScrollDeltas(); 323 scrollInfo = m_hostImpl->processScrollDeltas();
323 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); 324 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
324 } 325 }
325 326
326 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) 327 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
327 { 328 {
328 setupScrollAndContentsLayers(IntSize(100, 100)); 329 setupScrollAndContentsLayers(gfx::Size(100, 100));
329 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 330 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
330 initializeRendererAndDrawFrame(); 331 initializeRendererAndDrawFrame();
331 332
332 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted); 333 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted);
333 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); 334 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10));
334 m_hostImpl->scrollEnd(); 335 m_hostImpl->scrollEnd();
335 EXPECT_TRUE(m_didRequestRedraw); 336 EXPECT_TRUE(m_didRequestRedraw);
336 EXPECT_TRUE(m_didRequestCommit); 337 EXPECT_TRUE(m_didRequestCommit);
337 } 338 }
338 339
339 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) 340 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer)
340 { 341 {
341 // We should not crash when trying to scroll an empty layer tree. 342 // We should not crash when trying to scroll an empty layer tree.
342 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollIgnored); 343 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollIgnored);
343 } 344 }
344 345
345 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) 346 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer)
346 { 347 {
347 LayerTreeSettings settings; 348 LayerTreeSettings settings;
348 m_hostImpl = LayerTreeHostImpl::create(settings, this); 349 m_hostImpl = LayerTreeHostImpl::create(settings, this);
349 350
350 // Initialization will fail here. 351 // Initialization will fail here.
351 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails) ).PassAs<GraphicsContext>()); 352 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails) ).PassAs<GraphicsContext>());
352 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 353 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
353 354
354 setupScrollAndContentsLayers(IntSize(100, 100)); 355 setupScrollAndContentsLayers(gfx::Size(100, 100));
355 356
356 // We should not crash when trying to scroll after the renderer initializati on fails. 357 // We should not crash when trying to scroll after the renderer initializati on fails.
357 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollIgnored); 358 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollIgnored);
358 } 359 }
359 360
360 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) 361 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling)
361 { 362 {
362 const int scrollLayerId = 1; 363 const int scrollLayerId = 1;
363 364
364 setupScrollAndContentsLayers(IntSize(100, 100)); 365 setupScrollAndContentsLayers(gfx::Size(100, 100));
365 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 366 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
366 initializeRendererAndDrawFrame(); 367 initializeRendererAndDrawFrame();
367 368
368 // We should not crash if the tree is replaced while we are scrolling. 369 // We should not crash if the tree is replaced while we are scrolling.
369 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted); 370 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted);
370 m_hostImpl->detachLayerTree(); 371 m_hostImpl->detachLayerTree();
371 372
372 setupScrollAndContentsLayers(IntSize(100, 100)); 373 setupScrollAndContentsLayers(gfx::Size(100, 100));
373 374
374 // We should still be scrolling, because the scrolled layer also exists in t he new tree. 375 // We should still be scrolling, because the scrolled layer also exists in t he new tree.
375 IntSize scrollDelta(0, 10); 376 IntSize scrollDelta(0, 10);
376 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 377 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
377 m_hostImpl->scrollEnd(); 378 m_hostImpl->scrollEnd();
378 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 379 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
379 expectContains(*scrollInfo, scrollLayerId, scrollDelta); 380 expectContains(*scrollInfo, scrollLayerId, scrollDelta);
380 } 381 }
381 382
382 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) 383 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll)
383 { 384 {
384 setupScrollAndContentsLayers(IntSize(100, 100)); 385 setupScrollAndContentsLayers(gfx::Size(100, 100));
385 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 386 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
386 initializeRendererAndDrawFrame(); 387 initializeRendererAndDrawFrame();
387 388
388 // We should be able to scroll even if the root layer loses its render surfa ce after the most 389 // We should be able to scroll even if the root layer loses its render surfa ce after the most
389 // recent render. 390 // recent render.
390 m_hostImpl->rootLayer()->clearRenderSurface(); 391 m_hostImpl->rootLayer()->clearRenderSurface();
391 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted); 392 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted);
392 } 393 }
393 394
394 TEST_P(LayerTreeHostImplTest, wheelEventHandlers) 395 TEST_P(LayerTreeHostImplTest, wheelEventHandlers)
395 { 396 {
396 setupScrollAndContentsLayers(IntSize(100, 100)); 397 setupScrollAndContentsLayers(gfx::Size(100, 100));
397 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 398 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
398 initializeRendererAndDrawFrame(); 399 initializeRendererAndDrawFrame();
399 LayerImpl* root = m_hostImpl->rootLayer(); 400 LayerImpl* root = m_hostImpl->rootLayer();
400 401
401 root->setHaveWheelEventHandlers(true); 402 root->setHaveWheelEventHandlers(true);
402 403
403 // With registered event handlers, wheel scrolls have to go to the main thre ad. 404 // With registered event handlers, wheel scrolls have to go to the main thre ad.
404 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollOnMainThread); 405 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollOnMainThread);
405 406
406 // But gesture scrolls can still be handled. 407 // But gesture scrolls can still be handled.
407 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur e), InputHandlerClient::ScrollStarted); 408 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur e), InputHandlerClient::ScrollStarted);
408 } 409 }
409 410
410 TEST_P(LayerTreeHostImplTest, shouldScrollOnMainThread) 411 TEST_P(LayerTreeHostImplTest, shouldScrollOnMainThread)
411 { 412 {
412 setupScrollAndContentsLayers(IntSize(100, 100)); 413 setupScrollAndContentsLayers(gfx::Size(100, 100));
413 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 414 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
414 initializeRendererAndDrawFrame(); 415 initializeRendererAndDrawFrame();
415 LayerImpl* root = m_hostImpl->rootLayer(); 416 LayerImpl* root = m_hostImpl->rootLayer();
416 417
417 root->setShouldScrollOnMainThread(true); 418 root->setShouldScrollOnMainThread(true);
418 419
419 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollOnMainThread); 420 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollOnMainThread);
420 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur e), InputHandlerClient::ScrollOnMainThread); 421 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur e), InputHandlerClient::ScrollOnMainThread);
421 } 422 }
422 423
423 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionBasic) 424 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionBasic)
424 { 425 {
425 setupScrollAndContentsLayers(IntSize(200, 200)); 426 setupScrollAndContentsLayers(gfx::Size(200, 200));
426 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); 427 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
427 initializeRendererAndDrawFrame(); 428 initializeRendererAndDrawFrame();
428 LayerImpl* root = m_hostImpl->rootLayer(); 429 LayerImpl* root = m_hostImpl->rootLayer();
429 430
430 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); 431 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50));
431 432
432 // All scroll types inside the non-fast scrollable region should fail. 433 // All scroll types inside the non-fast scrollable region should fail.
433 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Whee l), InputHandlerClient::ScrollOnMainThread); 434 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Whee l), InputHandlerClient::ScrollOnMainThread);
434 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Gest ure), InputHandlerClient::ScrollOnMainThread); 435 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Gest ure), InputHandlerClient::ScrollOnMainThread);
435 436
436 // All scroll types outside this region should succeed. 437 // All scroll types outside this region should succeed.
437 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 438 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
438 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); 439 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10));
439 m_hostImpl->scrollEnd(); 440 m_hostImpl->scrollEnd();
440 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 441 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
441 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); 442 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10));
442 m_hostImpl->scrollEnd(); 443 m_hostImpl->scrollEnd();
443 } 444 }
444 445
445 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) 446 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset)
446 { 447 {
447 setupScrollAndContentsLayers(IntSize(200, 200)); 448 setupScrollAndContentsLayers(gfx::Size(200, 200));
448 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); 449 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
449 LayerImpl* root = m_hostImpl->rootLayer(); 450 LayerImpl* root = m_hostImpl->rootLayer();
450 451
451 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); 452 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50));
452 root->setPosition(FloatPoint(-25, 0)); 453 root->setPosition(gfx::PointF(-25, 0));
453 initializeRendererAndDrawFrame(); 454 initializeRendererAndDrawFrame();
454 455
455 // This point would fall into the non-fast scrollable region except that we' ve moved the layer down by 25 pixels. 456 // This point would fall into the non-fast scrollable region except that we' ve moved the layer down by 25 pixels.
456 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(40, 10), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 457 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(40, 10), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
457 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 1)); 458 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 1));
458 m_hostImpl->scrollEnd(); 459 m_hostImpl->scrollEnd();
459 460
460 // This point is still inside the non-fast region. 461 // This point is still inside the non-fast region.
461 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), InputHandlerClient::Whee l), InputHandlerClient::ScrollOnMainThread); 462 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), InputHandlerClient::Whee l), InputHandlerClient::ScrollOnMainThread);
462 } 463 }
463 464
464 TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor) 465 TEST_P(LayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor)
465 { 466 {
466 setupScrollAndContentsLayers(IntSize(100, 100)); 467 setupScrollAndContentsLayers(gfx::Size(100, 100));
467 468
468 float deviceScaleFactor = 2; 469 float deviceScaleFactor = 2;
469 IntSize layoutViewport(25, 25); 470 gfx::Size layoutViewport(25, 25);
470 IntSize deviceViewport(layoutViewport); 471 gfx::Size deviceViewport(gfx::ToFlooredSize(layoutViewport.Scale(deviceScale Factor)));
471 deviceViewport.scale(deviceScaleFactor);
472 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); 472 m_hostImpl->setViewportSize(layoutViewport, deviceViewport);
473 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); 473 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
474 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25)); 474 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25));
475 475
476 deviceScaleFactor = 1; 476 deviceScaleFactor = 1;
477 m_hostImpl->setViewportSize(layoutViewport, layoutViewport); 477 m_hostImpl->setViewportSize(layoutViewport, layoutViewport);
478 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); 478 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
479 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75)); 479 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75));
480 } 480 }
481 481
482 TEST_P(LayerTreeHostImplTest, implPinchZoom) 482 TEST_P(LayerTreeHostImplTest, implPinchZoom)
483 { 483 {
484 // This test is specific to the page-scale based pinch zoom. 484 // This test is specific to the page-scale based pinch zoom.
485 if (!Settings::pageScalePinchZoomEnabled()) 485 if (!Settings::pageScalePinchZoomEnabled())
486 return; 486 return;
487 487
488 setupScrollAndContentsLayers(IntSize(100, 100)); 488 setupScrollAndContentsLayers(gfx::Size(100, 100));
489 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 489 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
490 initializeRendererAndDrawFrame(); 490 initializeRendererAndDrawFrame();
491 491
492 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 492 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
493 DCHECK(scrollLayer); 493 DCHECK(scrollLayer);
494 494
495 const float minPageScale = 1, maxPageScale = 4; 495 const float minPageScale = 1, maxPageScale = 4;
496 const WebTransformationMatrix identityScaleTransform; 496 const WebTransformationMatrix identityScaleTransform;
497 497
498 // The impl-based pinch zoome should not adjust the max scroll position. 498 // The impl-based pinch zoome should not adjust the max scroll position.
499 { 499 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 531 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
532 m_hostImpl->scrollEnd(); 532 m_hostImpl->scrollEnd();
533 533
534 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 534 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
535 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 535 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
536 } 536 }
537 } 537 }
538 538
539 TEST_P(LayerTreeHostImplTest, pinchGesture) 539 TEST_P(LayerTreeHostImplTest, pinchGesture)
540 { 540 {
541 setupScrollAndContentsLayers(IntSize(100, 100)); 541 setupScrollAndContentsLayers(gfx::Size(100, 100));
542 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 542 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
543 initializeRendererAndDrawFrame(); 543 initializeRendererAndDrawFrame();
544 544
545 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 545 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
546 DCHECK(scrollLayer); 546 DCHECK(scrollLayer);
547 547
548 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; 548 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5;
549 const float maxPageScale = 4; 549 const float maxPageScale = 4;
550 const WebTransformationMatrix identityScaleTransform; 550 const WebTransformationMatrix identityScaleTransform;
551 551
552 // Basic pinch zoom in gesture 552 // Basic pinch zoom in gesture
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 m_hostImpl->pinchGestureEnd(); 618 m_hostImpl->pinchGestureEnd();
619 619
620 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 620 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
621 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 621 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
622 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); 622 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10));
623 } 623 }
624 } 624 }
625 625
626 TEST_P(LayerTreeHostImplTest, pageScaleAnimation) 626 TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
627 { 627 {
628 setupScrollAndContentsLayers(IntSize(100, 100)); 628 setupScrollAndContentsLayers(gfx::Size(100, 100));
629 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 629 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
630 initializeRendererAndDrawFrame(); 630 initializeRendererAndDrawFrame();
631 631
632 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 632 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
633 DCHECK(scrollLayer); 633 DCHECK(scrollLayer);
634 634
635 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; 635 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5;
636 const float maxPageScale = 4; 636 const float maxPageScale = 4;
637 const double startTime = 1; 637 const double startTime = 1;
638 const double duration = 0.1; 638 const double duration = 0.1;
639 const double halfwayThroughAnimation = startTime + duration / 2; 639 const double halfwayThroughAnimation = startTime + duration / 2;
(...skipping 30 matching lines...) Expand all
670 670
671 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 671 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
672 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); 672 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
673 // Pushed to (0,0) via clamping against contents layer size. 673 // Pushed to (0,0) via clamping against contents layer size.
674 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); 674 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
675 } 675 }
676 } 676 }
677 677
678 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming) 678 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
679 { 679 {
680 setupScrollAndContentsLayers(IntSize(100, 100)); 680 setupScrollAndContentsLayers(gfx::Size(100, 100));
681 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 681 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
682 initializeRendererAndDrawFrame(); 682 initializeRendererAndDrawFrame();
683 683
684 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 684 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
685 DCHECK(scrollLayer); 685 DCHECK(scrollLayer);
686 686
687 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; 687 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5;
688 const float maxPageScale = 4; 688 const float maxPageScale = 4;
689 689
690 // Pinch zoom in. 690 // Pinch zoom in.
691 { 691 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); 739 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
740 } else { 740 } else {
741 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); 741 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta);
742 expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8)); 742 expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8));
743 } 743 }
744 } 744 }
745 } 745 }
746 746
747 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage Scale) 747 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage Scale)
748 { 748 {
749 setupScrollAndContentsLayers(IntSize(100, 100)); 749 setupScrollAndContentsLayers(gfx::Size(100, 100));
750 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 750 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
751 initializeRendererAndDrawFrame(); 751 initializeRendererAndDrawFrame();
752 752
753 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 753 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
754 DCHECK(scrollLayer); 754 DCHECK(scrollLayer);
755 755
756 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; 756 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5;
757 const float maxPageScale = 4; 757 const float maxPageScale = 4;
758 const double startTime = 1; 758 const double startTime = 1;
759 const double duration = 0.1; 759 const double duration = 0.1;
760 const double halfwayThroughAnimation = startTime + duration / 2; 760 const double halfwayThroughAnimation = startTime + duration / 2;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 m_didDrawCalled = false; 814 m_didDrawCalled = false;
815 m_willDrawCalled = false; 815 m_willDrawCalled = false;
816 } 816 }
817 817
818 protected: 818 protected:
819 explicit DidDrawCheckLayer(int id) 819 explicit DidDrawCheckLayer(int id)
820 : TiledLayerImpl(id) 820 : TiledLayerImpl(id)
821 , m_didDrawCalled(false) 821 , m_didDrawCalled(false)
822 , m_willDrawCalled(false) 822 , m_willDrawCalled(false)
823 { 823 {
824 setAnchorPoint(FloatPoint(0, 0)); 824 setAnchorPoint(gfx::PointF(0, 0));
825 setBounds(IntSize(10, 10)); 825 setBounds(gfx::Size(10, 10));
826 setContentBounds(IntSize(10, 10)); 826 setContentBounds(gfx::Size(10, 10));
827 setDrawsContent(true); 827 setDrawsContent(true);
828 setSkipsDraw(false); 828 setSkipsDraw(false);
829 setVisibleContentRect(IntRect(0, 0, 10, 10)); 829 setVisibleContentRect(gfx::Rect(0, 0, 10, 10));
830 830
831 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(IntSize(100, 100), LayerTilingData::HasBorderTexels); 831 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10 0, 100), LayerTilingData::HasBorderTexels);
832 tiler->setBounds(contentBounds()); 832 tiler->setBounds(contentBounds());
833 setTilingData(*tiler.get()); 833 setTilingData(*tiler.get());
834 } 834 }
835 835
836 private: 836 private:
837 bool m_didDrawCalled; 837 bool m_didDrawCalled;
838 bool m_willDrawCalled; 838 bool m_willDrawCalled;
839 }; 839 };
840 840
841 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) 841 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer)
842 { 842 {
843 // The root layer is always drawn, so run this test on a child layer that 843 // The root layer is always drawn, so run this test on a child layer that
844 // will be masked out by the root layer's bounds. 844 // will be masked out by the root layer's bounds.
845 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 845 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
846 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); 846 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer());
847 root->setMasksToBounds(true); 847 root->setMasksToBounds(true);
848 848
849 root->addChild(DidDrawCheckLayer::create(2)); 849 root->addChild(DidDrawCheckLayer::create(2));
850 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[ 0]); 850 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[ 0]);
851 // Ensure visibleContentRect for layer is empty 851 // Ensure visibleContentRect for layer is empty
852 layer->setPosition(FloatPoint(100, 100)); 852 layer->setPosition(gfx::PointF(100, 100));
853 layer->setBounds(IntSize(10, 10)); 853 layer->setBounds(gfx::Size(10, 10));
854 layer->setContentBounds(IntSize(10, 10)); 854 layer->setContentBounds(gfx::Size(10, 10));
855 855
856 LayerTreeHostImpl::FrameData frame; 856 LayerTreeHostImpl::FrameData frame;
857 857
858 EXPECT_FALSE(layer->willDrawCalled()); 858 EXPECT_FALSE(layer->willDrawCalled());
859 EXPECT_FALSE(layer->didDrawCalled()); 859 EXPECT_FALSE(layer->didDrawCalled());
860 860
861 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 861 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
862 m_hostImpl->drawLayers(frame); 862 m_hostImpl->drawLayers(frame);
863 m_hostImpl->didDrawAllLayers(frame); 863 m_hostImpl->didDrawAllLayers(frame);
864 864
865 EXPECT_FALSE(layer->willDrawCalled()); 865 EXPECT_FALSE(layer->willDrawCalled());
866 EXPECT_FALSE(layer->didDrawCalled()); 866 EXPECT_FALSE(layer->didDrawCalled());
867 867
868 EXPECT_TRUE(layer->visibleContentRect().isEmpty()); 868 EXPECT_TRUE(layer->visibleContentRect().IsEmpty());
869 869
870 // Ensure visibleContentRect for layer layer is not empty 870 // Ensure visibleContentRect for layer layer is not empty
871 layer->setPosition(FloatPoint(0, 0)); 871 layer->setPosition(gfx::PointF(0, 0));
872 872
873 EXPECT_FALSE(layer->willDrawCalled()); 873 EXPECT_FALSE(layer->willDrawCalled());
874 EXPECT_FALSE(layer->didDrawCalled()); 874 EXPECT_FALSE(layer->didDrawCalled());
875 875
876 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 876 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
877 m_hostImpl->drawLayers(frame); 877 m_hostImpl->drawLayers(frame);
878 m_hostImpl->didDrawAllLayers(frame); 878 m_hostImpl->didDrawAllLayers(frame);
879 879
880 EXPECT_TRUE(layer->willDrawCalled()); 880 EXPECT_TRUE(layer->willDrawCalled());
881 EXPECT_TRUE(layer->didDrawCalled()); 881 EXPECT_TRUE(layer->didDrawCalled());
882 882
883 EXPECT_FALSE(layer->visibleContentRect().isEmpty()); 883 EXPECT_FALSE(layer->visibleContentRect().IsEmpty());
884 } 884 }
885 885
886 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) 886 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer)
887 { 887 {
888 IntSize bigSize(1000, 1000); 888 gfx::Size bigSize(1000, 1000);
889 m_hostImpl->setViewportSize(bigSize, bigSize); 889 m_hostImpl->setViewportSize(bigSize, bigSize);
890 890
891 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 891 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
892 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); 892 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer());
893 893
894 root->addChild(DidDrawCheckLayer::create(2)); 894 root->addChild(DidDrawCheckLayer::create(2));
895 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi ldren()[0]); 895 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi ldren()[0]);
896 896
897 root->addChild(DidDrawCheckLayer::create(3)); 897 root->addChild(DidDrawCheckLayer::create(3));
898 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children ()[1]); 898 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children ()[1]);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 public: 953 public:
954 static scoped_ptr<LayerImpl> create(int id, bool tileMissing, bool skipsDraw , bool animating, ResourceProvider* resourceProvider) 954 static scoped_ptr<LayerImpl> create(int id, bool tileMissing, bool skipsDraw , bool animating, ResourceProvider* resourceProvider)
955 { 955 {
956 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(id, tileMi ssing, skipsDraw, animating, resourceProvider)); 956 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(id, tileMi ssing, skipsDraw, animating, resourceProvider));
957 } 957 }
958 958
959 private: 959 private:
960 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr aw, bool animating, ResourceProvider* resourceProvider) 960 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr aw, bool animating, ResourceProvider* resourceProvider)
961 : DidDrawCheckLayer(id) 961 : DidDrawCheckLayer(id)
962 { 962 {
963 scoped_ptr<LayerTilingData> tilingData = LayerTilingData::create(IntSize (10, 10), LayerTilingData::NoBorderTexels); 963 scoped_ptr<LayerTilingData> tilingData = LayerTilingData::create(gfx::Si ze(10, 10), LayerTilingData::NoBorderTexels);
964 tilingData->setBounds(bounds()); 964 tilingData->setBounds(bounds());
965 setTilingData(*tilingData.get()); 965 setTilingData(*tilingData.get());
966 setSkipsDraw(skipsDraw); 966 setSkipsDraw(skipsDraw);
967 if (!tileMissing) { 967 if (!tileMissing) {
968 ResourceProvider::ResourceId resource = resourceProvider->createReso urce(Renderer::ContentPool, IntSize(), GL_RGBA, ResourceProvider::TextureUsageAn y); 968 ResourceProvider::ResourceId resource = resourceProvider->createReso urce(Renderer::ContentPool, gfx::Size(), GL_RGBA, ResourceProvider::TextureUsage Any);
969 pushTileProperties(0, 0, resource, IntRect(), false); 969 pushTileProperties(0, 0, resource, gfx::Rect(), false);
970 } 970 }
971 if (animating) 971 if (animating)
972 addAnimatedTransformToLayer(*this, 10, 3, 0); 972 addAnimatedTransformToLayer(*this, 10, 3, 0);
973 } 973 }
974 }; 974 };
975 975
976 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) 976 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard)
977 { 977 {
978 // When the texture is not missing, we draw as usual. 978 // When the texture is not missing, we draw as usual.
979 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); 979 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 // Scroll event is ignored because layer is not scrollable. 1024 // Scroll event is ignored because layer is not scrollable.
1025 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollIgnored); 1025 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollIgnored);
1026 EXPECT_FALSE(m_didRequestRedraw); 1026 EXPECT_FALSE(m_didRequestRedraw);
1027 EXPECT_FALSE(m_didRequestCommit); 1027 EXPECT_FALSE(m_didRequestCommit);
1028 } 1028 }
1029 1029
1030 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) 1030 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot)
1031 { 1031 {
1032 // Test the configuration where a non-composited root layer is embedded in a 1032 // Test the configuration where a non-composited root layer is embedded in a
1033 // scrollable outer layer. 1033 // scrollable outer layer.
1034 IntSize surfaceSize(10, 10); 1034 gfx::Size surfaceSize(10, 10);
1035 1035
1036 scoped_ptr<LayerImpl> contentLayer = LayerImpl::create(1); 1036 scoped_ptr<LayerImpl> contentLayer = LayerImpl::create(1);
1037 contentLayer->setUseLCDText(true); 1037 contentLayer->setUseLCDText(true);
1038 contentLayer->setDrawsContent(true); 1038 contentLayer->setDrawsContent(true);
1039 contentLayer->setPosition(FloatPoint(0, 0)); 1039 contentLayer->setPosition(gfx::PointF(0, 0));
1040 contentLayer->setAnchorPoint(FloatPoint(0, 0)); 1040 contentLayer->setAnchorPoint(gfx::PointF(0, 0));
1041 contentLayer->setBounds(surfaceSize); 1041 contentLayer->setBounds(surfaceSize);
1042 contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize. height() * 2)); 1042 contentLayer->setContentBounds(gfx::Size(surfaceSize.width() * 2, surfaceSiz e.height() * 2));
1043 1043
1044 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2); 1044 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2);
1045 scrollLayer->setScrollable(true); 1045 scrollLayer->setScrollable(true);
1046 scrollLayer->setMaxScrollPosition(surfaceSize); 1046 scrollLayer->setMaxScrollPosition(cc::IntSize(surfaceSize));
1047 scrollLayer->setBounds(surfaceSize); 1047 scrollLayer->setBounds(surfaceSize);
1048 scrollLayer->setContentBounds(surfaceSize); 1048 scrollLayer->setContentBounds(surfaceSize);
1049 scrollLayer->setPosition(FloatPoint(0, 0)); 1049 scrollLayer->setPosition(gfx::PointF(0, 0));
1050 scrollLayer->setAnchorPoint(FloatPoint(0, 0)); 1050 scrollLayer->setAnchorPoint(gfx::PointF(0, 0));
1051 scrollLayer->addChild(contentLayer.Pass()); 1051 scrollLayer->addChild(contentLayer.Pass());
1052 1052
1053 m_hostImpl->setRootLayer(scrollLayer.Pass()); 1053 m_hostImpl->setRootLayer(scrollLayer.Pass());
1054 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1054 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1055 initializeRendererAndDrawFrame(); 1055 initializeRendererAndDrawFrame();
1056 1056
1057 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted); 1057 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted);
1058 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); 1058 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10));
1059 m_hostImpl->scrollEnd(); 1059 m_hostImpl->scrollEnd();
1060 EXPECT_TRUE(m_didRequestRedraw); 1060 EXPECT_TRUE(m_didRequestRedraw);
1061 EXPECT_TRUE(m_didRequestCommit); 1061 EXPECT_TRUE(m_didRequestCommit);
1062 } 1062 }
1063 1063
1064 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) 1064 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
1065 { 1065 {
1066 IntSize surfaceSize(10, 10); 1066 gfx::Size surfaceSize(10, 10);
1067 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1067 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1068 root->setBounds(surfaceSize); 1068 root->setBounds(surfaceSize);
1069 root->setContentBounds(surfaceSize); 1069 root->setContentBounds(surfaceSize);
1070 root->addChild(createScrollableLayer(2, surfaceSize)); 1070 root->addChild(createScrollableLayer(2, surfaceSize));
1071 m_hostImpl->setRootLayer(root.Pass()); 1071 m_hostImpl->setRootLayer(root.Pass());
1072 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1072 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1073 initializeRendererAndDrawFrame(); 1073 initializeRendererAndDrawFrame();
1074 1074
1075 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted); 1075 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted);
1076 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); 1076 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10));
1077 m_hostImpl->scrollEnd(); 1077 m_hostImpl->scrollEnd();
1078 EXPECT_TRUE(m_didRequestRedraw); 1078 EXPECT_TRUE(m_didRequestRedraw);
1079 EXPECT_TRUE(m_didRequestCommit); 1079 EXPECT_TRUE(m_didRequestCommit);
1080 } 1080 }
1081 1081
1082 TEST_P(LayerTreeHostImplTest, scrollMissesChild) 1082 TEST_P(LayerTreeHostImplTest, scrollMissesChild)
1083 { 1083 {
1084 IntSize surfaceSize(10, 10); 1084 gfx::Size surfaceSize(10, 10);
1085 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1085 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1086 root->addChild(createScrollableLayer(2, surfaceSize)); 1086 root->addChild(createScrollableLayer(2, surfaceSize));
1087 m_hostImpl->setRootLayer(root.Pass()); 1087 m_hostImpl->setRootLayer(root.Pass());
1088 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1088 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1089 initializeRendererAndDrawFrame(); 1089 initializeRendererAndDrawFrame();
1090 1090
1091 // Scroll event is ignored because the input coordinate is outside the layer boundaries. 1091 // Scroll event is ignored because the input coordinate is outside the layer boundaries.
1092 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), InputHandlerClient::Wheel ), InputHandlerClient::ScrollIgnored); 1092 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), InputHandlerClient::Wheel ), InputHandlerClient::ScrollIgnored);
1093 EXPECT_FALSE(m_didRequestRedraw); 1093 EXPECT_FALSE(m_didRequestRedraw);
1094 EXPECT_FALSE(m_didRequestCommit); 1094 EXPECT_FALSE(m_didRequestCommit);
1095 } 1095 }
1096 1096
1097 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) 1097 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild)
1098 { 1098 {
1099 IntSize surfaceSize(10, 10); 1099 gfx::Size surfaceSize(10, 10);
1100 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1100 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1101 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1101 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1102 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1102 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1103 1103
1104 WebTransformationMatrix matrix; 1104 WebTransformationMatrix matrix;
1105 matrix.rotate3d(180, 0, 0); 1105 matrix.rotate3d(180, 0, 0);
1106 child->setTransform(matrix); 1106 child->setTransform(matrix);
1107 child->setDoubleSided(false); 1107 child->setDoubleSided(false);
1108 1108
1109 root->addChild(child.Pass()); 1109 root->addChild(child.Pass());
1110 m_hostImpl->setRootLayer(root.Pass()); 1110 m_hostImpl->setRootLayer(root.Pass());
1111 initializeRendererAndDrawFrame(); 1111 initializeRendererAndDrawFrame();
1112 1112
1113 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is 1113 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is
1114 // nothing scrollable behind it. 1114 // nothing scrollable behind it.
1115 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollIgnored); 1115 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollIgnored);
1116 EXPECT_FALSE(m_didRequestRedraw); 1116 EXPECT_FALSE(m_didRequestRedraw);
1117 EXPECT_FALSE(m_didRequestCommit); 1117 EXPECT_FALSE(m_didRequestCommit);
1118 } 1118 }
1119 1119
1120 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) 1120 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer)
1121 { 1121 {
1122 IntSize surfaceSize(10, 10); 1122 gfx::Size surfaceSize(10, 10);
1123 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); 1123 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize);
1124 contentLayer->setShouldScrollOnMainThread(true); 1124 contentLayer->setShouldScrollOnMainThread(true);
1125 contentLayer->setScrollable(false); 1125 contentLayer->setScrollable(false);
1126 1126
1127 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); 1127 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize);
1128 scrollLayer->addChild(contentLayer.Pass()); 1128 scrollLayer->addChild(contentLayer.Pass());
1129 1129
1130 m_hostImpl->setRootLayer(scrollLayer.Pass()); 1130 m_hostImpl->setRootLayer(scrollLayer.Pass());
1131 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1131 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1132 initializeRendererAndDrawFrame(); 1132 initializeRendererAndDrawFrame();
1133 1133
1134 // Scrolling fails because the content layer is asking to be scrolled on the main thread. 1134 // Scrolling fails because the content layer is asking to be scrolled on the main thread.
1135 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollOnMainThread); 1135 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollOnMainThread);
1136 } 1136 }
1137 1137
1138 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) 1138 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
1139 { 1139 {
1140 IntSize surfaceSize(10, 10); 1140 gfx::Size surfaceSize(10, 10);
1141 float pageScale = 2; 1141 float pageScale = 2;
1142 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1142 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1143 m_hostImpl->setRootLayer(root.Pass()); 1143 m_hostImpl->setRootLayer(root.Pass());
1144 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1144 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1145 initializeRendererAndDrawFrame(); 1145 initializeRendererAndDrawFrame();
1146 1146
1147 IntSize scrollDelta(0, 10); 1147 IntSize scrollDelta(0, 10);
1148 IntSize expectedScrollDelta(scrollDelta); 1148 IntSize expectedScrollDelta(scrollDelta);
1149 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); 1149 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition());
1150 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted); 1150 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted);
(...skipping 12 matching lines...) Expand all
1163 1163
1164 // The scroll range should also have been updated. 1164 // The scroll range should also have been updated.
1165 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); 1165 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
1166 1166
1167 // The page scale delta remains constant because the impl thread did not sca le. 1167 // The page scale delta remains constant because the impl thread did not sca le.
1168 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix( )); 1168 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix( ));
1169 } 1169 }
1170 1170
1171 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) 1171 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
1172 { 1172 {
1173 IntSize surfaceSize(10, 10); 1173 gfx::Size surfaceSize(10, 10);
1174 float pageScale = 2; 1174 float pageScale = 2;
1175 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1175 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1176 m_hostImpl->setRootLayer(root.Pass()); 1176 m_hostImpl->setRootLayer(root.Pass());
1177 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1177 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1178 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1178 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
1179 initializeRendererAndDrawFrame(); 1179 initializeRendererAndDrawFrame();
1180 1180
1181 IntSize scrollDelta(0, 10); 1181 IntSize scrollDelta(0, 10);
1182 IntSize expectedScrollDelta(scrollDelta); 1182 IntSize expectedScrollDelta(scrollDelta);
1183 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); 1183 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition());
(...skipping 15 matching lines...) Expand all
1199 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); 1199 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
1200 1200
1201 // The page scale delta should match the new scale on the impl side. 1201 // The page scale delta should match the new scale on the impl side.
1202 WebTransformationMatrix expectedScale; 1202 WebTransformationMatrix expectedScale;
1203 expectedScale.scale(pageScale); 1203 expectedScale.scale(pageScale);
1204 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); 1204 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
1205 } 1205 }
1206 1206
1207 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) 1207 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
1208 { 1208 {
1209 IntSize surfaceSize(10, 10); 1209 gfx::Size surfaceSize(10, 10);
1210 float defaultPageScale = 1; 1210 float defaultPageScale = 1;
1211 WebTransformationMatrix defaultPageScaleMatrix; 1211 WebTransformationMatrix defaultPageScaleMatrix;
1212 1212
1213 float newPageScale = 2; 1213 float newPageScale = 2;
1214 WebTransformationMatrix newPageScaleMatrix; 1214 WebTransformationMatrix newPageScaleMatrix;
1215 newPageScaleMatrix.scale(newPageScale); 1215 newPageScaleMatrix.scale(newPageScale);
1216 1216
1217 // Create a normal scrollable root layer and another scrollable child layer. 1217 // Create a normal scrollable root layer and another scrollable child layer.
1218 setupScrollAndContentsLayers(surfaceSize); 1218 setupScrollAndContentsLayers(surfaceSize);
1219 LayerImpl* root = m_hostImpl->rootLayer(); 1219 LayerImpl* root = m_hostImpl->rootLayer();
(...skipping 24 matching lines...) Expand all
1244 EXPECT_EQ(root->drawTransform().m11(), newPageScale); 1244 EXPECT_EQ(root->drawTransform().m11(), newPageScale);
1245 EXPECT_EQ(root->drawTransform().m22(), newPageScale); 1245 EXPECT_EQ(root->drawTransform().m22(), newPageScale);
1246 EXPECT_EQ(child->drawTransform().m11(), newPageScale); 1246 EXPECT_EQ(child->drawTransform().m11(), newPageScale);
1247 EXPECT_EQ(child->drawTransform().m22(), newPageScale); 1247 EXPECT_EQ(child->drawTransform().m22(), newPageScale);
1248 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); 1248 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale);
1249 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); 1249 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale);
1250 } 1250 }
1251 1251
1252 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) 1252 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
1253 { 1253 {
1254 IntSize surfaceSize(10, 10); 1254 gfx::Size surfaceSize(10, 10);
1255 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1255 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1256 root->setBounds(surfaceSize); 1256 root->setBounds(surfaceSize);
1257 root->setContentBounds(surfaceSize); 1257 root->setContentBounds(surfaceSize);
1258 // Also mark the root scrollable so it becomes the root scroll layer. 1258 // Also mark the root scrollable so it becomes the root scroll layer.
1259 root->setScrollable(true); 1259 root->setScrollable(true);
1260 int scrollLayerId = 2; 1260 int scrollLayerId = 2;
1261 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); 1261 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize));
1262 m_hostImpl->setRootLayer(root.Pass()); 1262 m_hostImpl->setRootLayer(root.Pass());
1263 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1263 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1264 initializeRendererAndDrawFrame(); 1264 initializeRendererAndDrawFrame();
(...skipping 25 matching lines...) Expand all
1290 // The page scale delta remains constant because the impl thread did not sca le. 1290 // The page scale delta remains constant because the impl thread did not sca le.
1291 WebTransformationMatrix identityTransform; 1291 WebTransformationMatrix identityTransform;
1292 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); 1292 EXPECT_EQ(child->implTransform(), WebTransformationMatrix());
1293 } 1293 }
1294 1294
1295 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit) 1295 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
1296 { 1296 {
1297 // Scroll a child layer beyond its maximum scroll range and make sure the 1297 // Scroll a child layer beyond its maximum scroll range and make sure the
1298 // parent layer is scrolled on the axis on which the child was unable to 1298 // parent layer is scrolled on the axis on which the child was unable to
1299 // scroll. 1299 // scroll.
1300 IntSize surfaceSize(10, 10); 1300 gfx::Size surfaceSize(10, 10);
1301 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1301 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1302 1302
1303 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); 1303 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize);
1304 grandChild->setScrollPosition(IntPoint(0, 5)); 1304 grandChild->setScrollPosition(IntPoint(0, 5));
1305 1305
1306 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1306 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1307 child->setScrollPosition(IntPoint(3, 0)); 1307 child->setScrollPosition(IntPoint(3, 0));
1308 child->addChild(grandChild.Pass()); 1308 child->addChild(grandChild.Pass());
1309 1309
1310 root->addChild(child.Pass()); 1310 root->addChild(child.Pass());
(...skipping 15 matching lines...) Expand all
1326 1326
1327 // The child should have only scrolled on the other axis. 1327 // The child should have only scrolled on the other axis.
1328 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); 1328 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0));
1329 } 1329 }
1330 } 1330 }
1331 1331
1332 TEST_P(LayerTreeHostImplTest, scrollEventBubbling) 1332 TEST_P(LayerTreeHostImplTest, scrollEventBubbling)
1333 { 1333 {
1334 // When we try to scroll a non-scrollable child layer, the scroll delta 1334 // When we try to scroll a non-scrollable child layer, the scroll delta
1335 // should be applied to one of its ancestors if possible. 1335 // should be applied to one of its ancestors if possible.
1336 IntSize surfaceSize(10, 10); 1336 gfx::Size surfaceSize(10, 10);
1337 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1337 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1338 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1338 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1339 1339
1340 child->setScrollable(false); 1340 child->setScrollable(false);
1341 root->addChild(child.Pass()); 1341 root->addChild(child.Pass());
1342 1342
1343 m_hostImpl->setRootLayer(root.Pass()); 1343 m_hostImpl->setRootLayer(root.Pass());
1344 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1344 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1345 initializeRendererAndDrawFrame(); 1345 initializeRendererAndDrawFrame();
1346 { 1346 {
1347 IntSize scrollDelta(0, 4); 1347 IntSize scrollDelta(0, 4);
1348 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted); 1348 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted);
1349 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1349 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1350 m_hostImpl->scrollEnd(); 1350 m_hostImpl->scrollEnd();
1351 1351
1352 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1352 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1353 1353
1354 // Only the root should have scrolled. 1354 // Only the root should have scrolled.
1355 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 1355 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
1356 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 1356 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
1357 } 1357 }
1358 } 1358 }
1359 1359
1360 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw) 1360 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw)
1361 { 1361 {
1362 IntSize surfaceSize(10, 10); 1362 gfx::Size surfaceSize(10, 10);
1363 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); 1363 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize));
1364 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1364 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1365 1365
1366 // Draw one frame and then immediately rebuild the layer tree to mimic a tre e synchronization. 1366 // Draw one frame and then immediately rebuild the layer tree to mimic a tre e synchronization.
1367 initializeRendererAndDrawFrame(); 1367 initializeRendererAndDrawFrame();
1368 m_hostImpl->detachLayerTree(); 1368 m_hostImpl->detachLayerTree();
1369 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); 1369 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize));
1370 1370
1371 // Scrolling should still work even though we did not draw yet. 1371 // Scrolling should still work even though we did not draw yet.
1372 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted); 1372 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted);
1373 } 1373 }
1374 1374
1375 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) 1375 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
1376 { 1376 {
1377 setupScrollAndContentsLayers(IntSize(100, 100)); 1377 setupScrollAndContentsLayers(gfx::Size(100, 100));
1378 1378
1379 // Rotate the root layer 90 degrees counter-clockwise about its center. 1379 // Rotate the root layer 90 degrees counter-clockwise about its center.
1380 WebTransformationMatrix rotateTransform; 1380 WebTransformationMatrix rotateTransform;
1381 rotateTransform.rotate(-90); 1381 rotateTransform.rotate(-90);
1382 m_hostImpl->rootLayer()->setTransform(rotateTransform); 1382 m_hostImpl->rootLayer()->setTransform(rotateTransform);
1383 1383
1384 IntSize surfaceSize(50, 50); 1384 gfx::Size surfaceSize(50, 50);
1385 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1385 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1386 initializeRendererAndDrawFrame(); 1386 initializeRendererAndDrawFrame();
1387 1387
1388 // Scroll to the right in screen coordinates with a gesture. 1388 // Scroll to the right in screen coordinates with a gesture.
1389 IntSize gestureScrollDelta(10, 0); 1389 IntSize gestureScrollDelta(10, 0);
1390 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur e), InputHandlerClient::ScrollStarted); 1390 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur e), InputHandlerClient::ScrollStarted);
1391 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); 1391 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta);
1392 m_hostImpl->scrollEnd(); 1392 m_hostImpl->scrollEnd();
1393 1393
1394 // The layer should have scrolled down in its local coordinates. 1394 // The layer should have scrolled down in its local coordinates.
1395 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1395 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1396 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, gestureScrollDelta.width())); 1396 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, gestureScrollDelta.width()));
1397 1397
1398 // Reset and scroll down with the wheel. 1398 // Reset and scroll down with the wheel.
1399 m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); 1399 m_hostImpl->rootLayer()->setScrollDelta(FloatSize());
1400 IntSize wheelScrollDelta(0, 10); 1400 IntSize wheelScrollDelta(0, 10);
1401 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted); 1401 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Wheel) , InputHandlerClient::ScrollStarted);
1402 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); 1402 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta);
1403 m_hostImpl->scrollEnd(); 1403 m_hostImpl->scrollEnd();
1404 1404
1405 // The layer should have scrolled down in its local coordinates. 1405 // The layer should have scrolled down in its local coordinates.
1406 scrollInfo = m_hostImpl->processScrollDeltas(); 1406 scrollInfo = m_hostImpl->processScrollDeltas();
1407 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); 1407 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta);
1408 } 1408 }
1409 1409
1410 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) 1410 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
1411 { 1411 {
1412 setupScrollAndContentsLayers(IntSize(100, 100)); 1412 setupScrollAndContentsLayers(gfx::Size(100, 100));
1413 int childLayerId = 3; 1413 int childLayerId = 3;
1414 float childLayerAngle = -20; 1414 float childLayerAngle = -20;
1415 1415
1416 // Create a child layer that is rotated to a non-axis-aligned angle. 1416 // Create a child layer that is rotated to a non-axis-aligned angle.
1417 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl ->rootLayer()->contentBounds()); 1417 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl ->rootLayer()->contentBounds());
1418 WebTransformationMatrix rotateTransform; 1418 WebTransformationMatrix rotateTransform;
1419 rotateTransform.translate(-50, -50); 1419 rotateTransform.translate(-50, -50);
1420 rotateTransform.rotate(childLayerAngle); 1420 rotateTransform.rotate(childLayerAngle);
1421 rotateTransform.translate(50, 50); 1421 rotateTransform.translate(50, 50);
1422 child->setTransform(rotateTransform); 1422 child->setTransform(rotateTransform);
1423 1423
1424 // Only allow vertical scrolling. 1424 // Only allow vertical scrolling.
1425 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); 1425 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height()));
1426 m_hostImpl->rootLayer()->addChild(child.Pass()); 1426 m_hostImpl->rootLayer()->addChild(child.Pass());
1427 1427
1428 IntSize surfaceSize(50, 50); 1428 gfx::Size surfaceSize(50, 50);
1429 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1429 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1430 initializeRendererAndDrawFrame(); 1430 initializeRendererAndDrawFrame();
1431 1431
1432 { 1432 {
1433 // Scroll down in screen coordinates with a gesture. 1433 // Scroll down in screen coordinates with a gesture.
1434 IntSize gestureScrollDelta(0, 10); 1434 IntSize gestureScrollDelta(0, 10);
1435 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Ge sture), InputHandlerClient::ScrollStarted); 1435 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Ge sture), InputHandlerClient::ScrollStarted);
1436 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); 1436 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta);
1437 m_hostImpl->scrollEnd(); 1437 m_hostImpl->scrollEnd();
1438 1438
(...skipping 24 matching lines...) Expand all
1463 1463
1464 // The root layer should have scrolled more, since the input scroll delt a was mostly 1464 // The root layer should have scrolled more, since the input scroll delt a was mostly
1465 // orthogonal to the child layer's vertical scroll axis. 1465 // orthogonal to the child layer's vertical scroll axis.
1466 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de g2rad(childLayerAngle)), 2), 0); 1466 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de g2rad(childLayerAngle)), 2), 0);
1467 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta); 1467 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta);
1468 } 1468 }
1469 } 1469 }
1470 1470
1471 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) 1471 TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
1472 { 1472 {
1473 setupScrollAndContentsLayers(IntSize(100, 100)); 1473 setupScrollAndContentsLayers(gfx::Size(100, 100));
1474 1474
1475 // Scale the layer to twice its normal size. 1475 // Scale the layer to twice its normal size.
1476 int scale = 2; 1476 int scale = 2;
1477 WebTransformationMatrix scaleTransform; 1477 WebTransformationMatrix scaleTransform;
1478 scaleTransform.scale(scale); 1478 scaleTransform.scale(scale);
1479 m_hostImpl->rootLayer()->setTransform(scaleTransform); 1479 m_hostImpl->rootLayer()->setTransform(scaleTransform);
1480 1480
1481 IntSize surfaceSize(50, 50); 1481 gfx::Size surfaceSize(50, 50);
1482 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1482 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1483 initializeRendererAndDrawFrame(); 1483 initializeRendererAndDrawFrame();
1484 1484
1485 // Scroll down in screen coordinates with a gesture. 1485 // Scroll down in screen coordinates with a gesture.
1486 IntSize scrollDelta(0, 10); 1486 IntSize scrollDelta(0, 10);
1487 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur e), InputHandlerClient::ScrollStarted); 1487 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), InputHandlerClient::Gestur e), InputHandlerClient::ScrollStarted);
1488 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1488 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1489 m_hostImpl->scrollEnd(); 1489 m_hostImpl->scrollEnd();
1490 1490
1491 // The layer should have scrolled down in its local coordinates, but half he amount. 1491 // The layer should have scrolled down in its local coordinates, but half he amount.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 }; 1527 };
1528 1528
1529 class BlendStateCheckLayer : public LayerImpl { 1529 class BlendStateCheckLayer : public LayerImpl {
1530 public: 1530 public:
1531 static scoped_ptr<LayerImpl> create(int id, ResourceProvider* resourceProvid er) { return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(id, resourceProvider )); } 1531 static scoped_ptr<LayerImpl> create(int id, ResourceProvider* resourceProvid er) { return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(id, resourceProvider )); }
1532 1532
1533 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat a) OVERRIDE 1533 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat a) OVERRIDE
1534 { 1534 {
1535 m_quadsAppended = true; 1535 m_quadsAppended = true;
1536 1536
1537 IntRect opaqueRect; 1537 gfx::Rect opaqueRect;
1538 if (contentsOpaque()) 1538 if (contentsOpaque())
1539 opaqueRect = m_quadRect; 1539 opaqueRect = m_quadRect;
1540 else 1540 else
1541 opaqueRect = m_opaqueContentRect; 1541 opaqueRect = m_opaqueContentRect;
1542 1542
1543 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha redQuadState()); 1543 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha redQuadState());
1544 scoped_ptr<TileDrawQuad> testBlendingDrawQuad = TileDrawQuad::create(sha redQuadState, m_quadRect, opaqueRect, m_resourceId, IntPoint(), IntSize(1, 1), 0 , false, false, false, false, false); 1544 scoped_ptr<TileDrawQuad> testBlendingDrawQuad = TileDrawQuad::create(sha redQuadState, m_quadRect, opaqueRect, m_resourceId, gfx::Vector2d(), gfx::Size(1 , 1), 0, false, false, false, false, false);
1545 testBlendingDrawQuad->setQuadVisibleRect(m_quadVisibleRect); 1545 testBlendingDrawQuad->setQuadVisibleRect(m_quadVisibleRect);
1546 EXPECT_EQ(m_blend, testBlendingDrawQuad->needsBlending()); 1546 EXPECT_EQ(m_blend, testBlendingDrawQuad->needsBlending());
1547 EXPECT_EQ(m_hasRenderSurface, !!renderSurface()); 1547 EXPECT_EQ(m_hasRenderSurface, !!renderSurface());
1548 quadSink.append(testBlendingDrawQuad.PassAs<DrawQuad>(), appendQuadsData ); 1548 quadSink.append(testBlendingDrawQuad.PassAs<DrawQuad>(), appendQuadsData );
1549 } 1549 }
1550 1550
1551 void setExpectation(bool blend, bool hasRenderSurface) 1551 void setExpectation(bool blend, bool hasRenderSurface)
1552 { 1552 {
1553 m_blend = blend; 1553 m_blend = blend;
1554 m_hasRenderSurface = hasRenderSurface; 1554 m_hasRenderSurface = hasRenderSurface;
1555 m_quadsAppended = false; 1555 m_quadsAppended = false;
1556 } 1556 }
1557 1557
1558 bool quadsAppended() const { return m_quadsAppended; } 1558 bool quadsAppended() const { return m_quadsAppended; }
1559 1559
1560 void setQuadRect(const IntRect& rect) { m_quadRect = rect; } 1560 void setQuadRect(const gfx::Rect& rect) { m_quadRect = rect; }
1561 void setQuadVisibleRect(const IntRect& rect) { m_quadVisibleRect = rect; } 1561 void setQuadVisibleRect(const gfx::Rect& rect) { m_quadVisibleRect = rect; }
1562 void setOpaqueContentRect(const IntRect& rect) { m_opaqueContentRect = rect; } 1562 void setOpaqueContentRect(const gfx::Rect& rect) { m_opaqueContentRect = rec t; }
1563 1563
1564 private: 1564 private:
1565 explicit BlendStateCheckLayer(int id, ResourceProvider* resourceProvider) 1565 explicit BlendStateCheckLayer(int id, ResourceProvider* resourceProvider)
1566 : LayerImpl(id) 1566 : LayerImpl(id)
1567 , m_blend(false) 1567 , m_blend(false)
1568 , m_hasRenderSurface(false) 1568 , m_hasRenderSurface(false)
1569 , m_quadsAppended(false) 1569 , m_quadsAppended(false)
1570 , m_quadRect(5, 5, 5, 5) 1570 , m_quadRect(5, 5, 5, 5)
1571 , m_quadVisibleRect(5, 5, 5, 5) 1571 , m_quadVisibleRect(5, 5, 5, 5)
1572 , m_resourceId(resourceProvider->createResource(Renderer::ContentPool, I ntSize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny)) 1572 , m_resourceId(resourceProvider->createResource(Renderer::ContentPool, g fx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny))
1573 { 1573 {
1574 setAnchorPoint(FloatPoint(0, 0)); 1574 setAnchorPoint(gfx::PointF(0, 0));
1575 setBounds(IntSize(10, 10)); 1575 setBounds(gfx::Size(10, 10));
1576 setContentBounds(IntSize(10, 10)); 1576 setContentBounds(gfx::Size(10, 10));
1577 setDrawsContent(true); 1577 setDrawsContent(true);
1578 } 1578 }
1579 1579
1580 bool m_blend; 1580 bool m_blend;
1581 bool m_hasRenderSurface; 1581 bool m_hasRenderSurface;
1582 bool m_quadsAppended; 1582 bool m_quadsAppended;
1583 IntRect m_quadRect; 1583 gfx::Rect m_quadRect;
1584 IntRect m_opaqueContentRect; 1584 gfx::Rect m_opaqueContentRect;
1585 IntRect m_quadVisibleRect; 1585 gfx::Rect m_quadVisibleRect;
1586 ResourceProvider::ResourceId m_resourceId; 1586 ResourceProvider::ResourceId m_resourceId;
1587 }; 1587 };
1588 1588
1589 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) 1589 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
1590 { 1590 {
1591 { 1591 {
1592 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1592 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1593 root->setAnchorPoint(FloatPoint(0, 0)); 1593 root->setAnchorPoint(gfx::PointF(0, 0));
1594 root->setBounds(IntSize(10, 10)); 1594 root->setBounds(gfx::Size(10, 10));
1595 root->setContentBounds(root->bounds()); 1595 root->setContentBounds(root->bounds());
1596 root->setDrawsContent(false); 1596 root->setDrawsContent(false);
1597 m_hostImpl->setRootLayer(root.Pass()); 1597 m_hostImpl->setRootLayer(root.Pass());
1598 } 1598 }
1599 LayerImpl* root = m_hostImpl->rootLayer(); 1599 LayerImpl* root = m_hostImpl->rootLayer();
1600 1600
1601 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider( ))); 1601 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider( )));
1602 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil dren()[0]); 1602 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil dren()[0]);
1603 layer1->setPosition(FloatPoint(2, 2)); 1603 layer1->setPosition(gfx::PointF(2, 2));
1604 1604
1605 LayerTreeHostImpl::FrameData frame; 1605 LayerTreeHostImpl::FrameData frame;
1606 1606
1607 // Opaque layer, drawn without blending. 1607 // Opaque layer, drawn without blending.
1608 layer1->setContentsOpaque(true); 1608 layer1->setContentsOpaque(true);
1609 layer1->setExpectation(false, false); 1609 layer1->setExpectation(false, false);
1610 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1610 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1611 m_hostImpl->drawLayers(frame); 1611 m_hostImpl->drawLayers(frame);
1612 EXPECT_TRUE(layer1->quadsAppended()); 1612 EXPECT_TRUE(layer1->quadsAppended());
1613 m_hostImpl->didDrawAllLayers(frame); 1613 m_hostImpl->didDrawAllLayers(frame);
(...skipping 19 matching lines...) Expand all
1633 layer1->setContentsOpaque(true); 1633 layer1->setContentsOpaque(true);
1634 layer1->setOpacity(0.5); 1634 layer1->setOpacity(0.5);
1635 layer1->setExpectation(true, false); 1635 layer1->setExpectation(true, false);
1636 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1636 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1637 m_hostImpl->drawLayers(frame); 1637 m_hostImpl->drawLayers(frame);
1638 EXPECT_TRUE(layer1->quadsAppended()); 1638 EXPECT_TRUE(layer1->quadsAppended());
1639 m_hostImpl->didDrawAllLayers(frame); 1639 m_hostImpl->didDrawAllLayers(frame);
1640 1640
1641 layer1->addChild(BlendStateCheckLayer::create(3, m_hostImpl->resourceProvide r())); 1641 layer1->addChild(BlendStateCheckLayer::create(3, m_hostImpl->resourceProvide r()));
1642 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch ildren()[0]); 1642 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch ildren()[0]);
1643 layer2->setPosition(FloatPoint(4, 4)); 1643 layer2->setPosition(gfx::PointF(4, 4));
1644 1644
1645 // 2 opaque layers, drawn without blending. 1645 // 2 opaque layers, drawn without blending.
1646 layer1->setContentsOpaque(true); 1646 layer1->setContentsOpaque(true);
1647 layer1->setOpacity(1); 1647 layer1->setOpacity(1);
1648 layer1->setExpectation(false, false); 1648 layer1->setExpectation(false, false);
1649 layer2->setContentsOpaque(true); 1649 layer2->setContentsOpaque(true);
1650 layer2->setOpacity(1); 1650 layer2->setOpacity(1);
1651 layer2->setExpectation(false, false); 1651 layer2->setExpectation(false, false);
1652 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1652 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1653 m_hostImpl->drawLayers(frame); 1653 m_hostImpl->drawLayers(frame);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 layer2->setOpacity(1); 1727 layer2->setOpacity(1);
1728 layer2->setExpectation(false, false); 1728 layer2->setExpectation(false, false);
1729 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1729 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1730 m_hostImpl->drawLayers(frame); 1730 m_hostImpl->drawLayers(frame);
1731 EXPECT_TRUE(layer1->quadsAppended()); 1731 EXPECT_TRUE(layer1->quadsAppended());
1732 EXPECT_TRUE(layer2->quadsAppended()); 1732 EXPECT_TRUE(layer2->quadsAppended());
1733 m_hostImpl->didDrawAllLayers(frame); 1733 m_hostImpl->didDrawAllLayers(frame);
1734 1734
1735 // Layer with partially opaque contents, drawn with blending. 1735 // Layer with partially opaque contents, drawn with blending.
1736 layer1->setContentsOpaque(false); 1736 layer1->setContentsOpaque(false);
1737 layer1->setQuadRect(IntRect(5, 5, 5, 5)); 1737 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5));
1738 layer1->setQuadVisibleRect(IntRect(5, 5, 5, 5)); 1738 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
1739 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); 1739 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
1740 layer1->setExpectation(true, false); 1740 layer1->setExpectation(true, false);
1741 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1741 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1742 m_hostImpl->drawLayers(frame); 1742 m_hostImpl->drawLayers(frame);
1743 EXPECT_TRUE(layer1->quadsAppended()); 1743 EXPECT_TRUE(layer1->quadsAppended());
1744 m_hostImpl->didDrawAllLayers(frame); 1744 m_hostImpl->didDrawAllLayers(frame);
1745 1745
1746 // Layer with partially opaque contents partially culled, drawn with blendin g. 1746 // Layer with partially opaque contents partially culled, drawn with blendin g.
1747 layer1->setContentsOpaque(false); 1747 layer1->setContentsOpaque(false);
1748 layer1->setQuadRect(IntRect(5, 5, 5, 5)); 1748 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5));
1749 layer1->setQuadVisibleRect(IntRect(5, 5, 5, 2)); 1749 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
1750 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); 1750 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
1751 layer1->setExpectation(true, false); 1751 layer1->setExpectation(true, false);
1752 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1752 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1753 m_hostImpl->drawLayers(frame); 1753 m_hostImpl->drawLayers(frame);
1754 EXPECT_TRUE(layer1->quadsAppended()); 1754 EXPECT_TRUE(layer1->quadsAppended());
1755 m_hostImpl->didDrawAllLayers(frame); 1755 m_hostImpl->didDrawAllLayers(frame);
1756 1756
1757 // Layer with partially opaque contents culled, drawn with blending. 1757 // Layer with partially opaque contents culled, drawn with blending.
1758 layer1->setContentsOpaque(false); 1758 layer1->setContentsOpaque(false);
1759 layer1->setQuadRect(IntRect(5, 5, 5, 5)); 1759 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5));
1760 layer1->setQuadVisibleRect(IntRect(7, 5, 3, 5)); 1760 layer1->setQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
1761 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); 1761 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
1762 layer1->setExpectation(true, false); 1762 layer1->setExpectation(true, false);
1763 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1763 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1764 m_hostImpl->drawLayers(frame); 1764 m_hostImpl->drawLayers(frame);
1765 EXPECT_TRUE(layer1->quadsAppended()); 1765 EXPECT_TRUE(layer1->quadsAppended());
1766 m_hostImpl->didDrawAllLayers(frame); 1766 m_hostImpl->didDrawAllLayers(frame);
1767 1767
1768 // Layer with partially opaque contents and translucent contents culled, dra wn without blending. 1768 // Layer with partially opaque contents and translucent contents culled, dra wn without blending.
1769 layer1->setContentsOpaque(false); 1769 layer1->setContentsOpaque(false);
1770 layer1->setQuadRect(IntRect(5, 5, 5, 5)); 1770 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5));
1771 layer1->setQuadVisibleRect(IntRect(5, 5, 2, 5)); 1771 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
1772 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); 1772 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
1773 layer1->setExpectation(false, false); 1773 layer1->setExpectation(false, false);
1774 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1774 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1775 m_hostImpl->drawLayers(frame); 1775 m_hostImpl->drawLayers(frame);
1776 EXPECT_TRUE(layer1->quadsAppended()); 1776 EXPECT_TRUE(layer1->quadsAppended());
1777 m_hostImpl->didDrawAllLayers(frame); 1777 m_hostImpl->didDrawAllLayers(frame);
1778 1778
1779 } 1779 }
1780 1780
1781 TEST_P(LayerTreeHostImplTest, viewportCovered) 1781 TEST_P(LayerTreeHostImplTest, viewportCovered)
1782 { 1782 {
1783 m_hostImpl->initializeRenderer(createContext()); 1783 m_hostImpl->initializeRenderer(createContext());
1784 m_hostImpl->setBackgroundColor(SK_ColorGRAY); 1784 m_hostImpl->setBackgroundColor(SK_ColorGRAY);
1785 1785
1786 IntSize viewportSize(1000, 1000); 1786 gfx::Size viewportSize(1000, 1000);
1787 m_hostImpl->setViewportSize(viewportSize, viewportSize); 1787 m_hostImpl->setViewportSize(viewportSize, viewportSize);
1788 1788
1789 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1, m_hostImpl->resourc eProvider())); 1789 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1, m_hostImpl->resourc eProvider()));
1790 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl-> rootLayer()); 1790 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl-> rootLayer());
1791 root->setExpectation(false, true); 1791 root->setExpectation(false, true);
1792 root->setContentsOpaque(true); 1792 root->setContentsOpaque(true);
1793 1793
1794 // No gutter rects 1794 // No gutter rects
1795 { 1795 {
1796 IntRect layerRect(0, 0, 1000, 1000); 1796 gfx::Rect layerRect(0, 0, 1000, 1000);
1797 root->setPosition(layerRect.location()); 1797 root->setPosition(layerRect.origin());
1798 root->setBounds(layerRect.size()); 1798 root->setBounds(layerRect.size());
1799 root->setContentBounds(layerRect.size()); 1799 root->setContentBounds(layerRect.size());
1800 root->setQuadRect(IntRect(IntPoint(), layerRect.size())); 1800 root->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size()));
1801 root->setQuadVisibleRect(IntRect(IntPoint(), layerRect.size())); 1801 root->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size()));
1802 1802
1803 LayerTreeHostImpl::FrameData frame; 1803 LayerTreeHostImpl::FrameData frame;
1804 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1804 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1805 ASSERT_EQ(1u, frame.renderPasses.size()); 1805 ASSERT_EQ(1u, frame.renderPasses.size());
1806 1806
1807 size_t numGutterQuads = 0; 1807 size_t numGutterQuads = 0;
1808 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) 1808 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i)
1809 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material() == DrawQuad::SolidColor) ? 1 : 0; 1809 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material() == DrawQuad::SolidColor) ? 1 : 0;
1810 EXPECT_EQ(0u, numGutterQuads); 1810 EXPECT_EQ(0u, numGutterQuads);
1811 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); 1811 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size());
1812 1812
1813 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), IntRect(- layerRect.location(), viewportSize)); 1813 gfx::Rect expectedRect(gfx::Point(-layerRect.x(), -layerRect.y()), viewp ortSize);
1814 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), expectedR ect);
1814 m_hostImpl->didDrawAllLayers(frame); 1815 m_hostImpl->didDrawAllLayers(frame);
1815 } 1816 }
1816 1817
1817 // Empty visible content area (fullscreen gutter rect) 1818 // Empty visible content area (fullscreen gutter rect)
1818 { 1819 {
1819 IntRect layerRect(0, 0, 0, 0); 1820 gfx::Rect layerRect(0, 0, 0, 0);
1820 root->setPosition(layerRect.location()); 1821 root->setPosition(layerRect.origin());
1821 root->setBounds(layerRect.size()); 1822 root->setBounds(layerRect.size());
1822 root->setContentBounds(layerRect.size()); 1823 root->setContentBounds(layerRect.size());
1823 root->setQuadRect(IntRect(IntPoint(), layerRect.size())); 1824 root->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size()));
1824 root->setQuadVisibleRect(IntRect(IntPoint(), layerRect.size())); 1825 root->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size()));
1825 1826
1826 LayerTreeHostImpl::FrameData frame; 1827 LayerTreeHostImpl::FrameData frame;
1827 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1828 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1828 ASSERT_EQ(1u, frame.renderPasses.size()); 1829 ASSERT_EQ(1u, frame.renderPasses.size());
1829 m_hostImpl->didDrawAllLayers(frame); 1830 m_hostImpl->didDrawAllLayers(frame);
1830 1831
1831 size_t numGutterQuads = 0; 1832 size_t numGutterQuads = 0;
1832 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) 1833 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i)
1833 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material() == DrawQuad::SolidColor) ? 1 : 0; 1834 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material() == DrawQuad::SolidColor) ? 1 : 0;
1834 EXPECT_EQ(1u, numGutterQuads); 1835 EXPECT_EQ(1u, numGutterQuads);
1835 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); 1836 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size());
1836 1837
1837 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), IntRect(- layerRect.location(), viewportSize)); 1838 gfx::Rect expectedRect(gfx::Point(-layerRect.x(), -layerRect.y()), viewp ortSize);
1839 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), expectedR ect);
1838 m_hostImpl->didDrawAllLayers(frame); 1840 m_hostImpl->didDrawAllLayers(frame);
1839 } 1841 }
1840 1842
1841 // Content area in middle of clip rect (four surrounding gutter rects) 1843 // Content area in middle of clip rect (four surrounding gutter rects)
1842 { 1844 {
1843 IntRect layerRect(500, 500, 200, 200); 1845 gfx::Rect layerRect(500, 500, 200, 200);
1844 root->setPosition(layerRect.location()); 1846 root->setPosition(layerRect.origin());
1845 root->setBounds(layerRect.size()); 1847 root->setBounds(layerRect.size());
1846 root->setContentBounds(layerRect.size()); 1848 root->setContentBounds(layerRect.size());
1847 root->setQuadRect(IntRect(IntPoint(), layerRect.size())); 1849 root->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size()));
1848 root->setQuadVisibleRect(IntRect(IntPoint(), layerRect.size())); 1850 root->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size()));
1849 1851
1850 LayerTreeHostImpl::FrameData frame; 1852 LayerTreeHostImpl::FrameData frame;
1851 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1853 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1852 ASSERT_EQ(1u, frame.renderPasses.size()); 1854 ASSERT_EQ(1u, frame.renderPasses.size());
1853 1855
1854 size_t numGutterQuads = 0; 1856 size_t numGutterQuads = 0;
1855 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) 1857 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i)
1856 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material() == DrawQuad::SolidColor) ? 1 : 0; 1858 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material() == DrawQuad::SolidColor) ? 1 : 0;
1857 EXPECT_EQ(4u, numGutterQuads); 1859 EXPECT_EQ(4u, numGutterQuads);
1858 EXPECT_EQ(5u, frame.renderPasses[0]->quadList().size()); 1860 EXPECT_EQ(5u, frame.renderPasses[0]->quadList().size());
1859 1861
1860 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), IntRect(- layerRect.location(), viewportSize)); 1862 gfx::Rect expectedRect(gfx::Point(-layerRect.x(), -layerRect.y()), viewp ortSize);
1863 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), expectedR ect);
1861 m_hostImpl->didDrawAllLayers(frame); 1864 m_hostImpl->didDrawAllLayers(frame);
1862 } 1865 }
1863 1866
1864 } 1867 }
1865 1868
1866 1869
1867 class ReshapeTrackerContext: public FakeWebGraphicsContext3D { 1870 class ReshapeTrackerContext: public FakeWebGraphicsContext3D {
1868 public: 1871 public:
1869 ReshapeTrackerContext() : m_reshapeCalled(false) { } 1872 ReshapeTrackerContext() : m_reshapeCalled(false) { }
1870 1873
(...skipping 18 matching lines...) Expand all
1889 // Only reshape when we know we are going to draw. Otherwise, the reshape 1892 // Only reshape when we know we are going to draw. Otherwise, the reshape
1890 // can leave the window at the wrong size if we never draw and the proper 1893 // can leave the window at the wrong size if we never draw and the proper
1891 // viewport size is never set. 1894 // viewport size is never set.
1892 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) 1895 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw)
1893 { 1896 {
1894 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface:: create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).Pass As<GraphicsContext>(); 1897 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface:: create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).Pass As<GraphicsContext>();
1895 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( outputSurface->context3D()); 1898 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( outputSurface->context3D());
1896 m_hostImpl->initializeRenderer(outputSurface.Pass()); 1899 m_hostImpl->initializeRenderer(outputSurface.Pass());
1897 1900
1898 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); 1901 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1);
1899 root->setAnchorPoint(FloatPoint(0, 0)); 1902 root->setAnchorPoint(gfx::PointF(0, 0));
1900 root->setBounds(IntSize(10, 10)); 1903 root->setBounds(gfx::Size(10, 10));
1901 root->setDrawsContent(true); 1904 root->setDrawsContent(true);
1902 m_hostImpl->setRootLayer(root.Pass()); 1905 m_hostImpl->setRootLayer(root.Pass());
1903 EXPECT_FALSE(reshapeTracker->reshapeCalled()); 1906 EXPECT_FALSE(reshapeTracker->reshapeCalled());
1904 1907
1905 LayerTreeHostImpl::FrameData frame; 1908 LayerTreeHostImpl::FrameData frame;
1906 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1909 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1907 m_hostImpl->drawLayers(frame); 1910 m_hostImpl->drawLayers(frame);
1908 EXPECT_TRUE(reshapeTracker->reshapeCalled()); 1911 EXPECT_TRUE(reshapeTracker->reshapeCalled());
1909 m_hostImpl->didDrawAllLayers(frame); 1912 m_hostImpl->didDrawAllLayers(frame);
1910 } 1913 }
1911 1914
1912 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { 1915 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D {
1913 public: 1916 public:
1914 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) 1917 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height)
1915 { 1918 {
1916 m_partialSwapRect = IntRect(x, y, width, height); 1919 m_partialSwapRect = gfx::Rect(x, y, width, height);
1917 } 1920 }
1918 1921
1919 virtual WebString getString(WGC3Denum name) 1922 virtual WebString getString(WGC3Denum name)
1920 { 1923 {
1921 if (name == GL_EXTENSIONS) 1924 if (name == GL_EXTENSIONS)
1922 return WebString("GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_set_visibi lity"); 1925 return WebString("GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_set_visibi lity");
1923 1926
1924 return WebString(); 1927 return WebString();
1925 } 1928 }
1926 1929
1927 IntRect partialSwapRect() const { return m_partialSwapRect; } 1930 gfx::Rect partialSwapRect() const { return m_partialSwapRect; }
1928 1931
1929 private: 1932 private:
1930 IntRect m_partialSwapRect; 1933 gfx::Rect m_partialSwapRect;
1931 }; 1934 };
1932 1935
1933 // Make sure damage tracking propagates all the way to the graphics context, 1936 // Make sure damage tracking propagates all the way to the graphics context,
1934 // where it should request to swap only the subBuffer that is damaged. 1937 // where it should request to swap only the subBuffer that is damaged.
1935 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) 1938 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect)
1936 { 1939 {
1937 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface:: create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)). PassAs<GraphicsContext>(); 1940 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface:: create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)). PassAs<GraphicsContext>();
1938 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(outputSurface->context3D()); 1941 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(outputSurface->context3D());
1939 1942
1940 // This test creates its own LayerTreeHostImpl, so 1943 // This test creates its own LayerTreeHostImpl, so
1941 // that we can force partial swap enabled. 1944 // that we can force partial swap enabled.
1942 LayerTreeSettings settings; 1945 LayerTreeSettings settings;
1943 Settings::setPartialSwapEnabled(true); 1946 Settings::setPartialSwapEnabled(true);
1944 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create( settings, this); 1947 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create( settings, this);
1945 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); 1948 layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
1946 layerTreeHostImpl->setViewportSize(IntSize(500, 500), IntSize(500, 500)); 1949 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500)) ;
1947 1950
1948 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); 1951 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1);
1949 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); 1952 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2);
1950 child->setPosition(FloatPoint(12, 13)); 1953 child->setPosition(gfx::PointF(12, 13));
1951 child->setAnchorPoint(FloatPoint(0, 0)); 1954 child->setAnchorPoint(gfx::PointF(0, 0));
1952 child->setBounds(IntSize(14, 15)); 1955 child->setBounds(gfx::Size(14, 15));
1953 child->setContentBounds(IntSize(14, 15)); 1956 child->setContentBounds(gfx::Size(14, 15));
1954 child->setDrawsContent(true); 1957 child->setDrawsContent(true);
1955 root->setAnchorPoint(FloatPoint(0, 0)); 1958 root->setAnchorPoint(gfx::PointF(0, 0));
1956 root->setBounds(IntSize(500, 500)); 1959 root->setBounds(gfx::Size(500, 500));
1957 root->setContentBounds(IntSize(500, 500)); 1960 root->setContentBounds(gfx::Size(500, 500));
1958 root->setDrawsContent(true); 1961 root->setDrawsContent(true);
1959 root->addChild(child.Pass()); 1962 root->addChild(child.Pass());
1960 layerTreeHostImpl->setRootLayer(root.Pass()); 1963 layerTreeHostImpl->setRootLayer(root.Pass());
1961 1964
1962 LayerTreeHostImpl::FrameData frame; 1965 LayerTreeHostImpl::FrameData frame;
1963 1966
1964 // First frame, the entire screen should get swapped. 1967 // First frame, the entire screen should get swapped.
1965 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); 1968 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame));
1966 layerTreeHostImpl->drawLayers(frame); 1969 layerTreeHostImpl->drawLayers(frame);
1967 layerTreeHostImpl->didDrawAllLayers(frame); 1970 layerTreeHostImpl->didDrawAllLayers(frame);
1968 layerTreeHostImpl->swapBuffers(); 1971 layerTreeHostImpl->swapBuffers();
1969 IntRect actualSwapRect = partialSwapTracker->partialSwapRect(); 1972 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect();
1970 IntRect expectedSwapRect = IntRect(IntPoint::zero(), IntSize(500, 500)); 1973 gfx::Rect expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(500, 500));
1971 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); 1974 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x());
1972 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); 1975 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y());
1973 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); 1976 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width());
1974 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); 1977 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height());
1975 1978
1976 // Second frame, only the damaged area should get swapped. Damage should be the union 1979 // Second frame, only the damaged area should get swapped. Damage should be the union
1977 // of old and new child rects. 1980 // of old and new child rects.
1978 // expected damage rect: IntRect(IntPoint::zero(), IntSize(26, 28)); 1981 // expected damage rect: gfx::Rect(gfx::Point(), gfx::Size(26, 28));
1979 // expected swap rect: vertically flipped, with origin at bottom left corner . 1982 // expected swap rect: vertically flipped, with origin at bottom left corner .
1980 layerTreeHostImpl->rootLayer()->children()[0]->setPosition(FloatPoint(0, 0)) ; 1983 layerTreeHostImpl->rootLayer()->children()[0]->setPosition(gfx::PointF(0, 0) );
1981 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); 1984 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame));
1982 layerTreeHostImpl->drawLayers(frame); 1985 layerTreeHostImpl->drawLayers(frame);
1983 m_hostImpl->didDrawAllLayers(frame); 1986 m_hostImpl->didDrawAllLayers(frame);
1984 layerTreeHostImpl->swapBuffers(); 1987 layerTreeHostImpl->swapBuffers();
1985 actualSwapRect = partialSwapTracker->partialSwapRect(); 1988 actualSwapRect = partialSwapTracker->partialSwapRect();
1986 expectedSwapRect = IntRect(IntPoint(0, 500-28), IntSize(26, 28)); 1989 expectedSwapRect = gfx::Rect(gfx::Point(0, 500-28), gfx::Size(26, 28));
1987 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); 1990 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x());
1988 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); 1991 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y());
1989 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); 1992 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width());
1990 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); 1993 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height());
1991 1994
1992 // Make sure that partial swap is constrained to the viewport dimensions 1995 // Make sure that partial swap is constrained to the viewport dimensions
1993 // expected damage rect: IntRect(IntPoint::zero(), IntSize(500, 500)); 1996 // expected damage rect: gfx::Rect(gfx::Point(), gfx::Size(500, 500));
1994 // expected swap rect: flipped damage rect, but also clamped to viewport 1997 // expected swap rect: flipped damage rect, but also clamped to viewport
1995 layerTreeHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 1998 layerTreeHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
1996 layerTreeHostImpl->rootLayer()->setOpacity(0.7f); // this will damage everyt hing 1999 layerTreeHostImpl->rootLayer()->setOpacity(0.7f); // this will damage everyt hing
1997 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); 2000 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame));
1998 layerTreeHostImpl->drawLayers(frame); 2001 layerTreeHostImpl->drawLayers(frame);
1999 m_hostImpl->didDrawAllLayers(frame); 2002 m_hostImpl->didDrawAllLayers(frame);
2000 layerTreeHostImpl->swapBuffers(); 2003 layerTreeHostImpl->swapBuffers();
2001 actualSwapRect = partialSwapTracker->partialSwapRect(); 2004 actualSwapRect = partialSwapTracker->partialSwapRect();
2002 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); 2005 expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(10, 10));
2003 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); 2006 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x());
2004 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); 2007 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y());
2005 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); 2008 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width());
2006 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); 2009 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height());
2007 } 2010 }
2008 2011
2009 TEST_P(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) 2012 TEST_P(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface)
2010 { 2013 {
2011 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); 2014 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1);
2012 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); 2015 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2);
2013 child->setAnchorPoint(FloatPoint(0, 0)); 2016 child->setAnchorPoint(gfx::PointF(0, 0));
2014 child->setBounds(IntSize(10, 10)); 2017 child->setBounds(gfx::Size(10, 10));
2015 child->setContentBounds(IntSize(10, 10)); 2018 child->setContentBounds(gfx::Size(10, 10));
2016 child->setDrawsContent(true); 2019 child->setDrawsContent(true);
2017 root->setAnchorPoint(FloatPoint(0, 0)); 2020 root->setAnchorPoint(gfx::PointF(0, 0));
2018 root->setBounds(IntSize(10, 10)); 2021 root->setBounds(gfx::Size(10, 10));
2019 root->setContentBounds(IntSize(10, 10)); 2022 root->setContentBounds(gfx::Size(10, 10));
2020 root->setDrawsContent(true); 2023 root->setDrawsContent(true);
2021 root->setOpacity(0.7f); 2024 root->setOpacity(0.7f);
2022 root->addChild(child.Pass()); 2025 root->addChild(child.Pass());
2023 2026
2024 m_hostImpl->setRootLayer(root.Pass()); 2027 m_hostImpl->setRootLayer(root.Pass());
2025 2028
2026 LayerTreeHostImpl::FrameData frame; 2029 LayerTreeHostImpl::FrameData frame;
2027 2030
2028 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2031 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2029 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); 2032 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size());
2030 EXPECT_EQ(1u, frame.renderPasses.size()); 2033 EXPECT_EQ(1u, frame.renderPasses.size());
2031 m_hostImpl->didDrawAllLayers(frame); 2034 m_hostImpl->didDrawAllLayers(frame);
2032 } 2035 }
2033 2036
2034 } // namespace 2037 } // namespace
2035 2038
2036 class FakeLayerWithQuads : public LayerImpl { 2039 class FakeLayerWithQuads : public LayerImpl {
2037 public: 2040 public:
2038 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n ew FakeLayerWithQuads(id)); } 2041 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n ew FakeLayerWithQuads(id)); }
2039 2042
2040 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat a) OVERRIDE 2043 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat a) OVERRIDE
2041 { 2044 {
2042 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha redQuadState()); 2045 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha redQuadState());
2043 2046
2044 SkColor gray = SkColorSetRGB(100, 100, 100); 2047 SkColor gray = SkColorSetRGB(100, 100, 100);
2045 IntRect quadRect(IntPoint(0, 0), contentBounds()); 2048 gfx::Rect quadRect(gfx::Point(0, 0), contentBounds());
2046 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::create(share dQuadState, quadRect, gray); 2049 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::create(share dQuadState, quadRect, gray);
2047 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData); 2050 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData);
2048 } 2051 }
2049 2052
2050 private: 2053 private:
2051 FakeLayerWithQuads(int id) 2054 FakeLayerWithQuads(int id)
2052 : LayerImpl(id) 2055 : LayerImpl(id)
2053 { 2056 {
2054 } 2057 }
2055 }; 2058 };
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 harness.mustDrawSolidQuad(); 2181 harness.mustDrawSolidQuad();
2179 { 2182 {
2180 LayerTreeHostImpl::FrameData frame; 2183 LayerTreeHostImpl::FrameData frame;
2181 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 2184 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
2182 myHostImpl->drawLayers(frame); 2185 myHostImpl->drawLayers(frame);
2183 myHostImpl->didDrawAllLayers(frame); 2186 myHostImpl->didDrawAllLayers(frame);
2184 } 2187 }
2185 Mock::VerifyAndClearExpectations(&mockContext); 2188 Mock::VerifyAndClearExpectations(&mockContext);
2186 2189
2187 // Damage a portion of the frame. 2190 // Damage a portion of the frame.
2188 myHostImpl->rootLayer()->setUpdateRect(IntRect(0, 0, 2, 3)); 2191 myHostImpl->rootLayer()->setUpdateRect(gfx::Rect(0, 0, 2, 3));
2189 2192
2190 // The second frame will be partially-swapped (the y coordinates are flipped ). 2193 // The second frame will be partially-swapped (the y coordinates are flipped ).
2191 harness.mustSetScissor(0, 7, 2, 3); 2194 harness.mustSetScissor(0, 7, 2, 3);
2192 harness.mustDrawSolidQuad(); 2195 harness.mustDrawSolidQuad();
2193 { 2196 {
2194 LayerTreeHostImpl::FrameData frame; 2197 LayerTreeHostImpl::FrameData frame;
2195 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 2198 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
2196 myHostImpl->drawLayers(frame); 2199 myHostImpl->drawLayers(frame);
2197 myHostImpl->didDrawAllLayers(frame); 2200 myHostImpl->didDrawAllLayers(frame);
2198 } 2201 }
(...skipping 24 matching lines...) Expand all
2223 2226
2224 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay erTreeHostImplClient* client) 2227 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay erTreeHostImplClient* client)
2225 { 2228 {
2226 Settings::setPartialSwapEnabled(partialSwap); 2229 Settings::setPartialSwapEnabled(partialSwap);
2227 2230
2228 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>(); 2231 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>();
2229 2232
2230 LayerTreeSettings settings; 2233 LayerTreeSettings settings;
2231 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, client); 2234 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, client);
2232 myHostImpl->initializeRenderer(context.Pass()); 2235 myHostImpl->initializeRenderer(context.Pass());
2233 myHostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); 2236 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
2234 2237
2235 /* 2238 /*
2236 Layers are created as follows: 2239 Layers are created as follows:
2237 2240
2238 +--------------------+ 2241 +--------------------+
2239 | 1 | 2242 | 1 |
2240 | +-----------+ | 2243 | +-----------+ |
2241 | | 2 | | 2244 | | 2 | |
2242 | | +-------------------+ 2245 | | +-------------------+
2243 | | | 3 | 2246 | | | 3 |
2244 | | +-------------------+ 2247 | | +-------------------+
2245 | | | | 2248 | | | |
2246 | +-----------+ | 2249 | +-----------+ |
2247 | | 2250 | |
2248 | | 2251 | |
2249 +--------------------+ 2252 +--------------------+
2250 2253
2251 Layers 1, 2 have render surfaces 2254 Layers 1, 2 have render surfaces
2252 */ 2255 */
2253 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 2256 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
2254 scoped_ptr<LayerImpl> child = LayerImpl::create(2); 2257 scoped_ptr<LayerImpl> child = LayerImpl::create(2);
2255 scoped_ptr<LayerImpl> grandChild = FakeLayerWithQuads::create(3); 2258 scoped_ptr<LayerImpl> grandChild = FakeLayerWithQuads::create(3);
2256 2259
2257 IntRect rootRect(0, 0, 100, 100); 2260 gfx::Rect rootRect(0, 0, 100, 100);
2258 IntRect childRect(10, 10, 50, 50); 2261 gfx::Rect childRect(10, 10, 50, 50);
2259 IntRect grandChildRect(5, 5, 150, 150); 2262 gfx::Rect grandChildRect(5, 5, 150, 150);
2260 2263
2261 root->createRenderSurface(); 2264 root->createRenderSurface();
2262 root->setAnchorPoint(FloatPoint(0, 0)); 2265 root->setAnchorPoint(gfx::PointF(0, 0));
2263 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); 2266 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y()));
2264 root->setBounds(IntSize(rootRect.width(), rootRect.height())); 2267 root->setBounds(gfx::Size(rootRect.width(), rootRect.height()));
2265 root->setContentBounds(root->bounds()); 2268 root->setContentBounds(root->bounds());
2266 root->setVisibleContentRect(rootRect); 2269 root->setVisibleContentRect(rootRect);
2267 root->setDrawsContent(false); 2270 root->setDrawsContent(false);
2268 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.w idth(), rootRect.height()))); 2271 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(root Rect.width(), rootRect.height())));
2269 2272
2270 child->setAnchorPoint(FloatPoint(0, 0)); 2273 child->setAnchorPoint(gfx::PointF(0, 0));
2271 child->setPosition(FloatPoint(childRect.x(), childRect.y())); 2274 child->setPosition(gfx::PointF(childRect.x(), childRect.y()));
2272 child->setOpacity(0.5f); 2275 child->setOpacity(0.5f);
2273 child->setBounds(IntSize(childRect.width(), childRect.height())); 2276 child->setBounds(gfx::Size(childRect.width(), childRect.height()));
2274 child->setContentBounds(child->bounds()); 2277 child->setContentBounds(child->bounds());
2275 child->setVisibleContentRect(childRect); 2278 child->setVisibleContentRect(childRect);
2276 child->setDrawsContent(false); 2279 child->setDrawsContent(false);
2277 2280
2278 grandChild->setAnchorPoint(FloatPoint(0, 0)); 2281 grandChild->setAnchorPoint(gfx::PointF(0, 0));
2279 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); 2282 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y()));
2280 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( ))); 2283 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh t()));
2281 grandChild->setContentBounds(grandChild->bounds()); 2284 grandChild->setContentBounds(grandChild->bounds());
2282 grandChild->setVisibleContentRect(grandChildRect); 2285 grandChild->setVisibleContentRect(grandChildRect);
2283 grandChild->setDrawsContent(true); 2286 grandChild->setDrawsContent(true);
2284 2287
2285 child->addChild(grandChild.Pass()); 2288 child->addChild(grandChild.Pass());
2286 root->addChild(child.Pass()); 2289 root->addChild(child.Pass());
2287 2290
2288 myHostImpl->setRootLayer(root.Pass()); 2291 myHostImpl->setRootLayer(root.Pass());
2289 return myHostImpl.Pass(); 2292 return myHostImpl.Pass();
2290 } 2293 }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 public: 2614 public:
2612 static scoped_ptr<FakeScrollbarLayerImpl> create(int id) 2615 static scoped_ptr<FakeScrollbarLayerImpl> create(int id)
2613 { 2616 {
2614 return make_scoped_ptr(new FakeScrollbarLayerImpl(id)); 2617 return make_scoped_ptr(new FakeScrollbarLayerImpl(id));
2615 } 2618 }
2616 2619
2617 void createResources(ResourceProvider* provider) 2620 void createResources(ResourceProvider* provider)
2618 { 2621 {
2619 DCHECK(provider); 2622 DCHECK(provider);
2620 int pool = 0; 2623 int pool = 0;
2621 IntSize size(10, 10); 2624 gfx::Size size(10, 10);
2622 GLenum format = GL_RGBA; 2625 GLenum format = GL_RGBA;
2623 ResourceProvider::TextureUsageHint hint = ResourceProvider::TextureUsage Any; 2626 ResourceProvider::TextureUsageHint hint = ResourceProvider::TextureUsage Any;
2624 setScrollbarGeometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollba rThemeGeometryNonEmpty::create())); 2627 setScrollbarGeometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollba rThemeGeometryNonEmpty::create()));
2625 2628
2626 setBackTrackResourceId(provider->createResource(pool, size, format, hint )); 2629 setBackTrackResourceId(provider->createResource(pool, size, format, hint ));
2627 setForeTrackResourceId(provider->createResource(pool, size, format, hint )); 2630 setForeTrackResourceId(provider->createResource(pool, size, format, hint ));
2628 setThumbResourceId(provider->createResource(pool, size, format, hint)); 2631 setThumbResourceId(provider->createResource(pool, size, format, hint));
2629 } 2632 }
2630 2633
2631 protected: 2634 protected:
2632 explicit FakeScrollbarLayerImpl(int id) 2635 explicit FakeScrollbarLayerImpl(int id)
2633 : ScrollbarLayerImpl(id) 2636 : ScrollbarLayerImpl(id)
2634 { 2637 {
2635 } 2638 }
2636 }; 2639 };
2637 2640
2638 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid er* provider) 2641 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid er* provider)
2639 { 2642 {
2640 ResourceProvider::ResourceId resourceId = provider->createResource(0, IntSiz e(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); 2643 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny);
2641 2644
2642 scoped_ptr<TestRenderPass> pass = TestRenderPass::create(RenderPass::Id(1, 1 ), IntRect(0, 0, 1, 1), WebTransformationMatrix()); 2645 scoped_ptr<TestRenderPass> pass = TestRenderPass::create(RenderPass::Id(1, 1 ), gfx::Rect(0, 0, 1, 1), WebTransformationMatrix());
2643 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::create(WebTransfo rmationMatrix(), IntRect(0, 0, 1, 1), IntRect(0, 0, 1, 1), 1, false); 2646 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::create(WebTransfo rmationMatrix(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 1, false);
2644 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::create(sharedState.get() , IntRect(0, 0, 1, 1), resourceId, false, FloatRect(0, 0, 1, 1), false); 2647 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::create(sharedState.get() , gfx::Rect(0, 0, 1, 1), resourceId, false, gfx::RectF(0, 0, 1, 1), false);
2645 2648
2646 pass->appendSharedQuadState(sharedState.Pass()); 2649 pass->appendSharedQuadState(sharedState.Pass());
2647 pass->appendQuad(quad.PassAs<DrawQuad>()); 2650 pass->appendQuad(quad.PassAs<DrawQuad>());
2648 2651
2649 return pass.PassAs<RenderPass>(); 2652 return pass.PassAs<RenderPass>();
2650 } 2653 }
2651 2654
2652 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) 2655 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
2653 { 2656 {
2654 int layerId = 1; 2657 int layerId = 1;
2655 2658
2656 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(layerId++)); 2659 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(layerId++));
2657 rootLayer->setBounds(IntSize(10, 10)); 2660 rootLayer->setBounds(gfx::Size(10, 10));
2658 rootLayer->setAnchorPoint(FloatPoint(0, 0)); 2661 rootLayer->setAnchorPoint(gfx::PointF(0, 0));
2659 2662
2660 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(layerId++); 2663 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(layerId++);
2661 tileLayer->setBounds(IntSize(10, 10)); 2664 tileLayer->setBounds(gfx::Size(10, 10));
2662 tileLayer->setAnchorPoint(FloatPoint(0, 0)); 2665 tileLayer->setAnchorPoint(gfx::PointF(0, 0));
2663 tileLayer->setContentBounds(IntSize(10, 10)); 2666 tileLayer->setContentBounds(gfx::Size(10, 10));
2664 tileLayer->setDrawsContent(true); 2667 tileLayer->setDrawsContent(true);
2665 tileLayer->setSkipsDraw(false); 2668 tileLayer->setSkipsDraw(false);
2666 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(IntSize(10, 1 0), LayerTilingData::NoBorderTexels)); 2669 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10, 10), LayerTilingData::NoBorderTexels));
2667 tilingData->setBounds(IntSize(10, 10)); 2670 tilingData->setBounds(gfx::Size(10, 10));
2668 tileLayer->setTilingData(*tilingData); 2671 tileLayer->setTilingData(*tilingData);
2669 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10), false); 2672 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false);
2670 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); 2673 rootLayer->addChild(tileLayer.PassAs<LayerImpl>());
2671 2674
2672 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(layerId ++); 2675 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(layerId ++);
2673 textureLayer->setBounds(IntSize(10, 10)); 2676 textureLayer->setBounds(gfx::Size(10, 10));
2674 textureLayer->setAnchorPoint(FloatPoint(0, 0)); 2677 textureLayer->setAnchorPoint(gfx::PointF(0, 0));
2675 textureLayer->setContentBounds(IntSize(10, 10)); 2678 textureLayer->setContentBounds(gfx::Size(10, 10));
2676 textureLayer->setDrawsContent(true); 2679 textureLayer->setDrawsContent(true);
2677 textureLayer->setTextureId(1); 2680 textureLayer->setTextureId(1);
2678 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); 2681 rootLayer->addChild(textureLayer.PassAs<LayerImpl>());
2679 2682
2680 scoped_ptr<TiledLayerImpl> maskLayer = TiledLayerImpl::create(layerId++); 2683 scoped_ptr<TiledLayerImpl> maskLayer = TiledLayerImpl::create(layerId++);
2681 maskLayer->setBounds(IntSize(10, 10)); 2684 maskLayer->setBounds(gfx::Size(10, 10));
2682 maskLayer->setAnchorPoint(FloatPoint(0, 0)); 2685 maskLayer->setAnchorPoint(gfx::PointF(0, 0));
2683 maskLayer->setContentBounds(IntSize(10, 10)); 2686 maskLayer->setContentBounds(gfx::Size(10, 10));
2684 maskLayer->setDrawsContent(true); 2687 maskLayer->setDrawsContent(true);
2685 maskLayer->setSkipsDraw(false); 2688 maskLayer->setSkipsDraw(false);
2686 maskLayer->setTilingData(*tilingData); 2689 maskLayer->setTilingData(*tilingData);
2687 maskLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10), false); 2690 maskLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false);
2688 2691
2689 scoped_ptr<TextureLayerImpl> textureLayerWithMask = TextureLayerImpl::create (layerId++); 2692 scoped_ptr<TextureLayerImpl> textureLayerWithMask = TextureLayerImpl::create (layerId++);
2690 textureLayerWithMask->setBounds(IntSize(10, 10)); 2693 textureLayerWithMask->setBounds(gfx::Size(10, 10));
2691 textureLayerWithMask->setAnchorPoint(FloatPoint(0, 0)); 2694 textureLayerWithMask->setAnchorPoint(gfx::PointF(0, 0));
2692 textureLayerWithMask->setContentBounds(IntSize(10, 10)); 2695 textureLayerWithMask->setContentBounds(gfx::Size(10, 10));
2693 textureLayerWithMask->setDrawsContent(true); 2696 textureLayerWithMask->setDrawsContent(true);
2694 textureLayerWithMask->setTextureId(1); 2697 textureLayerWithMask->setTextureId(1);
2695 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<LayerImpl>()); 2698 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<LayerImpl>());
2696 rootLayer->addChild(textureLayerWithMask.PassAs<LayerImpl>()); 2699 rootLayer->addChild(textureLayerWithMask.PassAs<LayerImpl>());
2697 2700
2698 FakeVideoFrame videoFrame; 2701 FakeVideoFrame videoFrame;
2699 FakeVideoFrameProvider provider; 2702 FakeVideoFrameProvider provider;
2700 provider.setFrame(&videoFrame); 2703 provider.setFrame(&videoFrame);
2701 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p rovider); 2704 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p rovider);
2702 videoLayer->setBounds(IntSize(10, 10)); 2705 videoLayer->setBounds(gfx::Size(10, 10));
2703 videoLayer->setAnchorPoint(FloatPoint(0, 0)); 2706 videoLayer->setAnchorPoint(gfx::PointF(0, 0));
2704 videoLayer->setContentBounds(IntSize(10, 10)); 2707 videoLayer->setContentBounds(gfx::Size(10, 10));
2705 videoLayer->setDrawsContent(true); 2708 videoLayer->setDrawsContent(true);
2706 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2709 videoLayer->setLayerTreeHostImpl(m_hostImpl.get());
2707 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); 2710 rootLayer->addChild(videoLayer.PassAs<LayerImpl>());
2708 2711
2709 FakeVideoFrame hwVideoFrame; 2712 FakeVideoFrame hwVideoFrame;
2710 FakeVideoFrameProvider hwProvider; 2713 FakeVideoFrameProvider hwProvider;
2711 hwProvider.setFrame(&hwVideoFrame); 2714 hwProvider.setFrame(&hwVideoFrame);
2712 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++, &hwProvider); 2715 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++, &hwProvider);
2713 hwVideoLayer->setBounds(IntSize(10, 10)); 2716 hwVideoLayer->setBounds(gfx::Size(10, 10));
2714 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); 2717 hwVideoLayer->setAnchorPoint(gfx::PointF(0, 0));
2715 hwVideoLayer->setContentBounds(IntSize(10, 10)); 2718 hwVideoLayer->setContentBounds(gfx::Size(10, 10));
2716 hwVideoLayer->setDrawsContent(true); 2719 hwVideoLayer->setDrawsContent(true);
2717 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2720 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get());
2718 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); 2721 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>());
2719 2722
2720 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(l ayerId++); 2723 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(l ayerId++);
2721 ioSurfaceLayer->setBounds(IntSize(10, 10)); 2724 ioSurfaceLayer->setBounds(gfx::Size(10, 10));
2722 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); 2725 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0));
2723 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); 2726 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10));
2724 ioSurfaceLayer->setDrawsContent(true); 2727 ioSurfaceLayer->setDrawsContent(true);
2725 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); 2728 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10));
2726 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2729 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
2727 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); 2730 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>());
2728 2731
2729 scoped_ptr<HeadsUpDisplayLayerImpl> hudLayer = HeadsUpDisplayLayerImpl::crea te(layerId++); 2732 scoped_ptr<HeadsUpDisplayLayerImpl> hudLayer = HeadsUpDisplayLayerImpl::crea te(layerId++);
2730 hudLayer->setBounds(IntSize(10, 10)); 2733 hudLayer->setBounds(gfx::Size(10, 10));
2731 hudLayer->setAnchorPoint(FloatPoint(0, 0)); 2734 hudLayer->setAnchorPoint(gfx::PointF(0, 0));
2732 hudLayer->setContentBounds(IntSize(10, 10)); 2735 hudLayer->setContentBounds(gfx::Size(10, 10));
2733 hudLayer->setDrawsContent(true); 2736 hudLayer->setDrawsContent(true);
2734 hudLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2737 hudLayer->setLayerTreeHostImpl(m_hostImpl.get());
2735 rootLayer->addChild(hudLayer.PassAs<LayerImpl>()); 2738 rootLayer->addChild(hudLayer.PassAs<LayerImpl>());
2736 2739
2737 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr eate(layerId++)); 2740 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr eate(layerId++));
2738 scrollbarLayer->setBounds(IntSize(10, 10)); 2741 scrollbarLayer->setBounds(gfx::Size(10, 10));
2739 scrollbarLayer->setContentBounds(IntSize(10, 10)); 2742 scrollbarLayer->setContentBounds(gfx::Size(10, 10));
2740 scrollbarLayer->setDrawsContent(true); 2743 scrollbarLayer->setDrawsContent(true);
2741 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2744 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get());
2742 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); 2745 scrollbarLayer->createResources(m_hostImpl->resourceProvider());
2743 rootLayer->addChild(scrollbarLayer.PassAs<LayerImpl>()); 2746 rootLayer->addChild(scrollbarLayer.PassAs<LayerImpl>());
2744 2747
2745 scoped_ptr<DelegatedRendererLayerImpl> delegatedRendererLayer(DelegatedRende rerLayerImpl::create(layerId++)); 2748 scoped_ptr<DelegatedRendererLayerImpl> delegatedRendererLayer(DelegatedRende rerLayerImpl::create(layerId++));
2746 delegatedRendererLayer->setBounds(IntSize(10, 10)); 2749 delegatedRendererLayer->setBounds(gfx::Size(10, 10));
2747 delegatedRendererLayer->setContentBounds(IntSize(10, 10)); 2750 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10));
2748 delegatedRendererLayer->setDrawsContent(true); 2751 delegatedRendererLayer->setDrawsContent(true);
2749 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2752 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get());
2750 ScopedPtrVector<RenderPass> passList; 2753 ScopedPtrVector<RenderPass> passList;
2751 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) ); 2754 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) );
2752 delegatedRendererLayer->setRenderPasses(passList); 2755 delegatedRendererLayer->setRenderPasses(passList);
2753 EXPECT_TRUE(passList.isEmpty()); 2756 EXPECT_TRUE(passList.isEmpty());
2754 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); 2757 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>());
2755 2758
2756 // Use a context that supports IOSurfaces 2759 // Use a context that supports IOSurfaces
2757 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P assAs<GraphicsContext>()); 2760 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P assAs<GraphicsContext>());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 unsigned numTextures() const { return m_numTextures; } 2835 unsigned numTextures() const { return m_numTextures; }
2833 2836
2834 private: 2837 private:
2835 base::hash_map<WebGLId, bool> m_textures; 2838 base::hash_map<WebGLId, bool> m_textures;
2836 unsigned m_numTextures; 2839 unsigned m_numTextures;
2837 }; 2840 };
2838 2841
2839 TEST_P(LayerTreeHostImplTest, layersFreeTextures) 2842 TEST_P(LayerTreeHostImplTest, layersFreeTextures)
2840 { 2843 {
2841 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(1)); 2844 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(1));
2842 rootLayer->setBounds(IntSize(10, 10)); 2845 rootLayer->setBounds(gfx::Size(10, 10));
2843 rootLayer->setAnchorPoint(FloatPoint(0, 0)); 2846 rootLayer->setAnchorPoint(gfx::PointF(0, 0));
2844 2847
2845 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(2); 2848 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(2);
2846 tileLayer->setBounds(IntSize(10, 10)); 2849 tileLayer->setBounds(gfx::Size(10, 10));
2847 tileLayer->setAnchorPoint(FloatPoint(0, 0)); 2850 tileLayer->setAnchorPoint(gfx::PointF(0, 0));
2848 tileLayer->setContentBounds(IntSize(10, 10)); 2851 tileLayer->setContentBounds(gfx::Size(10, 10));
2849 tileLayer->setDrawsContent(true); 2852 tileLayer->setDrawsContent(true);
2850 tileLayer->setSkipsDraw(false); 2853 tileLayer->setSkipsDraw(false);
2851 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(IntSize(10, 1 0), LayerTilingData::NoBorderTexels)); 2854 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10, 10), LayerTilingData::NoBorderTexels));
2852 tilingData->setBounds(IntSize(10, 10)); 2855 tilingData->setBounds(gfx::Size(10, 10));
2853 tileLayer->setTilingData(*tilingData); 2856 tileLayer->setTilingData(*tilingData);
2854 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10), false); 2857 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false);
2855 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); 2858 rootLayer->addChild(tileLayer.PassAs<LayerImpl>());
2856 2859
2857 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(3); 2860 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(3);
2858 textureLayer->setBounds(IntSize(10, 10)); 2861 textureLayer->setBounds(gfx::Size(10, 10));
2859 textureLayer->setAnchorPoint(FloatPoint(0, 0)); 2862 textureLayer->setAnchorPoint(gfx::PointF(0, 0));
2860 textureLayer->setContentBounds(IntSize(10, 10)); 2863 textureLayer->setContentBounds(gfx::Size(10, 10));
2861 textureLayer->setDrawsContent(true); 2864 textureLayer->setDrawsContent(true);
2862 textureLayer->setTextureId(1); 2865 textureLayer->setTextureId(1);
2863 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); 2866 rootLayer->addChild(textureLayer.PassAs<LayerImpl>());
2864 2867
2865 FakeVideoFrameProvider provider; 2868 FakeVideoFrameProvider provider;
2866 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(4, &provider) ; 2869 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(4, &provider) ;
2867 videoLayer->setBounds(IntSize(10, 10)); 2870 videoLayer->setBounds(gfx::Size(10, 10));
2868 videoLayer->setAnchorPoint(FloatPoint(0, 0)); 2871 videoLayer->setAnchorPoint(gfx::PointF(0, 0));
2869 videoLayer->setContentBounds(IntSize(10, 10)); 2872 videoLayer->setContentBounds(gfx::Size(10, 10));
2870 videoLayer->setDrawsContent(true); 2873 videoLayer->setDrawsContent(true);
2871 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2874 videoLayer->setLayerTreeHostImpl(m_hostImpl.get());
2872 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); 2875 rootLayer->addChild(videoLayer.PassAs<LayerImpl>());
2873 2876
2874 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5 ); 2877 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5 );
2875 ioSurfaceLayer->setBounds(IntSize(10, 10)); 2878 ioSurfaceLayer->setBounds(gfx::Size(10, 10));
2876 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); 2879 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0));
2877 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); 2880 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10));
2878 ioSurfaceLayer->setDrawsContent(true); 2881 ioSurfaceLayer->setDrawsContent(true);
2879 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); 2882 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10));
2880 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2883 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
2881 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); 2884 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>());
2882 2885
2883 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the LayerTreeHostImpl takes ownership of). 2886 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the LayerTreeHostImpl takes ownership of).
2884 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D)) ); 2887 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D)) );
2885 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track ingWebGraphicsContext3D*>(outputSurface->context3D()); 2888 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track ingWebGraphicsContext3D*>(outputSurface->context3D());
2886 m_hostImpl->initializeRenderer(outputSurface.Pass()); 2889 m_hostImpl->initializeRenderer(outputSurface.Pass());
2887 2890
2888 m_hostImpl->setRootLayer(rootLayer.Pass()); 2891 m_hostImpl->setRootLayer(rootLayer.Pass());
2889 2892
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2929 Mock::VerifyAndClearExpectations(&mockContext); 2932 Mock::VerifyAndClearExpectations(&mockContext);
2930 2933
2931 // Verify no quads are drawn when transparent background is set. 2934 // Verify no quads are drawn when transparent background is set.
2932 myHostImpl->setHasTransparentBackground(true); 2935 myHostImpl->setHasTransparentBackground(true);
2933 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 2936 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
2934 myHostImpl->drawLayers(frame); 2937 myHostImpl->drawLayers(frame);
2935 myHostImpl->didDrawAllLayers(frame); 2938 myHostImpl->didDrawAllLayers(frame);
2936 Mock::VerifyAndClearExpectations(&mockContext); 2939 Mock::VerifyAndClearExpectations(&mockContext);
2937 } 2940 }
2938 2941
2939 static void addDrawingLayerTo(LayerImpl* parent, int id, const IntRect& layerRec t, LayerImpl** result) 2942 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR ect, LayerImpl** result)
2940 { 2943 {
2941 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(id); 2944 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(id);
2942 LayerImpl* layerPtr = layer.get(); 2945 LayerImpl* layerPtr = layer.get();
2943 layerPtr->setAnchorPoint(FloatPoint(0, 0)); 2946 layerPtr->setAnchorPoint(gfx::PointF(0, 0));
2944 layerPtr->setPosition(FloatPoint(layerRect.location())); 2947 layerPtr->setPosition(gfx::PointF(layerRect.origin()));
2945 layerPtr->setBounds(layerRect.size()); 2948 layerPtr->setBounds(layerRect.size());
2946 layerPtr->setContentBounds(layerRect.size()); 2949 layerPtr->setContentBounds(layerRect.size());
2947 layerPtr->setDrawsContent(true); // only children draw content 2950 layerPtr->setDrawsContent(true); // only children draw content
2948 layerPtr->setContentsOpaque(true); 2951 layerPtr->setContentsOpaque(true);
2949 parent->addChild(layer.Pass()); 2952 parent->addChild(layer.Pass());
2950 if (result) 2953 if (result)
2951 *result = layerPtr; 2954 *result = layerPtr;
2952 } 2955 }
2953 2956
2954 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt r, LayerImpl*& childPtr, const IntSize& rootSize) 2957 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt r, LayerImpl*& childPtr, const gfx::Size& rootSize)
2955 { 2958 {
2956 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>(); 2959 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>();
2957 2960
2958 layerTreeHostImpl->initializeRenderer(context.Pass()); 2961 layerTreeHostImpl->initializeRenderer(context.Pass());
2959 layerTreeHostImpl->setViewportSize(rootSize, rootSize); 2962 layerTreeHostImpl->setViewportSize(rootSize, rootSize);
2960 2963
2961 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 2964 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
2962 rootPtr = root.get(); 2965 rootPtr = root.get();
2963 2966
2964 root->setAnchorPoint(FloatPoint(0, 0)); 2967 root->setAnchorPoint(gfx::PointF(0, 0));
2965 root->setPosition(FloatPoint(0, 0)); 2968 root->setPosition(gfx::PointF(0, 0));
2966 root->setBounds(rootSize); 2969 root->setBounds(rootSize);
2967 root->setContentBounds(rootSize); 2970 root->setContentBounds(rootSize);
2968 root->setDrawsContent(true); 2971 root->setDrawsContent(true);
2969 layerTreeHostImpl->setRootLayer(root.Pass()); 2972 layerTreeHostImpl->setRootLayer(root.Pass());
2970 2973
2971 addDrawingLayerTo(rootPtr, 2, IntRect(10, 10, rootSize.width(), rootSize.hei ght()), &intermediateLayerPtr); 2974 addDrawingLayerTo(rootPtr, 2, gfx::Rect(10, 10, rootSize.width(), rootSize.h eight()), &intermediateLayerPtr);
2972 intermediateLayerPtr->setDrawsContent(false); // only children draw content 2975 intermediateLayerPtr->setDrawsContent(false); // only children draw content
2973 2976
2974 // Surface layer is the layer that changes its opacity 2977 // Surface layer is the layer that changes its opacity
2975 // It will contain other layers that draw content. 2978 // It will contain other layers that draw content.
2976 addDrawingLayerTo(intermediateLayerPtr, 3, IntRect(10, 10, rootSize.width(), rootSize.height()), &surfaceLayerPtr); 2979 addDrawingLayerTo(intermediateLayerPtr, 3, gfx::Rect(10, 10, rootSize.width( ), rootSize.height()), &surfaceLayerPtr);
2977 surfaceLayerPtr->setDrawsContent(false); // only children draw content 2980 surfaceLayerPtr->setDrawsContent(false); // only children draw content
2978 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface 2981 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface
2979 2982
2980 // Child of the surface layer will produce some quads 2983 // Child of the surface layer will produce some quads
2981 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(5, 5, rootSize.width() - 25, r ootSize.height() - 25), &childPtr); 2984 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(5, 5, rootSize.width() - 25, rootSize.height() - 25), &childPtr);
2982 } 2985 }
2983 2986
2984 class GLRendererWithReleaseTextures : public GLRenderer { 2987 class GLRendererWithReleaseTextures : public GLRenderer {
2985 public: 2988 public:
2986 using GLRenderer::releaseRenderPassTextures; 2989 using GLRenderer::releaseRenderPassTextures;
2987 }; 2990 };
2988 2991
2989 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) 2992 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
2990 { 2993 {
2991 Settings::setPartialSwapEnabled(true); 2994 Settings::setPartialSwapEnabled(true);
2992 2995
2993 LayerTreeSettings settings; 2996 LayerTreeSettings settings;
2994 settings.minimumOcclusionTrackingSize = IntSize(); 2997 settings.minimumOcclusionTrackingSize = gfx::Size();
2995 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this); 2998 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this);
2996 2999
2997 LayerImpl* rootPtr; 3000 LayerImpl* rootPtr;
2998 LayerImpl* surfaceLayerPtr; 3001 LayerImpl* surfaceLayerPtr;
2999 3002
3000 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>(); 3003 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>();
3001 3004
3002 IntSize rootSize(100, 100); 3005 gfx::Size rootSize(100, 100);
3003 3006
3004 myHostImpl->initializeRenderer(context.Pass()); 3007 myHostImpl->initializeRenderer(context.Pass());
3005 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3008 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3006 3009
3007 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3010 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
3008 rootPtr = root.get(); 3011 rootPtr = root.get();
3009 3012
3010 root->setAnchorPoint(FloatPoint(0, 0)); 3013 root->setAnchorPoint(gfx::PointF(0, 0));
3011 root->setPosition(FloatPoint(0, 0)); 3014 root->setPosition(gfx::PointF(0, 0));
3012 root->setBounds(rootSize); 3015 root->setBounds(rootSize);
3013 root->setContentBounds(rootSize); 3016 root->setContentBounds(rootSize);
3014 root->setDrawsContent(true); 3017 root->setDrawsContent(true);
3015 root->setMasksToBounds(true); 3018 root->setMasksToBounds(true);
3016 myHostImpl->setRootLayer(root.Pass()); 3019 myHostImpl->setRootLayer(root.Pass());
3017 3020
3018 addDrawingLayerTo(rootPtr, 3, IntRect(0, 0, rootSize.width(), rootSize.heigh t()), &surfaceLayerPtr); 3021 addDrawingLayerTo(rootPtr, 3, gfx::Rect(0, 0, rootSize.width(), rootSize.hei ght()), &surfaceLayerPtr);
3019 surfaceLayerPtr->setDrawsContent(false); 3022 surfaceLayerPtr->setDrawsContent(false);
3020 3023
3021 // Surface layer is the layer that changes its opacity 3024 // Surface layer is the layer that changes its opacity
3022 // It will contain other layers that draw content. 3025 // It will contain other layers that draw content.
3023 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface 3026 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface
3024 3027
3025 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(0, 0, 100, 3), 0); 3028 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(0, 0, 100, 3), 0);
3026 addDrawingLayerTo(surfaceLayerPtr, 5, IntRect(0, 97, 100, 3), 0); 3029 addDrawingLayerTo(surfaceLayerPtr, 5, gfx::Rect(0, 97, 100, 3), 0);
3027 3030
3028 // Rotation will put part of the child ouside the bounds of the root layer. 3031 // Rotation will put part of the child ouside the bounds of the root layer.
3029 // Nevertheless, the child layers should be drawn. 3032 // Nevertheless, the child layers should be drawn.
3030 WebTransformationMatrix transform = surfaceLayerPtr->transform(); 3033 WebTransformationMatrix transform = surfaceLayerPtr->transform();
3031 transform.translate(50, 50); 3034 transform.translate(50, 50);
3032 transform.rotate(35); 3035 transform.rotate(35);
3033 transform.translate(-50, -50); 3036 transform.translate(-50, -50);
3034 surfaceLayerPtr->setTransform(transform); 3037 surfaceLayerPtr->setTransform(transform);
3035 3038
3036 { 3039 {
3037 LayerTreeHostImpl::FrameData frame; 3040 LayerTreeHostImpl::FrameData frame;
3038 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3041 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3039 3042
3040 // Must receive two render passes, each with one quad 3043 // Must receive two render passes, each with one quad
3041 ASSERT_EQ(2U, frame.renderPasses.size()); 3044 ASSERT_EQ(2U, frame.renderPasses.size());
3042 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); 3045 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size());
3043 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); 3046 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size());
3044 3047
3045 // Verify that the child layers are being clipped. 3048 // Verify that the child layers are being clipped.
3046 gfx::Rect quadVisibleRect = frame.renderPasses[0]->quadList()[0]->quadVi sibleRect(); 3049 gfx::Rect quadVisibleRect = frame.renderPasses[0]->quadList()[0]->quadVi sibleRect();
3047 EXPECT_LT(quadVisibleRect.width(), 100); 3050 EXPECT_LT(quadVisibleRect.width(), 100);
3048 3051
3049 quadVisibleRect = frame.renderPasses[0]->quadList()[1]->quadVisibleRect( ); 3052 quadVisibleRect = frame.renderPasses[0]->quadList()[1]->quadVisibleRect( );
3050 EXPECT_LT(quadVisibleRect.width(), 100); 3053 EXPECT_LT(quadVisibleRect.width(), 100);
3051 3054
3052 // Verify that the render surface texture is *not* clipped. 3055 // Verify that the render surface texture is *not* clipped.
3053 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), frame.renderPasses[0]->outputRec t()); 3056 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), frame.renderPasses[0]->outputR ect());
3054 3057
3055 EXPECT_EQ(DrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->ma terial()); 3058 EXPECT_EQ(DrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->ma terial());
3056 RenderPassDrawQuad* quad = static_cast<RenderPassDrawQuad*>(frame.render Passes[1]->quadList()[0]); 3059 RenderPassDrawQuad* quad = static_cast<RenderPassDrawQuad*>(frame.render Passes[1]->quadList()[0]);
3057 EXPECT_FALSE(quad->contentsChangedSinceLastFrame().IsEmpty()); 3060 EXPECT_FALSE(quad->contentsChangedSinceLastFrame().IsEmpty());
3058 3061
3059 myHostImpl->drawLayers(frame); 3062 myHostImpl->drawLayers(frame);
3060 myHostImpl->didDrawAllLayers(frame); 3063 myHostImpl->didDrawAllLayers(frame);
3061 } 3064 }
3062 3065
3063 transform = surfaceLayerPtr->transform(); 3066 transform = surfaceLayerPtr->transform();
(...skipping 17 matching lines...) Expand all
3081 myHostImpl->drawLayers(frame); 3084 myHostImpl->drawLayers(frame);
3082 myHostImpl->didDrawAllLayers(frame); 3085 myHostImpl->didDrawAllLayers(frame);
3083 } 3086 }
3084 } 3087 }
3085 3088
3086 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion) 3089 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
3087 { 3090 {
3088 Settings::setPartialSwapEnabled(false); 3091 Settings::setPartialSwapEnabled(false);
3089 3092
3090 LayerTreeSettings settings; 3093 LayerTreeSettings settings;
3091 settings.minimumOcclusionTrackingSize = IntSize(); 3094 settings.minimumOcclusionTrackingSize = gfx::Size();
3092 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this); 3095 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this);
3093 3096
3094 // Layers are structure as follows: 3097 // Layers are structure as follows:
3095 // 3098 //
3096 // R +-- S1 +- L10 (owning) 3099 // R +-- S1 +- L10 (owning)
3097 // | +- L11 3100 // | +- L11
3098 // | +- L12 3101 // | +- L12
3099 // | 3102 // |
3100 // +-- S2 +- L20 (owning) 3103 // +-- S2 +- L20 (owning)
3101 // +- L21 3104 // +- L21
3102 // 3105 //
3103 // Occlusion: 3106 // Occlusion:
3104 // L12 occludes L11 (internal) 3107 // L12 occludes L11 (internal)
3105 // L20 occludes L10 (external) 3108 // L20 occludes L10 (external)
3106 // L21 occludes L20 (internal) 3109 // L21 occludes L20 (internal)
3107 3110
3108 LayerImpl* rootPtr; 3111 LayerImpl* rootPtr;
3109 LayerImpl* layerS1Ptr; 3112 LayerImpl* layerS1Ptr;
3110 LayerImpl* layerS2Ptr; 3113 LayerImpl* layerS2Ptr;
3111 3114
3112 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>(); 3115 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>();
3113 3116
3114 IntSize rootSize(1000, 1000); 3117 gfx::Size rootSize(1000, 1000);
3115 3118
3116 myHostImpl->initializeRenderer(context.Pass()); 3119 myHostImpl->initializeRenderer(context.Pass());
3117 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3120 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3118 3121
3119 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3122 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
3120 rootPtr = root.get(); 3123 rootPtr = root.get();
3121 3124
3122 root->setAnchorPoint(FloatPoint(0, 0)); 3125 root->setAnchorPoint(gfx::PointF(0, 0));
3123 root->setPosition(FloatPoint(0, 0)); 3126 root->setPosition(gfx::PointF(0, 0));
3124 root->setBounds(rootSize); 3127 root->setBounds(rootSize);
3125 root->setContentBounds(rootSize); 3128 root->setContentBounds(rootSize);
3126 root->setDrawsContent(true); 3129 root->setDrawsContent(true);
3127 root->setMasksToBounds(true); 3130 root->setMasksToBounds(true);
3128 myHostImpl->setRootLayer(root.Pass()); 3131 myHostImpl->setRootLayer(root.Pass());
3129 3132
3130 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); 3133 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr);
3131 layerS1Ptr->setForceRenderSurface(true); 3134 layerS1Ptr->setForceRenderSurface(true);
3132 3135
3133 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 3136 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11
3134 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 3137 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12
3135 3138
3136 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); 3139 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr);
3137 layerS2Ptr->setForceRenderSurface(true); 3140 layerS2Ptr->setForceRenderSurface(true);
3138 3141
3139 addDrawingLayerTo(layerS2Ptr, 6, IntRect(20, 20, 5, 5), 0); // L21 3142 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21
3140 3143
3141 // Initial draw - must receive all quads 3144 // Initial draw - must receive all quads
3142 { 3145 {
3143 LayerTreeHostImpl::FrameData frame; 3146 LayerTreeHostImpl::FrameData frame;
3144 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3147 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3145 3148
3146 // Must receive 3 render passes. 3149 // Must receive 3 render passes.
3147 // For Root, there are 2 quads; for S1, there are 2 quads (1 is occluded ); for S2, there is 2 quads. 3150 // For Root, there are 2 quads; for S1, there are 2 quads (1 is occluded ); for S2, there is 2 quads.
3148 ASSERT_EQ(3U, frame.renderPasses.size()); 3151 ASSERT_EQ(3U, frame.renderPasses.size());
3149 3152
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 myHostImpl->didDrawAllLayers(frame); 3200 myHostImpl->didDrawAllLayers(frame);
3198 } 3201 }
3199 3202
3200 } 3203 }
3201 3204
3202 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) 3205 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
3203 { 3206 {
3204 Settings::setPartialSwapEnabled(false); 3207 Settings::setPartialSwapEnabled(false);
3205 3208
3206 LayerTreeSettings settings; 3209 LayerTreeSettings settings;
3207 settings.minimumOcclusionTrackingSize = IntSize(); 3210 settings.minimumOcclusionTrackingSize = gfx::Size();
3208 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this); 3211 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this);
3209 3212
3210 // Layers are structure as follows: 3213 // Layers are structure as follows:
3211 // 3214 //
3212 // R +-- S1 +- L10 (owning, non drawing) 3215 // R +-- S1 +- L10 (owning, non drawing)
3213 // | +- L11 (corner, unoccluded) 3216 // | +- L11 (corner, unoccluded)
3214 // | +- L12 (corner, unoccluded) 3217 // | +- L12 (corner, unoccluded)
3215 // | +- L13 (corner, unoccluded) 3218 // | +- L13 (corner, unoccluded)
3216 // | +- L14 (corner, entirely occluded) 3219 // | +- L14 (corner, entirely occluded)
3217 // | 3220 // |
3218 // +-- S2 +- L20 (owning, drawing) 3221 // +-- S2 +- L20 (owning, drawing)
3219 // 3222 //
3220 3223
3221 LayerImpl* rootPtr; 3224 LayerImpl* rootPtr;
3222 LayerImpl* layerS1Ptr; 3225 LayerImpl* layerS1Ptr;
3223 LayerImpl* layerS2Ptr; 3226 LayerImpl* layerS2Ptr;
3224 3227
3225 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>(); 3228 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>();
3226 3229
3227 IntSize rootSize(1000, 1000); 3230 gfx::Size rootSize(1000, 1000);
3228 3231
3229 myHostImpl->initializeRenderer(context.Pass()); 3232 myHostImpl->initializeRenderer(context.Pass());
3230 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3233 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3231 3234
3232 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3235 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
3233 rootPtr = root.get(); 3236 rootPtr = root.get();
3234 3237
3235 root->setAnchorPoint(FloatPoint(0, 0)); 3238 root->setAnchorPoint(gfx::PointF(0, 0));
3236 root->setPosition(FloatPoint(0, 0)); 3239 root->setPosition(gfx::PointF(0, 0));
3237 root->setBounds(rootSize); 3240 root->setBounds(rootSize);
3238 root->setContentBounds(rootSize); 3241 root->setContentBounds(rootSize);
3239 root->setDrawsContent(true); 3242 root->setDrawsContent(true);
3240 root->setMasksToBounds(true); 3243 root->setMasksToBounds(true);
3241 myHostImpl->setRootLayer(root.Pass()); 3244 myHostImpl->setRootLayer(root.Pass());
3242 3245
3243 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 800, 800), &layerS1Ptr); 3246 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr);
3244 layerS1Ptr->setForceRenderSurface(true); 3247 layerS1Ptr->setForceRenderSurface(true);
3245 layerS1Ptr->setDrawsContent(false); 3248 layerS1Ptr->setDrawsContent(false);
3246 3249
3247 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 3250 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11
3248 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 500, 300, 300), 0); // L12 3251 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12
3249 addDrawingLayerTo(layerS1Ptr, 5, IntRect(500, 0, 300, 300), 0); // L13 3252 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13
3250 addDrawingLayerTo(layerS1Ptr, 6, IntRect(500, 500, 300, 300), 0); // L14 3253 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14
3251 addDrawingLayerTo(layerS1Ptr, 9, IntRect(500, 500, 300, 300), 0); // L14 3254 addDrawingLayerTo(layerS1Ptr, 9, gfx::Rect(500, 500, 300, 300), 0); // L14
3252 3255
3253 addDrawingLayerTo(rootPtr, 7, IntRect(450, 450, 450, 450), &layerS2Ptr); 3256 addDrawingLayerTo(rootPtr, 7, gfx::Rect(450, 450, 450, 450), &layerS2Ptr);
3254 layerS2Ptr->setForceRenderSurface(true); 3257 layerS2Ptr->setForceRenderSurface(true);
3255 3258
3256 // Initial draw - must receive all quads 3259 // Initial draw - must receive all quads
3257 { 3260 {
3258 LayerTreeHostImpl::FrameData frame; 3261 LayerTreeHostImpl::FrameData frame;
3259 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3262 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3260 3263
3261 // Must receive 3 render passes. 3264 // Must receive 3 render passes.
3262 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad. 3265 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad.
3263 ASSERT_EQ(3U, frame.renderPasses.size()); 3266 ASSERT_EQ(3U, frame.renderPasses.size());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3313 myHostImpl->drawLayers(frame); 3316 myHostImpl->drawLayers(frame);
3314 myHostImpl->didDrawAllLayers(frame); 3317 myHostImpl->didDrawAllLayers(frame);
3315 } 3318 }
3316 } 3319 }
3317 3320
3318 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) 3321 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
3319 { 3322 {
3320 Settings::setPartialSwapEnabled(false); 3323 Settings::setPartialSwapEnabled(false);
3321 3324
3322 LayerTreeSettings settings; 3325 LayerTreeSettings settings;
3323 settings.minimumOcclusionTrackingSize = IntSize(); 3326 settings.minimumOcclusionTrackingSize = gfx::Size();
3324 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this); 3327 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this);
3325 3328
3326 // Layers are structured as follows: 3329 // Layers are structured as follows:
3327 // 3330 //
3328 // R +-- S1 +- L10 (owning, drawing) 3331 // R +-- S1 +- L10 (owning, drawing)
3329 // | +- L11 (corner, occluded by L12) 3332 // | +- L11 (corner, occluded by L12)
3330 // | +- L12 (opposite corner) 3333 // | +- L12 (opposite corner)
3331 // | 3334 // |
3332 // +-- S2 +- L20 (owning, drawing) 3335 // +-- S2 +- L20 (owning, drawing)
3333 // 3336 //
3334 3337
3335 LayerImpl* rootPtr; 3338 LayerImpl* rootPtr;
3336 LayerImpl* layerS1Ptr; 3339 LayerImpl* layerS1Ptr;
3337 LayerImpl* layerS2Ptr; 3340 LayerImpl* layerS2Ptr;
3338 3341
3339 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>(); 3342 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>();
3340 3343
3341 IntSize rootSize(1000, 1000); 3344 gfx::Size rootSize(1000, 1000);
3342 3345
3343 myHostImpl->initializeRenderer(context.Pass()); 3346 myHostImpl->initializeRenderer(context.Pass());
3344 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3347 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3345 3348
3346 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3349 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
3347 rootPtr = root.get(); 3350 rootPtr = root.get();
3348 3351
3349 root->setAnchorPoint(FloatPoint(0, 0)); 3352 root->setAnchorPoint(gfx::PointF(0, 0));
3350 root->setPosition(FloatPoint(0, 0)); 3353 root->setPosition(gfx::PointF(0, 0));
3351 root->setBounds(rootSize); 3354 root->setBounds(rootSize);
3352 root->setContentBounds(rootSize); 3355 root->setContentBounds(rootSize);
3353 root->setDrawsContent(true); 3356 root->setDrawsContent(true);
3354 root->setMasksToBounds(true); 3357 root->setMasksToBounds(true);
3355 myHostImpl->setRootLayer(root.Pass()); 3358 myHostImpl->setRootLayer(root.Pass());
3356 3359
3357 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); 3360 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
3358 layerS1Ptr->setForceRenderSurface(true); 3361 layerS1Ptr->setForceRenderSurface(true);
3359 3362
3360 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 3363 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11
3361 addDrawingLayerTo(layerS1Ptr, 4, IntRect(100, 0, 300, 300), 0); // L12 3364 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12
3362 3365
3363 addDrawingLayerTo(rootPtr, 7, IntRect(200, 0, 300, 300), &layerS2Ptr); 3366 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr);
3364 layerS2Ptr->setForceRenderSurface(true); 3367 layerS2Ptr->setForceRenderSurface(true);
3365 3368
3366 // Initial draw - must receive all quads 3369 // Initial draw - must receive all quads
3367 { 3370 {
3368 LayerTreeHostImpl::FrameData frame; 3371 LayerTreeHostImpl::FrameData frame;
3369 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3372 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3370 3373
3371 // Must receive 3 render passes. 3374 // Must receive 3 render passes.
3372 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad. 3375 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there is 1 quad.
3373 ASSERT_EQ(3U, frame.renderPasses.size()); 3376 ASSERT_EQ(3U, frame.renderPasses.size());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 // Layers are structured as follows: 3417 // Layers are structured as follows:
3415 // 3418 //
3416 // R +-- S1 +- L10 (rotated, drawing) 3419 // R +-- S1 +- L10 (rotated, drawing)
3417 // +- L11 (occupies half surface) 3420 // +- L11 (occupies half surface)
3418 3421
3419 LayerImpl* rootPtr; 3422 LayerImpl* rootPtr;
3420 LayerImpl* layerS1Ptr; 3423 LayerImpl* layerS1Ptr;
3421 3424
3422 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>(); 3425 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>();
3423 3426
3424 IntSize rootSize(1000, 1000); 3427 gfx::Size rootSize(1000, 1000);
3425 3428
3426 myHostImpl->initializeRenderer(context.Pass()); 3429 myHostImpl->initializeRenderer(context.Pass());
3427 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3430 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3428 3431
3429 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3432 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
3430 rootPtr = root.get(); 3433 rootPtr = root.get();
3431 3434
3432 root->setAnchorPoint(FloatPoint(0, 0)); 3435 root->setAnchorPoint(gfx::PointF(0, 0));
3433 root->setPosition(FloatPoint(0, 0)); 3436 root->setPosition(gfx::PointF(0, 0));
3434 root->setBounds(rootSize); 3437 root->setBounds(rootSize);
3435 root->setContentBounds(rootSize); 3438 root->setContentBounds(rootSize);
3436 root->setDrawsContent(true); 3439 root->setDrawsContent(true);
3437 root->setMasksToBounds(true); 3440 root->setMasksToBounds(true);
3438 myHostImpl->setRootLayer(root.Pass()); 3441 myHostImpl->setRootLayer(root.Pass());
3439 3442
3440 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); 3443 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
3441 layerS1Ptr->setForceRenderSurface(true); 3444 layerS1Ptr->setForceRenderSurface(true);
3442 WebTransformationMatrix transform = layerS1Ptr->transform(); 3445 WebTransformationMatrix transform = layerS1Ptr->transform();
3443 transform.translate(200, 200); 3446 transform.translate(200, 200);
3444 transform.rotate(45); 3447 transform.rotate(45);
3445 transform.translate(-200, -200); 3448 transform.translate(-200, -200);
3446 layerS1Ptr->setTransform(transform); 3449 layerS1Ptr->setTransform(transform);
3447 3450
3448 addDrawingLayerTo(layerS1Ptr, 3, IntRect(200, 0, 200, 400), 0); // L11 3451 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11
3449 3452
3450 // Initial draw - must receive all quads 3453 // Initial draw - must receive all quads
3451 { 3454 {
3452 LayerTreeHostImpl::FrameData frame; 3455 LayerTreeHostImpl::FrameData frame;
3453 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3456 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3454 3457
3455 // Must receive 2 render passes. 3458 // Must receive 2 render passes.
3456 ASSERT_EQ(2U, frame.renderPasses.size()); 3459 ASSERT_EQ(2U, frame.renderPasses.size());
3457 3460
3458 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); 3461 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size());
(...skipping 17 matching lines...) Expand all
3476 myHostImpl->drawLayers(frame); 3479 myHostImpl->drawLayers(frame);
3477 myHostImpl->didDrawAllLayers(frame); 3480 myHostImpl->didDrawAllLayers(frame);
3478 } 3481 }
3479 } 3482 }
3480 3483
3481 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) 3484 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
3482 { 3485 {
3483 Settings::setPartialSwapEnabled(true); 3486 Settings::setPartialSwapEnabled(true);
3484 3487
3485 LayerTreeSettings settings; 3488 LayerTreeSettings settings;
3486 settings.minimumOcclusionTrackingSize = IntSize(); 3489 settings.minimumOcclusionTrackingSize = gfx::Size();
3487 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this); 3490 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this);
3488 3491
3489 // Layers are structure as follows: 3492 // Layers are structure as follows:
3490 // 3493 //
3491 // R +-- S1 +- L10 (owning) 3494 // R +-- S1 +- L10 (owning)
3492 // | +- L11 3495 // | +- L11
3493 // | +- L12 3496 // | +- L12
3494 // | 3497 // |
3495 // +-- S2 +- L20 (owning) 3498 // +-- S2 +- L20 (owning)
3496 // +- L21 3499 // +- L21
3497 // 3500 //
3498 // Occlusion: 3501 // Occlusion:
3499 // L12 occludes L11 (internal) 3502 // L12 occludes L11 (internal)
3500 // L20 occludes L10 (external) 3503 // L20 occludes L10 (external)
3501 // L21 occludes L20 (internal) 3504 // L21 occludes L20 (internal)
3502 3505
3503 LayerImpl* rootPtr; 3506 LayerImpl* rootPtr;
3504 LayerImpl* layerS1Ptr; 3507 LayerImpl* layerS1Ptr;
3505 LayerImpl* layerS2Ptr; 3508 LayerImpl* layerS2Ptr;
3506 3509
3507 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>(); 3510 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>();
3508 3511
3509 IntSize rootSize(1000, 1000); 3512 gfx::Size rootSize(1000, 1000);
3510 3513
3511 myHostImpl->initializeRenderer(context.Pass()); 3514 myHostImpl->initializeRenderer(context.Pass());
3512 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3515 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3513 3516
3514 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3517 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
3515 rootPtr = root.get(); 3518 rootPtr = root.get();
3516 3519
3517 root->setAnchorPoint(FloatPoint(0, 0)); 3520 root->setAnchorPoint(gfx::PointF(0, 0));
3518 root->setPosition(FloatPoint(0, 0)); 3521 root->setPosition(gfx::PointF(0, 0));
3519 root->setBounds(rootSize); 3522 root->setBounds(rootSize);
3520 root->setContentBounds(rootSize); 3523 root->setContentBounds(rootSize);
3521 root->setDrawsContent(true); 3524 root->setDrawsContent(true);
3522 root->setMasksToBounds(true); 3525 root->setMasksToBounds(true);
3523 myHostImpl->setRootLayer(root.Pass()); 3526 myHostImpl->setRootLayer(root.Pass());
3524 3527
3525 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); 3528 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr);
3526 layerS1Ptr->setForceRenderSurface(true); 3529 layerS1Ptr->setForceRenderSurface(true);
3527 3530
3528 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 3531 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11
3529 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 3532 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12
3530 3533
3531 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); 3534 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr);
3532 layerS2Ptr->setForceRenderSurface(true); 3535 layerS2Ptr->setForceRenderSurface(true);
3533 3536
3534 addDrawingLayerTo(layerS2Ptr, 6, IntRect(20, 20, 5, 5), 0); // L21 3537 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21
3535 3538
3536 // Initial draw - must receive all quads 3539 // Initial draw - must receive all quads
3537 { 3540 {
3538 LayerTreeHostImpl::FrameData frame; 3541 LayerTreeHostImpl::FrameData frame;
3539 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3542 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3540 3543
3541 // Must receive 3 render passes. 3544 // Must receive 3 render passes.
3542 // For Root, there are 2 quads; for S1, there are 2 quads (one is occlud ed); for S2, there is 2 quads. 3545 // For Root, there are 2 quads; for S1, there are 2 quads (one is occlud ed); for S2, there is 2 quads.
3543 ASSERT_EQ(3U, frame.renderPasses.size()); 3546 ASSERT_EQ(3U, frame.renderPasses.size());
3544 3547
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 myHostImpl->drawLayers(frame); 3592 myHostImpl->drawLayers(frame);
3590 myHostImpl->didDrawAllLayers(frame); 3593 myHostImpl->didDrawAllLayers(frame);
3591 } 3594 }
3592 } 3595 }
3593 3596
3594 TEST_P(LayerTreeHostImplTest, textureCachingWithScissor) 3597 TEST_P(LayerTreeHostImplTest, textureCachingWithScissor)
3595 { 3598 {
3596 Settings::setPartialSwapEnabled(false); 3599 Settings::setPartialSwapEnabled(false);
3597 3600
3598 LayerTreeSettings settings; 3601 LayerTreeSettings settings;
3599 settings.minimumOcclusionTrackingSize = IntSize(); 3602 settings.minimumOcclusionTrackingSize = gfx::Size();
3600 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this); 3603 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this);
3601 3604
3602 /* 3605 /*
3603 Layers are created as follows: 3606 Layers are created as follows:
3604 3607
3605 +--------------------+ 3608 +--------------------+
3606 | 1 | 3609 | 1 |
3607 | +-----------+ | 3610 | +-----------+ |
3608 | | 2 | | 3611 | | 2 | |
3609 | | +-------------------+ 3612 | | +-------------------+
3610 | | | 3 | 3613 | | | 3 |
3611 | | +-------------------+ 3614 | | +-------------------+
3612 | | | | 3615 | | | |
3613 | +-----------+ | 3616 | +-----------+ |
3614 | | 3617 | |
3615 | | 3618 | |
3616 +--------------------+ 3619 +--------------------+
3617 3620
3618 Layers 1, 2 have render surfaces 3621 Layers 1, 2 have render surfaces
3619 */ 3622 */
3620 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 3623 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
3621 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(2); 3624 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(2);
3622 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); 3625 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3);
3623 3626
3624 IntRect rootRect(0, 0, 100, 100); 3627 gfx::Rect rootRect(0, 0, 100, 100);
3625 IntRect childRect(10, 10, 50, 50); 3628 gfx::Rect childRect(10, 10, 50, 50);
3626 IntRect grandChildRect(5, 5, 150, 150); 3629 gfx::Rect grandChildRect(5, 5, 150, 150);
3627 3630
3628 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>(); 3631 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create (scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi csContext>();
3629 myHostImpl->initializeRenderer(context.Pass()); 3632 myHostImpl->initializeRenderer(context.Pass());
3630 3633
3631 root->setAnchorPoint(FloatPoint(0, 0)); 3634 root->setAnchorPoint(gfx::PointF(0, 0));
3632 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); 3635 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y()));
3633 root->setBounds(IntSize(rootRect.width(), rootRect.height())); 3636 root->setBounds(gfx::Size(rootRect.width(), rootRect.height()));
3634 root->setContentBounds(root->bounds()); 3637 root->setContentBounds(root->bounds());
3635 root->setDrawsContent(true); 3638 root->setDrawsContent(true);
3636 root->setMasksToBounds(true); 3639 root->setMasksToBounds(true);
3637 3640
3638 child->setAnchorPoint(FloatPoint(0, 0)); 3641 child->setAnchorPoint(gfx::PointF(0, 0));
3639 child->setPosition(FloatPoint(childRect.x(), childRect.y())); 3642 child->setPosition(gfx::PointF(childRect.x(), childRect.y()));
3640 child->setOpacity(0.5); 3643 child->setOpacity(0.5);
3641 child->setBounds(IntSize(childRect.width(), childRect.height())); 3644 child->setBounds(gfx::Size(childRect.width(), childRect.height()));
3642 child->setContentBounds(child->bounds()); 3645 child->setContentBounds(child->bounds());
3643 child->setDrawsContent(true); 3646 child->setDrawsContent(true);
3644 child->setSkipsDraw(false); 3647 child->setSkipsDraw(false);
3645 3648
3646 // child layer has 10x10 tiles. 3649 // child layer has 10x10 tiles.
3647 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(IntSize(10, 10), LayerTilingData::HasBorderTexels); 3650 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10, 10 ), LayerTilingData::HasBorderTexels);
3648 tiler->setBounds(child->contentBounds()); 3651 tiler->setBounds(child->contentBounds());
3649 child->setTilingData(*tiler.get()); 3652 child->setTilingData(*tiler.get());
3650 3653
3651 grandChild->setAnchorPoint(FloatPoint(0, 0)); 3654 grandChild->setAnchorPoint(gfx::PointF(0, 0));
3652 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); 3655 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y()));
3653 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( ))); 3656 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh t()));
3654 grandChild->setContentBounds(grandChild->bounds()); 3657 grandChild->setContentBounds(grandChild->bounds());
3655 grandChild->setDrawsContent(true); 3658 grandChild->setDrawsContent(true);
3656 3659
3657 TiledLayerImpl* childPtr = child.get(); 3660 TiledLayerImpl* childPtr = child.get();
3658 RenderPass::Id childPassId(childPtr->id(), 0); 3661 RenderPass::Id childPassId(childPtr->id(), 0);
3659 3662
3660 child->addChild(grandChild.Pass()); 3663 child->addChild(grandChild.Pass());
3661 root->addChild(child.PassAs<LayerImpl>()); 3664 root->addChild(child.PassAs<LayerImpl>());
3662 myHostImpl->setRootLayer(root.Pass()); 3665 myHostImpl->setRootLayer(root.Pass());
3663 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); 3666 myHostImpl->setViewportSize(rootRect.size(), rootRect.size());
(...skipping 14 matching lines...) Expand all
3678 LayerTreeHostImpl::FrameData frame; 3681 LayerTreeHostImpl::FrameData frame;
3679 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3682 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3680 myHostImpl->drawLayers(frame); 3683 myHostImpl->drawLayers(frame);
3681 myHostImpl->didDrawAllLayers(frame); 3684 myHostImpl->didDrawAllLayers(frame);
3682 } 3685 }
3683 3686
3684 // We should still have cached textures for surface 2 after drawing with no damage. 3687 // We should still have cached textures for surface 2 after drawing with no damage.
3685 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child PassId)); 3688 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child PassId));
3686 3689
3687 // Damage a single tile of surface 2. 3690 // Damage a single tile of surface 2.
3688 childPtr->setUpdateRect(IntRect(10, 10, 10, 10)); 3691 childPtr->setUpdateRect(gfx::Rect(10, 10, 10, 10));
3689 3692
3690 { 3693 {
3691 LayerTreeHostImpl::FrameData frame; 3694 LayerTreeHostImpl::FrameData frame;
3692 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3695 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3693 myHostImpl->drawLayers(frame); 3696 myHostImpl->drawLayers(frame);
3694 myHostImpl->didDrawAllLayers(frame); 3697 myHostImpl->didDrawAllLayers(frame);
3695 } 3698 }
3696 3699
3697 // We should have a cached texture for surface 2 again even though it was da maged. 3700 // We should have a cached texture for surface 2 again even though it was da maged.
3698 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child PassId)); 3701 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child PassId));
3699 } 3702 }
3700 3703
3701 TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) 3704 TEST_P(LayerTreeHostImplTest, surfaceTextureCaching)
3702 { 3705 {
3703 Settings::setPartialSwapEnabled(true); 3706 Settings::setPartialSwapEnabled(true);
3704 3707
3705 LayerTreeSettings settings; 3708 LayerTreeSettings settings;
3706 settings.minimumOcclusionTrackingSize = IntSize(); 3709 settings.minimumOcclusionTrackingSize = gfx::Size();
3707 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this); 3710 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this);
3708 3711
3709 LayerImpl* rootPtr; 3712 LayerImpl* rootPtr;
3710 LayerImpl* intermediateLayerPtr; 3713 LayerImpl* intermediateLayerPtr;
3711 LayerImpl* surfaceLayerPtr; 3714 LayerImpl* surfaceLayerPtr;
3712 LayerImpl* childPtr; 3715 LayerImpl* childPtr;
3713 3716
3714 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr , surfaceLayerPtr, childPtr, IntSize(100, 100)); 3717 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr , surfaceLayerPtr, childPtr, gfx::Size(100, 100));
3715 3718
3716 { 3719 {
3717 LayerTreeHostImpl::FrameData frame; 3720 LayerTreeHostImpl::FrameData frame;
3718 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3721 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3719 3722
3720 // Must receive two render passes, each with one quad 3723 // Must receive two render passes, each with one quad
3721 ASSERT_EQ(2U, frame.renderPasses.size()); 3724 ASSERT_EQ(2U, frame.renderPasses.size());
3722 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); 3725 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size());
3723 EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); 3726 EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size());
3724 3727
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
3857 myHostImpl->drawLayers(frame); 3860 myHostImpl->drawLayers(frame);
3858 myHostImpl->didDrawAllLayers(frame); 3861 myHostImpl->didDrawAllLayers(frame);
3859 } 3862 }
3860 } 3863 }
3861 3864
3862 TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) 3865 TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
3863 { 3866 {
3864 Settings::setPartialSwapEnabled(false); 3867 Settings::setPartialSwapEnabled(false);
3865 3868
3866 LayerTreeSettings settings; 3869 LayerTreeSettings settings;
3867 settings.minimumOcclusionTrackingSize = IntSize(); 3870 settings.minimumOcclusionTrackingSize = gfx::Size();
3868 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this); 3871 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this);
3869 3872
3870 LayerImpl* rootPtr; 3873 LayerImpl* rootPtr;
3871 LayerImpl* intermediateLayerPtr; 3874 LayerImpl* intermediateLayerPtr;
3872 LayerImpl* surfaceLayerPtr; 3875 LayerImpl* surfaceLayerPtr;
3873 LayerImpl* childPtr; 3876 LayerImpl* childPtr;
3874 3877
3875 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr , surfaceLayerPtr, childPtr, IntSize(100, 100)); 3878 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr , surfaceLayerPtr, childPtr, gfx::Size(100, 100));
3876 3879
3877 { 3880 {
3878 LayerTreeHostImpl::FrameData frame; 3881 LayerTreeHostImpl::FrameData frame;
3879 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3882 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3880 3883
3881 // Must receive two render passes, each with one quad 3884 // Must receive two render passes, each with one quad
3882 ASSERT_EQ(2U, frame.renderPasses.size()); 3885 ASSERT_EQ(2U, frame.renderPasses.size());
3883 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); 3886 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size());
3884 EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size()); 3887 EXPECT_EQ(1U, frame.renderPasses[1]->quadList().size());
3885 3888
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
4065 4068
4066 return renderer.Pass(); 4069 return renderer.Pass();
4067 } 4070 }
4068 4071
4069 void clearCachedTextures() { m_textures.clear(); } 4072 void clearCachedTextures() { m_textures.clear(); }
4070 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i nsert(id); } 4073 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i nsert(id); }
4071 4074
4072 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE RRIDE { return m_textures.count(id); } 4075 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE RRIDE { return m_textures.count(id); }
4073 4076
4074 // RendererClient implementation. 4077 // RendererClient implementation.
4075 virtual const IntSize& deviceViewportSize() const OVERRIDE { return m_viewpo rtSize; } 4078 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view portSize; }
4076 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin gs; } 4079 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin gs; }
4077 virtual void didLoseContext() OVERRIDE { } 4080 virtual void didLoseContext() OVERRIDE { }
4078 virtual void onSwapBuffersComplete() OVERRIDE { } 4081 virtual void onSwapBuffersComplete() OVERRIDE { }
4079 virtual void setFullRootLayerDamage() OVERRIDE { } 4082 virtual void setFullRootLayerDamage() OVERRIDE { }
4080 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR IDE { } 4083 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR IDE { }
4081 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O VERRIDE { } 4084 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O VERRIDE { }
4082 4085
4083 protected: 4086 protected:
4084 TestRenderer(ResourceProvider* resourceProvider) : GLRenderer(this, resource Provider) { } 4087 TestRenderer(ResourceProvider* resourceProvider) : GLRenderer(this, resource Provider) { }
4085 4088
4086 private: 4089 private:
4087 LayerTreeSettings m_settings; 4090 LayerTreeSettings m_settings;
4088 IntSize m_viewportSize; 4091 gfx::Size m_viewportSize;
4089 base::hash_set<RenderPass::Id> m_textures; 4092 base::hash_set<RenderPass::Id> m_textures;
4090 }; 4093 };
4091 4094
4092 static void configureRenderPassTestData(const char* testScript, RenderPassRemova lTestData& testData, TestRenderer* renderer) 4095 static void configureRenderPassTestData(const char* testScript, RenderPassRemova lTestData& testData, TestRenderer* renderer)
4093 { 4096 {
4094 renderer->clearCachedTextures(); 4097 renderer->clearCachedTextures();
4095 4098
4096 // One shared state for all quads - we don't need the correct details 4099 // One shared state for all quads - we don't need the correct details
4097 testData.sharedQuadState = SharedQuadState::create(WebTransformationMatrix() , IntRect(), IntRect(), 1.0, true); 4100 testData.sharedQuadState = SharedQuadState::create(WebTransformationMatrix() , gfx::Rect(), gfx::Rect(), 1.0, true);
4098 4101
4099 const char* currentChar = testScript; 4102 const char* currentChar = testScript;
4100 4103
4101 // Pre-create root pass 4104 // Pre-create root pass
4102 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1 ]); 4105 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1 ]);
4103 testData.renderPassCache.add(rootRenderPassId, TestRenderPass::create(rootRe nderPassId, IntRect(), WebTransformationMatrix())); 4106 testData.renderPassCache.add(rootRenderPassId, TestRenderPass::create(rootRe nderPassId, gfx::Rect(), WebTransformationMatrix()));
4104 while (*currentChar) { 4107 while (*currentChar) {
4105 int layerId = *currentChar; 4108 int layerId = *currentChar;
4106 currentChar++; 4109 currentChar++;
4107 ASSERT_TRUE(currentChar); 4110 ASSERT_TRUE(currentChar);
4108 int index = *currentChar; 4111 int index = *currentChar;
4109 currentChar++; 4112 currentChar++;
4110 4113
4111 RenderPass::Id renderPassId = RenderPass::Id(layerId, index); 4114 RenderPass::Id renderPassId = RenderPass::Id(layerId, index);
4112 4115
4113 bool isReplica = false; 4116 bool isReplica = false;
4114 if (!testData.renderPassCache.contains(renderPassId)) 4117 if (!testData.renderPassCache.contains(renderPassId))
4115 isReplica = true; 4118 isReplica = true;
4116 4119
4117 scoped_ptr<TestRenderPass> renderPass = testData.renderPassCache.take(re nderPassId); 4120 scoped_ptr<TestRenderPass> renderPass = testData.renderPassCache.take(re nderPassId);
4118 4121
4119 // Cycle through quad data and create all quads 4122 // Cycle through quad data and create all quads
4120 while (*currentChar && *currentChar != '\n') { 4123 while (*currentChar && *currentChar != '\n') {
4121 if (*currentChar == 's') { 4124 if (*currentChar == 's') {
4122 // Solid color draw quad 4125 // Solid color draw quad
4123 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::create (testData.sharedQuadState.get(), IntRect(0, 0, 10, 10), SK_ColorWHITE); 4126 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::create (testData.sharedQuadState.get(), gfx::Rect(0, 0, 10, 10), SK_ColorWHITE);
4124 4127
4125 renderPass->appendQuad(quad.PassAs<DrawQuad>()); 4128 renderPass->appendQuad(quad.PassAs<DrawQuad>());
4126 currentChar++; 4129 currentChar++;
4127 } else if ((*currentChar >= 'A') && (*currentChar <= 'Z')) { 4130 } else if ((*currentChar >= 'A') && (*currentChar <= 'Z')) {
4128 // RenderPass draw quad 4131 // RenderPass draw quad
4129 int layerId = *currentChar; 4132 int layerId = *currentChar;
4130 currentChar++; 4133 currentChar++;
4131 ASSERT_TRUE(currentChar); 4134 ASSERT_TRUE(currentChar);
4132 int index = *currentChar; 4135 int index = *currentChar;
4133 currentChar++; 4136 currentChar++;
(...skipping 16 matching lines...) Expand all
4150 currentChar++; 4153 currentChar++;
4151 } 4154 }
4152 if (*currentChar == ']') 4155 if (*currentChar == ']')
4153 currentChar++; 4156 currentChar++;
4154 } 4157 }
4155 4158
4156 if (testData.renderPassCache.find(newRenderPassId) == testData.r enderPassCache.end()) { 4159 if (testData.renderPassCache.find(newRenderPassId) == testData.r enderPassCache.end()) {
4157 if (hasTexture) 4160 if (hasTexture)
4158 renderer->setHaveCachedResourcesForRenderPassId(newRende rPassId); 4161 renderer->setHaveCachedResourcesForRenderPassId(newRende rPassId);
4159 4162
4160 testData.renderPassCache.add(newRenderPassId, TestRenderPass ::create(newRenderPassId, IntRect(), WebTransformationMatrix())); 4163 testData.renderPassCache.add(newRenderPassId, TestRenderPass ::create(newRenderPassId, gfx::Rect(), WebTransformationMatrix()));
4161 } 4164 }
4162 4165
4163 IntRect quadRect = IntRect(0, 0, 1, 1); 4166 gfx::Rect quadRect = gfx::Rect(0, 0, 1, 1);
4164 IntRect contentsChangedRect = contentsChanged ? quadRect : IntRe ct(); 4167 gfx::Rect contentsChangedRect = contentsChanged ? quadRect : gfx ::Rect();
4165 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::create (testData.sharedQuadState.get(), quadRect, newRenderPassId, isReplica, 1, conten tsChangedRect, 1, 1, 0, 0); 4168 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::create (testData.sharedQuadState.get(), quadRect, newRenderPassId, isReplica, 1, conten tsChangedRect, 1, 1, 0, 0);
4166 renderPass->appendQuad(quad.PassAs<DrawQuad>()); 4169 renderPass->appendQuad(quad.PassAs<DrawQuad>());
4167 } 4170 }
4168 } 4171 }
4169 testData.renderPasses.insert(testData.renderPasses.begin(), renderPass.g et()); 4172 testData.renderPasses.insert(testData.renderPasses.begin(), renderPass.g et());
4170 testData.renderPassesById.add(renderPassId, renderPass.PassAs<RenderPass >()); 4173 testData.renderPassesById.add(renderPassId, renderPass.PassAs<RenderPass >());
4171 if (*currentChar) 4174 if (*currentChar)
4172 currentChar++; 4175 currentChar++;
4173 } 4176 }
4174 } 4177 }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4375 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); 4378 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a);
4376 testCaseIndex++; 4379 testCaseIndex++;
4377 } 4380 }
4378 } 4381 }
4379 4382
4380 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4383 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4381 LayerTreeHostImplTest, 4384 LayerTreeHostImplTest,
4382 ::testing::Values(false, true)); 4385 ::testing::Values(false, true));
4383 4386
4384 } // namespace 4387 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698