OLD | NEW |
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 "CCLayerTreeHostImpl.h" | 7 #include "CCLayerTreeHostImpl.h" |
8 | 8 |
9 #include "CCAnimationTestCommon.h" | 9 #include "CCAnimationTestCommon.h" |
10 #include "CCDelegatedRendererLayerImpl.h" | 10 #include "CCDelegatedRendererLayerImpl.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 using namespace WebKitTests; | 43 using namespace WebKitTests; |
44 | 44 |
45 using ::testing::Mock; | 45 using ::testing::Mock; |
46 using ::testing::Return; | 46 using ::testing::Return; |
47 using ::testing::AnyNumber; | 47 using ::testing::AnyNumber; |
48 using ::testing::AtLeast; | 48 using ::testing::AtLeast; |
49 using ::testing::_; | 49 using ::testing::_; |
50 | 50 |
51 namespace { | 51 namespace { |
52 | 52 |
53 class CCLayerTreeHostImplTest : public testing::Test, public CCLayerTreeHostImpl
Client { | 53 // This test is parametrized to run all tests with the |
| 54 // CCSettings::pageScalePinchZoomEnabled field enabled and disabled. |
| 55 class CCLayerTreeHostImplTest : public testing::TestWithParam<bool>, |
| 56 public CCLayerTreeHostImplClient { |
54 public: | 57 public: |
55 CCLayerTreeHostImplTest() | 58 CCLayerTreeHostImplTest() |
56 : m_onCanDrawStateChangedCalled(false) | 59 : m_onCanDrawStateChangedCalled(false) |
57 , m_didRequestCommit(false) | 60 , m_didRequestCommit(false) |
58 , m_didRequestRedraw(false) | 61 , m_didRequestRedraw(false) |
59 { | 62 { |
| 63 } |
| 64 |
| 65 virtual void SetUp() |
| 66 { |
| 67 CCSettings::setPageScalePinchZoomEnabled(GetParam()); |
60 CCLayerTreeSettings settings; | 68 CCLayerTreeSettings settings; |
61 settings.minimumOcclusionTrackingSize = IntSize(); | 69 settings.minimumOcclusionTrackingSize = IntSize(); |
62 | 70 |
63 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); | 71 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); |
64 m_hostImpl->initializeRenderer(createContext()); | 72 m_hostImpl->initializeRenderer(createContext()); |
65 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 73 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); |
66 } | 74 } |
67 | 75 |
| 76 virtual void TearDown() |
| 77 { |
| 78 CCSettings::reset(); |
| 79 } |
| 80 |
68 virtual void didLoseContextOnImplThread() OVERRIDE { } | 81 virtual void didLoseContextOnImplThread() OVERRIDE { } |
69 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 82 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
70 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } | 83 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } |
71 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } | 84 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } |
72 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } | 85 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } |
73 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } | 86 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } |
74 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat
ionEventsVector>, double wallClockTime) OVERRIDE { } | 87 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat
ionEventsVector>, double wallClockTime) OVERRIDE { } |
75 virtual void releaseContentsTexturesOnImplThread() OVERRIDE { } | 88 virtual void releaseContentsTexturesOnImplThread() OVERRIDE { } |
76 | 89 |
77 PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassOw
nPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr) | 90 PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassOw
nPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 bool m_didRequestCommit; | 188 bool m_didRequestCommit; |
176 bool m_didRequestRedraw; | 189 bool m_didRequestRedraw; |
177 CCScopedSettings m_scopedSettings; | 190 CCScopedSettings m_scopedSettings; |
178 }; | 191 }; |
179 | 192 |
180 class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D
{ | 193 class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D
{ |
181 public: | 194 public: |
182 virtual bool makeContextCurrent() { return false; } | 195 virtual bool makeContextCurrent() { return false; } |
183 }; | 196 }; |
184 | 197 |
185 TEST_F(CCLayerTreeHostImplTest, notifyIfCanDrawChanged) | 198 TEST_P(CCLayerTreeHostImplTest, notifyIfCanDrawChanged) |
186 { | 199 { |
187 // Note: It is not possible to disable the renderer once it has been set, | 200 // Note: It is not possible to disable the renderer once it has been set, |
188 // so we do not need to test that disabling the renderer notifies us | 201 // so we do not need to test that disabling the renderer notifies us |
189 // that canDraw changed. | 202 // that canDraw changed. |
190 EXPECT_FALSE(m_hostImpl->canDraw()); | 203 EXPECT_FALSE(m_hostImpl->canDraw()); |
191 m_onCanDrawStateChangedCalled = false; | 204 m_onCanDrawStateChangedCalled = false; |
192 | 205 |
193 setupScrollAndContentsLayers(IntSize(100, 100)); | 206 setupScrollAndContentsLayers(IntSize(100, 100)); |
194 EXPECT_TRUE(m_hostImpl->canDraw()); | 207 EXPECT_TRUE(m_hostImpl->canDraw()); |
195 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 208 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
(...skipping 26 matching lines...) Expand all Loading... |
222 EXPECT_FALSE(m_hostImpl->canDraw()); | 235 EXPECT_FALSE(m_hostImpl->canDraw()); |
223 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 236 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
224 m_onCanDrawStateChangedCalled = false; | 237 m_onCanDrawStateChangedCalled = false; |
225 | 238 |
226 m_hostImpl->resetContentsTexturesPurged(); | 239 m_hostImpl->resetContentsTexturesPurged(); |
227 EXPECT_TRUE(m_hostImpl->canDraw()); | 240 EXPECT_TRUE(m_hostImpl->canDraw()); |
228 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 241 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
229 m_onCanDrawStateChangedCalled = false; | 242 m_onCanDrawStateChangedCalled = false; |
230 } | 243 } |
231 | 244 |
232 TEST_F(CCLayerTreeHostImplTest, scrollDeltaNoLayers) | 245 TEST_P(CCLayerTreeHostImplTest, scrollDeltaNoLayers) |
233 { | 246 { |
234 ASSERT_FALSE(m_hostImpl->rootLayer()); | 247 ASSERT_FALSE(m_hostImpl->rootLayer()); |
235 | 248 |
236 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 249 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
237 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 250 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
238 } | 251 } |
239 | 252 |
240 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) | 253 TEST_P(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) |
241 { | 254 { |
242 { | 255 { |
243 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 256 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
244 root->addChild(CCLayerImpl::create(2)); | 257 root->addChild(CCLayerImpl::create(2)); |
245 root->addChild(CCLayerImpl::create(3)); | 258 root->addChild(CCLayerImpl::create(3)); |
246 root->children()[1]->addChild(CCLayerImpl::create(4)); | 259 root->children()[1]->addChild(CCLayerImpl::create(4)); |
247 root->children()[1]->addChild(CCLayerImpl::create(5)); | 260 root->children()[1]->addChild(CCLayerImpl::create(5)); |
248 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6)); | 261 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6)); |
249 m_hostImpl->setRootLayer(root.release()); | 262 m_hostImpl->setRootLayer(root.release()); |
250 } | 263 } |
251 CCLayerImpl* root = m_hostImpl->rootLayer(); | 264 CCLayerImpl* root = m_hostImpl->rootLayer(); |
252 | 265 |
253 expectClearedScrollDeltasRecursive(root); | 266 expectClearedScrollDeltasRecursive(root); |
254 | 267 |
255 OwnPtr<CCScrollAndScaleSet> scrollInfo; | 268 OwnPtr<CCScrollAndScaleSet> scrollInfo; |
256 | 269 |
257 scrollInfo = m_hostImpl->processScrollDeltas(); | 270 scrollInfo = m_hostImpl->processScrollDeltas(); |
258 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 271 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
259 expectClearedScrollDeltasRecursive(root); | 272 expectClearedScrollDeltasRecursive(root); |
260 | 273 |
261 scrollInfo = m_hostImpl->processScrollDeltas(); | 274 scrollInfo = m_hostImpl->processScrollDeltas(); |
262 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 275 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
263 expectClearedScrollDeltasRecursive(root); | 276 expectClearedScrollDeltasRecursive(root); |
264 } | 277 } |
265 | 278 |
266 TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) | 279 TEST_P(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) |
267 { | 280 { |
268 IntPoint scrollPosition(20, 30); | 281 IntPoint scrollPosition(20, 30); |
269 IntSize scrollDelta(11, -15); | 282 IntSize scrollDelta(11, -15); |
270 { | 283 { |
271 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 284 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
272 root->setScrollPosition(scrollPosition); | 285 root->setScrollPosition(scrollPosition); |
273 root->setScrollable(true); | 286 root->setScrollable(true); |
274 root->setMaxScrollPosition(IntSize(100, 100)); | 287 root->setMaxScrollPosition(IntSize(100, 100)); |
275 root->scrollBy(scrollDelta); | 288 root->scrollBy(scrollDelta); |
276 m_hostImpl->setRootLayer(root.release()); | 289 m_hostImpl->setRootLayer(root.release()); |
(...skipping 12 matching lines...) Expand all Loading... |
289 scrollInfo = m_hostImpl->processScrollDeltas(); | 302 scrollInfo = m_hostImpl->processScrollDeltas(); |
290 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 303 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
291 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); | 304 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); |
292 expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2); | 305 expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2); |
293 | 306 |
294 root->scrollBy(IntSize()); | 307 root->scrollBy(IntSize()); |
295 scrollInfo = m_hostImpl->processScrollDeltas(); | 308 scrollInfo = m_hostImpl->processScrollDeltas(); |
296 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); | 309 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); |
297 } | 310 } |
298 | 311 |
299 TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) | 312 TEST_P(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) |
300 { | 313 { |
301 setupScrollAndContentsLayers(IntSize(100, 100)); | 314 setupScrollAndContentsLayers(IntSize(100, 100)); |
302 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 315 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
303 initializeRendererAndDrawFrame(); | 316 initializeRendererAndDrawFrame(); |
304 | 317 |
305 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 318 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
306 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 319 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
307 m_hostImpl->scrollEnd(); | 320 m_hostImpl->scrollEnd(); |
308 EXPECT_TRUE(m_didRequestRedraw); | 321 EXPECT_TRUE(m_didRequestRedraw); |
309 EXPECT_TRUE(m_didRequestCommit); | 322 EXPECT_TRUE(m_didRequestCommit); |
310 } | 323 } |
311 | 324 |
312 TEST_F(CCLayerTreeHostImplTest, scrollWithoutRootLayer) | 325 TEST_P(CCLayerTreeHostImplTest, scrollWithoutRootLayer) |
313 { | 326 { |
314 // We should not crash when trying to scroll an empty layer tree. | 327 // We should not crash when trying to scroll an empty layer tree. |
315 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); | 328 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); |
316 } | 329 } |
317 | 330 |
318 TEST_F(CCLayerTreeHostImplTest, scrollWithoutRenderer) | 331 TEST_P(CCLayerTreeHostImplTest, scrollWithoutRenderer) |
319 { | 332 { |
320 CCLayerTreeSettings settings; | 333 CCLayerTreeSettings settings; |
321 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); | 334 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); |
322 | 335 |
323 // Initialization will fail here. | 336 // Initialization will fail here. |
324 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP
tr(new FakeWebGraphicsContext3DMakeCurrentFails))); | 337 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP
tr(new FakeWebGraphicsContext3DMakeCurrentFails))); |
325 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 338 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); |
326 | 339 |
327 setupScrollAndContentsLayers(IntSize(100, 100)); | 340 setupScrollAndContentsLayers(IntSize(100, 100)); |
328 | 341 |
329 // We should not crash when trying to scroll after the renderer initializati
on fails. | 342 // We should not crash when trying to scroll after the renderer initializati
on fails. |
330 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); | 343 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); |
331 } | 344 } |
332 | 345 |
333 TEST_F(CCLayerTreeHostImplTest, replaceTreeWhileScrolling) | 346 TEST_P(CCLayerTreeHostImplTest, replaceTreeWhileScrolling) |
334 { | 347 { |
335 const int scrollLayerId = 1; | 348 const int scrollLayerId = 1; |
336 | 349 |
337 setupScrollAndContentsLayers(IntSize(100, 100)); | 350 setupScrollAndContentsLayers(IntSize(100, 100)); |
338 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 351 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
339 initializeRendererAndDrawFrame(); | 352 initializeRendererAndDrawFrame(); |
340 | 353 |
341 // We should not crash if the tree is replaced while we are scrolling. | 354 // We should not crash if the tree is replaced while we are scrolling. |
342 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 355 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
343 m_hostImpl->detachLayerTree(); | 356 m_hostImpl->detachLayerTree(); |
344 | 357 |
345 setupScrollAndContentsLayers(IntSize(100, 100)); | 358 setupScrollAndContentsLayers(IntSize(100, 100)); |
346 | 359 |
347 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. | 360 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. |
348 IntSize scrollDelta(0, 10); | 361 IntSize scrollDelta(0, 10); |
349 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 362 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
350 m_hostImpl->scrollEnd(); | 363 m_hostImpl->scrollEnd(); |
351 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 364 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
352 expectContains(*scrollInfo, scrollLayerId, scrollDelta); | 365 expectContains(*scrollInfo, scrollLayerId, scrollDelta); |
353 } | 366 } |
354 | 367 |
355 TEST_F(CCLayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) | 368 TEST_P(CCLayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) |
356 { | 369 { |
357 setupScrollAndContentsLayers(IntSize(100, 100)); | 370 setupScrollAndContentsLayers(IntSize(100, 100)); |
358 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 371 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
359 initializeRendererAndDrawFrame(); | 372 initializeRendererAndDrawFrame(); |
360 | 373 |
361 // We should be able to scroll even if the root layer loses its render surfa
ce after the most | 374 // We should be able to scroll even if the root layer loses its render surfa
ce after the most |
362 // recent render. | 375 // recent render. |
363 m_hostImpl->rootLayer()->clearRenderSurface(); | 376 m_hostImpl->rootLayer()->clearRenderSurface(); |
364 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 377 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
365 } | 378 } |
366 | 379 |
367 TEST_F(CCLayerTreeHostImplTest, wheelEventHandlers) | 380 TEST_P(CCLayerTreeHostImplTest, wheelEventHandlers) |
368 { | 381 { |
369 setupScrollAndContentsLayers(IntSize(100, 100)); | 382 setupScrollAndContentsLayers(IntSize(100, 100)); |
370 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 383 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
371 initializeRendererAndDrawFrame(); | 384 initializeRendererAndDrawFrame(); |
372 CCLayerImpl* root = m_hostImpl->rootLayer(); | 385 CCLayerImpl* root = m_hostImpl->rootLayer(); |
373 | 386 |
374 root->setHaveWheelEventHandlers(true); | 387 root->setHaveWheelEventHandlers(true); |
375 | 388 |
376 // With registered event handlers, wheel scrolls have to go to the main thre
ad. | 389 // With registered event handlers, wheel scrolls have to go to the main thre
ad. |
377 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollOnMainThread); | 390 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollOnMainThread); |
378 | 391 |
379 // But gesture scrolls can still be handled. | 392 // But gesture scrolls can still be handled. |
380 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gest
ure), CCInputHandlerClient::ScrollStarted); | 393 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gest
ure), CCInputHandlerClient::ScrollStarted); |
381 } | 394 } |
382 | 395 |
383 TEST_F(CCLayerTreeHostImplTest, shouldScrollOnMainThread) | 396 TEST_P(CCLayerTreeHostImplTest, shouldScrollOnMainThread) |
384 { | 397 { |
385 setupScrollAndContentsLayers(IntSize(100, 100)); | 398 setupScrollAndContentsLayers(IntSize(100, 100)); |
386 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 399 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
387 initializeRendererAndDrawFrame(); | 400 initializeRendererAndDrawFrame(); |
388 CCLayerImpl* root = m_hostImpl->rootLayer(); | 401 CCLayerImpl* root = m_hostImpl->rootLayer(); |
389 | 402 |
390 root->setShouldScrollOnMainThread(true); | 403 root->setShouldScrollOnMainThread(true); |
391 | 404 |
392 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollOnMainThread); | 405 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollOnMainThread); |
393 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gest
ure), CCInputHandlerClient::ScrollOnMainThread); | 406 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gest
ure), CCInputHandlerClient::ScrollOnMainThread); |
394 } | 407 } |
395 | 408 |
396 TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionBasic) | 409 TEST_P(CCLayerTreeHostImplTest, nonFastScrollableRegionBasic) |
397 { | 410 { |
398 setupScrollAndContentsLayers(IntSize(200, 200)); | 411 setupScrollAndContentsLayers(IntSize(200, 200)); |
399 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); | 412 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); |
400 initializeRendererAndDrawFrame(); | 413 initializeRendererAndDrawFrame(); |
401 CCLayerImpl* root = m_hostImpl->rootLayer(); | 414 CCLayerImpl* root = m_hostImpl->rootLayer(); |
402 | 415 |
403 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); | 416 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); |
404 | 417 |
405 // All scroll types inside the non-fast scrollable region should fail. | 418 // All scroll types inside the non-fast scrollable region should fail. |
406 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollOnMainThread); | 419 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollOnMainThread); |
407 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Ge
sture), CCInputHandlerClient::ScrollOnMainThread); | 420 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Ge
sture), CCInputHandlerClient::ScrollOnMainThread); |
408 | 421 |
409 // All scroll types outside this region should succeed. | 422 // All scroll types outside this region should succeed. |
410 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollStarted); | 423 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollStarted); |
411 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 424 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
412 m_hostImpl->scrollEnd(); | 425 m_hostImpl->scrollEnd(); |
413 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Ge
sture), CCInputHandlerClient::ScrollStarted); | 426 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Ge
sture), CCInputHandlerClient::ScrollStarted); |
414 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 427 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
415 m_hostImpl->scrollEnd(); | 428 m_hostImpl->scrollEnd(); |
416 } | 429 } |
417 | 430 |
418 TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset) | 431 TEST_P(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset) |
419 { | 432 { |
420 setupScrollAndContentsLayers(IntSize(200, 200)); | 433 setupScrollAndContentsLayers(IntSize(200, 200)); |
421 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); | 434 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100)); |
422 CCLayerImpl* root = m_hostImpl->rootLayer(); | 435 CCLayerImpl* root = m_hostImpl->rootLayer(); |
423 | 436 |
424 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); | 437 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); |
425 root->setPosition(FloatPoint(-25, 0)); | 438 root->setPosition(FloatPoint(-25, 0)); |
426 initializeRendererAndDrawFrame(); | 439 initializeRendererAndDrawFrame(); |
427 | 440 |
428 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. | 441 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. |
429 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(40, 10), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollStarted); | 442 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(40, 10), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollStarted); |
430 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 1)); | 443 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 1)); |
431 m_hostImpl->scrollEnd(); | 444 m_hostImpl->scrollEnd(); |
432 | 445 |
433 // This point is still inside the non-fast region. | 446 // This point is still inside the non-fast region. |
434 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollOnMainThread); | 447 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollOnMainThread); |
435 } | 448 } |
436 | 449 |
437 TEST_F(CCLayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor) | 450 TEST_P(CCLayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor) |
438 { | 451 { |
439 setupScrollAndContentsLayers(IntSize(100, 100)); | 452 setupScrollAndContentsLayers(IntSize(100, 100)); |
440 | 453 |
441 float deviceScaleFactor = 2; | 454 float deviceScaleFactor = 2; |
442 IntSize layoutViewport(25, 25); | 455 IntSize layoutViewport(25, 25); |
443 IntSize deviceViewport(layoutViewport); | 456 IntSize deviceViewport(layoutViewport); |
444 deviceViewport.scale(deviceScaleFactor); | 457 deviceViewport.scale(deviceScaleFactor); |
445 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); | 458 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); |
446 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 459 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
447 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25)); | 460 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25)); |
448 | 461 |
449 deviceScaleFactor = 1; | 462 deviceScaleFactor = 1; |
450 m_hostImpl->setViewportSize(layoutViewport, layoutViewport); | 463 m_hostImpl->setViewportSize(layoutViewport, layoutViewport); |
451 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 464 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
452 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75)); | 465 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75)); |
453 } | 466 } |
454 | 467 |
455 TEST_F(CCLayerTreeHostImplTest, pinchGesture) | 468 TEST_P(CCLayerTreeHostImplTest, implPinchZoom) |
456 { | 469 { |
| 470 // This test is specific to the page-scale based pinch zoom. |
| 471 if (!CCSettings::pageScalePinchZoomEnabled()) |
| 472 return; |
| 473 |
457 setupScrollAndContentsLayers(IntSize(100, 100)); | 474 setupScrollAndContentsLayers(IntSize(100, 100)); |
458 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 475 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
459 initializeRendererAndDrawFrame(); | 476 initializeRendererAndDrawFrame(); |
460 | 477 |
461 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 478 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
462 ASSERT(scrollLayer); | 479 ASSERT(scrollLayer); |
463 | 480 |
464 const float minPageScale = 0.5, maxPageScale = 4; | 481 const float minPageScale = 1, maxPageScale = 4; |
| 482 const WebTransformationMatrix identityScaleTransform; |
| 483 |
| 484 // The impl-based pinch zoome should not adjust the max scroll position. |
| 485 { |
| 486 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
| 487 scrollLayer->setImplTransform(identityScaleTransform); |
| 488 scrollLayer->setScrollDelta(IntSize()); |
| 489 |
| 490 float pageScaleDelta = 2; |
| 491 m_hostImpl->pinchGestureBegin(); |
| 492 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); |
| 493 m_hostImpl->pinchGestureEnd(); |
| 494 EXPECT_TRUE(m_didRequestRedraw); |
| 495 EXPECT_TRUE(m_didRequestCommit); |
| 496 |
| 497 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
| 498 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 499 |
| 500 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(50, 50))
; |
| 501 } |
| 502 |
| 503 // Scrolling after a pinch gesture should always be in local space. The scr
oll deltas do not |
| 504 // have the page scale factor applied. |
| 505 { |
| 506 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
| 507 scrollLayer->setImplTransform(identityScaleTransform); |
| 508 scrollLayer->setScrollDelta(IntSize()); |
| 509 |
| 510 float pageScaleDelta = 2; |
| 511 m_hostImpl->pinchGestureBegin(); |
| 512 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); |
| 513 m_hostImpl->pinchGestureEnd(); |
| 514 |
| 515 IntSize scrollDelta(0, 10); |
| 516 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::
Wheel), CCInputHandlerClient::ScrollStarted); |
| 517 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
| 518 m_hostImpl->scrollEnd(); |
| 519 |
| 520 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
| 521 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
| 522 } |
| 523 } |
| 524 |
| 525 TEST_P(CCLayerTreeHostImplTest, pinchGesture) |
| 526 { |
| 527 setupScrollAndContentsLayers(IntSize(100, 100)); |
| 528 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
| 529 initializeRendererAndDrawFrame(); |
| 530 |
| 531 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
| 532 ASSERT(scrollLayer); |
| 533 |
| 534 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5
; |
| 535 const float maxPageScale = 4; |
| 536 const WebTransformationMatrix identityScaleTransform; |
465 | 537 |
466 // Basic pinch zoom in gesture | 538 // Basic pinch zoom in gesture |
467 { | 539 { |
468 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 540 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
469 scrollLayer->setPageScaleDelta(1); | 541 scrollLayer->setImplTransform(identityScaleTransform); |
470 scrollLayer->setScrollDelta(IntSize()); | 542 scrollLayer->setScrollDelta(IntSize()); |
471 | 543 |
472 float pageScaleDelta = 2; | 544 float pageScaleDelta = 2; |
473 m_hostImpl->pinchGestureBegin(); | 545 m_hostImpl->pinchGestureBegin(); |
474 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); | 546 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); |
475 m_hostImpl->pinchGestureEnd(); | 547 m_hostImpl->pinchGestureEnd(); |
476 EXPECT_TRUE(m_didRequestRedraw); | 548 EXPECT_TRUE(m_didRequestRedraw); |
477 EXPECT_TRUE(m_didRequestCommit); | 549 EXPECT_TRUE(m_didRequestCommit); |
478 | 550 |
479 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 551 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
480 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 552 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
481 } | 553 } |
482 | 554 |
483 // Zoom-in clamping | 555 // Zoom-in clamping |
484 { | 556 { |
485 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 557 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
486 scrollLayer->setPageScaleDelta(1); | 558 scrollLayer->setImplTransform(identityScaleTransform); |
487 scrollLayer->setScrollDelta(IntSize()); | 559 scrollLayer->setScrollDelta(IntSize()); |
488 float pageScaleDelta = 10; | 560 float pageScaleDelta = 10; |
489 | 561 |
490 m_hostImpl->pinchGestureBegin(); | 562 m_hostImpl->pinchGestureBegin(); |
491 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); | 563 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); |
492 m_hostImpl->pinchGestureEnd(); | 564 m_hostImpl->pinchGestureEnd(); |
493 | 565 |
494 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 566 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
495 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); | 567 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); |
496 } | 568 } |
497 | 569 |
498 // Zoom-out clamping | 570 // Zoom-out clamping |
499 { | 571 { |
500 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 572 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
501 scrollLayer->setPageScaleDelta(1); | 573 scrollLayer->setImplTransform(identityScaleTransform); |
502 scrollLayer->setScrollDelta(IntSize()); | 574 scrollLayer->setScrollDelta(IntSize()); |
503 scrollLayer->setScrollPosition(IntPoint(50, 50)); | 575 scrollLayer->setScrollPosition(IntPoint(50, 50)); |
504 | 576 |
505 float pageScaleDelta = 0.1f; | 577 float pageScaleDelta = 0.1f; |
506 m_hostImpl->pinchGestureBegin(); | 578 m_hostImpl->pinchGestureBegin(); |
507 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); | 579 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); |
508 m_hostImpl->pinchGestureEnd(); | 580 m_hostImpl->pinchGestureEnd(); |
509 | 581 |
510 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 582 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
511 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 583 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
512 | 584 |
513 // Pushed to (0,0) via clamping against contents layer size. | 585 if (!CCSettings::pageScalePinchZoomEnabled()) { |
514 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); | 586 // Pushed to (0,0) via clamping against contents layer size. |
| 587 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); |
| 588 } else { |
| 589 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); |
| 590 } |
515 } | 591 } |
516 | 592 |
517 // Two-finger panning | 593 // Two-finger panning |
518 { | 594 { |
519 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 595 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
520 scrollLayer->setPageScaleDelta(1); | 596 scrollLayer->setImplTransform(identityScaleTransform); |
521 scrollLayer->setScrollDelta(IntSize()); | 597 scrollLayer->setScrollDelta(IntSize()); |
522 scrollLayer->setScrollPosition(IntPoint(20, 20)); | 598 scrollLayer->setScrollPosition(IntPoint(20, 20)); |
523 | 599 |
524 float pageScaleDelta = 1; | 600 float pageScaleDelta = 1; |
525 m_hostImpl->pinchGestureBegin(); | 601 m_hostImpl->pinchGestureBegin(); |
526 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10)); | 602 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10)); |
527 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20)); | 603 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20)); |
528 m_hostImpl->pinchGestureEnd(); | 604 m_hostImpl->pinchGestureEnd(); |
529 | 605 |
530 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 606 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
531 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 607 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
532 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); | 608 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); |
533 } | 609 } |
534 } | 610 } |
535 | 611 |
536 TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation) | 612 TEST_P(CCLayerTreeHostImplTest, pageScaleAnimation) |
537 { | 613 { |
538 setupScrollAndContentsLayers(IntSize(100, 100)); | 614 setupScrollAndContentsLayers(IntSize(100, 100)); |
539 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 615 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
540 initializeRendererAndDrawFrame(); | 616 initializeRendererAndDrawFrame(); |
541 | 617 |
542 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 618 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
543 ASSERT(scrollLayer); | 619 ASSERT(scrollLayer); |
544 | 620 |
545 const float minPageScale = 0.5, maxPageScale = 4; | 621 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5
; |
| 622 const float maxPageScale = 4; |
546 const double startTime = 1; | 623 const double startTime = 1; |
547 const double duration = 0.1; | 624 const double duration = 0.1; |
548 const double halfwayThroughAnimation = startTime + duration / 2; | 625 const double halfwayThroughAnimation = startTime + duration / 2; |
549 const double endTime = startTime + duration; | 626 const double endTime = startTime + duration; |
| 627 const WebTransformationMatrix identityScaleTransform; |
550 | 628 |
551 // Non-anchor zoom-in | 629 // Non-anchor zoom-in |
552 { | 630 { |
553 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 631 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
554 scrollLayer->setPageScaleDelta(1); | 632 scrollLayer->setImplTransform(identityScaleTransform); |
555 scrollLayer->setScrollPosition(IntPoint(50, 50)); | 633 scrollLayer->setScrollPosition(IntPoint(50, 50)); |
556 | 634 |
557 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime,
duration); | 635 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime,
duration); |
558 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); | 636 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); |
559 EXPECT_TRUE(m_didRequestRedraw); | 637 EXPECT_TRUE(m_didRequestRedraw); |
560 m_hostImpl->animate(endTime, endTime); | 638 m_hostImpl->animate(endTime, endTime); |
561 EXPECT_TRUE(m_didRequestCommit); | 639 EXPECT_TRUE(m_didRequestCommit); |
562 | 640 |
563 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 641 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
564 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); | 642 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); |
565 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); | 643 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); |
566 } | 644 } |
567 | 645 |
568 // Anchor zoom-out | 646 // Anchor zoom-out |
569 { | 647 { |
570 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 648 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
571 scrollLayer->setPageScaleDelta(1); | 649 scrollLayer->setImplTransform(identityScaleTransform); |
572 scrollLayer->setScrollPosition(IntPoint(50, 50)); | 650 scrollLayer->setScrollPosition(IntPoint(50, 50)); |
573 | 651 |
574 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale,
startTime, duration); | 652 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale,
startTime, duration); |
575 m_hostImpl->animate(endTime, endTime); | 653 m_hostImpl->animate(endTime, endTime); |
576 EXPECT_TRUE(m_didRequestRedraw); | 654 EXPECT_TRUE(m_didRequestRedraw); |
577 EXPECT_TRUE(m_didRequestCommit); | 655 EXPECT_TRUE(m_didRequestCommit); |
578 | 656 |
579 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 657 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
580 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 658 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
581 // Pushed to (0,0) via clamping against contents layer size. | 659 // Pushed to (0,0) via clamping against contents layer size. |
582 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); | 660 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); |
583 } | 661 } |
584 } | 662 } |
585 | 663 |
586 TEST_F(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZoomin
g) | 664 TEST_P(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZoomin
g) |
587 { | 665 { |
588 setupScrollAndContentsLayers(IntSize(100, 100)); | 666 setupScrollAndContentsLayers(IntSize(100, 100)); |
589 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 667 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
590 initializeRendererAndDrawFrame(); | 668 initializeRendererAndDrawFrame(); |
591 | 669 |
592 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 670 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
593 ASSERT(scrollLayer); | 671 ASSERT(scrollLayer); |
594 | 672 |
595 const float minPageScale = 0.5, maxPageScale = 4; | 673 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5
; |
| 674 const float maxPageScale = 4; |
596 | 675 |
597 // Pinch zoom in. | 676 // Pinch zoom in. |
598 { | 677 { |
599 // Start a pinch in gesture at the bottom right corner of the viewport. | 678 // Start a pinch in gesture at the bottom right corner of the viewport. |
600 const float zoomInDelta = 2; | 679 const float zoomInDelta = 2; |
601 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 680 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
602 m_hostImpl->pinchGestureBegin(); | 681 m_hostImpl->pinchGestureBegin(); |
603 m_hostImpl->pinchGestureUpdate(zoomInDelta, IntPoint(50, 50)); | 682 m_hostImpl->pinchGestureUpdate(zoomInDelta, IntPoint(50, 50)); |
604 | 683 |
605 // Because we are pinch zooming in, we shouldn't get any scroll or page | 684 // Because we are pinch zooming in, we shouldn't get any scroll or page |
606 // scale deltas. | 685 // scale deltas. |
607 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 686 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
608 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); | 687 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); |
609 EXPECT_EQ(scrollInfo->scrolls.size(), 0u); | 688 EXPECT_EQ(scrollInfo->scrolls.size(), 0u); |
610 | 689 |
611 // Once the gesture ends, we get the final scroll and page scale values. | 690 // Once the gesture ends, we get the final scroll and page scale values. |
612 m_hostImpl->pinchGestureEnd(); | 691 m_hostImpl->pinchGestureEnd(); |
613 scrollInfo = m_hostImpl->processScrollDeltas(); | 692 scrollInfo = m_hostImpl->processScrollDeltas(); |
614 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta); | 693 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta); |
615 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | 694 if (!CCSettings::pageScalePinchZoomEnabled()) { |
| 695 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); |
| 696 } else { |
| 697 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); |
| 698 } |
616 } | 699 } |
617 | 700 |
618 // Pinch zoom out. | 701 // Pinch zoom out. |
619 { | 702 { |
620 // Start a pinch out gesture at the bottom right corner of the viewport. | 703 // Start a pinch out gesture at the bottom right corner of the viewport. |
621 const float zoomOutDelta = 0.75; | 704 const float zoomOutDelta = 0.75; |
622 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 705 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
623 m_hostImpl->pinchGestureBegin(); | 706 m_hostImpl->pinchGestureBegin(); |
624 m_hostImpl->pinchGestureUpdate(zoomOutDelta, IntPoint(50, 50)); | 707 m_hostImpl->pinchGestureUpdate(zoomOutDelta, IntPoint(50, 50)); |
625 | 708 |
626 // Since we are pinch zooming out, we should get an update to zoom all | 709 // Since we are pinch zooming out, we should get an update to zoom all |
627 // the way out to the minimum page scale. | 710 // the way out to the minimum page scale. |
628 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 711 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
629 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 712 if (!CCSettings::pageScalePinchZoomEnabled()) { |
630 expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0)); | 713 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 714 expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0)); |
| 715 } else { |
| 716 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); |
| 717 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); |
| 718 } |
631 | 719 |
632 // Once the gesture ends, we get the final scroll and page scale values. | 720 // Once the gesture ends, we get the final scroll and page scale values. |
633 m_hostImpl->pinchGestureEnd(); | 721 m_hostImpl->pinchGestureEnd(); |
634 scrollInfo = m_hostImpl->processScrollDeltas(); | 722 scrollInfo = m_hostImpl->processScrollDeltas(); |
635 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); | 723 if (CCSettings::pageScalePinchZoomEnabled()) { |
636 expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8)); | 724 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 725 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); |
| 726 } else { |
| 727 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); |
| 728 expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8)); |
| 729 } |
637 } | 730 } |
638 } | 731 } |
639 | 732 |
640 TEST_F(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPa
geScale) | 733 TEST_P(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPa
geScale) |
641 { | 734 { |
642 setupScrollAndContentsLayers(IntSize(100, 100)); | 735 setupScrollAndContentsLayers(IntSize(100, 100)); |
643 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 736 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
644 initializeRendererAndDrawFrame(); | 737 initializeRendererAndDrawFrame(); |
645 | 738 |
646 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 739 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
647 ASSERT(scrollLayer); | 740 ASSERT(scrollLayer); |
648 | 741 |
649 const float minPageScale = 0.5, maxPageScale = 4; | 742 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5
; |
| 743 const float maxPageScale = 4; |
650 const double startTime = 1; | 744 const double startTime = 1; |
651 const double duration = 0.1; | 745 const double duration = 0.1; |
652 const double halfwayThroughAnimation = startTime + duration / 2; | 746 const double halfwayThroughAnimation = startTime + duration / 2; |
653 const double endTime = startTime + duration; | 747 const double endTime = startTime + duration; |
654 | 748 |
655 // Start a page scale animation. | 749 // Start a page scale animation. |
656 const float pageScaleDelta = 2; | 750 const float pageScaleDelta = 2; |
657 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 751 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
658 m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta,
startTime, duration); | 752 m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta,
startTime, duration); |
659 | 753 |
660 // We should immediately get the final zoom and scroll values for the | 754 // We should immediately get the final zoom and scroll values for the |
661 // animation. | 755 // animation. |
662 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); | 756 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); |
663 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 757 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
664 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 758 |
665 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | 759 if (!CCSettings::pageScalePinchZoomEnabled()) { |
| 760 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 761 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); |
| 762 } else { |
| 763 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); |
| 764 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); |
| 765 } |
666 | 766 |
667 // Scrolling during the animation is ignored. | 767 // Scrolling during the animation is ignored. |
668 const IntSize scrollDelta(0, 10); | 768 const IntSize scrollDelta(0, 10); |
669 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollStarted); | 769 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollStarted); |
670 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 770 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
671 m_hostImpl->scrollEnd(); | 771 m_hostImpl->scrollEnd(); |
672 | 772 |
673 // The final page scale and scroll deltas should match what we got | 773 // The final page scale and scroll deltas should match what we got |
674 // earlier. | 774 // earlier. |
675 m_hostImpl->animate(endTime, endTime); | 775 m_hostImpl->animate(endTime, endTime); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100,
100), CCLayerTilingData::HasBorderTexels); | 817 OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100,
100), CCLayerTilingData::HasBorderTexels); |
718 tiler->setBounds(contentBounds()); | 818 tiler->setBounds(contentBounds()); |
719 setTilingData(*tiler.get()); | 819 setTilingData(*tiler.get()); |
720 } | 820 } |
721 | 821 |
722 private: | 822 private: |
723 bool m_didDrawCalled; | 823 bool m_didDrawCalled; |
724 bool m_willDrawCalled; | 824 bool m_willDrawCalled; |
725 }; | 825 }; |
726 | 826 |
727 TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) | 827 TEST_P(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) |
728 { | 828 { |
729 // The root layer is always drawn, so run this test on a child layer that | 829 // The root layer is always drawn, so run this test on a child layer that |
730 // will be masked out by the root layer's bounds. | 830 // will be masked out by the root layer's bounds. |
731 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 831 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
732 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 832 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
733 root->setMasksToBounds(true); | 833 root->setMasksToBounds(true); |
734 | 834 |
735 root->addChild(DidDrawCheckLayer::create(2)); | 835 root->addChild(DidDrawCheckLayer::create(2)); |
736 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); | 836 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); |
737 // Ensure visibleContentRect for layer is empty | 837 // Ensure visibleContentRect for layer is empty |
(...skipping 24 matching lines...) Expand all Loading... |
762 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 862 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
763 m_hostImpl->drawLayers(frame); | 863 m_hostImpl->drawLayers(frame); |
764 m_hostImpl->didDrawAllLayers(frame); | 864 m_hostImpl->didDrawAllLayers(frame); |
765 | 865 |
766 EXPECT_TRUE(layer->willDrawCalled()); | 866 EXPECT_TRUE(layer->willDrawCalled()); |
767 EXPECT_TRUE(layer->didDrawCalled()); | 867 EXPECT_TRUE(layer->didDrawCalled()); |
768 | 868 |
769 EXPECT_FALSE(layer->visibleContentRect().isEmpty()); | 869 EXPECT_FALSE(layer->visibleContentRect().isEmpty()); |
770 } | 870 } |
771 | 871 |
772 TEST_F(CCLayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) | 872 TEST_P(CCLayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) |
773 { | 873 { |
774 IntSize bigSize(1000, 1000); | 874 IntSize bigSize(1000, 1000); |
775 m_hostImpl->setViewportSize(bigSize, bigSize); | 875 m_hostImpl->setViewportSize(bigSize, bigSize); |
776 | 876 |
777 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 877 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
778 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 878 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
779 | 879 |
780 root->addChild(DidDrawCheckLayer::create(2)); | 880 root->addChild(DidDrawCheckLayer::create(2)); |
781 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); | 881 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); |
782 | 882 |
(...skipping 14 matching lines...) Expand all Loading... |
797 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 897 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
798 m_hostImpl->drawLayers(frame); | 898 m_hostImpl->drawLayers(frame); |
799 m_hostImpl->didDrawAllLayers(frame); | 899 m_hostImpl->didDrawAllLayers(frame); |
800 | 900 |
801 EXPECT_FALSE(occludedLayer->willDrawCalled()); | 901 EXPECT_FALSE(occludedLayer->willDrawCalled()); |
802 EXPECT_FALSE(occludedLayer->didDrawCalled()); | 902 EXPECT_FALSE(occludedLayer->didDrawCalled()); |
803 EXPECT_TRUE(topLayer->willDrawCalled()); | 903 EXPECT_TRUE(topLayer->willDrawCalled()); |
804 EXPECT_TRUE(topLayer->didDrawCalled()); | 904 EXPECT_TRUE(topLayer->didDrawCalled()); |
805 } | 905 } |
806 | 906 |
807 TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) | 907 TEST_P(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) |
808 { | 908 { |
809 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 909 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
810 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 910 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
811 | 911 |
812 root->addChild(DidDrawCheckLayer::create(2)); | 912 root->addChild(DidDrawCheckLayer::create(2)); |
813 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); | 913 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); |
814 | 914 |
815 layer1->addChild(DidDrawCheckLayer::create(3)); | 915 layer1->addChild(DidDrawCheckLayer::create(3)); |
816 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); | 916 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); |
817 | 917 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 setSkipsDraw(skipsDraw); | 949 setSkipsDraw(skipsDraw); |
850 if (!tileMissing) { | 950 if (!tileMissing) { |
851 CCResourceProvider::ResourceId resource = resourceProvider->createRe
source(CCRenderer::ContentPool, IntSize(), GraphicsContext3D::RGBA, CCResourcePr
ovider::TextureUsageAny); | 951 CCResourceProvider::ResourceId resource = resourceProvider->createRe
source(CCRenderer::ContentPool, IntSize(), GraphicsContext3D::RGBA, CCResourcePr
ovider::TextureUsageAny); |
852 pushTileProperties(0, 0, resource, IntRect()); | 952 pushTileProperties(0, 0, resource, IntRect()); |
853 } | 953 } |
854 if (animating) | 954 if (animating) |
855 addAnimatedTransformToLayer(*this, 10, 3, 0); | 955 addAnimatedTransformToLayer(*this, 10, 3, 0); |
856 } | 956 } |
857 }; | 957 }; |
858 | 958 |
859 TEST_F(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) | 959 TEST_P(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) |
860 { | 960 { |
861 // When the texture is not missing, we draw as usual. | 961 // When the texture is not missing, we draw as usual. |
862 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 962 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
863 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 963 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
864 root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true, m
_hostImpl->resourceProvider())); | 964 root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true, m
_hostImpl->resourceProvider())); |
865 | 965 |
866 CCLayerTreeHostImpl::FrameData frame; | 966 CCLayerTreeHostImpl::FrameData frame; |
867 | 967 |
868 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 968 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
869 m_hostImpl->drawLayers(frame); | 969 m_hostImpl->drawLayers(frame); |
(...skipping 20 matching lines...) Expand all Loading... |
890 // When the layer skips draw and we're animating, we still draw the frame. | 990 // When the layer skips draw and we're animating, we still draw the frame. |
891 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 991 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
892 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 992 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
893 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_
hostImpl->resourceProvider())); | 993 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_
hostImpl->resourceProvider())); |
894 | 994 |
895 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 995 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
896 m_hostImpl->drawLayers(frame); | 996 m_hostImpl->drawLayers(frame); |
897 m_hostImpl->didDrawAllLayers(frame); | 997 m_hostImpl->didDrawAllLayers(frame); |
898 } | 998 } |
899 | 999 |
900 TEST_F(CCLayerTreeHostImplTest, scrollRootIgnored) | 1000 TEST_P(CCLayerTreeHostImplTest, scrollRootIgnored) |
901 { | 1001 { |
902 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1002 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
903 root->setScrollable(false); | 1003 root->setScrollable(false); |
904 m_hostImpl->setRootLayer(root.release()); | 1004 m_hostImpl->setRootLayer(root.release()); |
905 initializeRendererAndDrawFrame(); | 1005 initializeRendererAndDrawFrame(); |
906 | 1006 |
907 // Scroll event is ignored because layer is not scrollable. | 1007 // Scroll event is ignored because layer is not scrollable. |
908 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); | 1008 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); |
909 EXPECT_FALSE(m_didRequestRedraw); | 1009 EXPECT_FALSE(m_didRequestRedraw); |
910 EXPECT_FALSE(m_didRequestCommit); | 1010 EXPECT_FALSE(m_didRequestCommit); |
911 } | 1011 } |
912 | 1012 |
913 TEST_F(CCLayerTreeHostImplTest, scrollNonCompositedRoot) | 1013 TEST_P(CCLayerTreeHostImplTest, scrollNonCompositedRoot) |
914 { | 1014 { |
915 // Test the configuration where a non-composited root layer is embedded in a | 1015 // Test the configuration where a non-composited root layer is embedded in a |
916 // scrollable outer layer. | 1016 // scrollable outer layer. |
917 IntSize surfaceSize(10, 10); | 1017 IntSize surfaceSize(10, 10); |
918 | 1018 |
919 OwnPtr<CCLayerImpl> contentLayer = CCLayerImpl::create(1); | 1019 OwnPtr<CCLayerImpl> contentLayer = CCLayerImpl::create(1); |
920 contentLayer->setUseLCDText(true); | 1020 contentLayer->setUseLCDText(true); |
921 contentLayer->setDrawsContent(true); | 1021 contentLayer->setDrawsContent(true); |
922 contentLayer->setPosition(FloatPoint(0, 0)); | 1022 contentLayer->setPosition(FloatPoint(0, 0)); |
923 contentLayer->setAnchorPoint(FloatPoint(0, 0)); | 1023 contentLayer->setAnchorPoint(FloatPoint(0, 0)); |
(...skipping 13 matching lines...) Expand all Loading... |
937 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1037 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
938 initializeRendererAndDrawFrame(); | 1038 initializeRendererAndDrawFrame(); |
939 | 1039 |
940 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1040 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
941 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1041 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
942 m_hostImpl->scrollEnd(); | 1042 m_hostImpl->scrollEnd(); |
943 EXPECT_TRUE(m_didRequestRedraw); | 1043 EXPECT_TRUE(m_didRequestRedraw); |
944 EXPECT_TRUE(m_didRequestCommit); | 1044 EXPECT_TRUE(m_didRequestCommit); |
945 } | 1045 } |
946 | 1046 |
947 TEST_F(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1047 TEST_P(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
948 { | 1048 { |
949 IntSize surfaceSize(10, 10); | 1049 IntSize surfaceSize(10, 10); |
950 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1050 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
951 root->setBounds(surfaceSize); | 1051 root->setBounds(surfaceSize); |
952 root->setContentBounds(surfaceSize); | 1052 root->setContentBounds(surfaceSize); |
953 root->addChild(createScrollableLayer(2, surfaceSize)); | 1053 root->addChild(createScrollableLayer(2, surfaceSize)); |
954 m_hostImpl->setRootLayer(root.release()); | 1054 m_hostImpl->setRootLayer(root.release()); |
955 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1055 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
956 initializeRendererAndDrawFrame(); | 1056 initializeRendererAndDrawFrame(); |
957 | 1057 |
958 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1058 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
959 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1059 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
960 m_hostImpl->scrollEnd(); | 1060 m_hostImpl->scrollEnd(); |
961 EXPECT_TRUE(m_didRequestRedraw); | 1061 EXPECT_TRUE(m_didRequestRedraw); |
962 EXPECT_TRUE(m_didRequestCommit); | 1062 EXPECT_TRUE(m_didRequestCommit); |
963 } | 1063 } |
964 | 1064 |
965 TEST_F(CCLayerTreeHostImplTest, scrollMissesChild) | 1065 TEST_P(CCLayerTreeHostImplTest, scrollMissesChild) |
966 { | 1066 { |
967 IntSize surfaceSize(10, 10); | 1067 IntSize surfaceSize(10, 10); |
968 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1068 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
969 root->addChild(createScrollableLayer(2, surfaceSize)); | 1069 root->addChild(createScrollableLayer(2, surfaceSize)); |
970 m_hostImpl->setRootLayer(root.release()); | 1070 m_hostImpl->setRootLayer(root.release()); |
971 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1071 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
972 initializeRendererAndDrawFrame(); | 1072 initializeRendererAndDrawFrame(); |
973 | 1073 |
974 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. | 1074 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. |
975 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), CCInputHandlerClient::Whe
el), CCInputHandlerClient::ScrollIgnored); | 1075 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), CCInputHandlerClient::Whe
el), CCInputHandlerClient::ScrollIgnored); |
976 EXPECT_FALSE(m_didRequestRedraw); | 1076 EXPECT_FALSE(m_didRequestRedraw); |
977 EXPECT_FALSE(m_didRequestCommit); | 1077 EXPECT_FALSE(m_didRequestCommit); |
978 } | 1078 } |
979 | 1079 |
980 TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) | 1080 TEST_P(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) |
981 { | 1081 { |
982 IntSize surfaceSize(10, 10); | 1082 IntSize surfaceSize(10, 10); |
983 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1083 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
984 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 1084 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
985 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1085 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
986 | 1086 |
987 WebTransformationMatrix matrix; | 1087 WebTransformationMatrix matrix; |
988 matrix.rotate3d(180, 0, 0); | 1088 matrix.rotate3d(180, 0, 0); |
989 child->setTransform(matrix); | 1089 child->setTransform(matrix); |
990 child->setDoubleSided(false); | 1090 child->setDoubleSided(false); |
991 | 1091 |
992 root->addChild(child.release()); | 1092 root->addChild(child.release()); |
993 m_hostImpl->setRootLayer(root.release()); | 1093 m_hostImpl->setRootLayer(root.release()); |
994 initializeRendererAndDrawFrame(); | 1094 initializeRendererAndDrawFrame(); |
995 | 1095 |
996 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is | 1096 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is |
997 // nothing scrollable behind it. | 1097 // nothing scrollable behind it. |
998 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); | 1098 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); |
999 EXPECT_FALSE(m_didRequestRedraw); | 1099 EXPECT_FALSE(m_didRequestRedraw); |
1000 EXPECT_FALSE(m_didRequestCommit); | 1100 EXPECT_FALSE(m_didRequestCommit); |
1001 } | 1101 } |
1002 | 1102 |
1003 TEST_F(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) | 1103 TEST_P(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) |
1004 { | 1104 { |
1005 IntSize surfaceSize(10, 10); | 1105 IntSize surfaceSize(10, 10); |
1006 OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); | 1106 OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); |
1007 contentLayer->setShouldScrollOnMainThread(true); | 1107 contentLayer->setShouldScrollOnMainThread(true); |
1008 contentLayer->setScrollable(false); | 1108 contentLayer->setScrollable(false); |
1009 | 1109 |
1010 OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); | 1110 OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); |
1011 scrollLayer->addChild(contentLayer.release()); | 1111 scrollLayer->addChild(contentLayer.release()); |
1012 | 1112 |
1013 m_hostImpl->setRootLayer(scrollLayer.release()); | 1113 m_hostImpl->setRootLayer(scrollLayer.release()); |
1014 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1114 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1015 initializeRendererAndDrawFrame(); | 1115 initializeRendererAndDrawFrame(); |
1016 | 1116 |
1017 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. | 1117 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. |
1018 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollOnMainThread); | 1118 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollOnMainThread); |
1019 } | 1119 } |
1020 | 1120 |
1021 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1121 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
1022 { | 1122 { |
1023 IntSize surfaceSize(10, 10); | 1123 IntSize surfaceSize(10, 10); |
1024 float pageScale = 2; | 1124 float pageScale = 2; |
1025 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1125 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1026 m_hostImpl->setRootLayer(root.release()); | 1126 m_hostImpl->setRootLayer(root.release()); |
1027 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1127 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1028 initializeRendererAndDrawFrame(); | 1128 initializeRendererAndDrawFrame(); |
1029 | 1129 |
1030 IntSize scrollDelta(0, 10); | 1130 IntSize scrollDelta(0, 10); |
1031 IntSize expectedScrollDelta(scrollDelta); | 1131 IntSize expectedScrollDelta(scrollDelta); |
1032 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1132 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
1033 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1133 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1034 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1134 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1035 m_hostImpl->scrollEnd(); | 1135 m_hostImpl->scrollEnd(); |
1036 | 1136 |
1037 // Set new page scale from main thread. | 1137 // Set new page scale from main thread. |
1038 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); | 1138 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); |
1039 | 1139 |
1040 // The scale should apply to the scroll delta. | 1140 if (!CCSettings::pageScalePinchZoomEnabled()) { |
1041 expectedScrollDelta.scale(pageScale); | 1141 // The scale should apply to the scroll delta. |
| 1142 expectedScrollDelta.scale(pageScale); |
| 1143 } |
1042 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 1144 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
1043 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 1145 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
1044 | 1146 |
1045 // The scroll range should also have been updated. | 1147 // The scroll range should also have been updated. |
1046 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); | 1148 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); |
1047 | 1149 |
1048 // The page scale delta remains constant because the impl thread did not sca
le. | 1150 // The page scale delta remains constant because the impl thread did not sca
le. |
1049 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), 1); | 1151 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix(
)); |
1050 } | 1152 } |
1051 | 1153 |
1052 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1154 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
1053 { | 1155 { |
1054 IntSize surfaceSize(10, 10); | 1156 IntSize surfaceSize(10, 10); |
1055 float pageScale = 2; | 1157 float pageScale = 2; |
1056 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1158 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1057 m_hostImpl->setRootLayer(root.release()); | 1159 m_hostImpl->setRootLayer(root.release()); |
1058 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1160 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1059 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1161 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
1060 initializeRendererAndDrawFrame(); | 1162 initializeRendererAndDrawFrame(); |
1061 | 1163 |
1062 IntSize scrollDelta(0, 10); | 1164 IntSize scrollDelta(0, 10); |
1063 IntSize expectedScrollDelta(scrollDelta); | 1165 IntSize expectedScrollDelta(scrollDelta); |
1064 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1166 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
1065 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1167 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1066 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1168 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1067 m_hostImpl->scrollEnd(); | 1169 m_hostImpl->scrollEnd(); |
1068 | 1170 |
1069 // Set new page scale on impl thread by pinching. | 1171 // Set new page scale on impl thread by pinching. |
1070 m_hostImpl->pinchGestureBegin(); | 1172 m_hostImpl->pinchGestureBegin(); |
1071 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint()); | 1173 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint()); |
1072 m_hostImpl->pinchGestureEnd(); | 1174 m_hostImpl->pinchGestureEnd(); |
| 1175 m_hostImpl->updateRootScrollLayerImplTransform(); |
1073 | 1176 |
1074 // The scroll delta is not scaled because the main thread did not scale. | 1177 // The scroll delta is not scaled because the main thread did not scale. |
1075 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 1178 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
1076 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 1179 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
1077 | 1180 |
1078 // The scroll range should also have been updated. | 1181 // The scroll range should also have been updated. |
1079 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); | 1182 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); |
1080 | 1183 |
1081 // The page scale delta should match the new scale on the impl side. | 1184 // The page scale delta should match the new scale on the impl side. |
1082 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), pageScale); | 1185 WebTransformationMatrix expectedScale; |
| 1186 expectedScale.scale(pageScale); |
| 1187 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); |
1083 } | 1188 } |
1084 | 1189 |
1085 TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) | 1190 TEST_P(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) |
1086 { | 1191 { |
1087 IntSize surfaceSize(10, 10); | 1192 IntSize surfaceSize(10, 10); |
1088 float defaultPageScale = 1; | 1193 float defaultPageScale = 1; |
| 1194 WebTransformationMatrix defaultPageScaleMatrix; |
| 1195 |
1089 float newPageScale = 2; | 1196 float newPageScale = 2; |
| 1197 WebTransformationMatrix newPageScaleMatrix; |
| 1198 newPageScaleMatrix.scale(newPageScale); |
1090 | 1199 |
1091 // Create a normal scrollable root layer and another scrollable child layer. | 1200 // Create a normal scrollable root layer and another scrollable child layer. |
1092 setupScrollAndContentsLayers(surfaceSize); | 1201 setupScrollAndContentsLayers(surfaceSize); |
1093 CCLayerImpl* root = m_hostImpl->rootLayer(); | 1202 CCLayerImpl* root = m_hostImpl->rootLayer(); |
1094 CCLayerImpl* child = root->children()[0]; | 1203 CCLayerImpl* child = root->children()[0]; |
1095 | 1204 |
1096 OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize); | 1205 OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize); |
1097 child->addChild(scrollableChild.release()); | 1206 child->addChild(scrollableChild.release()); |
1098 CCLayerImpl* grandChild = child->children()[0]; | 1207 CCLayerImpl* grandChild = child->children()[0]; |
1099 | 1208 |
1100 // Set new page scale on impl thread by pinching. | 1209 // Set new page scale on impl thread by pinching. |
1101 m_hostImpl->pinchGestureBegin(); | 1210 m_hostImpl->pinchGestureBegin(); |
1102 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); | 1211 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); |
1103 m_hostImpl->pinchGestureEnd(); | 1212 m_hostImpl->pinchGestureEnd(); |
| 1213 m_hostImpl->updateRootScrollLayerImplTransform(); |
1104 | 1214 |
1105 // The page scale delta should only be applied to the scrollable root layer. | 1215 // The page scale delta should only be applied to the scrollable root layer. |
1106 EXPECT_EQ(root->pageScaleDelta(), newPageScale); | 1216 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); |
1107 EXPECT_EQ(child->pageScaleDelta(), defaultPageScale); | 1217 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); |
1108 EXPECT_EQ(grandChild->pageScaleDelta(), defaultPageScale); | 1218 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); |
1109 | 1219 |
1110 // Make sure all the layers are drawn with the page scale delta applied, i.e
., the page scale | 1220 // Make sure all the layers are drawn with the page scale delta applied, i.e
., the page scale |
1111 // delta on the root layer is applied hierarchically. | 1221 // delta on the root layer is applied hierarchically. |
1112 CCLayerTreeHostImpl::FrameData frame; | 1222 CCLayerTreeHostImpl::FrameData frame; |
1113 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1223 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1114 m_hostImpl->drawLayers(frame); | 1224 m_hostImpl->drawLayers(frame); |
1115 m_hostImpl->didDrawAllLayers(frame); | 1225 m_hostImpl->didDrawAllLayers(frame); |
1116 | 1226 |
1117 EXPECT_EQ(root->drawTransform().m11(), newPageScale); | 1227 EXPECT_EQ(root->drawTransform().m11(), newPageScale); |
1118 EXPECT_EQ(root->drawTransform().m22(), newPageScale); | 1228 EXPECT_EQ(root->drawTransform().m22(), newPageScale); |
1119 EXPECT_EQ(child->drawTransform().m11(), newPageScale); | 1229 EXPECT_EQ(child->drawTransform().m11(), newPageScale); |
1120 EXPECT_EQ(child->drawTransform().m22(), newPageScale); | 1230 EXPECT_EQ(child->drawTransform().m22(), newPageScale); |
1121 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); | 1231 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); |
1122 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); | 1232 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); |
1123 } | 1233 } |
1124 | 1234 |
1125 TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) | 1235 TEST_P(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
1126 { | 1236 { |
1127 IntSize surfaceSize(10, 10); | 1237 IntSize surfaceSize(10, 10); |
1128 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1238 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
1129 root->setBounds(surfaceSize); | 1239 root->setBounds(surfaceSize); |
1130 root->setContentBounds(surfaceSize); | 1240 root->setContentBounds(surfaceSize); |
1131 // Also mark the root scrollable so it becomes the root scroll layer. | 1241 // Also mark the root scrollable so it becomes the root scroll layer. |
1132 root->setScrollable(true); | 1242 root->setScrollable(true); |
1133 int scrollLayerId = 2; | 1243 int scrollLayerId = 2; |
1134 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1244 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
1135 m_hostImpl->setRootLayer(root.release()); | 1245 m_hostImpl->setRootLayer(root.release()); |
1136 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1246 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1137 initializeRendererAndDrawFrame(); | 1247 initializeRendererAndDrawFrame(); |
1138 | 1248 |
1139 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1249 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1140 | 1250 |
1141 IntSize scrollDelta(0, 10); | 1251 IntSize scrollDelta(0, 10); |
1142 IntSize expectedScrollDelta(scrollDelta); | 1252 IntSize expectedScrollDelta(scrollDelta); |
1143 IntSize expectedMaxScroll(child->maxScrollPosition()); | 1253 IntSize expectedMaxScroll(child->maxScrollPosition()); |
1144 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1254 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1145 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1255 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1146 m_hostImpl->scrollEnd(); | 1256 m_hostImpl->scrollEnd(); |
1147 | 1257 |
1148 float pageScale = 2; | 1258 float pageScale = 2; |
1149 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); | 1259 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); |
1150 | 1260 |
1151 // The scale should apply to the scroll delta. | 1261 m_hostImpl->updateRootScrollLayerImplTransform(); |
1152 expectedScrollDelta.scale(pageScale); | 1262 |
| 1263 if (!CCSettings::pageScalePinchZoomEnabled()) { |
| 1264 // The scale should apply to the scroll delta. |
| 1265 expectedScrollDelta.scale(pageScale); |
| 1266 } |
1153 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 1267 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
1154 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); | 1268 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); |
1155 | 1269 |
1156 // The scroll range should not have changed. | 1270 // The scroll range should not have changed. |
1157 EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll); | 1271 EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll); |
1158 | 1272 |
1159 // The page scale delta remains constant because the impl thread did not sca
le. | 1273 // The page scale delta remains constant because the impl thread did not sca
le. |
1160 EXPECT_EQ(child->pageScaleDelta(), 1); | 1274 WebTransformationMatrix identityTransform; |
| 1275 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); |
1161 } | 1276 } |
1162 | 1277 |
1163 TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit) | 1278 TEST_P(CCLayerTreeHostImplTest, scrollChildBeyondLimit) |
1164 { | 1279 { |
1165 // Scroll a child layer beyond its maximum scroll range and make sure the | 1280 // Scroll a child layer beyond its maximum scroll range and make sure the |
1166 // parent layer is scrolled on the axis on which the child was unable to | 1281 // parent layer is scrolled on the axis on which the child was unable to |
1167 // scroll. | 1282 // scroll. |
1168 IntSize surfaceSize(10, 10); | 1283 IntSize surfaceSize(10, 10); |
1169 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1284 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1170 | 1285 |
1171 OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize); | 1286 OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize); |
1172 grandChild->setScrollPosition(IntPoint(0, 5)); | 1287 grandChild->setScrollPosition(IntPoint(0, 5)); |
1173 | 1288 |
(...skipping 16 matching lines...) Expand all Loading... |
1190 // The grand child should have scrolled up to its limit. | 1305 // The grand child should have scrolled up to its limit. |
1191 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1306 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1192 CCLayerImpl* grandChild = child->children()[0]; | 1307 CCLayerImpl* grandChild = child->children()[0]; |
1193 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); | 1308 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); |
1194 | 1309 |
1195 // The child should have only scrolled on the other axis. | 1310 // The child should have only scrolled on the other axis. |
1196 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); | 1311 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); |
1197 } | 1312 } |
1198 } | 1313 } |
1199 | 1314 |
1200 TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling) | 1315 TEST_P(CCLayerTreeHostImplTest, scrollEventBubbling) |
1201 { | 1316 { |
1202 // When we try to scroll a non-scrollable child layer, the scroll delta | 1317 // When we try to scroll a non-scrollable child layer, the scroll delta |
1203 // should be applied to one of its ancestors if possible. | 1318 // should be applied to one of its ancestors if possible. |
1204 IntSize surfaceSize(10, 10); | 1319 IntSize surfaceSize(10, 10); |
1205 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1320 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1206 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 1321 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
1207 | 1322 |
1208 child->setScrollable(false); | 1323 child->setScrollable(false); |
1209 root->addChild(child.release()); | 1324 root->addChild(child.release()); |
1210 | 1325 |
1211 m_hostImpl->setRootLayer(root.release()); | 1326 m_hostImpl->setRootLayer(root.release()); |
1212 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1327 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1213 initializeRendererAndDrawFrame(); | 1328 initializeRendererAndDrawFrame(); |
1214 { | 1329 { |
1215 IntSize scrollDelta(0, 4); | 1330 IntSize scrollDelta(0, 4); |
1216 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::
Wheel), CCInputHandlerClient::ScrollStarted); | 1331 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::
Wheel), CCInputHandlerClient::ScrollStarted); |
1217 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1332 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1218 m_hostImpl->scrollEnd(); | 1333 m_hostImpl->scrollEnd(); |
1219 | 1334 |
1220 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 1335 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
1221 | 1336 |
1222 // Only the root should have scrolled. | 1337 // Only the root should have scrolled. |
1223 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 1338 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
1224 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); | 1339 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
1225 } | 1340 } |
1226 } | 1341 } |
1227 | 1342 |
1228 TEST_F(CCLayerTreeHostImplTest, scrollBeforeRedraw) | 1343 TEST_P(CCLayerTreeHostImplTest, scrollBeforeRedraw) |
1229 { | 1344 { |
1230 IntSize surfaceSize(10, 10); | 1345 IntSize surfaceSize(10, 10); |
1231 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); | 1346 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); |
1232 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1347 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1233 | 1348 |
1234 // Draw one frame and then immediately rebuild the layer tree to mimic a tre
e synchronization. | 1349 // Draw one frame and then immediately rebuild the layer tree to mimic a tre
e synchronization. |
1235 initializeRendererAndDrawFrame(); | 1350 initializeRendererAndDrawFrame(); |
1236 m_hostImpl->detachLayerTree(); | 1351 m_hostImpl->detachLayerTree(); |
1237 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); | 1352 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); |
1238 | 1353 |
1239 // Scrolling should still work even though we did not draw yet. | 1354 // Scrolling should still work even though we did not draw yet. |
1240 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1355 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1241 } | 1356 } |
1242 | 1357 |
1243 TEST_F(CCLayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) | 1358 TEST_P(CCLayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) |
1244 { | 1359 { |
1245 setupScrollAndContentsLayers(IntSize(100, 100)); | 1360 setupScrollAndContentsLayers(IntSize(100, 100)); |
1246 | 1361 |
1247 // Rotate the root layer 90 degrees counter-clockwise about its center. | 1362 // Rotate the root layer 90 degrees counter-clockwise about its center. |
1248 WebTransformationMatrix rotateTransform; | 1363 WebTransformationMatrix rotateTransform; |
1249 rotateTransform.rotate(-90); | 1364 rotateTransform.rotate(-90); |
1250 m_hostImpl->rootLayer()->setTransform(rotateTransform); | 1365 m_hostImpl->rootLayer()->setTransform(rotateTransform); |
1251 | 1366 |
1252 IntSize surfaceSize(50, 50); | 1367 IntSize surfaceSize(50, 50); |
1253 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1368 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
(...skipping 14 matching lines...) Expand all Loading... |
1268 IntSize wheelScrollDelta(0, 10); | 1383 IntSize wheelScrollDelta(0, 10); |
1269 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1384 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1270 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); | 1385 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); |
1271 m_hostImpl->scrollEnd(); | 1386 m_hostImpl->scrollEnd(); |
1272 | 1387 |
1273 // The layer should have scrolled down in its local coordinates. | 1388 // The layer should have scrolled down in its local coordinates. |
1274 scrollInfo = m_hostImpl->processScrollDeltas(); | 1389 scrollInfo = m_hostImpl->processScrollDeltas(); |
1275 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1390 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
1276 } | 1391 } |
1277 | 1392 |
1278 TEST_F(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) | 1393 TEST_P(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) |
1279 { | 1394 { |
1280 setupScrollAndContentsLayers(IntSize(100, 100)); | 1395 setupScrollAndContentsLayers(IntSize(100, 100)); |
1281 int childLayerId = 3; | 1396 int childLayerId = 3; |
1282 float childLayerAngle = -20; | 1397 float childLayerAngle = -20; |
1283 | 1398 |
1284 // Create a child layer that is rotated to a non-axis-aligned angle. | 1399 // Create a child layer that is rotated to a non-axis-aligned angle. |
1285 OwnPtr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl->
rootLayer()->contentBounds()); | 1400 OwnPtr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl->
rootLayer()->contentBounds()); |
1286 WebTransformationMatrix rotateTransform; | 1401 WebTransformationMatrix rotateTransform; |
1287 rotateTransform.translate(-50, -50); | 1402 rotateTransform.translate(-50, -50); |
1288 rotateTransform.rotate(childLayerAngle); | 1403 rotateTransform.rotate(childLayerAngle); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 1444 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
1330 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1445 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
1331 | 1446 |
1332 // The root layer should have scrolled more, since the input scroll delt
a was mostly | 1447 // The root layer should have scrolled more, since the input scroll delt
a was mostly |
1333 // orthogonal to the child layer's vertical scroll axis. | 1448 // orthogonal to the child layer's vertical scroll axis. |
1334 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de
g2rad(childLayerAngle)), 2), 0); | 1449 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de
g2rad(childLayerAngle)), 2), 0); |
1335 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); | 1450 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); |
1336 } | 1451 } |
1337 } | 1452 } |
1338 | 1453 |
1339 TEST_F(CCLayerTreeHostImplTest, scrollScaledLayer) | 1454 TEST_P(CCLayerTreeHostImplTest, scrollScaledLayer) |
1340 { | 1455 { |
1341 setupScrollAndContentsLayers(IntSize(100, 100)); | 1456 setupScrollAndContentsLayers(IntSize(100, 100)); |
1342 | 1457 |
1343 // Scale the layer to twice its normal size. | 1458 // Scale the layer to twice its normal size. |
1344 int scale = 2; | 1459 int scale = 2; |
1345 WebTransformationMatrix scaleTransform; | 1460 WebTransformationMatrix scaleTransform; |
1346 scaleTransform.scale(scale); | 1461 scaleTransform.scale(scale); |
1347 m_hostImpl->rootLayer()->setTransform(scaleTransform); | 1462 m_hostImpl->rootLayer()->setTransform(scaleTransform); |
1348 | 1463 |
1349 IntSize surfaceSize(50, 50); | 1464 IntSize surfaceSize(50, 50); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 | 1562 |
1448 bool m_blend; | 1563 bool m_blend; |
1449 bool m_hasRenderSurface; | 1564 bool m_hasRenderSurface; |
1450 bool m_quadsAppended; | 1565 bool m_quadsAppended; |
1451 IntRect m_quadRect; | 1566 IntRect m_quadRect; |
1452 IntRect m_opaqueContentRect; | 1567 IntRect m_opaqueContentRect; |
1453 IntRect m_quadVisibleRect; | 1568 IntRect m_quadVisibleRect; |
1454 CCResourceProvider::ResourceId m_resourceId; | 1569 CCResourceProvider::ResourceId m_resourceId; |
1455 }; | 1570 }; |
1456 | 1571 |
1457 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 1572 TEST_P(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
1458 { | 1573 { |
1459 { | 1574 { |
1460 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1575 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
1461 root->setAnchorPoint(FloatPoint(0, 0)); | 1576 root->setAnchorPoint(FloatPoint(0, 0)); |
1462 root->setBounds(IntSize(10, 10)); | 1577 root->setBounds(IntSize(10, 10)); |
1463 root->setContentBounds(root->bounds()); | 1578 root->setContentBounds(root->bounds()); |
1464 root->setDrawsContent(false); | 1579 root->setDrawsContent(false); |
1465 m_hostImpl->setRootLayer(root.release()); | 1580 m_hostImpl->setRootLayer(root.release()); |
1466 } | 1581 } |
1467 CCLayerImpl* root = m_hostImpl->rootLayer(); | 1582 CCLayerImpl* root = m_hostImpl->rootLayer(); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 layer1->setQuadVisibleRect(IntRect(5, 5, 2, 5)); | 1754 layer1->setQuadVisibleRect(IntRect(5, 5, 2, 5)); |
1640 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); | 1755 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); |
1641 layer1->setExpectation(false, false); | 1756 layer1->setExpectation(false, false); |
1642 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1757 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1643 m_hostImpl->drawLayers(frame); | 1758 m_hostImpl->drawLayers(frame); |
1644 EXPECT_TRUE(layer1->quadsAppended()); | 1759 EXPECT_TRUE(layer1->quadsAppended()); |
1645 m_hostImpl->didDrawAllLayers(frame); | 1760 m_hostImpl->didDrawAllLayers(frame); |
1646 | 1761 |
1647 } | 1762 } |
1648 | 1763 |
1649 TEST_F(CCLayerTreeHostImplTest, viewportCovered) | 1764 TEST_P(CCLayerTreeHostImplTest, viewportCovered) |
1650 { | 1765 { |
1651 m_hostImpl->initializeRenderer(createContext()); | 1766 m_hostImpl->initializeRenderer(createContext()); |
1652 m_hostImpl->setBackgroundColor(SK_ColorGRAY); | 1767 m_hostImpl->setBackgroundColor(SK_ColorGRAY); |
1653 | 1768 |
1654 IntSize viewportSize(1000, 1000); | 1769 IntSize viewportSize(1000, 1000); |
1655 m_hostImpl->setViewportSize(viewportSize, viewportSize); | 1770 m_hostImpl->setViewportSize(viewportSize, viewportSize); |
1656 | 1771 |
1657 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1, m_hostImpl->resourc
eProvider())); | 1772 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1, m_hostImpl->resourc
eProvider())); |
1658 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl->
rootLayer()); | 1773 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl->
rootLayer()); |
1659 root->setExpectation(false, true); | 1774 root->setExpectation(false, true); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 }; | 1863 }; |
1749 | 1864 |
1750 class FakeDrawableCCLayerImpl: public CCLayerImpl { | 1865 class FakeDrawableCCLayerImpl: public CCLayerImpl { |
1751 public: | 1866 public: |
1752 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } | 1867 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } |
1753 }; | 1868 }; |
1754 | 1869 |
1755 // Only reshape when we know we are going to draw. Otherwise, the reshape | 1870 // Only reshape when we know we are going to draw. Otherwise, the reshape |
1756 // can leave the window at the wrong size if we never draw and the proper | 1871 // can leave the window at the wrong size if we never draw and the proper |
1757 // viewport size is never set. | 1872 // viewport size is never set. |
1758 TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 1873 TEST_P(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
1759 { | 1874 { |
1760 OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create
(adoptPtr(new ReshapeTrackerContext)); | 1875 OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create
(adoptPtr(new ReshapeTrackerContext)); |
1761 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
ccContext->context3D()); | 1876 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
ccContext->context3D()); |
1762 m_hostImpl->initializeRenderer(ccContext.release()); | 1877 m_hostImpl->initializeRenderer(ccContext.release()); |
1763 | 1878 |
1764 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 1879 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); |
1765 root->setAnchorPoint(FloatPoint(0, 0)); | 1880 root->setAnchorPoint(FloatPoint(0, 0)); |
1766 root->setBounds(IntSize(10, 10)); | 1881 root->setBounds(IntSize(10, 10)); |
1767 root->setDrawsContent(true); | 1882 root->setDrawsContent(true); |
1768 m_hostImpl->setRootLayer(adoptPtr(root)); | 1883 m_hostImpl->setRootLayer(adoptPtr(root)); |
(...skipping 22 matching lines...) Expand all Loading... |
1791 } | 1906 } |
1792 | 1907 |
1793 IntRect partialSwapRect() const { return m_partialSwapRect; } | 1908 IntRect partialSwapRect() const { return m_partialSwapRect; } |
1794 | 1909 |
1795 private: | 1910 private: |
1796 IntRect m_partialSwapRect; | 1911 IntRect m_partialSwapRect; |
1797 }; | 1912 }; |
1798 | 1913 |
1799 // Make sure damage tracking propagates all the way to the graphics context, | 1914 // Make sure damage tracking propagates all the way to the graphics context, |
1800 // where it should request to swap only the subBuffer that is damaged. | 1915 // where it should request to swap only the subBuffer that is damaged. |
1801 TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect) | 1916 TEST_P(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect) |
1802 { | 1917 { |
1803 OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create
(adoptPtr(new PartialSwapTrackerContext)); | 1918 OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create
(adoptPtr(new PartialSwapTrackerContext)); |
1804 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(ccContext->context3D()); | 1919 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(ccContext->context3D()); |
1805 | 1920 |
1806 // This test creates its own CCLayerTreeHostImpl, so | 1921 // This test creates its own CCLayerTreeHostImpl, so |
1807 // that we can force partial swap enabled. | 1922 // that we can force partial swap enabled. |
1808 CCLayerTreeSettings settings; | 1923 CCLayerTreeSettings settings; |
1809 CCSettings::setPartialSwapEnabled(true); | 1924 CCSettings::setPartialSwapEnabled(true); |
1810 OwnPtr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::create(
settings, this); | 1925 OwnPtr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::create(
settings, this); |
1811 layerTreeHostImpl->initializeRenderer(ccContext.release()); | 1926 layerTreeHostImpl->initializeRenderer(ccContext.release()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 m_hostImpl->didDrawAllLayers(frame); | 1980 m_hostImpl->didDrawAllLayers(frame); |
1866 layerTreeHostImpl->swapBuffers(); | 1981 layerTreeHostImpl->swapBuffers(); |
1867 actualSwapRect = partialSwapTracker->partialSwapRect(); | 1982 actualSwapRect = partialSwapTracker->partialSwapRect(); |
1868 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); | 1983 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); |
1869 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 1984 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
1870 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 1985 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
1871 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 1986 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
1872 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 1987 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
1873 } | 1988 } |
1874 | 1989 |
1875 TEST_F(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) | 1990 TEST_P(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) |
1876 { | 1991 { |
1877 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 1992 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); |
1878 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2); | 1993 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2); |
1879 child->setAnchorPoint(FloatPoint(0, 0)); | 1994 child->setAnchorPoint(FloatPoint(0, 0)); |
1880 child->setBounds(IntSize(10, 10)); | 1995 child->setBounds(IntSize(10, 10)); |
1881 child->setContentBounds(IntSize(10, 10)); | 1996 child->setContentBounds(IntSize(10, 10)); |
1882 child->setDrawsContent(true); | 1997 child->setDrawsContent(true); |
1883 root->setAnchorPoint(FloatPoint(0, 0)); | 1998 root->setAnchorPoint(FloatPoint(0, 0)); |
1884 root->setBounds(IntSize(10, 10)); | 1999 root->setBounds(IntSize(10, 10)); |
1885 root->setContentBounds(IntSize(10, 10)); | 2000 root->setContentBounds(IntSize(10, 10)); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2005 .WillRepeatedly(Return()); | 2120 .WillRepeatedly(Return()); |
2006 | 2121 |
2007 EXPECT_CALL(*m_context, enable(GraphicsContext3D::SCISSOR_TEST)) | 2122 EXPECT_CALL(*m_context, enable(GraphicsContext3D::SCISSOR_TEST)) |
2008 .Times(0); | 2123 .Times(0); |
2009 | 2124 |
2010 EXPECT_CALL(*m_context, scissor(_, _, _, _)) | 2125 EXPECT_CALL(*m_context, scissor(_, _, _, _)) |
2011 .Times(0); | 2126 .Times(0); |
2012 } | 2127 } |
2013 }; | 2128 }; |
2014 | 2129 |
2015 TEST_F(CCLayerTreeHostImplTest, noPartialSwap) | 2130 TEST_P(CCLayerTreeHostImplTest, noPartialSwap) |
2016 { | 2131 { |
2017 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a
doptPtr(new MockContext)); | 2132 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a
doptPtr(new MockContext)); |
2018 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); | 2133 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); |
2019 MockContextHarness harness(mockContext); | 2134 MockContextHarness harness(mockContext); |
2020 | 2135 |
2021 harness.mustDrawSolidQuad(); | 2136 harness.mustDrawSolidQuad(); |
2022 harness.mustSetScissor(0, 0, 10, 10); | 2137 harness.mustSetScissor(0, 0, 10, 10); |
2023 | 2138 |
2024 // Run test case | 2139 // Run test case |
2025 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context.
release(), FakeLayerWithQuads::create(1)); | 2140 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context.
release(), FakeLayerWithQuads::create(1)); |
2026 | 2141 |
2027 CCLayerTreeHostImpl::FrameData frame; | 2142 CCLayerTreeHostImpl::FrameData frame; |
2028 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2143 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2029 myHostImpl->drawLayers(frame); | 2144 myHostImpl->drawLayers(frame); |
2030 myHostImpl->didDrawAllLayers(frame); | 2145 myHostImpl->didDrawAllLayers(frame); |
2031 Mock::VerifyAndClearExpectations(&mockContext); | 2146 Mock::VerifyAndClearExpectations(&mockContext); |
2032 } | 2147 } |
2033 | 2148 |
2034 TEST_F(CCLayerTreeHostImplTest, partialSwap) | 2149 TEST_P(CCLayerTreeHostImplTest, partialSwap) |
2035 { | 2150 { |
2036 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a
doptPtr(new MockContext)); | 2151 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a
doptPtr(new MockContext)); |
2037 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); | 2152 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); |
2038 MockContextHarness harness(mockContext); | 2153 MockContextHarness harness(mockContext); |
2039 | 2154 |
2040 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context.r
elease(), FakeLayerWithQuads::create(1)); | 2155 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context.r
elease(), FakeLayerWithQuads::create(1)); |
2041 | 2156 |
2042 // The first frame is not a partially-swapped one. | 2157 // The first frame is not a partially-swapped one. |
2043 harness.mustSetScissor(0, 0, 10, 10); | 2158 harness.mustSetScissor(0, 0, 10, 10); |
2044 harness.mustDrawSolidQuad(); | 2159 harness.mustDrawSolidQuad(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2148 grandChild->setVisibleContentRect(grandChildRect); | 2263 grandChild->setVisibleContentRect(grandChildRect); |
2149 grandChild->setDrawsContent(true); | 2264 grandChild->setDrawsContent(true); |
2150 | 2265 |
2151 child->addChild(grandChild.release()); | 2266 child->addChild(grandChild.release()); |
2152 root->addChild(child.release()); | 2267 root->addChild(child.release()); |
2153 | 2268 |
2154 myHostImpl->setRootLayer(root.release()); | 2269 myHostImpl->setRootLayer(root.release()); |
2155 return myHostImpl.release(); | 2270 return myHostImpl.release(); |
2156 } | 2271 } |
2157 | 2272 |
2158 TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) | 2273 TEST_P(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) |
2159 { | 2274 { |
2160 OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this); | 2275 OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this); |
2161 | 2276 |
2162 { | 2277 { |
2163 CCLayerTreeHostImpl::FrameData frame; | 2278 CCLayerTreeHostImpl::FrameData frame; |
2164 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2279 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2165 | 2280 |
2166 // Just for consistency, the most interesting stuff already happened | 2281 // Just for consistency, the most interesting stuff already happened |
2167 myHostImpl->drawLayers(frame); | 2282 myHostImpl->drawLayers(frame); |
2168 myHostImpl->didDrawAllLayers(frame); | 2283 myHostImpl->didDrawAllLayers(frame); |
2169 | 2284 |
2170 // Verify all quads have been computed | 2285 // Verify all quads have been computed |
2171 ASSERT_EQ(2U, frame.renderPasses.size()); | 2286 ASSERT_EQ(2U, frame.renderPasses.size()); |
2172 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 2287 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
2173 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 2288 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
2174 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]->
material()); | 2289 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]->
material()); |
2175 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->
material()); | 2290 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->
material()); |
2176 } | 2291 } |
2177 } | 2292 } |
2178 | 2293 |
2179 TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap) | 2294 TEST_P(CCLayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap) |
2180 { | 2295 { |
2181 OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this); | 2296 OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this); |
2182 | 2297 |
2183 { | 2298 { |
2184 CCLayerTreeHostImpl::FrameData frame; | 2299 CCLayerTreeHostImpl::FrameData frame; |
2185 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2300 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2186 | 2301 |
2187 // Just for consistency, the most interesting stuff already happened | 2302 // Just for consistency, the most interesting stuff already happened |
2188 myHostImpl->drawLayers(frame); | 2303 myHostImpl->drawLayers(frame); |
2189 myHostImpl->didDrawAllLayers(frame); | 2304 myHostImpl->didDrawAllLayers(frame); |
(...skipping 22 matching lines...) Expand all Loading... |
2212 private: | 2327 private: |
2213 explicit ContextLostNotificationCheckLayer(int id) | 2328 explicit ContextLostNotificationCheckLayer(int id) |
2214 : CCLayerImpl(id) | 2329 : CCLayerImpl(id) |
2215 , m_didLoseContextCalled(false) | 2330 , m_didLoseContextCalled(false) |
2216 { | 2331 { |
2217 } | 2332 } |
2218 | 2333 |
2219 bool m_didLoseContextCalled; | 2334 bool m_didLoseContextCalled; |
2220 }; | 2335 }; |
2221 | 2336 |
2222 TEST_F(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayer
s) | 2337 TEST_P(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayer
s) |
2223 { | 2338 { |
2224 m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(1)); | 2339 m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(1)); |
2225 ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificatio
nCheckLayer*>(m_hostImpl->rootLayer()); | 2340 ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificatio
nCheckLayer*>(m_hostImpl->rootLayer()); |
2226 | 2341 |
2227 root->addChild(ContextLostNotificationCheckLayer::create(1)); | 2342 root->addChild(ContextLostNotificationCheckLayer::create(1)); |
2228 ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificat
ionCheckLayer*>(root->children()[0]); | 2343 ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificat
ionCheckLayer*>(root->children()[0]); |
2229 | 2344 |
2230 layer1->addChild(ContextLostNotificationCheckLayer::create(2)); | 2345 layer1->addChild(ContextLostNotificationCheckLayer::create(2)); |
2231 ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificat
ionCheckLayer*>(layer1->children()[0]); | 2346 ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificat
ionCheckLayer*>(layer1->children()[0]); |
2232 | 2347 |
2233 EXPECT_FALSE(root->didLoseContextCalled()); | 2348 EXPECT_FALSE(root->didLoseContextCalled()); |
2234 EXPECT_FALSE(layer1->didLoseContextCalled()); | 2349 EXPECT_FALSE(layer1->didLoseContextCalled()); |
2235 EXPECT_FALSE(layer2->didLoseContextCalled()); | 2350 EXPECT_FALSE(layer2->didLoseContextCalled()); |
2236 | 2351 |
2237 m_hostImpl->initializeRenderer(createContext()); | 2352 m_hostImpl->initializeRenderer(createContext()); |
2238 | 2353 |
2239 EXPECT_TRUE(root->didLoseContextCalled()); | 2354 EXPECT_TRUE(root->didLoseContextCalled()); |
2240 EXPECT_TRUE(layer1->didLoseContextCalled()); | 2355 EXPECT_TRUE(layer1->didLoseContextCalled()); |
2241 EXPECT_TRUE(layer2->didLoseContextCalled()); | 2356 EXPECT_TRUE(layer2->didLoseContextCalled()); |
2242 } | 2357 } |
2243 | 2358 |
2244 TEST_F(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost) | 2359 TEST_P(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost) |
2245 { | 2360 { |
2246 CCLayerTreeSettings settings; | 2361 CCLayerTreeSettings settings; |
2247 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); | 2362 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); |
2248 | 2363 |
2249 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. | 2364 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. |
2250 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP
tr(new FakeWebGraphicsContext3DMakeCurrentFails))); | 2365 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP
tr(new FakeWebGraphicsContext3DMakeCurrentFails))); |
2251 m_hostImpl->finishAllRendering(); | 2366 m_hostImpl->finishAllRendering(); |
2252 } | 2367 } |
2253 | 2368 |
2254 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic
sContext3D { | 2369 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic
sContext3D { |
2255 public: | 2370 public: |
2256 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed
Count) : m_succeedCount(succeedCount) { } | 2371 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed
Count) : m_succeedCount(succeedCount) { } |
2257 virtual bool makeContextCurrent() { | 2372 virtual bool makeContextCurrent() { |
2258 if (!m_succeedCount) | 2373 if (!m_succeedCount) |
2259 return false; | 2374 return false; |
2260 --m_succeedCount; | 2375 --m_succeedCount; |
2261 return true; | 2376 return true; |
2262 } | 2377 } |
2263 | 2378 |
2264 private: | 2379 private: |
2265 unsigned m_succeedCount; | 2380 unsigned m_succeedCount; |
2266 }; | 2381 }; |
2267 | 2382 |
2268 TEST_F(CCLayerTreeHostImplTest, contextLostDuringInitialize) | 2383 TEST_P(CCLayerTreeHostImplTest, contextLostDuringInitialize) |
2269 { | 2384 { |
2270 CCLayerTreeSettings settings; | 2385 CCLayerTreeSettings settings; |
2271 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); | 2386 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); |
2272 | 2387 |
2273 // Initialize into a known successful state. | 2388 // Initialize into a known successful state. |
2274 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); | 2389 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); |
2275 EXPECT_TRUE(m_hostImpl->context()); | 2390 EXPECT_TRUE(m_hostImpl->context()); |
2276 EXPECT_TRUE(m_hostImpl->renderer()); | 2391 EXPECT_TRUE(m_hostImpl->renderer()); |
2277 EXPECT_TRUE(m_hostImpl->resourceProvider()); | 2392 EXPECT_TRUE(m_hostImpl->resourceProvider()); |
2278 | 2393 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2508 scoped_ptr<CCRenderPass> pass = CCRenderPass::create(CCRenderPass::Id(1, 1),
IntRect(0, 0, 1, 1), WebTransformationMatrix()); | 2623 scoped_ptr<CCRenderPass> pass = CCRenderPass::create(CCRenderPass::Id(1, 1),
IntRect(0, 0, 1, 1), WebTransformationMatrix()); |
2509 scoped_ptr<CCSharedQuadState> sharedState = CCSharedQuadState::create(WebTra
nsformationMatrix(), IntRect(0, 0, 1, 1), IntRect(0, 0, 1, 1), 1, false); | 2624 scoped_ptr<CCSharedQuadState> sharedState = CCSharedQuadState::create(WebTra
nsformationMatrix(), IntRect(0, 0, 1, 1), IntRect(0, 0, 1, 1), 1, false); |
2510 scoped_ptr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedState.g
et(), IntRect(0, 0, 1, 1), resourceId, false, FloatRect(0, 0, 1, 1), false); | 2625 scoped_ptr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedState.g
et(), IntRect(0, 0, 1, 1), resourceId, false, FloatRect(0, 0, 1, 1), false); |
2511 | 2626 |
2512 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat
e.Pass()); | 2627 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat
e.Pass()); |
2513 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua
d>()); | 2628 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua
d>()); |
2514 | 2629 |
2515 return pass.Pass(); | 2630 return pass.Pass(); |
2516 } | 2631 } |
2517 | 2632 |
2518 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) | 2633 TEST_P(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) |
2519 { | 2634 { |
2520 int layerId = 1; | 2635 int layerId = 1; |
2521 | 2636 |
2522 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++)); | 2637 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++)); |
2523 rootLayer->setBounds(IntSize(10, 10)); | 2638 rootLayer->setBounds(IntSize(10, 10)); |
2524 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2639 rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
2525 | 2640 |
2526 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++); | 2641 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++); |
2527 tileLayer->setBounds(IntSize(10, 10)); | 2642 tileLayer->setBounds(IntSize(10, 10)); |
2528 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2643 tileLayer->setAnchorPoint(FloatPoint(0, 0)); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2695 return WebString(); | 2810 return WebString(); |
2696 } | 2811 } |
2697 | 2812 |
2698 unsigned numTextures() const { return m_numTextures; } | 2813 unsigned numTextures() const { return m_numTextures; } |
2699 | 2814 |
2700 private: | 2815 private: |
2701 HashMap<WebGLId, bool> m_textures; | 2816 HashMap<WebGLId, bool> m_textures; |
2702 unsigned m_numTextures; | 2817 unsigned m_numTextures; |
2703 }; | 2818 }; |
2704 | 2819 |
2705 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures) | 2820 TEST_P(CCLayerTreeHostImplTest, layersFreeTextures) |
2706 { | 2821 { |
2707 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); | 2822 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); |
2708 rootLayer->setBounds(IntSize(10, 10)); | 2823 rootLayer->setBounds(IntSize(10, 10)); |
2709 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2824 rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
2710 | 2825 |
2711 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); | 2826 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); |
2712 tileLayer->setBounds(IntSize(10, 10)); | 2827 tileLayer->setBounds(IntSize(10, 10)); |
2713 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2828 tileLayer->setAnchorPoint(FloatPoint(0, 0)); |
2714 tileLayer->setContentBounds(IntSize(10, 10)); | 2829 tileLayer->setContentBounds(IntSize(10, 10)); |
2715 tileLayer->setDrawsContent(true); | 2830 tileLayer->setDrawsContent(true); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2766 // There should be no textures left in use after. | 2881 // There should be no textures left in use after. |
2767 EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures()); | 2882 EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures()); |
2768 } | 2883 } |
2769 | 2884 |
2770 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { | 2885 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { |
2771 public: | 2886 public: |
2772 MOCK_METHOD1(useProgram, void(WebGLId program)); | 2887 MOCK_METHOD1(useProgram, void(WebGLId program)); |
2773 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); | 2888 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); |
2774 }; | 2889 }; |
2775 | 2890 |
2776 TEST_F(CCLayerTreeHostImplTest, hasTransparentBackground) | 2891 TEST_P(CCLayerTreeHostImplTest, hasTransparentBackground) |
2777 { | 2892 { |
2778 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a
doptPtr(new MockDrawQuadsToFillScreenContext)); | 2893 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a
doptPtr(new MockDrawQuadsToFillScreenContext)); |
2779 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(context->context3D()); | 2894 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(context->context3D()); |
2780 | 2895 |
2781 // Run test case | 2896 // Run test case |
2782 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context.
release(), CCLayerImpl::create(1)); | 2897 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context.
release(), CCLayerImpl::create(1)); |
2783 myHostImpl->setBackgroundColor(SK_ColorWHITE); | 2898 myHostImpl->setBackgroundColor(SK_ColorWHITE); |
2784 | 2899 |
2785 // Verify one quad is drawn when transparent background set is not set. | 2900 // Verify one quad is drawn when transparent background set is not set. |
2786 myHostImpl->setHasTransparentBackground(false); | 2901 myHostImpl->setHasTransparentBackground(false); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2845 | 2960 |
2846 // Child of the surface layer will produce some quads | 2961 // Child of the surface layer will produce some quads |
2847 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(5, 5, rootSize.width() - 25, r
ootSize.height() - 25), &childPtr); | 2962 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(5, 5, rootSize.width() - 25, r
ootSize.height() - 25), &childPtr); |
2848 } | 2963 } |
2849 | 2964 |
2850 class CCRendererGLWithReleaseTextures : public CCRendererGL { | 2965 class CCRendererGLWithReleaseTextures : public CCRendererGL { |
2851 public: | 2966 public: |
2852 using CCRendererGL::releaseRenderPassTextures; | 2967 using CCRendererGL::releaseRenderPassTextures; |
2853 }; | 2968 }; |
2854 | 2969 |
2855 TEST_F(CCLayerTreeHostImplTest, textureCachingWithClipping) | 2970 TEST_P(CCLayerTreeHostImplTest, textureCachingWithClipping) |
2856 { | 2971 { |
2857 CCSettings::setPartialSwapEnabled(true); | 2972 CCSettings::setPartialSwapEnabled(true); |
2858 | 2973 |
2859 CCLayerTreeSettings settings; | 2974 CCLayerTreeSettings settings; |
2860 settings.minimumOcclusionTrackingSize = IntSize(); | 2975 settings.minimumOcclusionTrackingSize = IntSize(); |
2861 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); | 2976 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); |
2862 | 2977 |
2863 CCLayerImpl* rootPtr; | 2978 CCLayerImpl* rootPtr; |
2864 CCLayerImpl* surfaceLayerPtr; | 2979 CCLayerImpl* surfaceLayerPtr; |
2865 | 2980 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2942 // Must receive two render passes, each with one quad | 3057 // Must receive two render passes, each with one quad |
2943 ASSERT_EQ(2U, frame.renderPasses.size()); | 3058 ASSERT_EQ(2U, frame.renderPasses.size()); |
2944 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3059 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
2945 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 3060 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
2946 | 3061 |
2947 myHostImpl->drawLayers(frame); | 3062 myHostImpl->drawLayers(frame); |
2948 myHostImpl->didDrawAllLayers(frame); | 3063 myHostImpl->didDrawAllLayers(frame); |
2949 } | 3064 } |
2950 } | 3065 } |
2951 | 3066 |
2952 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusion) | 3067 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusion) |
2953 { | 3068 { |
2954 CCSettings::setPartialSwapEnabled(false); | 3069 CCSettings::setPartialSwapEnabled(false); |
2955 | 3070 |
2956 CCLayerTreeSettings settings; | 3071 CCLayerTreeSettings settings; |
2957 settings.minimumOcclusionTrackingSize = IntSize(); | 3072 settings.minimumOcclusionTrackingSize = IntSize(); |
2958 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); | 3073 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); |
2959 | 3074 |
2960 // Layers are structure as follows: | 3075 // Layers are structure as follows: |
2961 // | 3076 // |
2962 // R +-- S1 +- L10 (owning) | 3077 // R +-- S1 +- L10 (owning) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3058 ASSERT_EQ(1U, frame.renderPasses.size()); | 3173 ASSERT_EQ(1U, frame.renderPasses.size()); |
3059 | 3174 |
3060 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3175 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
3061 | 3176 |
3062 myHostImpl->drawLayers(frame); | 3177 myHostImpl->drawLayers(frame); |
3063 myHostImpl->didDrawAllLayers(frame); | 3178 myHostImpl->didDrawAllLayers(frame); |
3064 } | 3179 } |
3065 | 3180 |
3066 } | 3181 } |
3067 | 3182 |
3068 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) | 3183 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) |
3069 { | 3184 { |
3070 CCSettings::setPartialSwapEnabled(false); | 3185 CCSettings::setPartialSwapEnabled(false); |
3071 | 3186 |
3072 CCLayerTreeSettings settings; | 3187 CCLayerTreeSettings settings; |
3073 settings.minimumOcclusionTrackingSize = IntSize(); | 3188 settings.minimumOcclusionTrackingSize = IntSize(); |
3074 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); | 3189 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); |
3075 | 3190 |
3076 // Layers are structure as follows: | 3191 // Layers are structure as follows: |
3077 // | 3192 // |
3078 // R +-- S1 +- L10 (owning, non drawing) | 3193 // R +-- S1 +- L10 (owning, non drawing) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3174 // Must receive 1 render pass - for the root. | 3289 // Must receive 1 render pass - for the root. |
3175 ASSERT_EQ(1U, frame.renderPasses.size()); | 3290 ASSERT_EQ(1U, frame.renderPasses.size()); |
3176 | 3291 |
3177 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3292 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
3178 | 3293 |
3179 myHostImpl->drawLayers(frame); | 3294 myHostImpl->drawLayers(frame); |
3180 myHostImpl->didDrawAllLayers(frame); | 3295 myHostImpl->didDrawAllLayers(frame); |
3181 } | 3296 } |
3182 } | 3297 } |
3183 | 3298 |
3184 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) | 3299 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) |
3185 { | 3300 { |
3186 CCSettings::setPartialSwapEnabled(false); | 3301 CCSettings::setPartialSwapEnabled(false); |
3187 | 3302 |
3188 CCLayerTreeSettings settings; | 3303 CCLayerTreeSettings settings; |
3189 settings.minimumOcclusionTrackingSize = IntSize(); | 3304 settings.minimumOcclusionTrackingSize = IntSize(); |
3190 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); | 3305 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); |
3191 | 3306 |
3192 // Layers are structured as follows: | 3307 // Layers are structured as follows: |
3193 // | 3308 // |
3194 // R +-- S1 +- L10 (owning, drawing) | 3309 // R +-- S1 +- L10 (owning, drawing) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3263 ASSERT_EQ(2U, frame.renderPasses.size()); | 3378 ASSERT_EQ(2U, frame.renderPasses.size()); |
3264 | 3379 |
3265 EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); | 3380 EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); |
3266 EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); | 3381 EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); |
3267 | 3382 |
3268 myHostImpl->drawLayers(frame); | 3383 myHostImpl->drawLayers(frame); |
3269 myHostImpl->didDrawAllLayers(frame); | 3384 myHostImpl->didDrawAllLayers(frame); |
3270 } | 3385 } |
3271 } | 3386 } |
3272 | 3387 |
3273 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) | 3388 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) |
3274 { | 3389 { |
3275 CCSettings::setPartialSwapEnabled(false); | 3390 CCSettings::setPartialSwapEnabled(false); |
3276 | 3391 |
3277 CCLayerTreeSettings settings; | 3392 CCLayerTreeSettings settings; |
3278 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); | 3393 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); |
3279 | 3394 |
3280 // Layers are structured as follows: | 3395 // Layers are structured as follows: |
3281 // | 3396 // |
3282 // R +-- S1 +- L10 (rotated, drawing) | 3397 // R +-- S1 +- L10 (rotated, drawing) |
3283 // +- L11 (occupies half surface) | 3398 // +- L11 (occupies half surface) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3337 // One render pass must be gone due to cached texture. | 3452 // One render pass must be gone due to cached texture. |
3338 ASSERT_EQ(1U, frame.renderPasses.size()); | 3453 ASSERT_EQ(1U, frame.renderPasses.size()); |
3339 | 3454 |
3340 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 3455 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
3341 | 3456 |
3342 myHostImpl->drawLayers(frame); | 3457 myHostImpl->drawLayers(frame); |
3343 myHostImpl->didDrawAllLayers(frame); | 3458 myHostImpl->didDrawAllLayers(frame); |
3344 } | 3459 } |
3345 } | 3460 } |
3346 | 3461 |
3347 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) | 3462 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) |
3348 { | 3463 { |
3349 CCSettings::setPartialSwapEnabled(true); | 3464 CCSettings::setPartialSwapEnabled(true); |
3350 | 3465 |
3351 CCLayerTreeSettings settings; | 3466 CCLayerTreeSettings settings; |
3352 settings.minimumOcclusionTrackingSize = IntSize(); | 3467 settings.minimumOcclusionTrackingSize = IntSize(); |
3353 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); | 3468 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); |
3354 | 3469 |
3355 // Layers are structure as follows: | 3470 // Layers are structure as follows: |
3356 // | 3471 // |
3357 // R +-- S1 +- L10 (owning) | 3472 // R +-- S1 +- L10 (owning) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3450 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3565 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3451 | 3566 |
3452 // Root render pass only. | 3567 // Root render pass only. |
3453 ASSERT_EQ(1U, frame.renderPasses.size()); | 3568 ASSERT_EQ(1U, frame.renderPasses.size()); |
3454 | 3569 |
3455 myHostImpl->drawLayers(frame); | 3570 myHostImpl->drawLayers(frame); |
3456 myHostImpl->didDrawAllLayers(frame); | 3571 myHostImpl->didDrawAllLayers(frame); |
3457 } | 3572 } |
3458 } | 3573 } |
3459 | 3574 |
3460 TEST_F(CCLayerTreeHostImplTest, textureCachingWithScissor) | 3575 TEST_P(CCLayerTreeHostImplTest, textureCachingWithScissor) |
3461 { | 3576 { |
3462 CCSettings::setPartialSwapEnabled(false); | 3577 CCSettings::setPartialSwapEnabled(false); |
3463 | 3578 |
3464 CCLayerTreeSettings settings; | 3579 CCLayerTreeSettings settings; |
3465 settings.minimumOcclusionTrackingSize = IntSize(); | 3580 settings.minimumOcclusionTrackingSize = IntSize(); |
3466 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); | 3581 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); |
3467 | 3582 |
3468 /* | 3583 /* |
3469 Layers are created as follows: | 3584 Layers are created as follows: |
3470 | 3585 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3557 CCLayerTreeHostImpl::FrameData frame; | 3672 CCLayerTreeHostImpl::FrameData frame; |
3558 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3673 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3559 myHostImpl->drawLayers(frame); | 3674 myHostImpl->drawLayers(frame); |
3560 myHostImpl->didDrawAllLayers(frame); | 3675 myHostImpl->didDrawAllLayers(frame); |
3561 } | 3676 } |
3562 | 3677 |
3563 // We should have a cached texture for surface 2 again even though it was da
maged. | 3678 // We should have a cached texture for surface 2 again even though it was da
maged. |
3564 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); | 3679 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); |
3565 } | 3680 } |
3566 | 3681 |
3567 TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching) | 3682 TEST_P(CCLayerTreeHostImplTest, surfaceTextureCaching) |
3568 { | 3683 { |
3569 CCSettings::setPartialSwapEnabled(true); | 3684 CCSettings::setPartialSwapEnabled(true); |
3570 | 3685 |
3571 CCLayerTreeSettings settings; | 3686 CCLayerTreeSettings settings; |
3572 settings.minimumOcclusionTrackingSize = IntSize(); | 3687 settings.minimumOcclusionTrackingSize = IntSize(); |
3573 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); | 3688 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); |
3574 | 3689 |
3575 CCLayerImpl* rootPtr; | 3690 CCLayerImpl* rootPtr; |
3576 CCLayerImpl* intermediateLayerPtr; | 3691 CCLayerImpl* intermediateLayerPtr; |
3577 CCLayerImpl* surfaceLayerPtr; | 3692 CCLayerImpl* surfaceLayerPtr; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3718 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->
material()); | 3833 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->
material()); |
3719 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.re
nderPasses[0]->quadList()[0]); | 3834 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.re
nderPasses[0]->quadList()[0]); |
3720 CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId
()); | 3835 CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId
()); |
3721 EXPECT_TRUE(targetPass->damageRect().isEmpty()); | 3836 EXPECT_TRUE(targetPass->damageRect().isEmpty()); |
3722 | 3837 |
3723 myHostImpl->drawLayers(frame); | 3838 myHostImpl->drawLayers(frame); |
3724 myHostImpl->didDrawAllLayers(frame); | 3839 myHostImpl->didDrawAllLayers(frame); |
3725 } | 3840 } |
3726 } | 3841 } |
3727 | 3842 |
3728 TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) | 3843 TEST_P(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) |
3729 { | 3844 { |
3730 CCSettings::setPartialSwapEnabled(false); | 3845 CCSettings::setPartialSwapEnabled(false); |
3731 | 3846 |
3732 CCLayerTreeSettings settings; | 3847 CCLayerTreeSettings settings; |
3733 settings.minimumOcclusionTrackingSize = IntSize(); | 3848 settings.minimumOcclusionTrackingSize = IntSize(); |
3734 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); | 3849 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting
s, this); |
3735 | 3850 |
3736 CCLayerImpl* rootPtr; | 3851 CCLayerImpl* rootPtr; |
3737 CCLayerImpl* intermediateLayerPtr; | 3852 CCLayerImpl* intermediateLayerPtr; |
3738 CCLayerImpl* surfaceLayerPtr; | 3853 CCLayerImpl* surfaceLayerPtr; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3881 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->
material()); | 3996 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]->
material()); |
3882 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.re
nderPasses[0]->quadList()[0]); | 3997 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.re
nderPasses[0]->quadList()[0]); |
3883 CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId
()); | 3998 CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId
()); |
3884 EXPECT_TRUE(targetPass->damageRect().isEmpty()); | 3999 EXPECT_TRUE(targetPass->damageRect().isEmpty()); |
3885 | 4000 |
3886 myHostImpl->drawLayers(frame); | 4001 myHostImpl->drawLayers(frame); |
3887 myHostImpl->didDrawAllLayers(frame); | 4002 myHostImpl->didDrawAllLayers(frame); |
3888 } | 4003 } |
3889 } | 4004 } |
3890 | 4005 |
3891 TEST_F(CCLayerTreeHostImplTest, releaseContentsTextureShouldTriggerCommit) | 4006 TEST_P(CCLayerTreeHostImplTest, releaseContentsTextureShouldTriggerCommit) |
3892 { | 4007 { |
3893 m_hostImpl->releaseContentsTextures(); | 4008 m_hostImpl->releaseContentsTextures(); |
3894 EXPECT_TRUE(m_didRequestCommit); | 4009 EXPECT_TRUE(m_didRequestCommit); |
3895 } | 4010 } |
3896 | 4011 |
3897 struct RenderPassRemovalTestData : public CCLayerTreeHostImpl::FrameData { | 4012 struct RenderPassRemovalTestData : public CCLayerTreeHostImpl::FrameData { |
3898 ScopedPtrHashMap<CCRenderPass::Id, CCRenderPass> renderPassCache; | 4013 ScopedPtrHashMap<CCRenderPass::Id, CCRenderPass> renderPassCache; |
3899 scoped_ptr<CCSharedQuadState> sharedQuadState; | 4014 scoped_ptr<CCSharedQuadState> sharedQuadState; |
3900 }; | 4015 }; |
3901 | 4016 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4196 } | 4311 } |
4197 }; | 4312 }; |
4198 | 4313 |
4199 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
ta& testData) | 4314 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
ta& testData) |
4200 { | 4315 { |
4201 char actualResult[1024]; | 4316 char actualResult[1024]; |
4202 dumpRenderPassTestData(testData, actualResult); | 4317 dumpRenderPassTestData(testData, actualResult); |
4203 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; | 4318 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; |
4204 } | 4319 } |
4205 | 4320 |
4206 TEST_F(CCLayerTreeHostImplTest, testRemoveRenderPasses) | 4321 TEST_P(CCLayerTreeHostImplTest, testRemoveRenderPasses) |
4207 { | 4322 { |
4208 OwnPtr<CCGraphicsContext> context(createContext()); | 4323 OwnPtr<CCGraphicsContext> context(createContext()); |
4209 ASSERT_TRUE(context->context3D()); | 4324 ASSERT_TRUE(context->context3D()); |
4210 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte
xt.get())); | 4325 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte
xt.get())); |
4211 | 4326 |
4212 OwnPtr<CCTestRenderer> renderer(CCTestRenderer::create(resourceProvider.get(
))); | 4327 OwnPtr<CCTestRenderer> renderer(CCTestRenderer::create(resourceProvider.get(
))); |
4213 | 4328 |
4214 int testCaseIndex = 0; | 4329 int testCaseIndex = 0; |
4215 while (removeRenderPassesCases[testCaseIndex].name) { | 4330 while (removeRenderPassesCases[testCaseIndex].name) { |
4216 RenderPassRemovalTestData testData; | 4331 RenderPassRemovalTestData testData; |
4217 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); | 4332 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); |
4218 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP
assesWithCachedTextures(*renderer), testData); | 4333 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP
assesWithCachedTextures(*renderer), testData); |
4219 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4334 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
4220 testCaseIndex++; | 4335 testCaseIndex++; |
4221 } | 4336 } |
4222 } | 4337 } |
4223 | 4338 |
| 4339 INSTANTIATE_TEST_CASE_P(CCLayerTreeHostImplTests, |
| 4340 CCLayerTreeHostImplTest, |
| 4341 ::testing::Values(false, true)); |
| 4342 |
4224 } // namespace | 4343 } // namespace |
OLD | NEW |