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

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 1126253005: cc: Add LayerTreeHost::InitParams for LayerTreeHost creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_unittest_no_message_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 private: 2354 private:
2355 int num_will_begin_impl_frame_; 2355 int num_will_begin_impl_frame_;
2356 int num_send_begin_main_frame_; 2356 int num_send_begin_main_frame_;
2357 }; 2357 };
2358 2358
2359 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); 2359 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits);
2360 2360
2361 class LayerTreeHostWithProxy : public LayerTreeHost { 2361 class LayerTreeHostWithProxy : public LayerTreeHost {
2362 public: 2362 public:
2363 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, 2363 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client,
2364 const LayerTreeSettings& settings, 2364 scoped_ptr<FakeProxy> proxy,
2365 scoped_ptr<FakeProxy> proxy) 2365 LayerTreeHost::InitParams* params)
2366 : LayerTreeHost(client, NULL, NULL, NULL, settings) { 2366 : LayerTreeHost(params) {
2367 proxy->SetLayerTreeHost(this); 2367 proxy->SetLayerTreeHost(this);
2368 client->SetLayerTreeHost(this); 2368 client->SetLayerTreeHost(this);
2369 InitializeForTesting(proxy.Pass()); 2369 InitializeForTesting(proxy.Pass());
2370 } 2370 }
2371 }; 2371 };
2372 2372
2373 TEST(LayerTreeHostTest, LimitPartialUpdates) { 2373 TEST(LayerTreeHostTest, LimitPartialUpdates) {
2374 // When partial updates are not allowed, max updates should be 0. 2374 // When partial updates are not allowed, max updates should be 0.
2375 { 2375 {
2376 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2376 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2377 2377
2378 scoped_ptr<FakeProxy> proxy(new FakeProxy); 2378 scoped_ptr<FakeProxy> proxy(new FakeProxy);
2379 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; 2379 proxy->GetRendererCapabilities().allow_partial_texture_updates = false;
2380 proxy->SetMaxPartialTextureUpdates(5); 2380 proxy->SetMaxPartialTextureUpdates(5);
2381 2381
2382 LayerTreeSettings settings; 2382 LayerTreeSettings settings;
2383 settings.impl_side_painting = false; 2383 settings.impl_side_painting = false;
2384 settings.max_partial_texture_updates = 10; 2384 settings.max_partial_texture_updates = 10;
2385 2385
2386 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); 2386 LayerTreeHost::InitParams params;
2387 params.client = &client;
2388 params.settings = &settings;
2389 LayerTreeHostWithProxy host(&client, proxy.Pass(), &params);
2387 2390
2388 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); 2391 EXPECT_EQ(0u, host.MaxPartialTextureUpdates());
2389 } 2392 }
2390 2393
2391 // When partial updates are allowed, 2394 // When partial updates are allowed,
2392 // max updates should be limited by the proxy. 2395 // max updates should be limited by the proxy.
2393 { 2396 {
2394 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2397 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2395 2398
2396 scoped_ptr<FakeProxy> proxy(new FakeProxy); 2399 scoped_ptr<FakeProxy> proxy(new FakeProxy);
2397 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; 2400 proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
2398 proxy->SetMaxPartialTextureUpdates(5); 2401 proxy->SetMaxPartialTextureUpdates(5);
2399 2402
2400 LayerTreeSettings settings; 2403 LayerTreeSettings settings;
2401 settings.impl_side_painting = false; 2404 settings.impl_side_painting = false;
2402 settings.max_partial_texture_updates = 10; 2405 settings.max_partial_texture_updates = 10;
2403 2406
2404 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); 2407 LayerTreeHost::InitParams params;
2408 params.client = &client;
2409 params.settings = &settings;
2410 LayerTreeHostWithProxy host(&client, proxy.Pass(), &params);
2405 2411
2406 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); 2412 EXPECT_EQ(5u, host.MaxPartialTextureUpdates());
2407 } 2413 }
2408 2414
2409 // When partial updates are allowed, 2415 // When partial updates are allowed,
2410 // max updates should also be limited by the settings. 2416 // max updates should also be limited by the settings.
2411 { 2417 {
2412 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2418 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2413 2419
2414 scoped_ptr<FakeProxy> proxy(new FakeProxy); 2420 scoped_ptr<FakeProxy> proxy(new FakeProxy);
2415 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; 2421 proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
2416 proxy->SetMaxPartialTextureUpdates(20); 2422 proxy->SetMaxPartialTextureUpdates(20);
2417 2423
2418 LayerTreeSettings settings; 2424 LayerTreeSettings settings;
2419 settings.impl_side_painting = false; 2425 settings.impl_side_painting = false;
2420 settings.max_partial_texture_updates = 10; 2426 settings.max_partial_texture_updates = 10;
2421 2427
2422 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); 2428 LayerTreeHost::InitParams params;
2429 params.client = &client;
2430 params.settings = &settings;
2431 LayerTreeHostWithProxy host(&client, proxy.Pass(), &params);
2423 2432
2424 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); 2433 EXPECT_EQ(10u, host.MaxPartialTextureUpdates());
2425 } 2434 }
2426 } 2435 }
2427 2436
2428 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { 2437 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) {
2429 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2438 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2430 2439
2431 LayerTreeSettings settings; 2440 LayerTreeSettings settings;
2432 settings.max_partial_texture_updates = 4; 2441 settings.max_partial_texture_updates = 4;
2433 settings.single_thread_proxy_scheduler = false; 2442 settings.single_thread_proxy_scheduler = false;
2434 settings.impl_side_painting = false; 2443 settings.impl_side_painting = false;
2435 2444
2436 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2445 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2437 new TestSharedBitmapManager()); 2446 new TestSharedBitmapManager());
2438 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( 2447 LayerTreeHost::InitParams params;
2439 &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, 2448 params.client = &client;
2440 base::ThreadTaskRunnerHandle::Get(), nullptr); 2449 params.shared_bitmap_manager = shared_bitmap_manager.get();
2450 params.settings = &settings;
2451 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
2452 scoped_ptr<LayerTreeHost> host =
2453 LayerTreeHost::CreateSingleThreaded(&client, &params);
2441 client.SetLayerTreeHost(host.get()); 2454 client.SetLayerTreeHost(host.get());
2442 host->Composite(base::TimeTicks::Now()); 2455 host->Composite(base::TimeTicks::Now());
2443 2456
2444 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); 2457 EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
2445 } 2458 }
2446 2459
2447 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { 2460 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) {
2448 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); 2461 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE);
2449 2462
2450 LayerTreeSettings settings; 2463 LayerTreeSettings settings;
2451 settings.max_partial_texture_updates = 4; 2464 settings.max_partial_texture_updates = 4;
2452 settings.single_thread_proxy_scheduler = false; 2465 settings.single_thread_proxy_scheduler = false;
2453 settings.impl_side_painting = false; 2466 settings.impl_side_painting = false;
2454 2467
2455 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2468 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2456 new TestSharedBitmapManager()); 2469 new TestSharedBitmapManager());
2457 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( 2470 LayerTreeHost::InitParams params;
2458 &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, 2471 params.client = &client;
2459 base::ThreadTaskRunnerHandle::Get(), nullptr); 2472 params.shared_bitmap_manager = shared_bitmap_manager.get();
2473 params.settings = &settings;
2474 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
2475 scoped_ptr<LayerTreeHost> host =
2476 LayerTreeHost::CreateSingleThreaded(&client, &params);
2460 client.SetLayerTreeHost(host.get()); 2477 client.SetLayerTreeHost(host.get());
2461 host->Composite(base::TimeTicks::Now()); 2478 host->Composite(base::TimeTicks::Now());
2462 2479
2463 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); 2480 EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
2464 } 2481 }
2465 2482
2466 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { 2483 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) {
2467 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); 2484 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D);
2468 2485
2469 LayerTreeSettings settings; 2486 LayerTreeSettings settings;
2470 settings.max_partial_texture_updates = 4; 2487 settings.max_partial_texture_updates = 4;
2471 settings.single_thread_proxy_scheduler = false; 2488 settings.single_thread_proxy_scheduler = false;
2472 settings.impl_side_painting = false; 2489 settings.impl_side_painting = false;
2473 2490
2474 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2491 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2475 new TestSharedBitmapManager()); 2492 new TestSharedBitmapManager());
2476 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( 2493 LayerTreeHost::InitParams params;
2477 &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, 2494 params.client = &client;
2478 base::ThreadTaskRunnerHandle::Get(), nullptr); 2495 params.shared_bitmap_manager = shared_bitmap_manager.get();
2496 params.settings = &settings;
2497 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
2498 scoped_ptr<LayerTreeHost> host =
2499 LayerTreeHost::CreateSingleThreaded(&client, &params);
2479 client.SetLayerTreeHost(host.get()); 2500 client.SetLayerTreeHost(host.get());
2480 host->Composite(base::TimeTicks::Now()); 2501 host->Composite(base::TimeTicks::Now());
2481 2502
2482 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); 2503 EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
2483 } 2504 }
2484 2505
2485 TEST(LayerTreeHostTest, 2506 TEST(LayerTreeHostTest,
2486 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { 2507 PartialUpdatesWithDelegatingRendererAndSoftwareContent) {
2487 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); 2508 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE);
2488 2509
2489 LayerTreeSettings settings; 2510 LayerTreeSettings settings;
2490 settings.max_partial_texture_updates = 4; 2511 settings.max_partial_texture_updates = 4;
2491 settings.single_thread_proxy_scheduler = false; 2512 settings.single_thread_proxy_scheduler = false;
2492 settings.impl_side_painting = false; 2513 settings.impl_side_painting = false;
2493 2514
2494 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2515 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2495 new TestSharedBitmapManager()); 2516 new TestSharedBitmapManager());
2496 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( 2517 LayerTreeHost::InitParams params;
2497 &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, 2518 params.client = &client;
2498 base::ThreadTaskRunnerHandle::Get(), nullptr); 2519 params.shared_bitmap_manager = shared_bitmap_manager.get();
2520 params.settings = &settings;
2521 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
2522 scoped_ptr<LayerTreeHost> host =
2523 LayerTreeHost::CreateSingleThreaded(&client, &params);
2499 client.SetLayerTreeHost(host.get()); 2524 client.SetLayerTreeHost(host.get());
2500 host->Composite(base::TimeTicks::Now()); 2525 host->Composite(base::TimeTicks::Now());
2501 2526
2502 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); 2527 EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
2503 } 2528 }
2504 2529
2505 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. 2530 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
2506 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted 2531 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
2507 : public LayerTreeHostTest { 2532 : public LayerTreeHostTest {
2508 public: 2533 public:
(...skipping 4541 matching lines...) Expand 10 before | Expand all | Expand 10 after
7050 void AfterTest() override {} 7075 void AfterTest() override {}
7051 7076
7052 scoped_refptr<FakePictureLayer> content_child_layer_; 7077 scoped_refptr<FakePictureLayer> content_child_layer_;
7053 FakeContentLayerClient client_; 7078 FakeContentLayerClient client_;
7054 }; 7079 };
7055 7080
7056 SINGLE_AND_MULTI_THREAD_TEST_F( 7081 SINGLE_AND_MULTI_THREAD_TEST_F(
7057 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); 7082 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild);
7058 7083
7059 } // namespace cc 7084 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_unittest_no_message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698