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 "cc/layer_tree_host.h" | 7 #include "cc/layer_tree_host.h" |
8 | 8 |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "cc/content_layer.h" | 10 #include "cc/content_layer.h" |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 public: | 1177 public: |
1178 LayerTreeHostTestOpacityChange() | 1178 LayerTreeHostTestOpacityChange() |
1179 : m_testOpacityChangeDelegate() | 1179 : m_testOpacityChangeDelegate() |
1180 , m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_testOpaci
tyChangeDelegate)) | 1180 , m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_testOpaci
tyChangeDelegate)) |
1181 { | 1181 { |
1182 m_testOpacityChangeDelegate.setTestLayer(m_updateCheckLayer.get()); | 1182 m_testOpacityChangeDelegate.setTestLayer(m_updateCheckLayer.get()); |
1183 } | 1183 } |
1184 | 1184 |
1185 virtual void beginTest() OVERRIDE | 1185 virtual void beginTest() OVERRIDE |
1186 { | 1186 { |
1187 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 1187 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
1188 m_layerTreeHost->rootLayer()->addChild(m_updateCheckLayer); | 1188 m_layerTreeHost->rootLayer()->addChild(m_updateCheckLayer); |
1189 | 1189 |
1190 postSetNeedsCommitToMainThread(); | 1190 postSetNeedsCommitToMainThread(); |
1191 } | 1191 } |
1192 | 1192 |
1193 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 1193 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
1194 { | 1194 { |
1195 endTest(); | 1195 endTest(); |
1196 } | 1196 } |
1197 | 1197 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 { | 1291 { |
1292 m_layerTreeHost->setViewportSize(gfx::Size(40, 40), gfx::Size(60, 60)); | 1292 m_layerTreeHost->setViewportSize(gfx::Size(40, 40), gfx::Size(60, 60)); |
1293 m_layerTreeHost->setDeviceScaleFactor(1.5); | 1293 m_layerTreeHost->setDeviceScaleFactor(1.5); |
1294 EXPECT_EQ(gfx::Size(40, 40), m_layerTreeHost->layoutViewportSize()); | 1294 EXPECT_EQ(gfx::Size(40, 40), m_layerTreeHost->layoutViewportSize()); |
1295 EXPECT_EQ(gfx::Size(60, 60), m_layerTreeHost->deviceViewportSize()); | 1295 EXPECT_EQ(gfx::Size(60, 60), m_layerTreeHost->deviceViewportSize()); |
1296 | 1296 |
1297 m_rootLayer->addChild(m_childLayer); | 1297 m_rootLayer->addChild(m_childLayer); |
1298 | 1298 |
1299 m_rootLayer->setIsDrawable(true); | 1299 m_rootLayer->setIsDrawable(true); |
1300 m_rootLayer->setBounds(gfx::Size(30, 30)); | 1300 m_rootLayer->setBounds(gfx::Size(30, 30)); |
1301 m_rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 1301 m_rootLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1302 | 1302 |
1303 m_childLayer->setIsDrawable(true); | 1303 m_childLayer->setIsDrawable(true); |
1304 m_childLayer->setPosition(gfx::Point(2, 2)); | 1304 m_childLayer->setPosition(gfx::Point(2, 2)); |
1305 m_childLayer->setBounds(gfx::Size(10, 10)); | 1305 m_childLayer->setBounds(gfx::Size(10, 10)); |
1306 m_childLayer->setAnchorPoint(FloatPoint(0, 0)); | 1306 m_childLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1307 | 1307 |
1308 m_layerTreeHost->setRootLayer(m_rootLayer); | 1308 m_layerTreeHost->setRootLayer(m_rootLayer); |
1309 } | 1309 } |
1310 | 1310 |
1311 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1311 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1312 { | 1312 { |
1313 // Get access to protected methods. | 1313 // Get access to protected methods. |
1314 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im
pl); | 1314 MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(im
pl); |
1315 | 1315 |
1316 // Should only do one commit. | 1316 // Should only do one commit. |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 : m_deviceScaleFactor(deviceScaleFactor) | 2225 : m_deviceScaleFactor(deviceScaleFactor) |
2226 , m_initialScroll(IntPoint(10, 20)) | 2226 , m_initialScroll(IntPoint(10, 20)) |
2227 , m_secondScroll(IntPoint(40, 5)) | 2227 , m_secondScroll(IntPoint(40, 5)) |
2228 , m_scrollAmount(2, -1) | 2228 , m_scrollAmount(2, -1) |
2229 , m_rootScrolls(0) | 2229 , m_rootScrolls(0) |
2230 { | 2230 { |
2231 } | 2231 } |
2232 | 2232 |
2233 virtual void beginTest() OVERRIDE | 2233 virtual void beginTest() OVERRIDE |
2234 { | 2234 { |
2235 IntSize viewportSize(10, 10); | 2235 gfx::Size viewportSize(10, 10); |
2236 IntSize deviceViewportSize = viewportSize; | 2236 gfx::Size deviceViewportSize = gfx::ToCeiledSize(viewportSize.Scale(m_de
viceScaleFactor)); |
2237 deviceViewportSize.scale(m_deviceScaleFactor, m_deviceScaleFactor); | |
2238 m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize); | 2237 m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize); |
2239 | 2238 |
2240 m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor); | 2239 m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor); |
2241 | 2240 |
2242 m_rootScrollLayer = ContentLayer::create(&m_mockDelegate); | 2241 m_rootScrollLayer = ContentLayer::create(&m_mockDelegate); |
2243 m_rootScrollLayer->setBounds(IntSize(110, 110)); | 2242 m_rootScrollLayer->setBounds(gfx::Size(110, 110)); |
2244 | 2243 |
2245 m_rootScrollLayer->setPosition(FloatPoint(0, 0)); | 2244 m_rootScrollLayer->setPosition(gfx::PointF(0, 0)); |
2246 m_rootScrollLayer->setAnchorPoint(FloatPoint(0, 0)); | 2245 m_rootScrollLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2247 | 2246 |
2248 m_rootScrollLayer->setIsDrawable(true); | 2247 m_rootScrollLayer->setIsDrawable(true); |
2249 m_rootScrollLayer->setScrollable(true); | 2248 m_rootScrollLayer->setScrollable(true); |
2250 m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100)); | 2249 m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100)); |
2251 m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer); | 2250 m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer); |
2252 | 2251 |
2253 m_childLayer = ContentLayer::create(&m_mockDelegate); | 2252 m_childLayer = ContentLayer::create(&m_mockDelegate); |
2254 m_childLayer->setLayerScrollClient(this); | 2253 m_childLayer->setLayerScrollClient(this); |
2255 m_childLayer->setBounds(IntSize(110, 110)); | 2254 m_childLayer->setBounds(gfx::Size(110, 110)); |
2256 | 2255 |
2257 // The scrolls will happen at 5, 5. If they are treated like device pixe
ls, then | 2256 // The scrolls will happen at 5, 5. If they are treated like device pixe
ls, then |
2258 // they will be at 2.5, 2.5 in logical pixels, and will miss this layer. | 2257 // they will be at 2.5, 2.5 in logical pixels, and will miss this layer. |
2259 m_childLayer->setPosition(FloatPoint(5, 5)); | 2258 m_childLayer->setPosition(gfx::PointF(5, 5)); |
2260 m_childLayer->setAnchorPoint(FloatPoint(0, 0)); | 2259 m_childLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2261 | 2260 |
2262 m_childLayer->setIsDrawable(true); | 2261 m_childLayer->setIsDrawable(true); |
2263 m_childLayer->setScrollable(true); | 2262 m_childLayer->setScrollable(true); |
2264 m_childLayer->setMaxScrollPosition(IntSize(100, 100)); | 2263 m_childLayer->setMaxScrollPosition(IntSize(100, 100)); |
2265 m_rootScrollLayer->addChild(m_childLayer); | 2264 m_rootScrollLayer->addChild(m_childLayer); |
2266 | 2265 |
2267 m_childLayer->setScrollPosition(m_initialScroll); | 2266 m_childLayer->setScrollPosition(m_initialScroll); |
2268 | 2267 |
2269 postSetNeedsCommitToMainThread(); | 2268 postSetNeedsCommitToMainThread(); |
2270 } | 2269 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 EXPECT_SIZE_EQ(root->scrollDelta(), IntSize()); | 2309 EXPECT_SIZE_EQ(root->scrollDelta(), IntSize()); |
2311 EXPECT_SIZE_EQ(rootScrollLayer->scrollDelta(), IntSize()); | 2310 EXPECT_SIZE_EQ(rootScrollLayer->scrollDelta(), IntSize()); |
2312 EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootS
crollLayer->contentBounds().width()); | 2311 EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootS
crollLayer->contentBounds().width()); |
2313 EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, root
ScrollLayer->contentBounds().height()); | 2312 EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, root
ScrollLayer->contentBounds().height()); |
2314 EXPECT_EQ(childLayer->bounds().width() * m_deviceScaleFactor, childLayer
->contentBounds().width()); | 2313 EXPECT_EQ(childLayer->bounds().width() * m_deviceScaleFactor, childLayer
->contentBounds().width()); |
2315 EXPECT_EQ(childLayer->bounds().height() * m_deviceScaleFactor, childLaye
r->contentBounds().height()); | 2314 EXPECT_EQ(childLayer->bounds().height() * m_deviceScaleFactor, childLaye
r->contentBounds().height()); |
2316 | 2315 |
2317 switch (impl->sourceFrameNumber()) { | 2316 switch (impl->sourceFrameNumber()) { |
2318 case 0: | 2317 case 0: |
2319 // Gesture scroll on impl thread. | 2318 // Gesture scroll on impl thread. |
2320 EXPECT_EQ(impl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); | 2319 EXPECT_EQ(impl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); |
2321 impl->scrollBy(IntPoint(), m_scrollAmount); | 2320 impl->scrollBy(gfx::Point(), m_scrollAmount); |
2322 impl->scrollEnd(); | 2321 impl->scrollEnd(); |
2323 | 2322 |
2324 EXPECT_POINT_EQ(m_initialScroll, childLayer->scrollPosition()); | 2323 EXPECT_POINT_EQ(m_initialScroll, childLayer->scrollPosition()); |
2325 EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta()); | 2324 EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta()); |
2326 break; | 2325 break; |
2327 case 1: | 2326 case 1: |
2328 // Wheel scroll on impl thread. | 2327 // Wheel scroll on impl thread. |
2329 EXPECT_EQ(impl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 2328 EXPECT_EQ(impl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
2330 impl->scrollBy(IntPoint(), m_scrollAmount); | 2329 impl->scrollBy(gfx::Point(), m_scrollAmount); |
2331 impl->scrollEnd(); | 2330 impl->scrollEnd(); |
2332 | 2331 |
2333 EXPECT_POINT_EQ(m_secondScroll, childLayer->scrollPosition()); | 2332 EXPECT_POINT_EQ(m_secondScroll, childLayer->scrollPosition()); |
2334 EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta()); | 2333 EXPECT_SIZE_EQ(m_scrollAmount, childLayer->scrollDelta()); |
2335 break; | 2334 break; |
2336 case 2: | 2335 case 2: |
2337 EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, childLayer->scrollP
osition()); | 2336 EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, childLayer->scrollP
osition()); |
2338 EXPECT_SIZE_EQ(IntSize(0, 0), childLayer->scrollDelta()); | 2337 EXPECT_SIZE_EQ(IntSize(0, 0), childLayer->scrollDelta()); |
2339 | 2338 |
2340 endTest(); | 2339 endTest(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2386 : m_deviceScaleFactor(deviceScaleFactor) | 2385 : m_deviceScaleFactor(deviceScaleFactor) |
2387 , m_initialScroll(IntPoint(10, 20)) | 2386 , m_initialScroll(IntPoint(10, 20)) |
2388 , m_secondScroll(IntPoint(40, 5)) | 2387 , m_secondScroll(IntPoint(40, 5)) |
2389 , m_scrollAmount(2, -1) | 2388 , m_scrollAmount(2, -1) |
2390 , m_rootScrolls(0) | 2389 , m_rootScrolls(0) |
2391 { | 2390 { |
2392 } | 2391 } |
2393 | 2392 |
2394 virtual void beginTest() OVERRIDE | 2393 virtual void beginTest() OVERRIDE |
2395 { | 2394 { |
2396 IntSize viewportSize(10, 10); | 2395 gfx::Size viewportSize(10, 10); |
2397 IntSize deviceViewportSize = viewportSize; | 2396 gfx::Size deviceViewportSize = gfx::ToCeiledSize(viewportSize.Scale(m_de
viceScaleFactor)); |
2398 deviceViewportSize.scale(m_deviceScaleFactor, m_deviceScaleFactor); | |
2399 m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize); | 2397 m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize); |
2400 | 2398 |
2401 m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor); | 2399 m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor); |
2402 | 2400 |
2403 m_rootScrollLayer = ContentLayer::create(&m_mockDelegate); | 2401 m_rootScrollLayer = ContentLayer::create(&m_mockDelegate); |
2404 m_rootScrollLayer->setBounds(IntSize(110, 110)); | 2402 m_rootScrollLayer->setBounds(IntSize(110, 110)); |
2405 | 2403 |
2406 m_rootScrollLayer->setPosition(FloatPoint(0, 0)); | 2404 m_rootScrollLayer->setPosition(gfx::PointF(0, 0)); |
2407 m_rootScrollLayer->setAnchorPoint(FloatPoint(0, 0)); | 2405 m_rootScrollLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2408 | 2406 |
2409 m_rootScrollLayer->setIsDrawable(true); | 2407 m_rootScrollLayer->setIsDrawable(true); |
2410 m_rootScrollLayer->setScrollable(true); | 2408 m_rootScrollLayer->setScrollable(true); |
2411 m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100)); | 2409 m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100)); |
2412 m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer); | 2410 m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer); |
2413 | 2411 |
2414 m_rootScrollLayer->setScrollPosition(m_initialScroll); | 2412 m_rootScrollLayer->setScrollPosition(m_initialScroll); |
2415 | 2413 |
2416 postSetNeedsCommitToMainThread(); | 2414 postSetNeedsCommitToMainThread(); |
2417 } | 2415 } |
(...skipping 28 matching lines...) Expand all Loading... |
2446 LayerImpl* root = impl->rootLayer(); | 2444 LayerImpl* root = impl->rootLayer(); |
2447 LayerImpl* rootScrollLayer = root->children()[0]; | 2445 LayerImpl* rootScrollLayer = root->children()[0]; |
2448 | 2446 |
2449 EXPECT_SIZE_EQ(root->scrollDelta(), IntSize()); | 2447 EXPECT_SIZE_EQ(root->scrollDelta(), IntSize()); |
2450 EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootS
crollLayer->contentBounds().width()); | 2448 EXPECT_EQ(rootScrollLayer->bounds().width() * m_deviceScaleFactor, rootS
crollLayer->contentBounds().width()); |
2451 EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, root
ScrollLayer->contentBounds().height()); | 2449 EXPECT_EQ(rootScrollLayer->bounds().height() * m_deviceScaleFactor, root
ScrollLayer->contentBounds().height()); |
2452 | 2450 |
2453 switch (impl->sourceFrameNumber()) { | 2451 switch (impl->sourceFrameNumber()) { |
2454 case 0: | 2452 case 0: |
2455 // Gesture scroll on impl thread. | 2453 // Gesture scroll on impl thread. |
2456 EXPECT_EQ(impl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); | 2454 EXPECT_EQ(impl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); |
2457 impl->scrollBy(IntPoint(), m_scrollAmount); | 2455 impl->scrollBy(gfx::Point(), m_scrollAmount); |
2458 impl->scrollEnd(); | 2456 impl->scrollEnd(); |
2459 | 2457 |
2460 EXPECT_POINT_EQ(m_initialScroll, rootScrollLayer->scrollPosition()); | 2458 EXPECT_POINT_EQ(m_initialScroll, rootScrollLayer->scrollPosition()); |
2461 EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta()); | 2459 EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta()); |
2462 break; | 2460 break; |
2463 case 1: | 2461 case 1: |
2464 // Wheel scroll on impl thread. | 2462 // Wheel scroll on impl thread. |
2465 EXPECT_EQ(impl->scrollBegin(IntPoint(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 2463 EXPECT_EQ(impl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
2466 impl->scrollBy(IntPoint(), m_scrollAmount); | 2464 impl->scrollBy(gfx::Point(), m_scrollAmount); |
2467 impl->scrollEnd(); | 2465 impl->scrollEnd(); |
2468 | 2466 |
2469 EXPECT_POINT_EQ(m_secondScroll, rootScrollLayer->scrollPosition()); | 2467 EXPECT_POINT_EQ(m_secondScroll, rootScrollLayer->scrollPosition()); |
2470 EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta()); | 2468 EXPECT_SIZE_EQ(m_scrollAmount, rootScrollLayer->scrollDelta()); |
2471 break; | 2469 break; |
2472 case 2: | 2470 case 2: |
2473 EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, rootScrollLayer->sc
rollPosition()); | 2471 EXPECT_POINT_EQ(m_secondScroll + m_scrollAmount, rootScrollLayer->sc
rollPosition()); |
2474 EXPECT_SIZE_EQ(IntSize(0, 0), rootScrollLayer->scrollDelta()); | 2472 EXPECT_SIZE_EQ(IntSize(0, 0), rootScrollLayer->scrollDelta()); |
2475 | 2473 |
2476 endTest(); | 2474 endTest(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2541 : m_rootLayer(ContentLayerWithUpdateTracking::create(&m_mockDelegate)) | 2539 : m_rootLayer(ContentLayerWithUpdateTracking::create(&m_mockDelegate)) |
2542 , m_surfaceLayer1(ContentLayerWithUpdateTracking::create(&m_mockDelegate
)) | 2540 , m_surfaceLayer1(ContentLayerWithUpdateTracking::create(&m_mockDelegate
)) |
2543 , m_replicaLayer1(ContentLayerWithUpdateTracking::create(&m_mockDelegate
)) | 2541 , m_replicaLayer1(ContentLayerWithUpdateTracking::create(&m_mockDelegate
)) |
2544 , m_surfaceLayer2(ContentLayerWithUpdateTracking::create(&m_mockDelegate
)) | 2542 , m_surfaceLayer2(ContentLayerWithUpdateTracking::create(&m_mockDelegate
)) |
2545 , m_replicaLayer2(ContentLayerWithUpdateTracking::create(&m_mockDelegate
)) | 2543 , m_replicaLayer2(ContentLayerWithUpdateTracking::create(&m_mockDelegate
)) |
2546 { | 2544 { |
2547 } | 2545 } |
2548 | 2546 |
2549 virtual void beginTest() OVERRIDE | 2547 virtual void beginTest() OVERRIDE |
2550 { | 2548 { |
2551 m_layerTreeHost->setViewportSize(IntSize(100, 100), IntSize(100, 100)); | 2549 m_layerTreeHost->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100
)); |
2552 | 2550 |
2553 m_rootLayer->setBounds(IntSize(100, 100)); | 2551 m_rootLayer->setBounds(gfx::Size(100, 100)); |
2554 m_surfaceLayer1->setBounds(IntSize(100, 100)); | 2552 m_surfaceLayer1->setBounds(gfx::Size(100, 100)); |
2555 m_surfaceLayer1->setForceRenderSurface(true); | 2553 m_surfaceLayer1->setForceRenderSurface(true); |
2556 m_surfaceLayer1->setOpacity(0.5); | 2554 m_surfaceLayer1->setOpacity(0.5); |
2557 m_surfaceLayer2->setBounds(IntSize(100, 100)); | 2555 m_surfaceLayer2->setBounds(gfx::Size(100, 100)); |
2558 m_surfaceLayer2->setForceRenderSurface(true); | 2556 m_surfaceLayer2->setForceRenderSurface(true); |
2559 m_surfaceLayer2->setOpacity(0.5); | 2557 m_surfaceLayer2->setOpacity(0.5); |
2560 | 2558 |
2561 m_surfaceLayer1->setReplicaLayer(m_replicaLayer1.get()); | 2559 m_surfaceLayer1->setReplicaLayer(m_replicaLayer1.get()); |
2562 m_surfaceLayer2->setReplicaLayer(m_replicaLayer2.get()); | 2560 m_surfaceLayer2->setReplicaLayer(m_replicaLayer2.get()); |
2563 | 2561 |
2564 m_rootLayer->addChild(m_surfaceLayer1); | 2562 m_rootLayer->addChild(m_surfaceLayer1); |
2565 m_surfaceLayer1->addChild(m_surfaceLayer2); | 2563 m_surfaceLayer1->addChild(m_surfaceLayer2); |
2566 m_layerTreeHost->setRootLayer(m_rootLayer); | 2564 m_layerTreeHost->setRootLayer(m_rootLayer); |
2567 | 2565 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2632 | 2630 |
2633 private: | 2631 private: |
2634 EvictionTestLayer() : Layer() { } | 2632 EvictionTestLayer() : Layer() { } |
2635 virtual ~EvictionTestLayer() { } | 2633 virtual ~EvictionTestLayer() { } |
2636 | 2634 |
2637 void createTextureIfNeeded() | 2635 void createTextureIfNeeded() |
2638 { | 2636 { |
2639 if (m_texture.get()) | 2637 if (m_texture.get()) |
2640 return; | 2638 return; |
2641 m_texture = PrioritizedTexture::create(layerTreeHost()->contentsTextureM
anager()); | 2639 m_texture = PrioritizedTexture::create(layerTreeHost()->contentsTextureM
anager()); |
2642 m_texture->setDimensions(IntSize(10, 10), GL_RGBA); | 2640 m_texture->setDimensions(gfx::Size(10, 10), GL_RGBA); |
2643 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); | 2641 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); |
2644 } | 2642 } |
2645 | 2643 |
2646 scoped_ptr<PrioritizedTexture> m_texture; | 2644 scoped_ptr<PrioritizedTexture> m_texture; |
2647 SkBitmap m_bitmap; | 2645 SkBitmap m_bitmap; |
2648 }; | 2646 }; |
2649 | 2647 |
2650 class EvictionTestLayerImpl : public LayerImpl { | 2648 class EvictionTestLayerImpl : public LayerImpl { |
2651 public: | 2649 public: |
2652 static scoped_ptr<EvictionTestLayerImpl> create(int id) | 2650 static scoped_ptr<EvictionTestLayerImpl> create(int id) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 LayerTreeHostTestEvictTextures() | 2707 LayerTreeHostTestEvictTextures() |
2710 : m_layer(EvictionTestLayer::create()) | 2708 : m_layer(EvictionTestLayer::create()) |
2711 , m_implForEvictTextures(0) | 2709 , m_implForEvictTextures(0) |
2712 , m_numCommits(0) | 2710 , m_numCommits(0) |
2713 { | 2711 { |
2714 } | 2712 } |
2715 | 2713 |
2716 virtual void beginTest() OVERRIDE | 2714 virtual void beginTest() OVERRIDE |
2717 { | 2715 { |
2718 m_layerTreeHost->setRootLayer(m_layer); | 2716 m_layerTreeHost->setRootLayer(m_layer); |
2719 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20)); | 2717 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); |
2720 | 2718 |
2721 WebTransformationMatrix identityMatrix; | 2719 WebTransformationMatrix identityMatrix; |
2722 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin
t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); | 2720 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::Poin
tF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); |
2723 | 2721 |
2724 postSetNeedsCommitToMainThread(); | 2722 postSetNeedsCommitToMainThread(); |
2725 } | 2723 } |
2726 | 2724 |
2727 void postEvictTextures() | 2725 void postEvictTextures() |
2728 { | 2726 { |
2729 DCHECK(implThread()); | 2727 DCHECK(implThread()); |
2730 implThread()->postTask(base::Bind(&LayerTreeHostTestEvictTextures::evict
TexturesOnImplThread, | 2728 implThread()->postTask(base::Bind(&LayerTreeHostTestEvictTextures::evict
TexturesOnImplThread, |
2731 base::Unretained(this))); | 2729 base::Unretained(this))); |
2732 } | 2730 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2842 LayerTreeHostTestLostContextAfterEvictTextures() | 2840 LayerTreeHostTestLostContextAfterEvictTextures() |
2843 : m_layer(EvictionTestLayer::create()) | 2841 : m_layer(EvictionTestLayer::create()) |
2844 , m_implForEvictTextures(0) | 2842 , m_implForEvictTextures(0) |
2845 , m_numCommits(0) | 2843 , m_numCommits(0) |
2846 { | 2844 { |
2847 } | 2845 } |
2848 | 2846 |
2849 virtual void beginTest() OVERRIDE | 2847 virtual void beginTest() OVERRIDE |
2850 { | 2848 { |
2851 m_layerTreeHost->setRootLayer(m_layer); | 2849 m_layerTreeHost->setRootLayer(m_layer); |
2852 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20)); | 2850 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); |
2853 | 2851 |
2854 WebTransformationMatrix identityMatrix; | 2852 WebTransformationMatrix identityMatrix; |
2855 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin
t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); | 2853 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::Poin
tF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); |
2856 | 2854 |
2857 postSetNeedsCommitToMainThread(); | 2855 postSetNeedsCommitToMainThread(); |
2858 } | 2856 } |
2859 | 2857 |
2860 void postEvictTextures() | 2858 void postEvictTextures() |
2861 { | 2859 { |
2862 if (implThread()) { | 2860 if (implThread()) { |
2863 implThread()->postTask(base::Bind(&LayerTreeHostTestLostContextAfter
EvictTextures::evictTexturesOnImplThread, | 2861 implThread()->postTask(base::Bind(&LayerTreeHostTestLostContextAfter
EvictTextures::evictTexturesOnImplThread, |
2864 base::Unretained(this))); | 2862 base::Unretained(this))); |
2865 } else { | 2863 } else { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2967 } | 2965 } |
2968 | 2966 |
2969 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() | 2967 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() |
2970 { | 2968 { |
2971 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC
ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes(
)).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSur
face>(); | 2969 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC
ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes(
)).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSur
face>(); |
2972 } | 2970 } |
2973 | 2971 |
2974 virtual void beginTest() | 2972 virtual void beginTest() |
2975 { | 2973 { |
2976 m_layerTreeHost->setRootLayer(m_parent); | 2974 m_layerTreeHost->setRootLayer(m_parent); |
2977 m_layerTreeHost->setViewportSize(IntSize(m_numChildren, 1), IntSize(m_nu
mChildren, 1)); | 2975 m_layerTreeHost->setViewportSize(gfx::Size(m_numChildren, 1), gfx::Size(
m_numChildren, 1)); |
2978 | 2976 |
2979 WebTransformationMatrix identityMatrix; | 2977 WebTransformationMatrix identityMatrix; |
2980 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, FloatPoi
nt(0, 0), FloatPoint(0, 0), IntSize(m_numChildren, 1), true); | 2978 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi
ntF(0, 0), gfx::PointF(0, 0), gfx::Size(m_numChildren, 1), true); |
2981 for (int i = 0; i < m_numChildren; i++) | 2979 for (int i = 0; i < m_numChildren; i++) |
2982 setLayerPropertiesForTesting(m_children[i].get(), m_parent.get(), id
entityMatrix, FloatPoint(0, 0), FloatPoint(i, 0), IntSize(1, 1), false); | 2980 setLayerPropertiesForTesting(m_children[i].get(), m_parent.get(), id
entityMatrix, gfx::PointF(0, 0), gfx::PointF(i, 0), gfx::Size(1, 1), false); |
2983 | 2981 |
2984 postSetNeedsCommitToMainThread(); | 2982 postSetNeedsCommitToMainThread(); |
2985 } | 2983 } |
2986 | 2984 |
2987 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) | 2985 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) |
2988 { | 2986 { |
2989 endTest(); | 2987 endTest(); |
2990 } | 2988 } |
2991 | 2989 |
2992 virtual void layout() | 2990 virtual void layout() |
(...skipping 22 matching lines...) Expand all Loading... |
3015 class LayerTreeHostTestContinuousCommit : public LayerTreeHostTest { | 3013 class LayerTreeHostTestContinuousCommit : public LayerTreeHostTest { |
3016 public: | 3014 public: |
3017 LayerTreeHostTestContinuousCommit() | 3015 LayerTreeHostTestContinuousCommit() |
3018 : m_numCommitComplete(0) | 3016 : m_numCommitComplete(0) |
3019 , m_numDrawLayers(0) | 3017 , m_numDrawLayers(0) |
3020 { | 3018 { |
3021 } | 3019 } |
3022 | 3020 |
3023 virtual void beginTest() OVERRIDE | 3021 virtual void beginTest() OVERRIDE |
3024 { | 3022 { |
3025 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 3023 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
3026 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); | 3024 m_layerTreeHost->rootLayer()->setBounds(gfx::Size(10, 10)); |
3027 | 3025 |
3028 postSetNeedsCommitToMainThread(); | 3026 postSetNeedsCommitToMainThread(); |
3029 } | 3027 } |
3030 | 3028 |
3031 virtual void didCommit() OVERRIDE | 3029 virtual void didCommit() OVERRIDE |
3032 { | 3030 { |
3033 postSetNeedsCommitToMainThread(); | 3031 postSetNeedsCommitToMainThread(); |
3034 } | 3032 } |
3035 | 3033 |
3036 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 3034 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
(...skipping 28 matching lines...) Expand all Loading... |
3065 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { | 3063 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { |
3066 public: | 3064 public: |
3067 LayerTreeHostTestContinuousInvalidate() | 3065 LayerTreeHostTestContinuousInvalidate() |
3068 : m_numCommitComplete(0) | 3066 : m_numCommitComplete(0) |
3069 , m_numDrawLayers(0) | 3067 , m_numDrawLayers(0) |
3070 { | 3068 { |
3071 } | 3069 } |
3072 | 3070 |
3073 virtual void beginTest() OVERRIDE | 3071 virtual void beginTest() OVERRIDE |
3074 { | 3072 { |
3075 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 3073 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
3076 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); | 3074 m_layerTreeHost->rootLayer()->setBounds(gfx::Size(10, 10)); |
3077 | 3075 |
3078 m_contentLayer = ContentLayer::create(&m_mockDelegate); | 3076 m_contentLayer = ContentLayer::create(&m_mockDelegate); |
3079 m_contentLayer->setBounds(gfx::Size(10, 10)); | 3077 m_contentLayer->setBounds(gfx::Size(10, 10)); |
3080 m_contentLayer->setPosition(gfx::PointF(0, 0)); | 3078 m_contentLayer->setPosition(gfx::PointF(0, 0)); |
3081 m_contentLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3079 m_contentLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3082 m_contentLayer->setIsDrawable(true); | 3080 m_contentLayer->setIsDrawable(true); |
3083 m_layerTreeHost->rootLayer()->addChild(m_contentLayer); | 3081 m_layerTreeHost->rootLayer()->addChild(m_contentLayer); |
3084 | 3082 |
3085 postSetNeedsCommitToMainThread(); | 3083 postSetNeedsCommitToMainThread(); |
3086 } | 3084 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3167 class LayerTreeHostTestContinuousAnimate : public LayerTreeHostTest { | 3165 class LayerTreeHostTestContinuousAnimate : public LayerTreeHostTest { |
3168 public: | 3166 public: |
3169 LayerTreeHostTestContinuousAnimate() | 3167 LayerTreeHostTestContinuousAnimate() |
3170 : m_numCommitComplete(0) | 3168 : m_numCommitComplete(0) |
3171 , m_numDrawLayers(0) | 3169 , m_numDrawLayers(0) |
3172 { | 3170 { |
3173 } | 3171 } |
3174 | 3172 |
3175 virtual void beginTest() OVERRIDE | 3173 virtual void beginTest() OVERRIDE |
3176 { | 3174 { |
3177 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 3175 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
3178 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); | 3176 m_layerTreeHost->rootLayer()->setBounds(gfx::Size(10, 10)); |
3179 | 3177 |
3180 postSetNeedsCommitToMainThread(); | 3178 postSetNeedsCommitToMainThread(); |
3181 } | 3179 } |
3182 | 3180 |
3183 virtual void animate(base::TimeTicks) OVERRIDE | 3181 virtual void animate(base::TimeTicks) OVERRIDE |
3184 { | 3182 { |
3185 m_layerTreeHost->setNeedsAnimate(); | 3183 m_layerTreeHost->setNeedsAnimate(); |
3186 } | 3184 } |
3187 | 3185 |
3188 virtual void layout() OVERRIDE | 3186 virtual void layout() OVERRIDE |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3266 int m_numCommitsDeferred; | 3264 int m_numCommitsDeferred; |
3267 int m_numCompleteCommits; | 3265 int m_numCompleteCommits; |
3268 }; | 3266 }; |
3269 | 3267 |
3270 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) | 3268 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) |
3271 { | 3269 { |
3272 runTest(true); | 3270 runTest(true); |
3273 } | 3271 } |
3274 | 3272 |
3275 } // namespace | 3273 } // namespace |
OLD | NEW |