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

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: all 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
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 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 private: 2329 private:
2330 int num_will_begin_impl_frame_; 2330 int num_will_begin_impl_frame_;
2331 int num_send_begin_main_frame_; 2331 int num_send_begin_main_frame_;
2332 }; 2332 };
2333 2333
2334 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); 2334 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits);
2335 2335
2336 class LayerTreeHostWithProxy : public LayerTreeHost { 2336 class LayerTreeHostWithProxy : public LayerTreeHost {
2337 public: 2337 public:
2338 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, 2338 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client,
2339 const LayerTreeSettings& settings, 2339 scoped_ptr<FakeProxy> proxy,
2340 scoped_ptr<FakeProxy> proxy) 2340 LayerTreeHost::InitParams* params)
2341 : LayerTreeHost(client, NULL, NULL, NULL, settings) { 2341 : LayerTreeHost(params) {
2342 proxy->SetLayerTreeHost(this); 2342 proxy->SetLayerTreeHost(this);
2343 client->SetLayerTreeHost(this); 2343 client->SetLayerTreeHost(this);
2344 InitializeForTesting(proxy.Pass()); 2344 InitializeForTesting(proxy.Pass());
2345 } 2345 }
2346 }; 2346 };
2347 2347
2348 TEST(LayerTreeHostTest, LimitPartialUpdates) { 2348 TEST(LayerTreeHostTest, LimitPartialUpdates) {
2349 // When partial updates are not allowed, max updates should be 0. 2349 // When partial updates are not allowed, max updates should be 0.
2350 { 2350 {
2351 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2351 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2352 2352
2353 scoped_ptr<FakeProxy> proxy(new FakeProxy); 2353 scoped_ptr<FakeProxy> proxy(new FakeProxy);
2354 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; 2354 proxy->GetRendererCapabilities().allow_partial_texture_updates = false;
2355 proxy->SetMaxPartialTextureUpdates(5); 2355 proxy->SetMaxPartialTextureUpdates(5);
2356 2356
2357 LayerTreeSettings settings; 2357 LayerTreeSettings settings;
2358 settings.impl_side_painting = false; 2358 settings.impl_side_painting = false;
2359 settings.max_partial_texture_updates = 10; 2359 settings.max_partial_texture_updates = 10;
2360 2360
2361 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); 2361 LayerTreeHost::InitParams params;
2362 params.client = &client;
2363 params.settings = &settings;
2364 LayerTreeHostWithProxy host(&client, proxy.Pass(), &params);
2362 2365
2363 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); 2366 EXPECT_EQ(0u, host.MaxPartialTextureUpdates());
2364 } 2367 }
2365 2368
2366 // When partial updates are allowed, 2369 // When partial updates are allowed,
2367 // max updates should be limited by the proxy. 2370 // max updates should be limited by the proxy.
2368 { 2371 {
2369 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2372 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2370 2373
2371 scoped_ptr<FakeProxy> proxy(new FakeProxy); 2374 scoped_ptr<FakeProxy> proxy(new FakeProxy);
2372 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; 2375 proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
2373 proxy->SetMaxPartialTextureUpdates(5); 2376 proxy->SetMaxPartialTextureUpdates(5);
2374 2377
2375 LayerTreeSettings settings; 2378 LayerTreeSettings settings;
2376 settings.impl_side_painting = false; 2379 settings.impl_side_painting = false;
2377 settings.max_partial_texture_updates = 10; 2380 settings.max_partial_texture_updates = 10;
2378 2381
2379 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); 2382 LayerTreeHost::InitParams params;
2383 params.client = &client;
2384 params.settings = &settings;
2385 LayerTreeHostWithProxy host(&client, proxy.Pass(), &params);
2380 2386
2381 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); 2387 EXPECT_EQ(5u, host.MaxPartialTextureUpdates());
2382 } 2388 }
2383 2389
2384 // When partial updates are allowed, 2390 // When partial updates are allowed,
2385 // max updates should also be limited by the settings. 2391 // max updates should also be limited by the settings.
2386 { 2392 {
2387 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2393 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2388 2394
2389 scoped_ptr<FakeProxy> proxy(new FakeProxy); 2395 scoped_ptr<FakeProxy> proxy(new FakeProxy);
2390 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; 2396 proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
2391 proxy->SetMaxPartialTextureUpdates(20); 2397 proxy->SetMaxPartialTextureUpdates(20);
2392 2398
2393 LayerTreeSettings settings; 2399 LayerTreeSettings settings;
2394 settings.impl_side_painting = false; 2400 settings.impl_side_painting = false;
2395 settings.max_partial_texture_updates = 10; 2401 settings.max_partial_texture_updates = 10;
2396 2402
2397 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); 2403 LayerTreeHost::InitParams params;
2404 params.client = &client;
2405 params.settings = &settings;
2406 LayerTreeHostWithProxy host(&client, proxy.Pass(), &params);
2398 2407
2399 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); 2408 EXPECT_EQ(10u, host.MaxPartialTextureUpdates());
2400 } 2409 }
2401 } 2410 }
2402 2411
2403 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { 2412 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) {
2404 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2413 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2405 2414
2406 LayerTreeSettings settings; 2415 LayerTreeSettings settings;
2407 settings.max_partial_texture_updates = 4; 2416 settings.max_partial_texture_updates = 4;
2408 settings.single_thread_proxy_scheduler = false; 2417 settings.single_thread_proxy_scheduler = false;
2409 settings.impl_side_painting = false; 2418 settings.impl_side_painting = false;
2410 2419
2411 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2420 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2412 new TestSharedBitmapManager()); 2421 new TestSharedBitmapManager());
2413 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( 2422 LayerTreeHost::InitParams params;
2414 &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, 2423 params.client = &client;
2415 base::ThreadTaskRunnerHandle::Get(), nullptr); 2424 params.shared_bitmap_manager = shared_bitmap_manager.get();
2425 params.settings = &settings;
2426 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
2427 scoped_ptr<LayerTreeHost> host =
2428 LayerTreeHost::CreateSingleThreaded(&client, &params);
2416 client.SetLayerTreeHost(host.get()); 2429 client.SetLayerTreeHost(host.get());
2417 host->Composite(base::TimeTicks::Now()); 2430 host->Composite(base::TimeTicks::Now());
2418 2431
2419 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); 2432 EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
2420 } 2433 }
2421 2434
2422 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { 2435 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) {
2423 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); 2436 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE);
2424 2437
2425 LayerTreeSettings settings; 2438 LayerTreeSettings settings;
2426 settings.max_partial_texture_updates = 4; 2439 settings.max_partial_texture_updates = 4;
2427 settings.single_thread_proxy_scheduler = false; 2440 settings.single_thread_proxy_scheduler = false;
2428 settings.impl_side_painting = false; 2441 settings.impl_side_painting = false;
2429 2442
2430 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2443 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2431 new TestSharedBitmapManager()); 2444 new TestSharedBitmapManager());
2432 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( 2445 LayerTreeHost::InitParams params;
2433 &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, 2446 params.client = &client;
2434 base::ThreadTaskRunnerHandle::Get(), nullptr); 2447 params.shared_bitmap_manager = shared_bitmap_manager.get();
2448 params.settings = &settings;
2449 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
2450 scoped_ptr<LayerTreeHost> host =
2451 LayerTreeHost::CreateSingleThreaded(&client, &params);
2435 client.SetLayerTreeHost(host.get()); 2452 client.SetLayerTreeHost(host.get());
2436 host->Composite(base::TimeTicks::Now()); 2453 host->Composite(base::TimeTicks::Now());
2437 2454
2438 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); 2455 EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
2439 } 2456 }
2440 2457
2441 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { 2458 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) {
2442 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); 2459 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D);
2443 2460
2444 LayerTreeSettings settings; 2461 LayerTreeSettings settings;
2445 settings.max_partial_texture_updates = 4; 2462 settings.max_partial_texture_updates = 4;
2446 settings.single_thread_proxy_scheduler = false; 2463 settings.single_thread_proxy_scheduler = false;
2447 settings.impl_side_painting = false; 2464 settings.impl_side_painting = false;
2448 2465
2449 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2466 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2450 new TestSharedBitmapManager()); 2467 new TestSharedBitmapManager());
2451 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( 2468 LayerTreeHost::InitParams params;
2452 &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, 2469 params.client = &client;
2453 base::ThreadTaskRunnerHandle::Get(), nullptr); 2470 params.shared_bitmap_manager = shared_bitmap_manager.get();
2471 params.settings = &settings;
2472 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
2473 scoped_ptr<LayerTreeHost> host =
2474 LayerTreeHost::CreateSingleThreaded(&client, &params);
2454 client.SetLayerTreeHost(host.get()); 2475 client.SetLayerTreeHost(host.get());
2455 host->Composite(base::TimeTicks::Now()); 2476 host->Composite(base::TimeTicks::Now());
2456 2477
2457 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); 2478 EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
2458 } 2479 }
2459 2480
2460 TEST(LayerTreeHostTest, 2481 TEST(LayerTreeHostTest,
2461 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { 2482 PartialUpdatesWithDelegatingRendererAndSoftwareContent) {
2462 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); 2483 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE);
2463 2484
2464 LayerTreeSettings settings; 2485 LayerTreeSettings settings;
2465 settings.max_partial_texture_updates = 4; 2486 settings.max_partial_texture_updates = 4;
2466 settings.single_thread_proxy_scheduler = false; 2487 settings.single_thread_proxy_scheduler = false;
2467 settings.impl_side_painting = false; 2488 settings.impl_side_painting = false;
2468 2489
2469 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2490 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2470 new TestSharedBitmapManager()); 2491 new TestSharedBitmapManager());
2471 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( 2492 LayerTreeHost::InitParams params;
2472 &client, &client, shared_bitmap_manager.get(), NULL, NULL, settings, 2493 params.client = &client;
2473 base::ThreadTaskRunnerHandle::Get(), nullptr); 2494 params.shared_bitmap_manager = shared_bitmap_manager.get();
2495 params.settings = &settings;
2496 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
2497 scoped_ptr<LayerTreeHost> host =
2498 LayerTreeHost::CreateSingleThreaded(&client, &params);
2474 client.SetLayerTreeHost(host.get()); 2499 client.SetLayerTreeHost(host.get());
2475 host->Composite(base::TimeTicks::Now()); 2500 host->Composite(base::TimeTicks::Now());
2476 2501
2477 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); 2502 EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
2478 } 2503 }
2479 2504
2480 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. 2505 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
2481 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted 2506 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
2482 : public LayerTreeHostTest { 2507 : public LayerTreeHostTest {
2483 public: 2508 public:
(...skipping 4541 matching lines...) Expand 10 before | Expand all | Expand 10 after
7025 void AfterTest() override {} 7050 void AfterTest() override {}
7026 7051
7027 scoped_refptr<FakePictureLayer> content_child_layer_; 7052 scoped_refptr<FakePictureLayer> content_child_layer_;
7028 FakeContentLayerClient client_; 7053 FakeContentLayerClient client_;
7029 }; 7054 };
7030 7055
7031 SINGLE_AND_MULTI_THREAD_TEST_F( 7056 SINGLE_AND_MULTI_THREAD_TEST_F(
7032 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); 7057 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild);
7033 7058
7034 } // namespace cc 7059 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698