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 class CCLayerTreeHostImplTest : public testing::TestWithParam<bool>, |
54 /* public ::testi ng::WithParamInterface<bool>,*/ | |
jamesr
2012/10/03 19:48:57
hm, what's this? leftovers?
Jeff Timanus
2012/10/03 20:56:04
Yes. Old cruft. Removed.
| |
55 public CCLayerTreeHostImplClient { | |
54 public: | 56 public: |
55 CCLayerTreeHostImplTest() | 57 CCLayerTreeHostImplTest() |
56 : m_onCanDrawStateChangedCalled(false) | 58 : m_onCanDrawStateChangedCalled(false) |
57 , m_didRequestCommit(false) | 59 , m_didRequestCommit(false) |
58 , m_didRequestRedraw(false) | 60 , m_didRequestRedraw(false) |
59 { | 61 { |
62 } | |
63 | |
64 virtual void SetUp() | |
65 { | |
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()) | |
jamesr
2012/10/03 19:48:57
not sure I grok this with line 474 - it looks like
Jeff Timanus
2012/10/03 20:56:04
This is a good catch. Previous patches (before I
| |
472 return; | |
473 | |
474 CCSettings::setPageScalePinchZoomEnabled(true); | |
457 setupScrollAndContentsLayers(IntSize(100, 100)); | 475 setupScrollAndContentsLayers(IntSize(100, 100)); |
458 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 476 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
459 initializeRendererAndDrawFrame(); | 477 initializeRendererAndDrawFrame(); |
460 | 478 |
461 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 479 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
462 ASSERT(scrollLayer); | 480 ASSERT(scrollLayer); |
463 | 481 |
464 const float minPageScale = 0.5, maxPageScale = 4; | 482 const float minPageScale = 1, maxPageScale = 4; |
483 const WebTransformationMatrix identityScaleTransform; | |
484 | |
485 // The impl-based pinch zoome should not adjust the max scroll position. | |
486 { | |
487 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | |
488 scrollLayer->setImplTransform(identityScaleTransform); | |
489 scrollLayer->setScrollDelta(IntSize()); | |
490 | |
491 float pageScaleDelta = 2; | |
492 m_hostImpl->pinchGestureBegin(); | |
493 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); | |
494 m_hostImpl->pinchGestureEnd(); | |
495 EXPECT_TRUE(m_didRequestRedraw); | |
496 EXPECT_TRUE(m_didRequestCommit); | |
497 | |
498 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | |
499 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | |
500 | |
501 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(50, 50)) ; | |
502 } | |
503 | |
504 // Scrolling after a pinch gesture should always be in local space. The scr oll deltas do not | |
505 // have the page scale factor applied. | |
506 { | |
507 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | |
508 scrollLayer->setImplTransform(identityScaleTransform); | |
509 scrollLayer->setScrollDelta(IntSize()); | |
510 | |
511 float pageScaleDelta = 2; | |
512 m_hostImpl->pinchGestureBegin(); | |
513 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); | |
514 m_hostImpl->pinchGestureEnd(); | |
515 | |
516 IntSize scrollDelta(0, 10); | |
517 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); | |
518 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | |
519 m_hostImpl->scrollEnd(); | |
520 | |
521 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | |
522 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); | |
523 } | |
524 } | |
525 | |
526 TEST_P(CCLayerTreeHostImplTest, pinchGesture) | |
527 { | |
528 setupScrollAndContentsLayers(IntSize(100, 100)); | |
529 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | |
530 initializeRendererAndDrawFrame(); | |
531 | |
532 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | |
533 ASSERT(scrollLayer); | |
534 | |
535 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5 ; | |
536 const float maxPageScale = 4; | |
537 const WebTransformationMatrix identityScaleTransform; | |
465 | 538 |
466 // Basic pinch zoom in gesture | 539 // Basic pinch zoom in gesture |
467 { | 540 { |
468 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 541 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
469 scrollLayer->setPageScaleDelta(1); | 542 scrollLayer->setImplTransform(identityScaleTransform); |
470 scrollLayer->setScrollDelta(IntSize()); | 543 scrollLayer->setScrollDelta(IntSize()); |
471 | 544 |
472 float pageScaleDelta = 2; | 545 float pageScaleDelta = 2; |
473 m_hostImpl->pinchGestureBegin(); | 546 m_hostImpl->pinchGestureBegin(); |
474 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); | 547 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); |
475 m_hostImpl->pinchGestureEnd(); | 548 m_hostImpl->pinchGestureEnd(); |
476 EXPECT_TRUE(m_didRequestRedraw); | 549 EXPECT_TRUE(m_didRequestRedraw); |
477 EXPECT_TRUE(m_didRequestCommit); | 550 EXPECT_TRUE(m_didRequestCommit); |
478 | 551 |
479 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 552 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
480 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 553 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
481 } | 554 } |
482 | 555 |
483 // Zoom-in clamping | 556 // Zoom-in clamping |
484 { | 557 { |
485 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 558 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
486 scrollLayer->setPageScaleDelta(1); | 559 scrollLayer->setImplTransform(identityScaleTransform); |
487 scrollLayer->setScrollDelta(IntSize()); | 560 scrollLayer->setScrollDelta(IntSize()); |
488 float pageScaleDelta = 10; | 561 float pageScaleDelta = 10; |
489 | 562 |
490 m_hostImpl->pinchGestureBegin(); | 563 m_hostImpl->pinchGestureBegin(); |
491 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); | 564 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); |
492 m_hostImpl->pinchGestureEnd(); | 565 m_hostImpl->pinchGestureEnd(); |
493 | 566 |
494 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 567 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
495 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); | 568 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); |
496 } | 569 } |
497 | 570 |
498 // Zoom-out clamping | 571 // Zoom-out clamping |
499 { | 572 { |
500 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 573 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
501 scrollLayer->setPageScaleDelta(1); | 574 scrollLayer->setImplTransform(identityScaleTransform); |
502 scrollLayer->setScrollDelta(IntSize()); | 575 scrollLayer->setScrollDelta(IntSize()); |
503 scrollLayer->setScrollPosition(IntPoint(50, 50)); | 576 scrollLayer->setScrollPosition(IntPoint(50, 50)); |
504 | 577 |
505 float pageScaleDelta = 0.1f; | 578 float pageScaleDelta = 0.1f; |
506 m_hostImpl->pinchGestureBegin(); | 579 m_hostImpl->pinchGestureBegin(); |
507 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); | 580 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); |
508 m_hostImpl->pinchGestureEnd(); | 581 m_hostImpl->pinchGestureEnd(); |
509 | 582 |
510 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 583 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
511 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 584 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
512 | 585 |
513 // Pushed to (0,0) via clamping against contents layer size. | 586 if (!CCSettings::pageScalePinchZoomEnabled()) { |
514 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); | 587 // Pushed to (0,0) via clamping against contents layer size. |
588 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); | |
589 } else { | |
590 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); | |
591 } | |
515 } | 592 } |
516 | 593 |
517 // Two-finger panning | 594 // Two-finger panning |
518 { | 595 { |
519 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 596 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
520 scrollLayer->setPageScaleDelta(1); | 597 scrollLayer->setImplTransform(identityScaleTransform); |
521 scrollLayer->setScrollDelta(IntSize()); | 598 scrollLayer->setScrollDelta(IntSize()); |
522 scrollLayer->setScrollPosition(IntPoint(20, 20)); | 599 scrollLayer->setScrollPosition(IntPoint(20, 20)); |
523 | 600 |
524 float pageScaleDelta = 1; | 601 float pageScaleDelta = 1; |
525 m_hostImpl->pinchGestureBegin(); | 602 m_hostImpl->pinchGestureBegin(); |
526 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10)); | 603 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10)); |
527 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20)); | 604 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20)); |
528 m_hostImpl->pinchGestureEnd(); | 605 m_hostImpl->pinchGestureEnd(); |
529 | 606 |
530 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 607 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
531 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 608 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
532 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); | 609 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); |
533 } | 610 } |
534 } | 611 } |
535 | 612 |
536 TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation) | 613 TEST_P(CCLayerTreeHostImplTest, pageScaleAnimation) |
537 { | 614 { |
538 setupScrollAndContentsLayers(IntSize(100, 100)); | 615 setupScrollAndContentsLayers(IntSize(100, 100)); |
539 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 616 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
540 initializeRendererAndDrawFrame(); | 617 initializeRendererAndDrawFrame(); |
541 | 618 |
542 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 619 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
543 ASSERT(scrollLayer); | 620 ASSERT(scrollLayer); |
544 | 621 |
545 const float minPageScale = 0.5, maxPageScale = 4; | 622 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5 ; |
623 const float maxPageScale = 4; | |
546 const double startTime = 1; | 624 const double startTime = 1; |
547 const double duration = 0.1; | 625 const double duration = 0.1; |
548 const double halfwayThroughAnimation = startTime + duration / 2; | 626 const double halfwayThroughAnimation = startTime + duration / 2; |
549 const double endTime = startTime + duration; | 627 const double endTime = startTime + duration; |
628 const WebTransformationMatrix identityScaleTransform; | |
550 | 629 |
551 // Non-anchor zoom-in | 630 // Non-anchor zoom-in |
552 { | 631 { |
553 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 632 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
554 scrollLayer->setPageScaleDelta(1); | 633 scrollLayer->setImplTransform(identityScaleTransform); |
555 scrollLayer->setScrollPosition(IntPoint(50, 50)); | 634 scrollLayer->setScrollPosition(IntPoint(50, 50)); |
556 | 635 |
557 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration); | 636 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration); |
558 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); | 637 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); |
559 EXPECT_TRUE(m_didRequestRedraw); | 638 EXPECT_TRUE(m_didRequestRedraw); |
560 m_hostImpl->animate(endTime, endTime); | 639 m_hostImpl->animate(endTime, endTime); |
561 EXPECT_TRUE(m_didRequestCommit); | 640 EXPECT_TRUE(m_didRequestCommit); |
562 | 641 |
563 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 642 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
564 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); | 643 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); |
565 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); | 644 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); |
566 } | 645 } |
567 | 646 |
568 // Anchor zoom-out | 647 // Anchor zoom-out |
569 { | 648 { |
570 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 649 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
571 scrollLayer->setPageScaleDelta(1); | 650 scrollLayer->setImplTransform(identityScaleTransform); |
572 scrollLayer->setScrollPosition(IntPoint(50, 50)); | 651 scrollLayer->setScrollPosition(IntPoint(50, 50)); |
573 | 652 |
574 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration); | 653 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration); |
575 m_hostImpl->animate(endTime, endTime); | 654 m_hostImpl->animate(endTime, endTime); |
576 EXPECT_TRUE(m_didRequestRedraw); | 655 EXPECT_TRUE(m_didRequestRedraw); |
577 EXPECT_TRUE(m_didRequestCommit); | 656 EXPECT_TRUE(m_didRequestCommit); |
578 | 657 |
579 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 658 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
580 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 659 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
581 // Pushed to (0,0) via clamping against contents layer size. | 660 // Pushed to (0,0) via clamping against contents layer size. |
582 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); | 661 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); |
583 } | 662 } |
584 } | 663 } |
585 | 664 |
586 TEST_F(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZoomin g) | 665 TEST_P(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZoomin g) |
587 { | 666 { |
588 setupScrollAndContentsLayers(IntSize(100, 100)); | 667 setupScrollAndContentsLayers(IntSize(100, 100)); |
589 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 668 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
590 initializeRendererAndDrawFrame(); | 669 initializeRendererAndDrawFrame(); |
591 | 670 |
592 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 671 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
593 ASSERT(scrollLayer); | 672 ASSERT(scrollLayer); |
594 | 673 |
595 const float minPageScale = 0.5, maxPageScale = 4; | 674 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5 ; |
675 const float maxPageScale = 4; | |
596 | 676 |
597 // Pinch zoom in. | 677 // Pinch zoom in. |
598 { | 678 { |
599 // Start a pinch in gesture at the bottom right corner of the viewport. | 679 // Start a pinch in gesture at the bottom right corner of the viewport. |
600 const float zoomInDelta = 2; | 680 const float zoomInDelta = 2; |
601 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 681 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
602 m_hostImpl->pinchGestureBegin(); | 682 m_hostImpl->pinchGestureBegin(); |
603 m_hostImpl->pinchGestureUpdate(zoomInDelta, IntPoint(50, 50)); | 683 m_hostImpl->pinchGestureUpdate(zoomInDelta, IntPoint(50, 50)); |
604 | 684 |
605 // Because we are pinch zooming in, we shouldn't get any scroll or page | 685 // Because we are pinch zooming in, we shouldn't get any scroll or page |
606 // scale deltas. | 686 // scale deltas. |
607 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 687 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
608 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); | 688 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); |
609 EXPECT_EQ(scrollInfo->scrolls.size(), 0u); | 689 EXPECT_EQ(scrollInfo->scrolls.size(), 0u); |
610 | 690 |
611 // Once the gesture ends, we get the final scroll and page scale values. | 691 // Once the gesture ends, we get the final scroll and page scale values. |
612 m_hostImpl->pinchGestureEnd(); | 692 m_hostImpl->pinchGestureEnd(); |
613 scrollInfo = m_hostImpl->processScrollDeltas(); | 693 scrollInfo = m_hostImpl->processScrollDeltas(); |
614 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta); | 694 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta); |
615 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | 695 if (!CCSettings::pageScalePinchZoomEnabled()) { |
696 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | |
697 } else { | |
698 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); | |
699 } | |
616 } | 700 } |
617 | 701 |
618 // Pinch zoom out. | 702 // Pinch zoom out. |
619 { | 703 { |
620 // Start a pinch out gesture at the bottom right corner of the viewport. | 704 // Start a pinch out gesture at the bottom right corner of the viewport. |
621 const float zoomOutDelta = 0.75; | 705 const float zoomOutDelta = 0.75; |
622 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 706 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
623 m_hostImpl->pinchGestureBegin(); | 707 m_hostImpl->pinchGestureBegin(); |
624 m_hostImpl->pinchGestureUpdate(zoomOutDelta, IntPoint(50, 50)); | 708 m_hostImpl->pinchGestureUpdate(zoomOutDelta, IntPoint(50, 50)); |
625 | 709 |
626 // Since we are pinch zooming out, we should get an update to zoom all | 710 // Since we are pinch zooming out, we should get an update to zoom all |
627 // the way out to the minimum page scale. | 711 // the way out to the minimum page scale. |
628 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 712 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
629 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 713 if (!CCSettings::pageScalePinchZoomEnabled()) { |
630 expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0)); | 714 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
715 expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0)); | |
716 } else { | |
717 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); | |
718 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); | |
719 } | |
631 | 720 |
632 // Once the gesture ends, we get the final scroll and page scale values. | 721 // Once the gesture ends, we get the final scroll and page scale values. |
633 m_hostImpl->pinchGestureEnd(); | 722 m_hostImpl->pinchGestureEnd(); |
634 scrollInfo = m_hostImpl->processScrollDeltas(); | 723 scrollInfo = m_hostImpl->processScrollDeltas(); |
635 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); | 724 if (CCSettings::pageScalePinchZoomEnabled()) { |
636 expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8)); | 725 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
726 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | |
727 } else { | |
728 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); | |
729 expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8)); | |
730 } | |
637 } | 731 } |
638 } | 732 } |
639 | 733 |
640 TEST_F(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPa geScale) | 734 TEST_P(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPa geScale) |
641 { | 735 { |
642 setupScrollAndContentsLayers(IntSize(100, 100)); | 736 setupScrollAndContentsLayers(IntSize(100, 100)); |
643 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 737 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
644 initializeRendererAndDrawFrame(); | 738 initializeRendererAndDrawFrame(); |
645 | 739 |
646 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 740 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
647 ASSERT(scrollLayer); | 741 ASSERT(scrollLayer); |
648 | 742 |
649 const float minPageScale = 0.5, maxPageScale = 4; | 743 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5 ; |
744 const float maxPageScale = 4; | |
650 const double startTime = 1; | 745 const double startTime = 1; |
651 const double duration = 0.1; | 746 const double duration = 0.1; |
652 const double halfwayThroughAnimation = startTime + duration / 2; | 747 const double halfwayThroughAnimation = startTime + duration / 2; |
653 const double endTime = startTime + duration; | 748 const double endTime = startTime + duration; |
654 | 749 |
655 // Start a page scale animation. | 750 // Start a page scale animation. |
656 const float pageScaleDelta = 2; | 751 const float pageScaleDelta = 2; |
657 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 752 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
658 m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta, startTime, duration); | 753 m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta, startTime, duration); |
659 | 754 |
660 // We should immediately get the final zoom and scroll values for the | 755 // We should immediately get the final zoom and scroll values for the |
661 // animation. | 756 // animation. |
662 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); | 757 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); |
663 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 758 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
664 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 759 |
665 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | 760 if (!CCSettings::pageScalePinchZoomEnabled()) { |
761 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | |
762 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | |
763 } else { | |
764 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); | |
765 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); | |
766 } | |
666 | 767 |
667 // Scrolling during the animation is ignored. | 768 // Scrolling during the animation is ignored. |
668 const IntSize scrollDelta(0, 10); | 769 const IntSize scrollDelta(0, 10); |
669 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Wh eel), CCInputHandlerClient::ScrollStarted); | 770 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Wh eel), CCInputHandlerClient::ScrollStarted); |
670 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 771 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
671 m_hostImpl->scrollEnd(); | 772 m_hostImpl->scrollEnd(); |
672 | 773 |
673 // The final page scale and scroll deltas should match what we got | 774 // The final page scale and scroll deltas should match what we got |
674 // earlier. | 775 // earlier. |
675 m_hostImpl->animate(endTime, endTime); | 776 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); | 818 OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::HasBorderTexels); |
718 tiler->setBounds(contentBounds()); | 819 tiler->setBounds(contentBounds()); |
719 setTilingData(*tiler.get()); | 820 setTilingData(*tiler.get()); |
720 } | 821 } |
721 | 822 |
722 private: | 823 private: |
723 bool m_didDrawCalled; | 824 bool m_didDrawCalled; |
724 bool m_willDrawCalled; | 825 bool m_willDrawCalled; |
725 }; | 826 }; |
726 | 827 |
727 TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) | 828 TEST_P(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) |
728 { | 829 { |
729 // The root layer is always drawn, so run this test on a child layer that | 830 // 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. | 831 // will be masked out by the root layer's bounds. |
731 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 832 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
732 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); | 833 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); |
733 root->setMasksToBounds(true); | 834 root->setMasksToBounds(true); |
734 | 835 |
735 root->addChild(DidDrawCheckLayer::create(2)); | 836 root->addChild(DidDrawCheckLayer::create(2)); |
736 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[ 0]); | 837 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[ 0]); |
737 // Ensure visibleContentRect for layer is empty | 838 // Ensure visibleContentRect for layer is empty |
(...skipping 24 matching lines...) Expand all Loading... | |
762 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 863 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
763 m_hostImpl->drawLayers(frame); | 864 m_hostImpl->drawLayers(frame); |
764 m_hostImpl->didDrawAllLayers(frame); | 865 m_hostImpl->didDrawAllLayers(frame); |
765 | 866 |
766 EXPECT_TRUE(layer->willDrawCalled()); | 867 EXPECT_TRUE(layer->willDrawCalled()); |
767 EXPECT_TRUE(layer->didDrawCalled()); | 868 EXPECT_TRUE(layer->didDrawCalled()); |
768 | 869 |
769 EXPECT_FALSE(layer->visibleContentRect().isEmpty()); | 870 EXPECT_FALSE(layer->visibleContentRect().isEmpty()); |
770 } | 871 } |
771 | 872 |
772 TEST_F(CCLayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) | 873 TEST_P(CCLayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) |
773 { | 874 { |
774 IntSize bigSize(1000, 1000); | 875 IntSize bigSize(1000, 1000); |
775 m_hostImpl->setViewportSize(bigSize, bigSize); | 876 m_hostImpl->setViewportSize(bigSize, bigSize); |
776 | 877 |
777 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 878 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
778 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); | 879 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); |
779 | 880 |
780 root->addChild(DidDrawCheckLayer::create(2)); | 881 root->addChild(DidDrawCheckLayer::create(2)); |
781 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi ldren()[0]); | 882 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi ldren()[0]); |
782 | 883 |
(...skipping 14 matching lines...) Expand all Loading... | |
797 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 898 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
798 m_hostImpl->drawLayers(frame); | 899 m_hostImpl->drawLayers(frame); |
799 m_hostImpl->didDrawAllLayers(frame); | 900 m_hostImpl->didDrawAllLayers(frame); |
800 | 901 |
801 EXPECT_FALSE(occludedLayer->willDrawCalled()); | 902 EXPECT_FALSE(occludedLayer->willDrawCalled()); |
802 EXPECT_FALSE(occludedLayer->didDrawCalled()); | 903 EXPECT_FALSE(occludedLayer->didDrawCalled()); |
803 EXPECT_TRUE(topLayer->willDrawCalled()); | 904 EXPECT_TRUE(topLayer->willDrawCalled()); |
804 EXPECT_TRUE(topLayer->didDrawCalled()); | 905 EXPECT_TRUE(topLayer->didDrawCalled()); |
805 } | 906 } |
806 | 907 |
807 TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) | 908 TEST_P(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) |
808 { | 909 { |
809 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 910 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
810 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); | 911 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); |
811 | 912 |
812 root->addChild(DidDrawCheckLayer::create(2)); | 913 root->addChild(DidDrawCheckLayer::create(2)); |
813 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children() [0]); | 914 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children() [0]); |
814 | 915 |
815 layer1->addChild(DidDrawCheckLayer::create(3)); | 916 layer1->addChild(DidDrawCheckLayer::create(3)); |
816 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children ()[0]); | 917 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children ()[0]); |
817 | 918 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 setSkipsDraw(skipsDraw); | 950 setSkipsDraw(skipsDraw); |
850 if (!tileMissing) { | 951 if (!tileMissing) { |
851 CCResourceProvider::ResourceId resource = resourceProvider->createRe source(CCRenderer::ContentPool, IntSize(), GraphicsContext3D::RGBA, CCResourcePr ovider::TextureUsageAny); | 952 CCResourceProvider::ResourceId resource = resourceProvider->createRe source(CCRenderer::ContentPool, IntSize(), GraphicsContext3D::RGBA, CCResourcePr ovider::TextureUsageAny); |
852 pushTileProperties(0, 0, resource, IntRect()); | 953 pushTileProperties(0, 0, resource, IntRect()); |
853 } | 954 } |
854 if (animating) | 955 if (animating) |
855 addAnimatedTransformToLayer(*this, 10, 3, 0); | 956 addAnimatedTransformToLayer(*this, 10, 3, 0); |
856 } | 957 } |
857 }; | 958 }; |
858 | 959 |
859 TEST_F(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) | 960 TEST_P(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) |
860 { | 961 { |
861 // When the texture is not missing, we draw as usual. | 962 // When the texture is not missing, we draw as usual. |
862 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 963 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
863 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); | 964 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); |
864 root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true, m _hostImpl->resourceProvider())); | 965 root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true, m _hostImpl->resourceProvider())); |
865 | 966 |
866 CCLayerTreeHostImpl::FrameData frame; | 967 CCLayerTreeHostImpl::FrameData frame; |
867 | 968 |
868 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 969 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
869 m_hostImpl->drawLayers(frame); | 970 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. | 991 // When the layer skips draw and we're animating, we still draw the frame. |
891 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 992 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
892 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 993 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
893 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_ hostImpl->resourceProvider())); | 994 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_ hostImpl->resourceProvider())); |
894 | 995 |
895 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 996 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
896 m_hostImpl->drawLayers(frame); | 997 m_hostImpl->drawLayers(frame); |
897 m_hostImpl->didDrawAllLayers(frame); | 998 m_hostImpl->didDrawAllLayers(frame); |
898 } | 999 } |
899 | 1000 |
900 TEST_F(CCLayerTreeHostImplTest, scrollRootIgnored) | 1001 TEST_P(CCLayerTreeHostImplTest, scrollRootIgnored) |
901 { | 1002 { |
902 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1003 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
903 root->setScrollable(false); | 1004 root->setScrollable(false); |
904 m_hostImpl->setRootLayer(root.release()); | 1005 m_hostImpl->setRootLayer(root.release()); |
905 initializeRendererAndDrawFrame(); | 1006 initializeRendererAndDrawFrame(); |
906 | 1007 |
907 // Scroll event is ignored because layer is not scrollable. | 1008 // Scroll event is ignored because layer is not scrollable. |
908 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); | 1009 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); |
909 EXPECT_FALSE(m_didRequestRedraw); | 1010 EXPECT_FALSE(m_didRequestRedraw); |
910 EXPECT_FALSE(m_didRequestCommit); | 1011 EXPECT_FALSE(m_didRequestCommit); |
911 } | 1012 } |
912 | 1013 |
913 TEST_F(CCLayerTreeHostImplTest, scrollNonCompositedRoot) | 1014 TEST_P(CCLayerTreeHostImplTest, scrollNonCompositedRoot) |
914 { | 1015 { |
915 // Test the configuration where a non-composited root layer is embedded in a | 1016 // Test the configuration where a non-composited root layer is embedded in a |
916 // scrollable outer layer. | 1017 // scrollable outer layer. |
917 IntSize surfaceSize(10, 10); | 1018 IntSize surfaceSize(10, 10); |
918 | 1019 |
919 OwnPtr<CCLayerImpl> contentLayer = CCLayerImpl::create(1); | 1020 OwnPtr<CCLayerImpl> contentLayer = CCLayerImpl::create(1); |
920 contentLayer->setUseLCDText(true); | 1021 contentLayer->setUseLCDText(true); |
921 contentLayer->setDrawsContent(true); | 1022 contentLayer->setDrawsContent(true); |
922 contentLayer->setPosition(FloatPoint(0, 0)); | 1023 contentLayer->setPosition(FloatPoint(0, 0)); |
923 contentLayer->setAnchorPoint(FloatPoint(0, 0)); | 1024 contentLayer->setAnchorPoint(FloatPoint(0, 0)); |
(...skipping 13 matching lines...) Expand all Loading... | |
937 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1038 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
938 initializeRendererAndDrawFrame(); | 1039 initializeRendererAndDrawFrame(); |
939 | 1040 |
940 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 1041 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
941 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1042 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
942 m_hostImpl->scrollEnd(); | 1043 m_hostImpl->scrollEnd(); |
943 EXPECT_TRUE(m_didRequestRedraw); | 1044 EXPECT_TRUE(m_didRequestRedraw); |
944 EXPECT_TRUE(m_didRequestCommit); | 1045 EXPECT_TRUE(m_didRequestCommit); |
945 } | 1046 } |
946 | 1047 |
947 TEST_F(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1048 TEST_P(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
948 { | 1049 { |
949 IntSize surfaceSize(10, 10); | 1050 IntSize surfaceSize(10, 10); |
950 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1051 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
951 root->setBounds(surfaceSize); | 1052 root->setBounds(surfaceSize); |
952 root->setContentBounds(surfaceSize); | 1053 root->setContentBounds(surfaceSize); |
953 root->addChild(createScrollableLayer(2, surfaceSize)); | 1054 root->addChild(createScrollableLayer(2, surfaceSize)); |
954 m_hostImpl->setRootLayer(root.release()); | 1055 m_hostImpl->setRootLayer(root.release()); |
955 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1056 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
956 initializeRendererAndDrawFrame(); | 1057 initializeRendererAndDrawFrame(); |
957 | 1058 |
958 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 1059 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
959 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1060 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
960 m_hostImpl->scrollEnd(); | 1061 m_hostImpl->scrollEnd(); |
961 EXPECT_TRUE(m_didRequestRedraw); | 1062 EXPECT_TRUE(m_didRequestRedraw); |
962 EXPECT_TRUE(m_didRequestCommit); | 1063 EXPECT_TRUE(m_didRequestCommit); |
963 } | 1064 } |
964 | 1065 |
965 TEST_F(CCLayerTreeHostImplTest, scrollMissesChild) | 1066 TEST_P(CCLayerTreeHostImplTest, scrollMissesChild) |
966 { | 1067 { |
967 IntSize surfaceSize(10, 10); | 1068 IntSize surfaceSize(10, 10); |
968 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1069 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
969 root->addChild(createScrollableLayer(2, surfaceSize)); | 1070 root->addChild(createScrollableLayer(2, surfaceSize)); |
970 m_hostImpl->setRootLayer(root.release()); | 1071 m_hostImpl->setRootLayer(root.release()); |
971 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1072 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
972 initializeRendererAndDrawFrame(); | 1073 initializeRendererAndDrawFrame(); |
973 | 1074 |
974 // Scroll event is ignored because the input coordinate is outside the layer boundaries. | 1075 // 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); | 1076 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), CCInputHandlerClient::Whe el), CCInputHandlerClient::ScrollIgnored); |
976 EXPECT_FALSE(m_didRequestRedraw); | 1077 EXPECT_FALSE(m_didRequestRedraw); |
977 EXPECT_FALSE(m_didRequestCommit); | 1078 EXPECT_FALSE(m_didRequestCommit); |
978 } | 1079 } |
979 | 1080 |
980 TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) | 1081 TEST_P(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) |
981 { | 1082 { |
982 IntSize surfaceSize(10, 10); | 1083 IntSize surfaceSize(10, 10); |
983 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1084 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
984 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 1085 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
985 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1086 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
986 | 1087 |
987 WebTransformationMatrix matrix; | 1088 WebTransformationMatrix matrix; |
988 matrix.rotate3d(180, 0, 0); | 1089 matrix.rotate3d(180, 0, 0); |
989 child->setTransform(matrix); | 1090 child->setTransform(matrix); |
990 child->setDoubleSided(false); | 1091 child->setDoubleSided(false); |
991 | 1092 |
992 root->addChild(child.release()); | 1093 root->addChild(child.release()); |
993 m_hostImpl->setRootLayer(root.release()); | 1094 m_hostImpl->setRootLayer(root.release()); |
994 initializeRendererAndDrawFrame(); | 1095 initializeRendererAndDrawFrame(); |
995 | 1096 |
996 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is | 1097 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is |
997 // nothing scrollable behind it. | 1098 // nothing scrollable behind it. |
998 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); | 1099 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); |
999 EXPECT_FALSE(m_didRequestRedraw); | 1100 EXPECT_FALSE(m_didRequestRedraw); |
1000 EXPECT_FALSE(m_didRequestCommit); | 1101 EXPECT_FALSE(m_didRequestCommit); |
1001 } | 1102 } |
1002 | 1103 |
1003 TEST_F(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) | 1104 TEST_P(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) |
1004 { | 1105 { |
1005 IntSize surfaceSize(10, 10); | 1106 IntSize surfaceSize(10, 10); |
1006 OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); | 1107 OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); |
1007 contentLayer->setShouldScrollOnMainThread(true); | 1108 contentLayer->setShouldScrollOnMainThread(true); |
1008 contentLayer->setScrollable(false); | 1109 contentLayer->setScrollable(false); |
1009 | 1110 |
1010 OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); | 1111 OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); |
1011 scrollLayer->addChild(contentLayer.release()); | 1112 scrollLayer->addChild(contentLayer.release()); |
1012 | 1113 |
1013 m_hostImpl->setRootLayer(scrollLayer.release()); | 1114 m_hostImpl->setRootLayer(scrollLayer.release()); |
1014 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1115 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1015 initializeRendererAndDrawFrame(); | 1116 initializeRendererAndDrawFrame(); |
1016 | 1117 |
1017 // Scrolling fails because the content layer is asking to be scrolled on the main thread. | 1118 // 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); | 1119 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollOnMainThread); |
1019 } | 1120 } |
1020 | 1121 |
1021 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1122 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
1022 { | 1123 { |
1023 IntSize surfaceSize(10, 10); | 1124 IntSize surfaceSize(10, 10); |
1024 float pageScale = 2; | 1125 float pageScale = 2; |
1025 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1126 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1026 m_hostImpl->setRootLayer(root.release()); | 1127 m_hostImpl->setRootLayer(root.release()); |
1027 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1128 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1028 initializeRendererAndDrawFrame(); | 1129 initializeRendererAndDrawFrame(); |
1029 | 1130 |
1030 IntSize scrollDelta(0, 10); | 1131 IntSize scrollDelta(0, 10); |
1031 IntSize expectedScrollDelta(scrollDelta); | 1132 IntSize expectedScrollDelta(scrollDelta); |
1032 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1133 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
1033 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 1134 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
1034 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1135 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1035 m_hostImpl->scrollEnd(); | 1136 m_hostImpl->scrollEnd(); |
1036 | 1137 |
1037 // Set new page scale from main thread. | 1138 // Set new page scale from main thread. |
1038 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); | 1139 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); |
1039 | 1140 |
1040 // The scale should apply to the scroll delta. | 1141 if (!CCSettings::pageScalePinchZoomEnabled()) { |
1041 expectedScrollDelta.scale(pageScale); | 1142 // The scale should apply to the scroll delta. |
1143 expectedScrollDelta.scale(pageScale); | |
1144 } | |
1042 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 1145 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
1043 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 1146 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
1044 | 1147 |
1045 // The scroll range should also have been updated. | 1148 // The scroll range should also have been updated. |
1046 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); | 1149 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); |
1047 | 1150 |
1048 // The page scale delta remains constant because the impl thread did not sca le. | 1151 // The page scale delta remains constant because the impl thread did not sca le. |
1049 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), 1); | 1152 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix( )); |
1050 } | 1153 } |
1051 | 1154 |
1052 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1155 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
1053 { | 1156 { |
1054 IntSize surfaceSize(10, 10); | 1157 IntSize surfaceSize(10, 10); |
1055 float pageScale = 2; | 1158 float pageScale = 2; |
1056 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1159 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1057 m_hostImpl->setRootLayer(root.release()); | 1160 m_hostImpl->setRootLayer(root.release()); |
1058 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1161 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1059 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1162 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
1060 initializeRendererAndDrawFrame(); | 1163 initializeRendererAndDrawFrame(); |
1061 | 1164 |
1062 IntSize scrollDelta(0, 10); | 1165 IntSize scrollDelta(0, 10); |
1063 IntSize expectedScrollDelta(scrollDelta); | 1166 IntSize expectedScrollDelta(scrollDelta); |
1064 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1167 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
1065 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 1168 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
1066 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1169 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1067 m_hostImpl->scrollEnd(); | 1170 m_hostImpl->scrollEnd(); |
1068 | 1171 |
1069 // Set new page scale on impl thread by pinching. | 1172 // Set new page scale on impl thread by pinching. |
1070 m_hostImpl->pinchGestureBegin(); | 1173 m_hostImpl->pinchGestureBegin(); |
1071 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint()); | 1174 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint()); |
1072 m_hostImpl->pinchGestureEnd(); | 1175 m_hostImpl->pinchGestureEnd(); |
1176 m_hostImpl->updateRootScrollLayerImplTransform(); | |
1073 | 1177 |
1074 // The scroll delta is not scaled because the main thread did not scale. | 1178 // The scroll delta is not scaled because the main thread did not scale. |
1075 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 1179 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
1076 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 1180 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
1077 | 1181 |
1078 // The scroll range should also have been updated. | 1182 // The scroll range should also have been updated. |
1079 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); | 1183 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); |
1080 | 1184 |
1081 // The page scale delta should match the new scale on the impl side. | 1185 // The page scale delta should match the new scale on the impl side. |
1082 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), pageScale); | 1186 WebTransformationMatrix expectedScale; |
1187 expectedScale.scale(pageScale); | |
1188 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); | |
1083 } | 1189 } |
1084 | 1190 |
1085 TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) | 1191 TEST_P(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) |
1086 { | 1192 { |
1087 IntSize surfaceSize(10, 10); | 1193 IntSize surfaceSize(10, 10); |
1088 float defaultPageScale = 1; | 1194 float defaultPageScale = 1; |
1195 WebTransformationMatrix defaultPageScaleMatrix; | |
1196 | |
1089 float newPageScale = 2; | 1197 float newPageScale = 2; |
1198 WebTransformationMatrix newPageScaleMatrix; | |
1199 newPageScaleMatrix.scale(newPageScale); | |
1090 | 1200 |
1091 // Create a normal scrollable root layer and another scrollable child layer. | 1201 // Create a normal scrollable root layer and another scrollable child layer. |
1092 setupScrollAndContentsLayers(surfaceSize); | 1202 setupScrollAndContentsLayers(surfaceSize); |
1093 CCLayerImpl* root = m_hostImpl->rootLayer(); | 1203 CCLayerImpl* root = m_hostImpl->rootLayer(); |
1094 CCLayerImpl* child = root->children()[0]; | 1204 CCLayerImpl* child = root->children()[0]; |
1095 | 1205 |
1096 OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize); | 1206 OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize); |
1097 child->addChild(scrollableChild.release()); | 1207 child->addChild(scrollableChild.release()); |
1098 CCLayerImpl* grandChild = child->children()[0]; | 1208 CCLayerImpl* grandChild = child->children()[0]; |
1099 | 1209 |
1100 // Set new page scale on impl thread by pinching. | 1210 // Set new page scale on impl thread by pinching. |
1101 m_hostImpl->pinchGestureBegin(); | 1211 m_hostImpl->pinchGestureBegin(); |
1102 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); | 1212 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); |
1103 m_hostImpl->pinchGestureEnd(); | 1213 m_hostImpl->pinchGestureEnd(); |
1214 m_hostImpl->updateRootScrollLayerImplTransform(); | |
1104 | 1215 |
1105 // The page scale delta should only be applied to the scrollable root layer. | 1216 // The page scale delta should only be applied to the scrollable root layer. |
1106 EXPECT_EQ(root->pageScaleDelta(), newPageScale); | 1217 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); |
1107 EXPECT_EQ(child->pageScaleDelta(), defaultPageScale); | 1218 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); |
1108 EXPECT_EQ(grandChild->pageScaleDelta(), defaultPageScale); | 1219 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); |
1109 | 1220 |
1110 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale | 1221 // 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. | 1222 // delta on the root layer is applied hierarchically. |
1112 CCLayerTreeHostImpl::FrameData frame; | 1223 CCLayerTreeHostImpl::FrameData frame; |
1113 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1224 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1114 m_hostImpl->drawLayers(frame); | 1225 m_hostImpl->drawLayers(frame); |
1115 m_hostImpl->didDrawAllLayers(frame); | 1226 m_hostImpl->didDrawAllLayers(frame); |
1116 | 1227 |
1117 EXPECT_EQ(root->drawTransform().m11(), newPageScale); | 1228 EXPECT_EQ(root->drawTransform().m11(), newPageScale); |
1118 EXPECT_EQ(root->drawTransform().m22(), newPageScale); | 1229 EXPECT_EQ(root->drawTransform().m22(), newPageScale); |
1119 EXPECT_EQ(child->drawTransform().m11(), newPageScale); | 1230 EXPECT_EQ(child->drawTransform().m11(), newPageScale); |
1120 EXPECT_EQ(child->drawTransform().m22(), newPageScale); | 1231 EXPECT_EQ(child->drawTransform().m22(), newPageScale); |
1121 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); | 1232 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); |
1122 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); | 1233 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); |
1123 } | 1234 } |
1124 | 1235 |
1125 TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) | 1236 TEST_P(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
1126 { | 1237 { |
1127 IntSize surfaceSize(10, 10); | 1238 IntSize surfaceSize(10, 10); |
1128 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1239 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
1129 root->setBounds(surfaceSize); | 1240 root->setBounds(surfaceSize); |
1130 root->setContentBounds(surfaceSize); | 1241 root->setContentBounds(surfaceSize); |
1131 // Also mark the root scrollable so it becomes the root scroll layer. | 1242 // Also mark the root scrollable so it becomes the root scroll layer. |
1132 root->setScrollable(true); | 1243 root->setScrollable(true); |
1133 int scrollLayerId = 2; | 1244 int scrollLayerId = 2; |
1134 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1245 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
1135 m_hostImpl->setRootLayer(root.release()); | 1246 m_hostImpl->setRootLayer(root.release()); |
1136 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1247 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1137 initializeRendererAndDrawFrame(); | 1248 initializeRendererAndDrawFrame(); |
1138 | 1249 |
1139 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1250 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1140 | 1251 |
1141 IntSize scrollDelta(0, 10); | 1252 IntSize scrollDelta(0, 10); |
1142 IntSize expectedScrollDelta(scrollDelta); | 1253 IntSize expectedScrollDelta(scrollDelta); |
1143 IntSize expectedMaxScroll(child->maxScrollPosition()); | 1254 IntSize expectedMaxScroll(child->maxScrollPosition()); |
1144 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 1255 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
1145 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1256 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1146 m_hostImpl->scrollEnd(); | 1257 m_hostImpl->scrollEnd(); |
1147 | 1258 |
1148 float pageScale = 2; | 1259 float pageScale = 2; |
1149 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); | 1260 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); |
1150 | 1261 |
1151 // The scale should apply to the scroll delta. | 1262 m_hostImpl->updateRootScrollLayerImplTransform(); |
1152 expectedScrollDelta.scale(pageScale); | 1263 |
1264 if (!CCSettings::pageScalePinchZoomEnabled()) { | |
1265 // The scale should apply to the scroll delta. | |
1266 expectedScrollDelta.scale(pageScale); | |
1267 } | |
1153 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 1268 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
1154 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); | 1269 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); |
1155 | 1270 |
1156 // The scroll range should not have changed. | 1271 // The scroll range should not have changed. |
1157 EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll); | 1272 EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll); |
1158 | 1273 |
1159 // The page scale delta remains constant because the impl thread did not sca le. | 1274 // The page scale delta remains constant because the impl thread did not sca le. |
1160 EXPECT_EQ(child->pageScaleDelta(), 1); | 1275 WebTransformationMatrix identityTransform; |
1276 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); | |
1161 } | 1277 } |
1162 | 1278 |
1163 TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit) | 1279 TEST_P(CCLayerTreeHostImplTest, scrollChildBeyondLimit) |
1164 { | 1280 { |
1165 // Scroll a child layer beyond its maximum scroll range and make sure the | 1281 // 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 | 1282 // parent layer is scrolled on the axis on which the child was unable to |
1167 // scroll. | 1283 // scroll. |
1168 IntSize surfaceSize(10, 10); | 1284 IntSize surfaceSize(10, 10); |
1169 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1285 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1170 | 1286 |
1171 OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize); | 1287 OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize); |
1172 grandChild->setScrollPosition(IntPoint(0, 5)); | 1288 grandChild->setScrollPosition(IntPoint(0, 5)); |
1173 | 1289 |
(...skipping 16 matching lines...) Expand all Loading... | |
1190 // The grand child should have scrolled up to its limit. | 1306 // The grand child should have scrolled up to its limit. |
1191 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1307 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1192 CCLayerImpl* grandChild = child->children()[0]; | 1308 CCLayerImpl* grandChild = child->children()[0]; |
1193 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); | 1309 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); |
1194 | 1310 |
1195 // The child should have only scrolled on the other axis. | 1311 // The child should have only scrolled on the other axis. |
1196 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); | 1312 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); |
1197 } | 1313 } |
1198 } | 1314 } |
1199 | 1315 |
1200 TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling) | 1316 TEST_P(CCLayerTreeHostImplTest, scrollEventBubbling) |
1201 { | 1317 { |
1202 // When we try to scroll a non-scrollable child layer, the scroll delta | 1318 // When we try to scroll a non-scrollable child layer, the scroll delta |
1203 // should be applied to one of its ancestors if possible. | 1319 // should be applied to one of its ancestors if possible. |
1204 IntSize surfaceSize(10, 10); | 1320 IntSize surfaceSize(10, 10); |
1205 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1321 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1206 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 1322 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
1207 | 1323 |
1208 child->setScrollable(false); | 1324 child->setScrollable(false); |
1209 root->addChild(child.release()); | 1325 root->addChild(child.release()); |
1210 | 1326 |
1211 m_hostImpl->setRootLayer(root.release()); | 1327 m_hostImpl->setRootLayer(root.release()); |
1212 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1328 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1213 initializeRendererAndDrawFrame(); | 1329 initializeRendererAndDrawFrame(); |
1214 { | 1330 { |
1215 IntSize scrollDelta(0, 4); | 1331 IntSize scrollDelta(0, 4); |
1216 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); | 1332 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); |
1217 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1333 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1218 m_hostImpl->scrollEnd(); | 1334 m_hostImpl->scrollEnd(); |
1219 | 1335 |
1220 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 1336 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
1221 | 1337 |
1222 // Only the root should have scrolled. | 1338 // Only the root should have scrolled. |
1223 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 1339 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
1224 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); | 1340 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); |
1225 } | 1341 } |
1226 } | 1342 } |
1227 | 1343 |
1228 TEST_F(CCLayerTreeHostImplTest, scrollBeforeRedraw) | 1344 TEST_P(CCLayerTreeHostImplTest, scrollBeforeRedraw) |
1229 { | 1345 { |
1230 IntSize surfaceSize(10, 10); | 1346 IntSize surfaceSize(10, 10); |
1231 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); | 1347 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); |
1232 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1348 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1233 | 1349 |
1234 // Draw one frame and then immediately rebuild the layer tree to mimic a tre e synchronization. | 1350 // Draw one frame and then immediately rebuild the layer tree to mimic a tre e synchronization. |
1235 initializeRendererAndDrawFrame(); | 1351 initializeRendererAndDrawFrame(); |
1236 m_hostImpl->detachLayerTree(); | 1352 m_hostImpl->detachLayerTree(); |
1237 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); | 1353 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); |
1238 | 1354 |
1239 // Scrolling should still work even though we did not draw yet. | 1355 // 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); | 1356 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
1241 } | 1357 } |
1242 | 1358 |
1243 TEST_F(CCLayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) | 1359 TEST_P(CCLayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) |
1244 { | 1360 { |
1245 setupScrollAndContentsLayers(IntSize(100, 100)); | 1361 setupScrollAndContentsLayers(IntSize(100, 100)); |
1246 | 1362 |
1247 // Rotate the root layer 90 degrees counter-clockwise about its center. | 1363 // Rotate the root layer 90 degrees counter-clockwise about its center. |
1248 WebTransformationMatrix rotateTransform; | 1364 WebTransformationMatrix rotateTransform; |
1249 rotateTransform.rotate(-90); | 1365 rotateTransform.rotate(-90); |
1250 m_hostImpl->rootLayer()->setTransform(rotateTransform); | 1366 m_hostImpl->rootLayer()->setTransform(rotateTransform); |
1251 | 1367 |
1252 IntSize surfaceSize(50, 50); | 1368 IntSize surfaceSize(50, 50); |
1253 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1369 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
(...skipping 14 matching lines...) Expand all Loading... | |
1268 IntSize wheelScrollDelta(0, 10); | 1384 IntSize wheelScrollDelta(0, 10); |
1269 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 1385 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
1270 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); | 1386 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); |
1271 m_hostImpl->scrollEnd(); | 1387 m_hostImpl->scrollEnd(); |
1272 | 1388 |
1273 // The layer should have scrolled down in its local coordinates. | 1389 // The layer should have scrolled down in its local coordinates. |
1274 scrollInfo = m_hostImpl->processScrollDeltas(); | 1390 scrollInfo = m_hostImpl->processScrollDeltas(); |
1275 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); | 1391 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); |
1276 } | 1392 } |
1277 | 1393 |
1278 TEST_F(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) | 1394 TEST_P(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) |
1279 { | 1395 { |
1280 setupScrollAndContentsLayers(IntSize(100, 100)); | 1396 setupScrollAndContentsLayers(IntSize(100, 100)); |
1281 int childLayerId = 3; | 1397 int childLayerId = 3; |
1282 float childLayerAngle = -20; | 1398 float childLayerAngle = -20; |
1283 | 1399 |
1284 // Create a child layer that is rotated to a non-axis-aligned angle. | 1400 // Create a child layer that is rotated to a non-axis-aligned angle. |
1285 OwnPtr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl-> rootLayer()->contentBounds()); | 1401 OwnPtr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl-> rootLayer()->contentBounds()); |
1286 WebTransformationMatrix rotateTransform; | 1402 WebTransformationMatrix rotateTransform; |
1287 rotateTransform.translate(-50, -50); | 1403 rotateTransform.translate(-50, -50); |
1288 rotateTransform.rotate(childLayerAngle); | 1404 rotateTransform.rotate(childLayerAngle); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1329 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 1445 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
1330 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1446 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
1331 | 1447 |
1332 // The root layer should have scrolled more, since the input scroll delt a was mostly | 1448 // 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. | 1449 // orthogonal to the child layer's vertical scroll axis. |
1334 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de g2rad(childLayerAngle)), 2), 0); | 1450 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de g2rad(childLayerAngle)), 2), 0); |
1335 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta); | 1451 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta); |
1336 } | 1452 } |
1337 } | 1453 } |
1338 | 1454 |
1339 TEST_F(CCLayerTreeHostImplTest, scrollScaledLayer) | 1455 TEST_P(CCLayerTreeHostImplTest, scrollScaledLayer) |
1340 { | 1456 { |
1341 setupScrollAndContentsLayers(IntSize(100, 100)); | 1457 setupScrollAndContentsLayers(IntSize(100, 100)); |
1342 | 1458 |
1343 // Scale the layer to twice its normal size. | 1459 // Scale the layer to twice its normal size. |
1344 int scale = 2; | 1460 int scale = 2; |
1345 WebTransformationMatrix scaleTransform; | 1461 WebTransformationMatrix scaleTransform; |
1346 scaleTransform.scale(scale); | 1462 scaleTransform.scale(scale); |
1347 m_hostImpl->rootLayer()->setTransform(scaleTransform); | 1463 m_hostImpl->rootLayer()->setTransform(scaleTransform); |
1348 | 1464 |
1349 IntSize surfaceSize(50, 50); | 1465 IntSize surfaceSize(50, 50); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1450 bool m_blend; | 1566 bool m_blend; |
1451 bool m_hasRenderSurface; | 1567 bool m_hasRenderSurface; |
1452 bool m_quadsAppended; | 1568 bool m_quadsAppended; |
1453 bool m_opaqueContents; | 1569 bool m_opaqueContents; |
1454 IntRect m_quadRect; | 1570 IntRect m_quadRect; |
1455 IntRect m_opaqueContentRect; | 1571 IntRect m_opaqueContentRect; |
1456 IntRect m_quadVisibleRect; | 1572 IntRect m_quadVisibleRect; |
1457 CCResourceProvider::ResourceId m_resourceId; | 1573 CCResourceProvider::ResourceId m_resourceId; |
1458 }; | 1574 }; |
1459 | 1575 |
1460 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 1576 TEST_P(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
1461 { | 1577 { |
1462 { | 1578 { |
1463 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1579 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); |
1464 root->setAnchorPoint(FloatPoint(0, 0)); | 1580 root->setAnchorPoint(FloatPoint(0, 0)); |
1465 root->setBounds(IntSize(10, 10)); | 1581 root->setBounds(IntSize(10, 10)); |
1466 root->setContentBounds(root->bounds()); | 1582 root->setContentBounds(root->bounds()); |
1467 root->setDrawsContent(false); | 1583 root->setDrawsContent(false); |
1468 m_hostImpl->setRootLayer(root.release()); | 1584 m_hostImpl->setRootLayer(root.release()); |
1469 } | 1585 } |
1470 CCLayerImpl* root = m_hostImpl->rootLayer(); | 1586 CCLayerImpl* root = m_hostImpl->rootLayer(); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1668 layer1->setOpaqueContents(false); | 1784 layer1->setOpaqueContents(false); |
1669 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); | 1785 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); |
1670 layer1->setExpectation(false, false); | 1786 layer1->setExpectation(false, false); |
1671 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1787 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1672 m_hostImpl->drawLayers(frame); | 1788 m_hostImpl->drawLayers(frame); |
1673 EXPECT_TRUE(layer1->quadsAppended()); | 1789 EXPECT_TRUE(layer1->quadsAppended()); |
1674 m_hostImpl->didDrawAllLayers(frame); | 1790 m_hostImpl->didDrawAllLayers(frame); |
1675 | 1791 |
1676 } | 1792 } |
1677 | 1793 |
1678 TEST_F(CCLayerTreeHostImplTest, viewportCovered) | 1794 TEST_P(CCLayerTreeHostImplTest, viewportCovered) |
1679 { | 1795 { |
1680 m_hostImpl->initializeRenderer(createContext()); | 1796 m_hostImpl->initializeRenderer(createContext()); |
1681 m_hostImpl->setBackgroundColor(SK_ColorGRAY); | 1797 m_hostImpl->setBackgroundColor(SK_ColorGRAY); |
1682 | 1798 |
1683 IntSize viewportSize(1000, 1000); | 1799 IntSize viewportSize(1000, 1000); |
1684 m_hostImpl->setViewportSize(viewportSize, viewportSize); | 1800 m_hostImpl->setViewportSize(viewportSize, viewportSize); |
1685 | 1801 |
1686 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1, m_hostImpl->resourc eProvider())); | 1802 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1, m_hostImpl->resourc eProvider())); |
1687 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl-> rootLayer()); | 1803 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl-> rootLayer()); |
1688 root->setExpectation(false, true); | 1804 root->setExpectation(false, true); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1777 }; | 1893 }; |
1778 | 1894 |
1779 class FakeDrawableCCLayerImpl: public CCLayerImpl { | 1895 class FakeDrawableCCLayerImpl: public CCLayerImpl { |
1780 public: | 1896 public: |
1781 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } | 1897 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } |
1782 }; | 1898 }; |
1783 | 1899 |
1784 // Only reshape when we know we are going to draw. Otherwise, the reshape | 1900 // Only reshape when we know we are going to draw. Otherwise, the reshape |
1785 // can leave the window at the wrong size if we never draw and the proper | 1901 // can leave the window at the wrong size if we never draw and the proper |
1786 // viewport size is never set. | 1902 // viewport size is never set. |
1787 TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 1903 TEST_P(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
1788 { | 1904 { |
1789 OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create (adoptPtr(new ReshapeTrackerContext)); | 1905 OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create (adoptPtr(new ReshapeTrackerContext)); |
1790 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( ccContext->context3D()); | 1906 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( ccContext->context3D()); |
1791 m_hostImpl->initializeRenderer(ccContext.release()); | 1907 m_hostImpl->initializeRenderer(ccContext.release()); |
1792 | 1908 |
1793 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 1909 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); |
1794 root->setAnchorPoint(FloatPoint(0, 0)); | 1910 root->setAnchorPoint(FloatPoint(0, 0)); |
1795 root->setBounds(IntSize(10, 10)); | 1911 root->setBounds(IntSize(10, 10)); |
1796 root->setDrawsContent(true); | 1912 root->setDrawsContent(true); |
1797 m_hostImpl->setRootLayer(adoptPtr(root)); | 1913 m_hostImpl->setRootLayer(adoptPtr(root)); |
(...skipping 22 matching lines...) Expand all Loading... | |
1820 } | 1936 } |
1821 | 1937 |
1822 IntRect partialSwapRect() const { return m_partialSwapRect; } | 1938 IntRect partialSwapRect() const { return m_partialSwapRect; } |
1823 | 1939 |
1824 private: | 1940 private: |
1825 IntRect m_partialSwapRect; | 1941 IntRect m_partialSwapRect; |
1826 }; | 1942 }; |
1827 | 1943 |
1828 // Make sure damage tracking propagates all the way to the graphics context, | 1944 // Make sure damage tracking propagates all the way to the graphics context, |
1829 // where it should request to swap only the subBuffer that is damaged. | 1945 // where it should request to swap only the subBuffer that is damaged. |
1830 TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect) | 1946 TEST_P(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect) |
1831 { | 1947 { |
1832 OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create (adoptPtr(new PartialSwapTrackerContext)); | 1948 OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create (adoptPtr(new PartialSwapTrackerContext)); |
1833 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(ccContext->context3D()); | 1949 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(ccContext->context3D()); |
1834 | 1950 |
1835 // This test creates its own CCLayerTreeHostImpl, so | 1951 // This test creates its own CCLayerTreeHostImpl, so |
1836 // that we can force partial swap enabled. | 1952 // that we can force partial swap enabled. |
1837 CCLayerTreeSettings settings; | 1953 CCLayerTreeSettings settings; |
1838 CCSettings::setPartialSwapEnabled(true); | 1954 CCSettings::setPartialSwapEnabled(true); |
1839 OwnPtr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::create( settings, this); | 1955 OwnPtr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::create( settings, this); |
1840 layerTreeHostImpl->initializeRenderer(ccContext.release()); | 1956 layerTreeHostImpl->initializeRenderer(ccContext.release()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1894 m_hostImpl->didDrawAllLayers(frame); | 2010 m_hostImpl->didDrawAllLayers(frame); |
1895 layerTreeHostImpl->swapBuffers(); | 2011 layerTreeHostImpl->swapBuffers(); |
1896 actualSwapRect = partialSwapTracker->partialSwapRect(); | 2012 actualSwapRect = partialSwapTracker->partialSwapRect(); |
1897 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); | 2013 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); |
1898 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 2014 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
1899 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 2015 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
1900 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 2016 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
1901 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 2017 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
1902 } | 2018 } |
1903 | 2019 |
1904 TEST_F(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) | 2020 TEST_P(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) |
1905 { | 2021 { |
1906 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 2022 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); |
1907 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2); | 2023 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2); |
1908 child->setAnchorPoint(FloatPoint(0, 0)); | 2024 child->setAnchorPoint(FloatPoint(0, 0)); |
1909 child->setBounds(IntSize(10, 10)); | 2025 child->setBounds(IntSize(10, 10)); |
1910 child->setContentBounds(IntSize(10, 10)); | 2026 child->setContentBounds(IntSize(10, 10)); |
1911 child->setDrawsContent(true); | 2027 child->setDrawsContent(true); |
1912 root->setAnchorPoint(FloatPoint(0, 0)); | 2028 root->setAnchorPoint(FloatPoint(0, 0)); |
1913 root->setBounds(IntSize(10, 10)); | 2029 root->setBounds(IntSize(10, 10)); |
1914 root->setContentBounds(IntSize(10, 10)); | 2030 root->setContentBounds(IntSize(10, 10)); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2034 .WillRepeatedly(Return()); | 2150 .WillRepeatedly(Return()); |
2035 | 2151 |
2036 EXPECT_CALL(*m_context, enable(GraphicsContext3D::SCISSOR_TEST)) | 2152 EXPECT_CALL(*m_context, enable(GraphicsContext3D::SCISSOR_TEST)) |
2037 .Times(0); | 2153 .Times(0); |
2038 | 2154 |
2039 EXPECT_CALL(*m_context, scissor(_, _, _, _)) | 2155 EXPECT_CALL(*m_context, scissor(_, _, _, _)) |
2040 .Times(0); | 2156 .Times(0); |
2041 } | 2157 } |
2042 }; | 2158 }; |
2043 | 2159 |
2044 TEST_F(CCLayerTreeHostImplTest, noPartialSwap) | 2160 TEST_P(CCLayerTreeHostImplTest, noPartialSwap) |
2045 { | 2161 { |
2046 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a doptPtr(new MockContext)); | 2162 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a doptPtr(new MockContext)); |
2047 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); | 2163 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); |
2048 MockContextHarness harness(mockContext); | 2164 MockContextHarness harness(mockContext); |
2049 | 2165 |
2050 harness.mustDrawSolidQuad(); | 2166 harness.mustDrawSolidQuad(); |
2051 harness.mustSetScissor(0, 0, 10, 10); | 2167 harness.mustSetScissor(0, 0, 10, 10); |
2052 | 2168 |
2053 // Run test case | 2169 // Run test case |
2054 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context. release(), FakeLayerWithQuads::create(1)); | 2170 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context. release(), FakeLayerWithQuads::create(1)); |
2055 | 2171 |
2056 CCLayerTreeHostImpl::FrameData frame; | 2172 CCLayerTreeHostImpl::FrameData frame; |
2057 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2173 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2058 myHostImpl->drawLayers(frame); | 2174 myHostImpl->drawLayers(frame); |
2059 myHostImpl->didDrawAllLayers(frame); | 2175 myHostImpl->didDrawAllLayers(frame); |
2060 Mock::VerifyAndClearExpectations(&mockContext); | 2176 Mock::VerifyAndClearExpectations(&mockContext); |
2061 } | 2177 } |
2062 | 2178 |
2063 TEST_F(CCLayerTreeHostImplTest, partialSwap) | 2179 TEST_P(CCLayerTreeHostImplTest, partialSwap) |
2064 { | 2180 { |
2065 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a doptPtr(new MockContext)); | 2181 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a doptPtr(new MockContext)); |
2066 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); | 2182 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); |
2067 MockContextHarness harness(mockContext); | 2183 MockContextHarness harness(mockContext); |
2068 | 2184 |
2069 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context.r elease(), FakeLayerWithQuads::create(1)); | 2185 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context.r elease(), FakeLayerWithQuads::create(1)); |
2070 | 2186 |
2071 // The first frame is not a partially-swapped one. | 2187 // The first frame is not a partially-swapped one. |
2072 harness.mustSetScissor(0, 0, 10, 10); | 2188 harness.mustSetScissor(0, 0, 10, 10); |
2073 harness.mustDrawSolidQuad(); | 2189 harness.mustDrawSolidQuad(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2177 grandChild->setVisibleContentRect(grandChildRect); | 2293 grandChild->setVisibleContentRect(grandChildRect); |
2178 grandChild->setDrawsContent(true); | 2294 grandChild->setDrawsContent(true); |
2179 | 2295 |
2180 child->addChild(grandChild.release()); | 2296 child->addChild(grandChild.release()); |
2181 root->addChild(child.release()); | 2297 root->addChild(child.release()); |
2182 | 2298 |
2183 myHostImpl->setRootLayer(root.release()); | 2299 myHostImpl->setRootLayer(root.release()); |
2184 return myHostImpl.release(); | 2300 return myHostImpl.release(); |
2185 } | 2301 } |
2186 | 2302 |
2187 TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) | 2303 TEST_P(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) |
2188 { | 2304 { |
2189 OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this); | 2305 OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this); |
2190 | 2306 |
2191 { | 2307 { |
2192 CCLayerTreeHostImpl::FrameData frame; | 2308 CCLayerTreeHostImpl::FrameData frame; |
2193 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2309 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2194 | 2310 |
2195 // Just for consistency, the most interesting stuff already happened | 2311 // Just for consistency, the most interesting stuff already happened |
2196 myHostImpl->drawLayers(frame); | 2312 myHostImpl->drawLayers(frame); |
2197 myHostImpl->didDrawAllLayers(frame); | 2313 myHostImpl->didDrawAllLayers(frame); |
2198 | 2314 |
2199 // Verify all quads have been computed | 2315 // Verify all quads have been computed |
2200 ASSERT_EQ(2U, frame.renderPasses.size()); | 2316 ASSERT_EQ(2U, frame.renderPasses.size()); |
2201 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 2317 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
2202 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 2318 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
2203 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]-> material()); | 2319 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]-> material()); |
2204 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]-> material()); | 2320 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]-> material()); |
2205 } | 2321 } |
2206 } | 2322 } |
2207 | 2323 |
2208 TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap) | 2324 TEST_P(CCLayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap) |
2209 { | 2325 { |
2210 OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this); | 2326 OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this); |
2211 | 2327 |
2212 { | 2328 { |
2213 CCLayerTreeHostImpl::FrameData frame; | 2329 CCLayerTreeHostImpl::FrameData frame; |
2214 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2330 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2215 | 2331 |
2216 // Just for consistency, the most interesting stuff already happened | 2332 // Just for consistency, the most interesting stuff already happened |
2217 myHostImpl->drawLayers(frame); | 2333 myHostImpl->drawLayers(frame); |
2218 myHostImpl->didDrawAllLayers(frame); | 2334 myHostImpl->didDrawAllLayers(frame); |
(...skipping 22 matching lines...) Expand all Loading... | |
2241 private: | 2357 private: |
2242 explicit ContextLostNotificationCheckLayer(int id) | 2358 explicit ContextLostNotificationCheckLayer(int id) |
2243 : CCLayerImpl(id) | 2359 : CCLayerImpl(id) |
2244 , m_didLoseContextCalled(false) | 2360 , m_didLoseContextCalled(false) |
2245 { | 2361 { |
2246 } | 2362 } |
2247 | 2363 |
2248 bool m_didLoseContextCalled; | 2364 bool m_didLoseContextCalled; |
2249 }; | 2365 }; |
2250 | 2366 |
2251 TEST_F(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayer s) | 2367 TEST_P(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayer s) |
2252 { | 2368 { |
2253 m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(1)); | 2369 m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(1)); |
2254 ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificatio nCheckLayer*>(m_hostImpl->rootLayer()); | 2370 ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificatio nCheckLayer*>(m_hostImpl->rootLayer()); |
2255 | 2371 |
2256 root->addChild(ContextLostNotificationCheckLayer::create(1)); | 2372 root->addChild(ContextLostNotificationCheckLayer::create(1)); |
2257 ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificat ionCheckLayer*>(root->children()[0]); | 2373 ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificat ionCheckLayer*>(root->children()[0]); |
2258 | 2374 |
2259 layer1->addChild(ContextLostNotificationCheckLayer::create(2)); | 2375 layer1->addChild(ContextLostNotificationCheckLayer::create(2)); |
2260 ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificat ionCheckLayer*>(layer1->children()[0]); | 2376 ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificat ionCheckLayer*>(layer1->children()[0]); |
2261 | 2377 |
2262 EXPECT_FALSE(root->didLoseContextCalled()); | 2378 EXPECT_FALSE(root->didLoseContextCalled()); |
2263 EXPECT_FALSE(layer1->didLoseContextCalled()); | 2379 EXPECT_FALSE(layer1->didLoseContextCalled()); |
2264 EXPECT_FALSE(layer2->didLoseContextCalled()); | 2380 EXPECT_FALSE(layer2->didLoseContextCalled()); |
2265 | 2381 |
2266 m_hostImpl->initializeRenderer(createContext()); | 2382 m_hostImpl->initializeRenderer(createContext()); |
2267 | 2383 |
2268 EXPECT_TRUE(root->didLoseContextCalled()); | 2384 EXPECT_TRUE(root->didLoseContextCalled()); |
2269 EXPECT_TRUE(layer1->didLoseContextCalled()); | 2385 EXPECT_TRUE(layer1->didLoseContextCalled()); |
2270 EXPECT_TRUE(layer2->didLoseContextCalled()); | 2386 EXPECT_TRUE(layer2->didLoseContextCalled()); |
2271 } | 2387 } |
2272 | 2388 |
2273 TEST_F(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost) | 2389 TEST_P(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost) |
2274 { | 2390 { |
2275 CCLayerTreeSettings settings; | 2391 CCLayerTreeSettings settings; |
2276 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); | 2392 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); |
2277 | 2393 |
2278 // The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects. | 2394 // The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects. |
2279 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP tr(new FakeWebGraphicsContext3DMakeCurrentFails))); | 2395 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP tr(new FakeWebGraphicsContext3DMakeCurrentFails))); |
2280 m_hostImpl->finishAllRendering(); | 2396 m_hostImpl->finishAllRendering(); |
2281 } | 2397 } |
2282 | 2398 |
2283 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic sContext3D { | 2399 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic sContext3D { |
2284 public: | 2400 public: |
2285 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed Count) : m_succeedCount(succeedCount) { } | 2401 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed Count) : m_succeedCount(succeedCount) { } |
2286 virtual bool makeContextCurrent() { | 2402 virtual bool makeContextCurrent() { |
2287 if (!m_succeedCount) | 2403 if (!m_succeedCount) |
2288 return false; | 2404 return false; |
2289 --m_succeedCount; | 2405 --m_succeedCount; |
2290 return true; | 2406 return true; |
2291 } | 2407 } |
2292 | 2408 |
2293 private: | 2409 private: |
2294 unsigned m_succeedCount; | 2410 unsigned m_succeedCount; |
2295 }; | 2411 }; |
2296 | 2412 |
2297 TEST_F(CCLayerTreeHostImplTest, contextLostDuringInitialize) | 2413 TEST_P(CCLayerTreeHostImplTest, contextLostDuringInitialize) |
2298 { | 2414 { |
2299 CCLayerTreeSettings settings; | 2415 CCLayerTreeSettings settings; |
2300 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); | 2416 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); |
2301 | 2417 |
2302 // Initialize into a known successful state. | 2418 // Initialize into a known successful state. |
2303 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); | 2419 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); |
2304 EXPECT_TRUE(m_hostImpl->context()); | 2420 EXPECT_TRUE(m_hostImpl->context()); |
2305 EXPECT_TRUE(m_hostImpl->renderer()); | 2421 EXPECT_TRUE(m_hostImpl->renderer()); |
2306 EXPECT_TRUE(m_hostImpl->resourceProvider()); | 2422 EXPECT_TRUE(m_hostImpl->resourceProvider()); |
2307 | 2423 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2537 scoped_ptr<CCRenderPass> pass = CCRenderPass::create(CCRenderPass::Id(1, 1), IntRect(0, 0, 1, 1), WebTransformationMatrix()); | 2653 scoped_ptr<CCRenderPass> pass = CCRenderPass::create(CCRenderPass::Id(1, 1), IntRect(0, 0, 1, 1), WebTransformationMatrix()); |
2538 scoped_ptr<CCSharedQuadState> sharedState = CCSharedQuadState::create(WebTra nsformationMatrix(), IntRect(0, 0, 1, 1), IntRect(0, 0, 1, 1), 1, false); | 2654 scoped_ptr<CCSharedQuadState> sharedState = CCSharedQuadState::create(WebTra nsformationMatrix(), IntRect(0, 0, 1, 1), IntRect(0, 0, 1, 1), 1, false); |
2539 scoped_ptr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedState.g et(), IntRect(0, 0, 1, 1), resourceId, false, FloatRect(0, 0, 1, 1), false); | 2655 scoped_ptr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedState.g et(), IntRect(0, 0, 1, 1), resourceId, false, FloatRect(0, 0, 1, 1), false); |
2540 | 2656 |
2541 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat e.Pass()); | 2657 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat e.Pass()); |
2542 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua d>()); | 2658 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua d>()); |
2543 | 2659 |
2544 return pass.Pass(); | 2660 return pass.Pass(); |
2545 } | 2661 } |
2546 | 2662 |
2547 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) | 2663 TEST_P(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) |
2548 { | 2664 { |
2549 int layerId = 1; | 2665 int layerId = 1; |
2550 | 2666 |
2551 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++)); | 2667 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++)); |
2552 rootLayer->setBounds(IntSize(10, 10)); | 2668 rootLayer->setBounds(IntSize(10, 10)); |
2553 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2669 rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
2554 | 2670 |
2555 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++); | 2671 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++); |
2556 tileLayer->setBounds(IntSize(10, 10)); | 2672 tileLayer->setBounds(IntSize(10, 10)); |
2557 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2673 tileLayer->setAnchorPoint(FloatPoint(0, 0)); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2724 return WebString(); | 2840 return WebString(); |
2725 } | 2841 } |
2726 | 2842 |
2727 unsigned numTextures() const { return m_numTextures; } | 2843 unsigned numTextures() const { return m_numTextures; } |
2728 | 2844 |
2729 private: | 2845 private: |
2730 HashMap<WebGLId, bool> m_textures; | 2846 HashMap<WebGLId, bool> m_textures; |
2731 unsigned m_numTextures; | 2847 unsigned m_numTextures; |
2732 }; | 2848 }; |
2733 | 2849 |
2734 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures) | 2850 TEST_P(CCLayerTreeHostImplTest, layersFreeTextures) |
2735 { | 2851 { |
2736 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); | 2852 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); |
2737 rootLayer->setBounds(IntSize(10, 10)); | 2853 rootLayer->setBounds(IntSize(10, 10)); |
2738 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2854 rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
2739 | 2855 |
2740 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); | 2856 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); |
2741 tileLayer->setBounds(IntSize(10, 10)); | 2857 tileLayer->setBounds(IntSize(10, 10)); |
2742 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2858 tileLayer->setAnchorPoint(FloatPoint(0, 0)); |
2743 tileLayer->setContentBounds(IntSize(10, 10)); | 2859 tileLayer->setContentBounds(IntSize(10, 10)); |
2744 tileLayer->setDrawsContent(true); | 2860 tileLayer->setDrawsContent(true); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2795 // There should be no textures left in use after. | 2911 // There should be no textures left in use after. |
2796 EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures()); | 2912 EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures()); |
2797 } | 2913 } |
2798 | 2914 |
2799 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { | 2915 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { |
2800 public: | 2916 public: |
2801 MOCK_METHOD1(useProgram, void(WebGLId program)); | 2917 MOCK_METHOD1(useProgram, void(WebGLId program)); |
2802 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset)); | 2918 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset)); |
2803 }; | 2919 }; |
2804 | 2920 |
2805 TEST_F(CCLayerTreeHostImplTest, hasTransparentBackground) | 2921 TEST_P(CCLayerTreeHostImplTest, hasTransparentBackground) |
2806 { | 2922 { |
2807 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a doptPtr(new MockDrawQuadsToFillScreenContext)); | 2923 OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(a doptPtr(new MockDrawQuadsToFillScreenContext)); |
2808 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF illScreenContext*>(context->context3D()); | 2924 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF illScreenContext*>(context->context3D()); |
2809 | 2925 |
2810 // Run test case | 2926 // Run test case |
2811 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context. release(), CCLayerImpl::create(1)); | 2927 OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context. release(), CCLayerImpl::create(1)); |
2812 myHostImpl->setBackgroundColor(SK_ColorWHITE); | 2928 myHostImpl->setBackgroundColor(SK_ColorWHITE); |
2813 | 2929 |
2814 // Verify one quad is drawn when transparent background set is not set. | 2930 // Verify one quad is drawn when transparent background set is not set. |
2815 myHostImpl->setHasTransparentBackground(false); | 2931 myHostImpl->setHasTransparentBackground(false); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2874 | 2990 |
2875 // Child of the surface layer will produce some quads | 2991 // Child of the surface layer will produce some quads |
2876 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(5, 5, rootSize.width() - 25, r ootSize.height() - 25), &childPtr); | 2992 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(5, 5, rootSize.width() - 25, r ootSize.height() - 25), &childPtr); |
2877 } | 2993 } |
2878 | 2994 |
2879 class CCRendererGLWithReleaseTextures : public CCRendererGL { | 2995 class CCRendererGLWithReleaseTextures : public CCRendererGL { |
2880 public: | 2996 public: |
2881 using CCRendererGL::releaseRenderPassTextures; | 2997 using CCRendererGL::releaseRenderPassTextures; |
2882 }; | 2998 }; |
2883 | 2999 |
2884 TEST_F(CCLayerTreeHostImplTest, textureCachingWithClipping) | 3000 TEST_P(CCLayerTreeHostImplTest, textureCachingWithClipping) |
2885 { | 3001 { |
2886 CCSettings::setPartialSwapEnabled(true); | 3002 CCSettings::setPartialSwapEnabled(true); |
2887 | 3003 |
2888 CCLayerTreeSettings settings; | 3004 CCLayerTreeSettings settings; |
2889 settings.minimumOcclusionTrackingSize = IntSize(); | 3005 settings.minimumOcclusionTrackingSize = IntSize(); |
2890 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); | 3006 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); |
2891 | 3007 |
2892 CCLayerImpl* rootPtr; | 3008 CCLayerImpl* rootPtr; |
2893 CCLayerImpl* surfaceLayerPtr; | 3009 CCLayerImpl* surfaceLayerPtr; |
2894 | 3010 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2971 // Must receive two render passes, each with one quad | 3087 // Must receive two render passes, each with one quad |
2972 ASSERT_EQ(2U, frame.renderPasses.size()); | 3088 ASSERT_EQ(2U, frame.renderPasses.size()); |
2973 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3089 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
2974 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 3090 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
2975 | 3091 |
2976 myHostImpl->drawLayers(frame); | 3092 myHostImpl->drawLayers(frame); |
2977 myHostImpl->didDrawAllLayers(frame); | 3093 myHostImpl->didDrawAllLayers(frame); |
2978 } | 3094 } |
2979 } | 3095 } |
2980 | 3096 |
2981 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusion) | 3097 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusion) |
2982 { | 3098 { |
2983 CCSettings::setPartialSwapEnabled(false); | 3099 CCSettings::setPartialSwapEnabled(false); |
2984 | 3100 |
2985 CCLayerTreeSettings settings; | 3101 CCLayerTreeSettings settings; |
2986 settings.minimumOcclusionTrackingSize = IntSize(); | 3102 settings.minimumOcclusionTrackingSize = IntSize(); |
2987 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); | 3103 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); |
2988 | 3104 |
2989 // Layers are structure as follows: | 3105 // Layers are structure as follows: |
2990 // | 3106 // |
2991 // R +-- S1 +- L10 (owning) | 3107 // R +-- S1 +- L10 (owning) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3087 ASSERT_EQ(1U, frame.renderPasses.size()); | 3203 ASSERT_EQ(1U, frame.renderPasses.size()); |
3088 | 3204 |
3089 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3205 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
3090 | 3206 |
3091 myHostImpl->drawLayers(frame); | 3207 myHostImpl->drawLayers(frame); |
3092 myHostImpl->didDrawAllLayers(frame); | 3208 myHostImpl->didDrawAllLayers(frame); |
3093 } | 3209 } |
3094 | 3210 |
3095 } | 3211 } |
3096 | 3212 |
3097 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) | 3213 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) |
3098 { | 3214 { |
3099 CCSettings::setPartialSwapEnabled(false); | 3215 CCSettings::setPartialSwapEnabled(false); |
3100 | 3216 |
3101 CCLayerTreeSettings settings; | 3217 CCLayerTreeSettings settings; |
3102 settings.minimumOcclusionTrackingSize = IntSize(); | 3218 settings.minimumOcclusionTrackingSize = IntSize(); |
3103 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); | 3219 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); |
3104 | 3220 |
3105 // Layers are structure as follows: | 3221 // Layers are structure as follows: |
3106 // | 3222 // |
3107 // R +-- S1 +- L10 (owning, non drawing) | 3223 // R +-- S1 +- L10 (owning, non drawing) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3203 // Must receive 1 render pass - for the root. | 3319 // Must receive 1 render pass - for the root. |
3204 ASSERT_EQ(1U, frame.renderPasses.size()); | 3320 ASSERT_EQ(1U, frame.renderPasses.size()); |
3205 | 3321 |
3206 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3322 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
3207 | 3323 |
3208 myHostImpl->drawLayers(frame); | 3324 myHostImpl->drawLayers(frame); |
3209 myHostImpl->didDrawAllLayers(frame); | 3325 myHostImpl->didDrawAllLayers(frame); |
3210 } | 3326 } |
3211 } | 3327 } |
3212 | 3328 |
3213 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) | 3329 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) |
3214 { | 3330 { |
3215 CCSettings::setPartialSwapEnabled(false); | 3331 CCSettings::setPartialSwapEnabled(false); |
3216 | 3332 |
3217 CCLayerTreeSettings settings; | 3333 CCLayerTreeSettings settings; |
3218 settings.minimumOcclusionTrackingSize = IntSize(); | 3334 settings.minimumOcclusionTrackingSize = IntSize(); |
3219 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); | 3335 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); |
3220 | 3336 |
3221 // Layers are structured as follows: | 3337 // Layers are structured as follows: |
3222 // | 3338 // |
3223 // R +-- S1 +- L10 (owning, drawing) | 3339 // R +-- S1 +- L10 (owning, drawing) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3292 ASSERT_EQ(2U, frame.renderPasses.size()); | 3408 ASSERT_EQ(2U, frame.renderPasses.size()); |
3293 | 3409 |
3294 EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); | 3410 EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); |
3295 EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); | 3411 EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); |
3296 | 3412 |
3297 myHostImpl->drawLayers(frame); | 3413 myHostImpl->drawLayers(frame); |
3298 myHostImpl->didDrawAllLayers(frame); | 3414 myHostImpl->didDrawAllLayers(frame); |
3299 } | 3415 } |
3300 } | 3416 } |
3301 | 3417 |
3302 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) | 3418 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) |
3303 { | 3419 { |
3304 CCSettings::setPartialSwapEnabled(false); | 3420 CCSettings::setPartialSwapEnabled(false); |
3305 | 3421 |
3306 CCLayerTreeSettings settings; | 3422 CCLayerTreeSettings settings; |
3307 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); | 3423 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); |
3308 | 3424 |
3309 // Layers are structured as follows: | 3425 // Layers are structured as follows: |
3310 // | 3426 // |
3311 // R +-- S1 +- L10 (rotated, drawing) | 3427 // R +-- S1 +- L10 (rotated, drawing) |
3312 // +- L11 (occupies half surface) | 3428 // +- L11 (occupies half surface) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3366 // One render pass must be gone due to cached texture. | 3482 // One render pass must be gone due to cached texture. |
3367 ASSERT_EQ(1U, frame.renderPasses.size()); | 3483 ASSERT_EQ(1U, frame.renderPasses.size()); |
3368 | 3484 |
3369 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 3485 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
3370 | 3486 |
3371 myHostImpl->drawLayers(frame); | 3487 myHostImpl->drawLayers(frame); |
3372 myHostImpl->didDrawAllLayers(frame); | 3488 myHostImpl->didDrawAllLayers(frame); |
3373 } | 3489 } |
3374 } | 3490 } |
3375 | 3491 |
3376 TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) | 3492 TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) |
3377 { | 3493 { |
3378 CCSettings::setPartialSwapEnabled(true); | 3494 CCSettings::setPartialSwapEnabled(true); |
3379 | 3495 |
3380 CCLayerTreeSettings settings; | 3496 CCLayerTreeSettings settings; |
3381 settings.minimumOcclusionTrackingSize = IntSize(); | 3497 settings.minimumOcclusionTrackingSize = IntSize(); |
3382 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); | 3498 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); |
3383 | 3499 |
3384 // Layers are structure as follows: | 3500 // Layers are structure as follows: |
3385 // | 3501 // |
3386 // R +-- S1 +- L10 (owning) | 3502 // R +-- S1 +- L10 (owning) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3479 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3595 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3480 | 3596 |
3481 // Root render pass only. | 3597 // Root render pass only. |
3482 ASSERT_EQ(1U, frame.renderPasses.size()); | 3598 ASSERT_EQ(1U, frame.renderPasses.size()); |
3483 | 3599 |
3484 myHostImpl->drawLayers(frame); | 3600 myHostImpl->drawLayers(frame); |
3485 myHostImpl->didDrawAllLayers(frame); | 3601 myHostImpl->didDrawAllLayers(frame); |
3486 } | 3602 } |
3487 } | 3603 } |
3488 | 3604 |
3489 TEST_F(CCLayerTreeHostImplTest, textureCachingWithScissor) | 3605 TEST_P(CCLayerTreeHostImplTest, textureCachingWithScissor) |
3490 { | 3606 { |
3491 CCSettings::setPartialSwapEnabled(false); | 3607 CCSettings::setPartialSwapEnabled(false); |
3492 | 3608 |
3493 CCLayerTreeSettings settings; | 3609 CCLayerTreeSettings settings; |
3494 settings.minimumOcclusionTrackingSize = IntSize(); | 3610 settings.minimumOcclusionTrackingSize = IntSize(); |
3495 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); | 3611 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); |
3496 | 3612 |
3497 /* | 3613 /* |
3498 Layers are created as follows: | 3614 Layers are created as follows: |
3499 | 3615 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3586 CCLayerTreeHostImpl::FrameData frame; | 3702 CCLayerTreeHostImpl::FrameData frame; |
3587 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3703 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3588 myHostImpl->drawLayers(frame); | 3704 myHostImpl->drawLayers(frame); |
3589 myHostImpl->didDrawAllLayers(frame); | 3705 myHostImpl->didDrawAllLayers(frame); |
3590 } | 3706 } |
3591 | 3707 |
3592 // We should have a cached texture for surface 2 again even though it was da maged. | 3708 // We should have a cached texture for surface 2 again even though it was da maged. |
3593 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child PassId)); | 3709 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child PassId)); |
3594 } | 3710 } |
3595 | 3711 |
3596 TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching) | 3712 TEST_P(CCLayerTreeHostImplTest, surfaceTextureCaching) |
3597 { | 3713 { |
3598 CCSettings::setPartialSwapEnabled(true); | 3714 CCSettings::setPartialSwapEnabled(true); |
3599 | 3715 |
3600 CCLayerTreeSettings settings; | 3716 CCLayerTreeSettings settings; |
3601 settings.minimumOcclusionTrackingSize = IntSize(); | 3717 settings.minimumOcclusionTrackingSize = IntSize(); |
3602 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); | 3718 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); |
3603 | 3719 |
3604 CCLayerImpl* rootPtr; | 3720 CCLayerImpl* rootPtr; |
3605 CCLayerImpl* intermediateLayerPtr; | 3721 CCLayerImpl* intermediateLayerPtr; |
3606 CCLayerImpl* surfaceLayerPtr; | 3722 CCLayerImpl* surfaceLayerPtr; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3747 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]-> material()); | 3863 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]-> material()); |
3748 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.re nderPasses[0]->quadList()[0]); | 3864 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.re nderPasses[0]->quadList()[0]); |
3749 CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId ()); | 3865 CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId ()); |
3750 EXPECT_TRUE(targetPass->damageRect().isEmpty()); | 3866 EXPECT_TRUE(targetPass->damageRect().isEmpty()); |
3751 | 3867 |
3752 myHostImpl->drawLayers(frame); | 3868 myHostImpl->drawLayers(frame); |
3753 myHostImpl->didDrawAllLayers(frame); | 3869 myHostImpl->didDrawAllLayers(frame); |
3754 } | 3870 } |
3755 } | 3871 } |
3756 | 3872 |
3757 TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) | 3873 TEST_P(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) |
3758 { | 3874 { |
3759 CCSettings::setPartialSwapEnabled(false); | 3875 CCSettings::setPartialSwapEnabled(false); |
3760 | 3876 |
3761 CCLayerTreeSettings settings; | 3877 CCLayerTreeSettings settings; |
3762 settings.minimumOcclusionTrackingSize = IntSize(); | 3878 settings.minimumOcclusionTrackingSize = IntSize(); |
3763 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); | 3879 OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(setting s, this); |
3764 | 3880 |
3765 CCLayerImpl* rootPtr; | 3881 CCLayerImpl* rootPtr; |
3766 CCLayerImpl* intermediateLayerPtr; | 3882 CCLayerImpl* intermediateLayerPtr; |
3767 CCLayerImpl* surfaceLayerPtr; | 3883 CCLayerImpl* surfaceLayerPtr; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3910 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]-> material()); | 4026 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[0]->quadList()[0]-> material()); |
3911 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.re nderPasses[0]->quadList()[0]); | 4027 CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.re nderPasses[0]->quadList()[0]); |
3912 CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId ()); | 4028 CCRenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId ()); |
3913 EXPECT_TRUE(targetPass->damageRect().isEmpty()); | 4029 EXPECT_TRUE(targetPass->damageRect().isEmpty()); |
3914 | 4030 |
3915 myHostImpl->drawLayers(frame); | 4031 myHostImpl->drawLayers(frame); |
3916 myHostImpl->didDrawAllLayers(frame); | 4032 myHostImpl->didDrawAllLayers(frame); |
3917 } | 4033 } |
3918 } | 4034 } |
3919 | 4035 |
3920 TEST_F(CCLayerTreeHostImplTest, releaseContentsTextureShouldTriggerCommit) | 4036 TEST_P(CCLayerTreeHostImplTest, releaseContentsTextureShouldTriggerCommit) |
3921 { | 4037 { |
3922 m_hostImpl->releaseContentsTextures(); | 4038 m_hostImpl->releaseContentsTextures(); |
3923 EXPECT_TRUE(m_didRequestCommit); | 4039 EXPECT_TRUE(m_didRequestCommit); |
3924 } | 4040 } |
3925 | 4041 |
3926 struct RenderPassRemovalTestData : public CCLayerTreeHostImpl::FrameData { | 4042 struct RenderPassRemovalTestData : public CCLayerTreeHostImpl::FrameData { |
3927 ScopedPtrHashMap<CCRenderPass::Id, CCRenderPass> renderPassCache; | 4043 ScopedPtrHashMap<CCRenderPass::Id, CCRenderPass> renderPassCache; |
3928 scoped_ptr<CCSharedQuadState> sharedQuadState; | 4044 scoped_ptr<CCSharedQuadState> sharedQuadState; |
3929 }; | 4045 }; |
3930 | 4046 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4225 } | 4341 } |
4226 }; | 4342 }; |
4227 | 4343 |
4228 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa ta& testData) | 4344 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa ta& testData) |
4229 { | 4345 { |
4230 char actualResult[1024]; | 4346 char actualResult[1024]; |
4231 dumpRenderPassTestData(testData, actualResult); | 4347 dumpRenderPassTestData(testData, actualResult); |
4232 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t estCase.name; | 4348 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t estCase.name; |
4233 } | 4349 } |
4234 | 4350 |
4235 TEST_F(CCLayerTreeHostImplTest, testRemoveRenderPasses) | 4351 TEST_P(CCLayerTreeHostImplTest, testRemoveRenderPasses) |
4236 { | 4352 { |
4237 OwnPtr<CCGraphicsContext> context(createContext()); | 4353 OwnPtr<CCGraphicsContext> context(createContext()); |
4238 ASSERT_TRUE(context->context3D()); | 4354 ASSERT_TRUE(context->context3D()); |
4239 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get())); | 4355 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get())); |
4240 | 4356 |
4241 OwnPtr<CCTestRenderer> renderer(CCTestRenderer::create(resourceProvider.get( ))); | 4357 OwnPtr<CCTestRenderer> renderer(CCTestRenderer::create(resourceProvider.get( ))); |
4242 | 4358 |
4243 int testCaseIndex = 0; | 4359 int testCaseIndex = 0; |
4244 while (removeRenderPassesCases[testCaseIndex].name) { | 4360 while (removeRenderPassesCases[testCaseIndex].name) { |
4245 RenderPassRemovalTestData testData; | 4361 RenderPassRemovalTestData testData; |
4246 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get()); | 4362 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get()); |
4247 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData); | 4363 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData); |
4248 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); | 4364 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); |
4249 testCaseIndex++; | 4365 testCaseIndex++; |
4250 } | 4366 } |
4251 } | 4367 } |
4252 | 4368 |
4369 INSTANTIATE_TEST_CASE_P(CCLayerTreeHostImplTests, | |
4370 CCLayerTreeHostImplTest, | |
4371 ::testing::Values(false, true)); | |
4372 | |
4253 } // namespace | 4373 } // namespace |
OLD | NEW |