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

Side by Side Diff: cc/resources/resource_provider_unittest.cc

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: rebase Created 4 years, 3 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <deque> 11 #include <deque>
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 #include <unordered_map> 14 #include <unordered_map>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/ptr_util.h" 19 #include "base/memory/ptr_util.h"
20 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
21 #include "cc/output/buffer_to_texture_target_map.h" 21 #include "cc/output/buffer_to_texture_target_map.h"
22 #include "cc/output/output_surface.h"
23 #include "cc/resources/returned_resource.h" 22 #include "cc/resources/returned_resource.h"
24 #include "cc/resources/shared_bitmap_manager.h" 23 #include "cc/resources/shared_bitmap_manager.h"
25 #include "cc/resources/single_release_callback.h" 24 #include "cc/resources/single_release_callback.h"
26 #include "cc/test/fake_output_surface.h" 25 #include "cc/test/test_context_provider.h"
27 #include "cc/test/fake_output_surface_client.h"
28 #include "cc/test/test_gpu_memory_buffer_manager.h" 26 #include "cc/test/test_gpu_memory_buffer_manager.h"
29 #include "cc/test/test_shared_bitmap_manager.h" 27 #include "cc/test/test_shared_bitmap_manager.h"
30 #include "cc/test/test_texture.h" 28 #include "cc/test/test_texture.h"
31 #include "cc/test/test_web_graphics_context_3d.h" 29 #include "cc/test/test_web_graphics_context_3d.h"
32 #include "cc/trees/blocking_task_runner.h" 30 #include "cc/trees/blocking_task_runner.h"
33 #include "gpu/GLES2/gl2extchromium.h" 31 #include "gpu/GLES2/gl2extchromium.h"
34 #include "testing/gmock/include/gmock/gmock.h" 32 #include "testing/gmock/include/gmock/gmock.h"
35 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
36 #include "third_party/khronos/GLES2/gl2.h" 34 #include "third_party/khronos/GLES2/gl2.h"
37 #include "third_party/khronos/GLES2/gl2ext.h" 35 #include "third_party/khronos/GLES2/gl2ext.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 : shared_data_(ContextSharedData::Create()), 422 : shared_data_(ContextSharedData::Create()),
425 context3d_(NULL), 423 context3d_(NULL),
426 child_context_(NULL), 424 child_context_(NULL),
427 main_thread_task_runner_(BlockingTaskRunner::Create(NULL)) { 425 main_thread_task_runner_(BlockingTaskRunner::Create(NULL)) {
428 switch (GetParam()) { 426 switch (GetParam()) {
429 case ResourceProvider::RESOURCE_TYPE_GPU_MEMORY_BUFFER: 427 case ResourceProvider::RESOURCE_TYPE_GPU_MEMORY_BUFFER:
430 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: { 428 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: {
431 std::unique_ptr<ResourceProviderContext> context3d( 429 std::unique_ptr<ResourceProviderContext> context3d(
432 ResourceProviderContext::Create(shared_data_.get())); 430 ResourceProviderContext::Create(shared_data_.get()));
433 context3d_ = context3d.get(); 431 context3d_ = context3d.get();
434 432 context_provider_ = TestContextProvider::Create(std::move(context3d));
435 scoped_refptr<TestContextProvider> context_provider =
436 TestContextProvider::Create(std::move(context3d));
437
438 output_surface_ = FakeOutputSurface::Create3d(context_provider);
439 433
440 std::unique_ptr<ResourceProviderContext> child_context_owned = 434 std::unique_ptr<ResourceProviderContext> child_context_owned =
441 ResourceProviderContext::Create(shared_data_.get()); 435 ResourceProviderContext::Create(shared_data_.get());
442 child_context_ = child_context_owned.get(); 436 child_context_ = child_context_owned.get();
443 if (child_needs_sync_token) { 437 child_context_provider_ =
444 child_output_surface_ = 438 TestContextProvider::Create(std::move(child_context_owned));
445 FakeOutputSurface::Create3d(std::move(child_context_owned));
446 } else {
447 child_output_surface_ = FakeOutputSurface::CreateNoRequireSyncPoint(
448 std::move(child_context_owned));
449 }
450 break; 439 break;
451 } 440 }
452 case ResourceProvider::RESOURCE_TYPE_BITMAP: 441 case ResourceProvider::RESOURCE_TYPE_BITMAP:
453 output_surface_ = FakeOutputSurface::CreateSoftware(
454 base::WrapUnique(new SoftwareOutputDevice));
455 child_output_surface_ = FakeOutputSurface::CreateSoftware(
456 base::WrapUnique(new SoftwareOutputDevice));
457 break; 442 break;
458 } 443 }
459 CHECK(output_surface_->BindToClient(&output_surface_client_));
460 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_));
461 444
462 shared_bitmap_manager_.reset(new TestSharedBitmapManager); 445 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
463 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); 446 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
464 child_gpu_memory_buffer_manager_ = 447 child_gpu_memory_buffer_manager_ =
465 gpu_memory_buffer_manager_->CreateClientGpuMemoryBufferManager(); 448 gpu_memory_buffer_manager_->CreateClientGpuMemoryBufferManager();
466 449
467 resource_provider_ = base::MakeUnique<ResourceProvider>( 450 resource_provider_ = base::MakeUnique<ResourceProvider>(
468 output_surface_->context_provider(), shared_bitmap_manager_.get(), 451 context_provider_.get(), shared_bitmap_manager_.get(),
469 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 1, 452 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 1,
470 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 453 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
471 kEnableColorCorrectRendering, 454 kEnableColorCorrectRendering,
472 DefaultBufferToTextureTargetMapForTesting()); 455 DefaultBufferToTextureTargetMapForTesting());
473 child_resource_provider_ = base::MakeUnique<ResourceProvider>( 456 child_resource_provider_ = base::MakeUnique<ResourceProvider>(
474 child_output_surface_->context_provider(), shared_bitmap_manager_.get(), 457 child_context_provider_.get(), shared_bitmap_manager_.get(),
475 child_gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 458 child_gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(),
476 0, 1, 459 0, 1, child_needs_sync_token, kUseGpuMemoryBufferResources,
477 child_output_surface_->capabilities().delegated_sync_points_required, 460 kEnableColorCorrectRendering,
478 kUseGpuMemoryBufferResources, kEnableColorCorrectRendering,
479 DefaultBufferToTextureTargetMapForTesting()); 461 DefaultBufferToTextureTargetMapForTesting());
480 } 462 }
481 463
482 ResourceProviderTest() : ResourceProviderTest(true) {} 464 ResourceProviderTest() : ResourceProviderTest(true) {}
483 465
484 static void CollectResources(ReturnedResourceArray* array, 466 static void CollectResources(ReturnedResourceArray* array,
485 const ReturnedResourceArray& returned, 467 const ReturnedResourceArray& returned,
486 BlockingTaskRunner* main_thread_task_runner) { 468 BlockingTaskRunner* main_thread_task_runner) {
487 array->insert(array->end(), returned.begin(), returned.end()); 469 array->insert(array->end(), returned.begin(), returned.end());
488 } 470 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 release_called, release_sync_token, lost_resource)); 516 release_called, release_sync_token, lost_resource));
535 return child_resource_provider_->CreateResourceFromTextureMailbox( 517 return child_resource_provider_->CreateResourceFromTextureMailbox(
536 TextureMailbox(shared_bitmap_ptr, size), std::move(callback)); 518 TextureMailbox(shared_bitmap_ptr, size), std::move(callback));
537 } 519 }
538 } 520 }
539 521
540 protected: 522 protected:
541 std::unique_ptr<ContextSharedData> shared_data_; 523 std::unique_ptr<ContextSharedData> shared_data_;
542 ResourceProviderContext* context3d_; 524 ResourceProviderContext* context3d_;
543 ResourceProviderContext* child_context_; 525 ResourceProviderContext* child_context_;
544 FakeOutputSurfaceClient output_surface_client_; 526 scoped_refptr<TestContextProvider> context_provider_;
545 FakeOutputSurfaceClient child_output_surface_client_; 527 scoped_refptr<TestContextProvider> child_context_provider_;
546 std::unique_ptr<OutputSurface> output_surface_;
547 std::unique_ptr<OutputSurface> child_output_surface_;
548 std::unique_ptr<BlockingTaskRunner> main_thread_task_runner_; 528 std::unique_ptr<BlockingTaskRunner> main_thread_task_runner_;
549 std::unique_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; 529 std::unique_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_;
550 std::unique_ptr<ResourceProvider> resource_provider_; 530 std::unique_ptr<ResourceProvider> resource_provider_;
551 std::unique_ptr<TestGpuMemoryBufferManager> child_gpu_memory_buffer_manager_; 531 std::unique_ptr<TestGpuMemoryBufferManager> child_gpu_memory_buffer_manager_;
552 std::unique_ptr<ResourceProvider> child_resource_provider_; 532 std::unique_ptr<ResourceProvider> child_resource_provider_;
553 std::unique_ptr<TestSharedBitmapManager> shared_bitmap_manager_; 533 std::unique_ptr<TestSharedBitmapManager> shared_bitmap_manager_;
554 }; 534 };
555 535
556 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, 536 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type,
557 ResourceProvider* resource_provider, 537 ResourceProvider* resource_provider,
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 for (size_t i = 0; i < list.size(); i++) { 1235 for (size_t i = 0; i < list.size(); i++) {
1256 unsigned parent_id = list[i].id; 1236 unsigned parent_id = list[i].id;
1257 resource_provider_->WaitSyncTokenIfNeeded(parent_id); 1237 resource_provider_->WaitSyncTokenIfNeeded(parent_id);
1258 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), 1238 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(),
1259 parent_id); 1239 parent_id);
1260 } 1240 }
1261 } 1241 }
1262 EXPECT_EQ(0u, returned_to_child.size()); 1242 EXPECT_EQ(0u, returned_to_child.size());
1263 1243
1264 EXPECT_EQ(2u, resource_provider_->num_resources()); 1244 EXPECT_EQ(2u, resource_provider_->num_resources());
1265 resource_provider_->DidLoseOutputSurface(); 1245 resource_provider_->DidLoseContextProvider();
1266 resource_provider_ = nullptr; 1246 resource_provider_ = nullptr;
1267 1247
1268 EXPECT_EQ(2u, returned_to_child.size()); 1248 EXPECT_EQ(2u, returned_to_child.size());
1269 1249
1270 EXPECT_TRUE(returned_to_child[0].lost); 1250 EXPECT_TRUE(returned_to_child[0].lost);
1271 EXPECT_TRUE(returned_to_child[1].lost); 1251 EXPECT_TRUE(returned_to_child[1].lost);
1272 } 1252 }
1273 1253
1274 TEST_P(ResourceProviderTest, TransferSoftwareResources) { 1254 TEST_P(ResourceProviderTest, TransferSoftwareResources) {
1275 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) 1255 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP)
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 EXPECT_EQ(expected_ids, returned_ids); 1453 EXPECT_EQ(expected_ids, returned_ids);
1474 EXPECT_FALSE(returned_to_child[0].lost); 1454 EXPECT_FALSE(returned_to_child[0].lost);
1475 EXPECT_FALSE(returned_to_child[1].lost); 1455 EXPECT_FALSE(returned_to_child[1].lost);
1476 EXPECT_FALSE(returned_to_child[2].lost); 1456 EXPECT_FALSE(returned_to_child[2].lost);
1477 } 1457 }
1478 1458
1479 TEST_P(ResourceProviderTest, TransferGLToSoftware) { 1459 TEST_P(ResourceProviderTest, TransferGLToSoftware) {
1480 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) 1460 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP)
1481 return; 1461 return;
1482 1462
1483 std::unique_ptr<ResourceProviderContext> child_context_owned( 1463 scoped_refptr<TestContextProvider> child_context_provider =
1484 ResourceProviderContext::Create(shared_data_.get())); 1464 TestContextProvider::Create(
1485 1465 ResourceProviderContext::Create(shared_data_.get()));
1486 FakeOutputSurfaceClient child_output_surface_client;
1487 std::unique_ptr<OutputSurface> child_output_surface(
1488 FakeOutputSurface::Create3d(std::move(child_context_owned)));
1489 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1490 1466
1491 std::unique_ptr<ResourceProvider> child_resource_provider( 1467 std::unique_ptr<ResourceProvider> child_resource_provider(
1492 base::MakeUnique<ResourceProvider>( 1468 base::MakeUnique<ResourceProvider>(
1493 child_output_surface->context_provider(), 1469 child_context_provider.get(), shared_bitmap_manager_.get(),
1494 shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), 1470 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
1495 nullptr, 0, 1, kDelegatedSyncPointsRequired, 1471 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
1496 kUseGpuMemoryBufferResources, kEnableColorCorrectRendering, 1472 kEnableColorCorrectRendering,
1497 DefaultBufferToTextureTargetMapForTesting())); 1473 DefaultBufferToTextureTargetMapForTesting()));
1498 1474
1499 gfx::Size size(1, 1); 1475 gfx::Size size(1, 1);
1500 ResourceFormat format = RGBA_8888; 1476 ResourceFormat format = RGBA_8888;
1501 size_t pixel_size = TextureSizeBytes(size, format); 1477 size_t pixel_size = TextureSizeBytes(size, format);
1502 ASSERT_EQ(4U, pixel_size); 1478 ASSERT_EQ(4U, pixel_size);
1503 1479
1504 ResourceId id1 = child_resource_provider->CreateResource( 1480 ResourceId id1 = child_resource_provider->CreateResource(
1505 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, 1481 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format,
1506 gfx::ColorSpace()); 1482 gfx::ColorSpace());
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 } 1975 }
2000 } 1976 }
2001 1977
2002 class ResourceProviderTestTextureFilters : public ResourceProviderTest { 1978 class ResourceProviderTestTextureFilters : public ResourceProviderTest {
2003 public: 1979 public:
2004 static void RunTest(GLenum child_filter, GLenum parent_filter) { 1980 static void RunTest(GLenum child_filter, GLenum parent_filter) {
2005 std::unique_ptr<TextureStateTrackingContext> child_context_owned( 1981 std::unique_ptr<TextureStateTrackingContext> child_context_owned(
2006 new TextureStateTrackingContext); 1982 new TextureStateTrackingContext);
2007 TextureStateTrackingContext* child_context = child_context_owned.get(); 1983 TextureStateTrackingContext* child_context = child_context_owned.get();
2008 1984
2009 FakeOutputSurfaceClient child_output_surface_client; 1985 auto child_context_provider =
2010 std::unique_ptr<OutputSurface> child_output_surface( 1986 TestContextProvider::Create(std::move(child_context_owned));
2011 FakeOutputSurface::Create3d(std::move(child_context_owned))); 1987 auto shared_bitmap_manager = base::MakeUnique<TestSharedBitmapManager>();
2012 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
2013 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
2014 new TestSharedBitmapManager());
2015 1988
2016 std::unique_ptr<ResourceProvider> child_resource_provider( 1989 std::unique_ptr<ResourceProvider> child_resource_provider(
2017 base::MakeUnique<ResourceProvider>( 1990 base::MakeUnique<ResourceProvider>(
2018 child_output_surface->context_provider(), 1991 child_context_provider.get(), shared_bitmap_manager.get(), nullptr,
2019 shared_bitmap_manager.get(), nullptr, nullptr, 0, 1, 1992 nullptr, 0, 1, kDelegatedSyncPointsRequired,
2020 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 1993 kUseGpuMemoryBufferResources, kEnableColorCorrectRendering,
2021 kEnableColorCorrectRendering,
2022 DefaultBufferToTextureTargetMapForTesting())); 1994 DefaultBufferToTextureTargetMapForTesting()));
2023 1995
2024 std::unique_ptr<TextureStateTrackingContext> parent_context_owned( 1996 std::unique_ptr<TextureStateTrackingContext> parent_context_owned(
2025 new TextureStateTrackingContext); 1997 new TextureStateTrackingContext);
2026 TextureStateTrackingContext* parent_context = parent_context_owned.get(); 1998 TextureStateTrackingContext* parent_context = parent_context_owned.get();
2027 1999
2028 FakeOutputSurfaceClient parent_output_surface_client; 2000 auto parent_context_provider =
2029 std::unique_ptr<OutputSurface> parent_output_surface( 2001 TestContextProvider::Create(std::move(parent_context_owned));
2030 FakeOutputSurface::Create3d(std::move(parent_context_owned)));
2031 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
2032 2002
2033 std::unique_ptr<ResourceProvider> parent_resource_provider( 2003 std::unique_ptr<ResourceProvider> parent_resource_provider(
2034 base::MakeUnique<ResourceProvider>( 2004 base::MakeUnique<ResourceProvider>(
2035 parent_output_surface->context_provider(), 2005 parent_context_provider.get(), shared_bitmap_manager.get(), nullptr,
2036 shared_bitmap_manager.get(), nullptr, nullptr, 0, 1, 2006 nullptr, 0, 1, kDelegatedSyncPointsRequired,
2037 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 2007 kUseGpuMemoryBufferResources, kEnableColorCorrectRendering,
2038 kEnableColorCorrectRendering,
2039 DefaultBufferToTextureTargetMapForTesting())); 2008 DefaultBufferToTextureTargetMapForTesting()));
2040 2009
2041 gfx::Size size(1, 1); 2010 gfx::Size size(1, 1);
2042 ResourceFormat format = RGBA_8888; 2011 ResourceFormat format = RGBA_8888;
2043 int child_texture_id = 1; 2012 int child_texture_id = 1;
2044 int parent_texture_id = 2; 2013 int parent_texture_id = 2;
2045 2014
2046 size_t pixel_size = TextureSizeBytes(size, format); 2015 size_t pixel_size = TextureSizeBytes(size, format);
2047 ASSERT_EQ(4U, pixel_size); 2016 ASSERT_EQ(4U, pixel_size);
2048 2017
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 EXPECT_EQ(1u, list.size()); 2313 EXPECT_EQ(1u, list.size());
2345 2314
2346 resource_provider_->ReceiveFromChild(child_id, list); 2315 resource_provider_->ReceiveFromChild(child_id, list);
2347 ResourceProvider::ResourceIdSet resource_ids_to_receive; 2316 ResourceProvider::ResourceIdSet resource_ids_to_receive;
2348 resource_ids_to_receive.insert(resource); 2317 resource_ids_to_receive.insert(resource);
2349 resource_provider_->DeclareUsedResourcesFromChild(child_id, 2318 resource_provider_->DeclareUsedResourcesFromChild(child_id,
2350 resource_ids_to_receive); 2319 resource_ids_to_receive);
2351 } 2320 }
2352 2321
2353 // Lose the output surface in the parent. 2322 // Lose the output surface in the parent.
2354 resource_provider_->DidLoseOutputSurface(); 2323 resource_provider_->DidLoseContextProvider();
2355 2324
2356 { 2325 {
2357 EXPECT_EQ(0u, returned_to_child.size()); 2326 EXPECT_EQ(0u, returned_to_child.size());
2358 2327
2359 // Transfer resources back from the parent to the child. Set no resources as 2328 // Transfer resources back from the parent to the child. Set no resources as
2360 // being in use. 2329 // being in use.
2361 ResourceProvider::ResourceIdSet no_resources; 2330 ResourceProvider::ResourceIdSet no_resources;
2362 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); 2331 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources);
2363 2332
2364 // Expect a GL resource to be lost. 2333 // Expect a GL resource to be lost.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 EXPECT_EQ(1u, list.size()); 2444 EXPECT_EQ(1u, list.size());
2476 2445
2477 resource_provider_->ReceiveFromChild(child_id, list); 2446 resource_provider_->ReceiveFromChild(child_id, list);
2478 ResourceProvider::ResourceIdSet resource_ids_to_receive; 2447 ResourceProvider::ResourceIdSet resource_ids_to_receive;
2479 resource_ids_to_receive.insert(resource); 2448 resource_ids_to_receive.insert(resource);
2480 resource_provider_->DeclareUsedResourcesFromChild(child_id, 2449 resource_provider_->DeclareUsedResourcesFromChild(child_id,
2481 resource_ids_to_receive); 2450 resource_ids_to_receive);
2482 } 2451 }
2483 2452
2484 // Lose the output surface in the parent. 2453 // Lose the output surface in the parent.
2485 resource_provider_->DidLoseOutputSurface(); 2454 resource_provider_->DidLoseContextProvider();
2486 2455
2487 { 2456 {
2488 EXPECT_EQ(0u, returned_to_child.size()); 2457 EXPECT_EQ(0u, returned_to_child.size());
2489 2458
2490 // Transfer resources back from the parent to the child. Set no resources as 2459 // Transfer resources back from the parent to the child. Set no resources as
2491 // being in use. 2460 // being in use.
2492 ResourceProvider::ResourceIdSet no_resources; 2461 ResourceProvider::ResourceIdSet no_resources;
2493 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); 2462 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources);
2494 2463
2495 ASSERT_EQ(1u, returned_to_child.size()); 2464 ASSERT_EQ(1u, returned_to_child.size());
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 SingleReleaseCallbackImpl::Create( 2611 SingleReleaseCallbackImpl::Create(
2643 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource, 2612 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource,
2644 &main_thread_task_runner)); 2613 &main_thread_task_runner));
2645 resource_provider_->CreateResourceFromTextureMailbox( 2614 resource_provider_->CreateResourceFromTextureMailbox(
2646 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), std::move(callback)); 2615 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), std::move(callback));
2647 2616
2648 EXPECT_FALSE(release_sync_token.HasData()); 2617 EXPECT_FALSE(release_sync_token.HasData());
2649 EXPECT_FALSE(lost_resource); 2618 EXPECT_FALSE(lost_resource);
2650 EXPECT_FALSE(main_thread_task_runner); 2619 EXPECT_FALSE(main_thread_task_runner);
2651 2620
2652 resource_provider_->DidLoseOutputSurface(); 2621 resource_provider_->DidLoseContextProvider();
2653 resource_provider_ = nullptr; 2622 resource_provider_ = nullptr;
2654 2623
2655 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count()); 2624 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count());
2656 EXPECT_TRUE(lost_resource); 2625 EXPECT_TRUE(lost_resource);
2657 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); 2626 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
2658 } 2627 }
2659 2628
2660 TEST_P(ResourceProviderTest, ScopedSampler) { 2629 TEST_P(ResourceProviderTest, ScopedSampler) {
2661 // Sampling is only supported for GL textures. 2630 // Sampling is only supported for GL textures.
2662 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2631 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2663 return; 2632 return;
2664 2633
2665 std::unique_ptr<TextureStateTrackingContext> context_owned( 2634 std::unique_ptr<TextureStateTrackingContext> context_owned(
2666 new TextureStateTrackingContext); 2635 new TextureStateTrackingContext);
2667 TextureStateTrackingContext* context = context_owned.get(); 2636 TextureStateTrackingContext* context = context_owned.get();
2668 2637 auto context_provider = TestContextProvider::Create(std::move(context_owned));
2669 FakeOutputSurfaceClient output_surface_client;
2670 std::unique_ptr<OutputSurface> output_surface(
2671 FakeOutputSurface::Create3d(std::move(context_owned)));
2672 CHECK(output_surface->BindToClient(&output_surface_client));
2673 2638
2674 std::unique_ptr<ResourceProvider> resource_provider( 2639 std::unique_ptr<ResourceProvider> resource_provider(
2675 base::MakeUnique<ResourceProvider>( 2640 base::MakeUnique<ResourceProvider>(
2676 output_surface->context_provider(), shared_bitmap_manager_.get(), 2641 context_provider.get(), shared_bitmap_manager_.get(),
2677 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 2642 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
2678 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 2643 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
2679 kEnableColorCorrectRendering, 2644 kEnableColorCorrectRendering,
2680 DefaultBufferToTextureTargetMapForTesting())); 2645 DefaultBufferToTextureTargetMapForTesting()));
2681 2646
2682 gfx::Size size(1, 1); 2647 gfx::Size size(1, 1);
2683 ResourceFormat format = RGBA_8888; 2648 ResourceFormat format = RGBA_8888;
2684 int texture_id = 1; 2649 int texture_id = 1;
2685 2650
2686 ResourceId id = resource_provider->CreateResource( 2651 ResourceId id = resource_provider->CreateResource(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2741 } 2706 }
2742 2707
2743 TEST_P(ResourceProviderTest, ManagedResource) { 2708 TEST_P(ResourceProviderTest, ManagedResource) {
2744 // Sampling is only supported for GL textures. 2709 // Sampling is only supported for GL textures.
2745 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2710 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2746 return; 2711 return;
2747 2712
2748 std::unique_ptr<TextureStateTrackingContext> context_owned( 2713 std::unique_ptr<TextureStateTrackingContext> context_owned(
2749 new TextureStateTrackingContext); 2714 new TextureStateTrackingContext);
2750 TextureStateTrackingContext* context = context_owned.get(); 2715 TextureStateTrackingContext* context = context_owned.get();
2751 2716 auto context_provider = TestContextProvider::Create(std::move(context_owned));
2752 FakeOutputSurfaceClient output_surface_client;
2753 std::unique_ptr<OutputSurface> output_surface(
2754 FakeOutputSurface::Create3d(std::move(context_owned)));
2755 CHECK(output_surface->BindToClient(&output_surface_client));
2756 2717
2757 std::unique_ptr<ResourceProvider> resource_provider( 2718 std::unique_ptr<ResourceProvider> resource_provider(
2758 base::MakeUnique<ResourceProvider>( 2719 base::MakeUnique<ResourceProvider>(
2759 output_surface->context_provider(), shared_bitmap_manager_.get(), 2720 context_provider.get(), shared_bitmap_manager_.get(),
2760 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 2721 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
2761 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 2722 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
2762 kEnableColorCorrectRendering, 2723 kEnableColorCorrectRendering,
2763 DefaultBufferToTextureTargetMapForTesting())); 2724 DefaultBufferToTextureTargetMapForTesting()));
2764 2725
2765 gfx::Size size(1, 1); 2726 gfx::Size size(1, 1);
2766 ResourceFormat format = RGBA_8888; 2727 ResourceFormat format = RGBA_8888;
2767 int texture_id = 1; 2728 int texture_id = 1;
2768 2729
2769 // Check that the texture gets created with the right sampler settings. 2730 // Check that the texture gets created with the right sampler settings.
(...skipping 18 matching lines...) Expand all
2788 } 2749 }
2789 2750
2790 TEST_P(ResourceProviderTest, TextureWrapMode) { 2751 TEST_P(ResourceProviderTest, TextureWrapMode) {
2791 // Sampling is only supported for GL textures. 2752 // Sampling is only supported for GL textures.
2792 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2753 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2793 return; 2754 return;
2794 2755
2795 std::unique_ptr<TextureStateTrackingContext> context_owned( 2756 std::unique_ptr<TextureStateTrackingContext> context_owned(
2796 new TextureStateTrackingContext); 2757 new TextureStateTrackingContext);
2797 TextureStateTrackingContext* context = context_owned.get(); 2758 TextureStateTrackingContext* context = context_owned.get();
2798 2759 auto context_provider = TestContextProvider::Create(std::move(context_owned));
2799 FakeOutputSurfaceClient output_surface_client;
2800 std::unique_ptr<OutputSurface> output_surface(
2801 FakeOutputSurface::Create3d(std::move(context_owned)));
2802 CHECK(output_surface->BindToClient(&output_surface_client));
2803 2760
2804 std::unique_ptr<ResourceProvider> resource_provider( 2761 std::unique_ptr<ResourceProvider> resource_provider(
2805 base::MakeUnique<ResourceProvider>( 2762 base::MakeUnique<ResourceProvider>(
2806 output_surface->context_provider(), shared_bitmap_manager_.get(), 2763 context_provider.get(), shared_bitmap_manager_.get(),
2807 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 2764 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
2808 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 2765 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
2809 kEnableColorCorrectRendering, 2766 kEnableColorCorrectRendering,
2810 DefaultBufferToTextureTargetMapForTesting())); 2767 DefaultBufferToTextureTargetMapForTesting()));
2811 2768
2812 gfx::Size size(1, 1); 2769 gfx::Size size(1, 1);
2813 ResourceFormat format = RGBA_8888; 2770 ResourceFormat format = RGBA_8888;
2814 2771
2815 for (int texture_id = 1; texture_id <= 2; ++texture_id) { 2772 for (int texture_id = 1; texture_id <= 2; ++texture_id) {
2816 // Check that the texture gets created with the right sampler settings. 2773 // Check that the texture gets created with the right sampler settings.
(...skipping 19 matching lines...) Expand all
2836 TEST_P(ResourceProviderTest, TextureHint) { 2793 TEST_P(ResourceProviderTest, TextureHint) {
2837 // Sampling is only supported for GL textures. 2794 // Sampling is only supported for GL textures.
2838 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2795 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2839 return; 2796 return;
2840 2797
2841 std::unique_ptr<TextureStateTrackingContext> context_owned( 2798 std::unique_ptr<TextureStateTrackingContext> context_owned(
2842 new TextureStateTrackingContext); 2799 new TextureStateTrackingContext);
2843 TextureStateTrackingContext* context = context_owned.get(); 2800 TextureStateTrackingContext* context = context_owned.get();
2844 context->set_support_texture_storage(true); 2801 context->set_support_texture_storage(true);
2845 context->set_support_texture_usage(true); 2802 context->set_support_texture_usage(true);
2846 2803 auto context_provider = TestContextProvider::Create(std::move(context_owned));
2847 FakeOutputSurfaceClient output_surface_client;
2848 std::unique_ptr<OutputSurface> output_surface(
2849 FakeOutputSurface::Create3d(std::move(context_owned)));
2850 CHECK(output_surface->BindToClient(&output_surface_client));
2851 2804
2852 std::unique_ptr<ResourceProvider> resource_provider( 2805 std::unique_ptr<ResourceProvider> resource_provider(
2853 base::MakeUnique<ResourceProvider>( 2806 base::MakeUnique<ResourceProvider>(
2854 output_surface->context_provider(), shared_bitmap_manager_.get(), 2807 context_provider.get(), shared_bitmap_manager_.get(),
2855 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 2808 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
2856 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 2809 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
2857 kEnableColorCorrectRendering, 2810 kEnableColorCorrectRendering,
2858 DefaultBufferToTextureTargetMapForTesting())); 2811 DefaultBufferToTextureTargetMapForTesting()));
2859 2812
2860 gfx::Size size(1, 1); 2813 gfx::Size size(1, 1);
2861 ResourceFormat format = RGBA_8888; 2814 ResourceFormat format = RGBA_8888;
2862 2815
2863 const ResourceProvider::TextureHint hints[4] = { 2816 const ResourceProvider::TextureHint hints[4] = {
2864 ResourceProvider::TEXTURE_HINT_DEFAULT, 2817 ResourceProvider::TEXTURE_HINT_DEFAULT,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 2851
2899 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) { 2852 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) {
2900 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) 2853 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP)
2901 return; 2854 return;
2902 2855
2903 gfx::Size size(64, 64); 2856 gfx::Size size(64, 64);
2904 const uint32_t kBadBeef = 0xbadbeef; 2857 const uint32_t kBadBeef = 0xbadbeef;
2905 std::unique_ptr<SharedBitmap> shared_bitmap( 2858 std::unique_ptr<SharedBitmap> shared_bitmap(
2906 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, kBadBeef)); 2859 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, kBadBeef));
2907 2860
2908 FakeOutputSurfaceClient output_surface_client;
2909 std::unique_ptr<OutputSurface> output_surface(
2910 FakeOutputSurface::CreateSoftware(
2911 base::WrapUnique(new SoftwareOutputDevice)));
2912 CHECK(output_surface->BindToClient(&output_surface_client));
2913
2914 std::unique_ptr<ResourceProvider> resource_provider( 2861 std::unique_ptr<ResourceProvider> resource_provider(
2915 base::MakeUnique<ResourceProvider>( 2862 base::MakeUnique<ResourceProvider>(
2916 output_surface->context_provider(), shared_bitmap_manager_.get(), 2863 nullptr, shared_bitmap_manager_.get(),
2917 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 2864 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
2918 1, kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 2865 1, kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
2919 kEnableColorCorrectRendering, 2866 kEnableColorCorrectRendering,
2920 DefaultBufferToTextureTargetMapForTesting())); 2867 DefaultBufferToTextureTargetMapForTesting()));
2921 2868
2922 gpu::SyncToken release_sync_token; 2869 gpu::SyncToken release_sync_token;
2923 bool lost_resource = false; 2870 bool lost_resource = false;
2924 BlockingTaskRunner* main_thread_task_runner = nullptr; 2871 BlockingTaskRunner* main_thread_task_runner = nullptr;
2925 std::unique_ptr<SingleReleaseCallbackImpl> callback = 2872 std::unique_ptr<SingleReleaseCallbackImpl> callback =
2926 SingleReleaseCallbackImpl::Create( 2873 SingleReleaseCallbackImpl::Create(
(...skipping 23 matching lines...) Expand all
2950 : public ResourceProviderTest { 2897 : public ResourceProviderTest {
2951 public: 2898 public:
2952 static void RunTest(TestSharedBitmapManager* shared_bitmap_manager, 2899 static void RunTest(TestSharedBitmapManager* shared_bitmap_manager,
2953 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, 2900 TestGpuMemoryBufferManager* gpu_memory_buffer_manager,
2954 BlockingTaskRunner* main_thread_task_runner, 2901 BlockingTaskRunner* main_thread_task_runner,
2955 bool mailbox_nearest_neighbor, 2902 bool mailbox_nearest_neighbor,
2956 GLenum sampler_filter) { 2903 GLenum sampler_filter) {
2957 std::unique_ptr<TextureStateTrackingContext> context_owned( 2904 std::unique_ptr<TextureStateTrackingContext> context_owned(
2958 new TextureStateTrackingContext); 2905 new TextureStateTrackingContext);
2959 TextureStateTrackingContext* context = context_owned.get(); 2906 TextureStateTrackingContext* context = context_owned.get();
2960 2907 auto context_provider =
2961 FakeOutputSurfaceClient output_surface_client; 2908 TestContextProvider::Create(std::move(context_owned));
2962 std::unique_ptr<OutputSurface> output_surface(
2963 FakeOutputSurface::Create3d(std::move(context_owned)));
2964 CHECK(output_surface->BindToClient(&output_surface_client));
2965 2909
2966 std::unique_ptr<ResourceProvider> resource_provider( 2910 std::unique_ptr<ResourceProvider> resource_provider(
2967 base::MakeUnique<ResourceProvider>( 2911 base::MakeUnique<ResourceProvider>(
2968 output_surface->context_provider(), shared_bitmap_manager, 2912 context_provider.get(), shared_bitmap_manager,
2969 gpu_memory_buffer_manager, main_thread_task_runner, 0, 1, 2913 gpu_memory_buffer_manager, main_thread_task_runner, 0, 1,
2970 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 2914 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
2971 kEnableColorCorrectRendering, 2915 kEnableColorCorrectRendering,
2972 DefaultBufferToTextureTargetMapForTesting())); 2916 DefaultBufferToTextureTargetMapForTesting()));
2973 2917
2974 unsigned texture_id = 1; 2918 unsigned texture_id = 1;
2975 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 2919 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
2976 gpu::CommandBufferId::FromUnsafeValue(0x12), 2920 gpu::CommandBufferId::FromUnsafeValue(0x12),
2977 0x34); 2921 0x34);
2978 unsigned target = GL_TEXTURE_2D; 2922 unsigned target = GL_TEXTURE_2D;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 } 3042 }
3099 3043
3100 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) { 3044 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) {
3101 // Mailboxing is only supported for GL textures. 3045 // Mailboxing is only supported for GL textures.
3102 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3046 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3103 return; 3047 return;
3104 3048
3105 std::unique_ptr<TextureStateTrackingContext> context_owned( 3049 std::unique_ptr<TextureStateTrackingContext> context_owned(
3106 new TextureStateTrackingContext); 3050 new TextureStateTrackingContext);
3107 TextureStateTrackingContext* context = context_owned.get(); 3051 TextureStateTrackingContext* context = context_owned.get();
3108 3052 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3109 FakeOutputSurfaceClient output_surface_client;
3110 std::unique_ptr<OutputSurface> output_surface(
3111 FakeOutputSurface::Create3d(std::move(context_owned)));
3112 CHECK(output_surface->BindToClient(&output_surface_client));
3113 3053
3114 std::unique_ptr<ResourceProvider> resource_provider( 3054 std::unique_ptr<ResourceProvider> resource_provider(
3115 base::MakeUnique<ResourceProvider>( 3055 base::MakeUnique<ResourceProvider>(
3116 output_surface->context_provider(), shared_bitmap_manager_.get(), 3056 context_provider.get(), shared_bitmap_manager_.get(),
3117 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 3057 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
3118 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3058 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3119 kEnableColorCorrectRendering, 3059 kEnableColorCorrectRendering,
3120 DefaultBufferToTextureTargetMapForTesting())); 3060 DefaultBufferToTextureTargetMapForTesting()));
3121 3061
3122 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 3062 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
3123 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); 3063 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34);
3124 const GLuint64 current_fence_sync = context->GetNextFenceSync(); 3064 const GLuint64 current_fence_sync = context->GetNextFenceSync();
3125 unsigned target = GL_TEXTURE_EXTERNAL_OES; 3065 unsigned target = GL_TEXTURE_EXTERNAL_OES;
3126 3066
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 3111
3172 TEST_P(ResourceProviderTest, 3112 TEST_P(ResourceProviderTest,
3173 TextureMailbox_WaitSyncTokenIfNeeded_WithSyncToken) { 3113 TextureMailbox_WaitSyncTokenIfNeeded_WithSyncToken) {
3174 // Mailboxing is only supported for GL textures. 3114 // Mailboxing is only supported for GL textures.
3175 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3115 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3176 return; 3116 return;
3177 3117
3178 std::unique_ptr<TextureStateTrackingContext> context_owned( 3118 std::unique_ptr<TextureStateTrackingContext> context_owned(
3179 new TextureStateTrackingContext); 3119 new TextureStateTrackingContext);
3180 TextureStateTrackingContext* context = context_owned.get(); 3120 TextureStateTrackingContext* context = context_owned.get();
3181 3121 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3182 FakeOutputSurfaceClient output_surface_client;
3183 std::unique_ptr<OutputSurface> output_surface(
3184 FakeOutputSurface::Create3d(std::move(context_owned)));
3185 CHECK(output_surface->BindToClient(&output_surface_client));
3186 3122
3187 std::unique_ptr<ResourceProvider> resource_provider( 3123 std::unique_ptr<ResourceProvider> resource_provider(
3188 base::MakeUnique<ResourceProvider>( 3124 base::MakeUnique<ResourceProvider>(
3189 output_surface->context_provider(), shared_bitmap_manager_.get(), 3125 context_provider.get(), shared_bitmap_manager_.get(),
3190 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 3126 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
3191 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3127 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3192 kEnableColorCorrectRendering, 3128 kEnableColorCorrectRendering,
3193 DefaultBufferToTextureTargetMapForTesting())); 3129 DefaultBufferToTextureTargetMapForTesting()));
3194 3130
3195 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 3131 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
3196 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); 3132 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34);
3197 const GLuint64 current_fence_sync = context->GetNextFenceSync(); 3133 const GLuint64 current_fence_sync = context->GetNextFenceSync();
3198 unsigned target = GL_TEXTURE_2D; 3134 unsigned target = GL_TEXTURE_2D;
3199 3135
(...skipping 30 matching lines...) Expand all
3230 } 3166 }
3231 3167
3232 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncTokenIfNeeded_NoSyncToken) { 3168 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncTokenIfNeeded_NoSyncToken) {
3233 // Mailboxing is only supported for GL textures. 3169 // Mailboxing is only supported for GL textures.
3234 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3170 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3235 return; 3171 return;
3236 3172
3237 std::unique_ptr<TextureStateTrackingContext> context_owned( 3173 std::unique_ptr<TextureStateTrackingContext> context_owned(
3238 new TextureStateTrackingContext); 3174 new TextureStateTrackingContext);
3239 TextureStateTrackingContext* context = context_owned.get(); 3175 TextureStateTrackingContext* context = context_owned.get();
3240 3176 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3241 FakeOutputSurfaceClient output_surface_client;
3242 std::unique_ptr<OutputSurface> output_surface(
3243 FakeOutputSurface::Create3d(std::move(context_owned)));
3244 CHECK(output_surface->BindToClient(&output_surface_client));
3245 3177
3246 std::unique_ptr<ResourceProvider> resource_provider( 3178 std::unique_ptr<ResourceProvider> resource_provider(
3247 base::MakeUnique<ResourceProvider>( 3179 base::MakeUnique<ResourceProvider>(
3248 output_surface->context_provider(), shared_bitmap_manager_.get(), 3180 context_provider.get(), shared_bitmap_manager_.get(),
3249 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 3181 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
3250 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3182 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3251 kEnableColorCorrectRendering, 3183 kEnableColorCorrectRendering,
3252 DefaultBufferToTextureTargetMapForTesting())); 3184 DefaultBufferToTextureTargetMapForTesting()));
3253 3185
3254 gpu::SyncToken sync_token; 3186 gpu::SyncToken sync_token;
3255 const GLuint64 current_fence_sync = context->GetNextFenceSync(); 3187 const GLuint64 current_fence_sync = context->GetNextFenceSync();
3256 unsigned target = GL_TEXTURE_2D; 3188 unsigned target = GL_TEXTURE_2D;
3257 3189
3258 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3190 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {} 3287 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {}
3356 }; 3288 };
3357 3289
3358 TEST_P(ResourceProviderTest, TextureAllocation) { 3290 TEST_P(ResourceProviderTest, TextureAllocation) {
3359 // Only for GL textures. 3291 // Only for GL textures.
3360 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3292 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3361 return; 3293 return;
3362 std::unique_ptr<AllocationTrackingContext3D> context_owned( 3294 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3363 new StrictMock<AllocationTrackingContext3D>); 3295 new StrictMock<AllocationTrackingContext3D>);
3364 AllocationTrackingContext3D* context = context_owned.get(); 3296 AllocationTrackingContext3D* context = context_owned.get();
3365 3297 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3366 FakeOutputSurfaceClient output_surface_client;
3367 std::unique_ptr<OutputSurface> output_surface(
3368 FakeOutputSurface::Create3d(std::move(context_owned)));
3369 CHECK(output_surface->BindToClient(&output_surface_client));
3370 3298
3371 std::unique_ptr<ResourceProvider> resource_provider( 3299 std::unique_ptr<ResourceProvider> resource_provider(
3372 base::MakeUnique<ResourceProvider>( 3300 base::MakeUnique<ResourceProvider>(
3373 output_surface->context_provider(), shared_bitmap_manager_.get(), 3301 context_provider.get(), shared_bitmap_manager_.get(),
3374 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 3302 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
3375 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3303 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3376 kEnableColorCorrectRendering, 3304 kEnableColorCorrectRendering,
3377 DefaultBufferToTextureTargetMapForTesting())); 3305 DefaultBufferToTextureTargetMapForTesting()));
3378 3306
3379 gfx::Size size(2, 2); 3307 gfx::Size size(2, 2);
3380 gfx::Vector2d offset(0, 0); 3308 gfx::Vector2d offset(0, 0);
3381 ResourceFormat format = RGBA_8888; 3309 ResourceFormat format = RGBA_8888;
3382 ResourceId id = 0; 3310 ResourceId id = 0;
3383 uint8_t pixels[16] = { 0 }; 3311 uint8_t pixels[16] = { 0 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3416 3344
3417 TEST_P(ResourceProviderTest, TextureAllocationHint) { 3345 TEST_P(ResourceProviderTest, TextureAllocationHint) {
3418 // Only for GL textures. 3346 // Only for GL textures.
3419 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3347 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3420 return; 3348 return;
3421 std::unique_ptr<AllocationTrackingContext3D> context_owned( 3349 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3422 new StrictMock<AllocationTrackingContext3D>); 3350 new StrictMock<AllocationTrackingContext3D>);
3423 AllocationTrackingContext3D* context = context_owned.get(); 3351 AllocationTrackingContext3D* context = context_owned.get();
3424 context->set_support_texture_storage(true); 3352 context->set_support_texture_storage(true);
3425 context->set_support_texture_usage(true); 3353 context->set_support_texture_usage(true);
3426 3354 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3427 FakeOutputSurfaceClient output_surface_client;
3428 std::unique_ptr<OutputSurface> output_surface(
3429 FakeOutputSurface::Create3d(std::move(context_owned)));
3430 CHECK(output_surface->BindToClient(&output_surface_client));
3431 3355
3432 std::unique_ptr<ResourceProvider> resource_provider( 3356 std::unique_ptr<ResourceProvider> resource_provider(
3433 base::MakeUnique<ResourceProvider>( 3357 base::MakeUnique<ResourceProvider>(
3434 output_surface->context_provider(), shared_bitmap_manager_.get(), 3358 context_provider.get(), shared_bitmap_manager_.get(),
3435 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 3359 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
3436 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3360 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3437 kEnableColorCorrectRendering, 3361 kEnableColorCorrectRendering,
3438 DefaultBufferToTextureTargetMapForTesting())); 3362 DefaultBufferToTextureTargetMapForTesting()));
3439 3363
3440 gfx::Size size(2, 2); 3364 gfx::Size size(2, 2);
3441 3365
3442 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3366 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3443 const ResourceProvider::TextureHint hints[4] = { 3367 const ResourceProvider::TextureHint hints[4] = {
3444 ResourceProvider::TEXTURE_HINT_DEFAULT, 3368 ResourceProvider::TEXTURE_HINT_DEFAULT,
(...skipping 30 matching lines...) Expand all
3475 TEST_P(ResourceProviderTest, TextureAllocationHint_BGRA) { 3399 TEST_P(ResourceProviderTest, TextureAllocationHint_BGRA) {
3476 // Only for GL textures. 3400 // Only for GL textures.
3477 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3401 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3478 return; 3402 return;
3479 std::unique_ptr<AllocationTrackingContext3D> context_owned( 3403 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3480 new StrictMock<AllocationTrackingContext3D>); 3404 new StrictMock<AllocationTrackingContext3D>);
3481 AllocationTrackingContext3D* context = context_owned.get(); 3405 AllocationTrackingContext3D* context = context_owned.get();
3482 context->set_support_texture_format_bgra8888(true); 3406 context->set_support_texture_format_bgra8888(true);
3483 context->set_support_texture_storage(true); 3407 context->set_support_texture_storage(true);
3484 context->set_support_texture_usage(true); 3408 context->set_support_texture_usage(true);
3485 3409 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3486 FakeOutputSurfaceClient output_surface_client;
3487 std::unique_ptr<OutputSurface> output_surface(
3488 FakeOutputSurface::Create3d(std::move(context_owned)));
3489 CHECK(output_surface->BindToClient(&output_surface_client));
3490 3410
3491 std::unique_ptr<ResourceProvider> resource_provider( 3411 std::unique_ptr<ResourceProvider> resource_provider(
3492 base::MakeUnique<ResourceProvider>( 3412 base::MakeUnique<ResourceProvider>(
3493 output_surface->context_provider(), shared_bitmap_manager_.get(), 3413 context_provider.get(), shared_bitmap_manager_.get(),
3494 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 3414 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
3495 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3415 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3496 kEnableColorCorrectRendering, 3416 kEnableColorCorrectRendering,
3497 DefaultBufferToTextureTargetMapForTesting())); 3417 DefaultBufferToTextureTargetMapForTesting()));
3498 3418
3499 gfx::Size size(2, 2); 3419 gfx::Size size(2, 2);
3500 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3420 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3501 3421
3502 const ResourceProvider::TextureHint hints[4] = { 3422 const ResourceProvider::TextureHint hints[4] = {
3503 ResourceProvider::TEXTURE_HINT_DEFAULT, 3423 ResourceProvider::TEXTURE_HINT_DEFAULT,
(...skipping 25 matching lines...) Expand all
3529 } 3449 }
3530 } 3450 }
3531 3451
3532 TEST_P(ResourceProviderTest, Image_GLTexture) { 3452 TEST_P(ResourceProviderTest, Image_GLTexture) {
3533 // Only for GL textures. 3453 // Only for GL textures.
3534 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3454 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3535 return; 3455 return;
3536 std::unique_ptr<AllocationTrackingContext3D> context_owned( 3456 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3537 new StrictMock<AllocationTrackingContext3D>); 3457 new StrictMock<AllocationTrackingContext3D>);
3538 AllocationTrackingContext3D* context = context_owned.get(); 3458 AllocationTrackingContext3D* context = context_owned.get();
3539 3459 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3540 FakeOutputSurfaceClient output_surface_client;
enne (OOO) 2016/09/14 00:35:44 Removing output surface for all these resource pro
3541 std::unique_ptr<OutputSurface> output_surface(
3542 FakeOutputSurface::Create3d(std::move(context_owned)));
3543 CHECK(output_surface->BindToClient(&output_surface_client));
3544 3460
3545 const int kWidth = 2; 3461 const int kWidth = 2;
3546 const int kHeight = 2; 3462 const int kHeight = 2;
3547 gfx::Size size(kWidth, kHeight); 3463 gfx::Size size(kWidth, kHeight);
3548 ResourceFormat format = RGBA_8888; 3464 ResourceFormat format = RGBA_8888;
3549 ResourceId id = 0; 3465 ResourceId id = 0;
3550 const unsigned kTextureId = 123u; 3466 const unsigned kTextureId = 123u;
3551 const unsigned kImageId = 234u; 3467 const unsigned kImageId = 234u;
3552 3468
3553 std::unique_ptr<ResourceProvider> resource_provider( 3469 std::unique_ptr<ResourceProvider> resource_provider(
3554 base::MakeUnique<ResourceProvider>( 3470 base::MakeUnique<ResourceProvider>(
3555 output_surface->context_provider(), shared_bitmap_manager_.get(), 3471 context_provider.get(), shared_bitmap_manager_.get(),
3556 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 3472 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
3557 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3473 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3558 kEnableColorCorrectRendering, 3474 kEnableColorCorrectRendering,
3559 DefaultBufferToTextureTargetMapForTesting())); 3475 DefaultBufferToTextureTargetMapForTesting()));
3560 3476
3561 id = resource_provider->CreateResource( 3477 id = resource_provider->CreateResource(
3562 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, 3478 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format,
3563 gfx::ColorSpace()); 3479 gfx::ColorSpace());
3564 3480
3565 EXPECT_CALL(*context, NextTextureId()) 3481 EXPECT_CALL(*context, NextTextureId())
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3618 } 3534 }
3619 3535
3620 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) { 3536 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) {
3621 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3537 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3622 return; 3538 return;
3623 3539
3624 std::unique_ptr<AllocationTrackingContext3D> context_owned( 3540 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3625 new AllocationTrackingContext3D); 3541 new AllocationTrackingContext3D);
3626 AllocationTrackingContext3D* context = context_owned.get(); 3542 AllocationTrackingContext3D* context = context_owned.get();
3627 context_owned->set_support_compressed_texture_etc1(true); 3543 context_owned->set_support_compressed_texture_etc1(true);
3628 3544 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3629 FakeOutputSurfaceClient output_surface_client;
3630 std::unique_ptr<OutputSurface> output_surface(
3631 FakeOutputSurface::Create3d(std::move(context_owned)));
3632 CHECK(output_surface->BindToClient(&output_surface_client));
3633 3545
3634 gfx::Size size(4, 4); 3546 gfx::Size size(4, 4);
3635 std::unique_ptr<ResourceProvider> resource_provider( 3547 std::unique_ptr<ResourceProvider> resource_provider(
3636 base::MakeUnique<ResourceProvider>( 3548 base::MakeUnique<ResourceProvider>(
3637 output_surface->context_provider(), shared_bitmap_manager_.get(), 3549 context_provider.get(), shared_bitmap_manager_.get(),
3638 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 3550 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
3639 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3551 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3640 kEnableColorCorrectRendering, 3552 kEnableColorCorrectRendering,
3641 DefaultBufferToTextureTargetMapForTesting())); 3553 DefaultBufferToTextureTargetMapForTesting()));
3642 int texture_id = 123; 3554 int texture_id = 123;
3643 3555
3644 ResourceId id = resource_provider->CreateResource( 3556 ResourceId id = resource_provider->CreateResource(
3645 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace()); 3557 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace());
3646 EXPECT_NE(0u, id); 3558 EXPECT_NE(0u, id);
3647 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3559 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3648 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3560 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3649 resource_provider->AllocateForTesting(id); 3561 resource_provider->AllocateForTesting(id);
3650 3562
3651 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); 3563 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
3652 resource_provider->DeleteResource(id); 3564 resource_provider->DeleteResource(id);
3653 } 3565 }
3654 3566
3655 TEST_P(ResourceProviderTest, CompressedTextureETC1Upload) { 3567 TEST_P(ResourceProviderTest, CompressedTextureETC1Upload) {
3656 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3568 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3657 return; 3569 return;
3658 3570
3659 std::unique_ptr<AllocationTrackingContext3D> context_owned( 3571 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3660 new AllocationTrackingContext3D); 3572 new AllocationTrackingContext3D);
3661 AllocationTrackingContext3D* context = context_owned.get(); 3573 AllocationTrackingContext3D* context = context_owned.get();
3662 context_owned->set_support_compressed_texture_etc1(true); 3574 context_owned->set_support_compressed_texture_etc1(true);
3663 3575 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3664 FakeOutputSurfaceClient output_surface_client;
3665 std::unique_ptr<OutputSurface> output_surface(
3666 FakeOutputSurface::Create3d(std::move(context_owned)));
3667 CHECK(output_surface->BindToClient(&output_surface_client));
3668 3576
3669 gfx::Size size(4, 4); 3577 gfx::Size size(4, 4);
3670 std::unique_ptr<ResourceProvider> resource_provider( 3578 std::unique_ptr<ResourceProvider> resource_provider(
3671 base::MakeUnique<ResourceProvider>( 3579 base::MakeUnique<ResourceProvider>(
3672 output_surface->context_provider(), shared_bitmap_manager_.get(), 3580 context_provider.get(), shared_bitmap_manager_.get(),
3673 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, 3581 gpu_memory_buffer_manager_.get(), nullptr, 0, 1,
3674 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3582 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3675 kEnableColorCorrectRendering, 3583 kEnableColorCorrectRendering,
3676 DefaultBufferToTextureTargetMapForTesting())); 3584 DefaultBufferToTextureTargetMapForTesting()));
3677 int texture_id = 123; 3585 int texture_id = 123;
3678 uint8_t pixels[8]; 3586 uint8_t pixels[8];
3679 3587
3680 ResourceId id = resource_provider->CreateResource( 3588 ResourceId id = resource_provider->CreateResource(
3681 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace()); 3589 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace());
3682 EXPECT_NE(0u, id); 3590 EXPECT_NE(0u, id);
(...skipping 24 matching lines...) Expand all
3707 GLuint PeekTextureId() { 3615 GLuint PeekTextureId() {
3708 base::AutoLock lock(namespace_->lock); 3616 base::AutoLock lock(namespace_->lock);
3709 return namespace_->next_texture_id; 3617 return namespace_->next_texture_id;
3710 } 3618 }
3711 }; 3619 };
3712 3620
3713 TEST(ResourceProviderTest, TextureAllocationChunkSize) { 3621 TEST(ResourceProviderTest, TextureAllocationChunkSize) {
3714 std::unique_ptr<TextureIdAllocationTrackingContext> context_owned( 3622 std::unique_ptr<TextureIdAllocationTrackingContext> context_owned(
3715 new TextureIdAllocationTrackingContext); 3623 new TextureIdAllocationTrackingContext);
3716 TextureIdAllocationTrackingContext* context = context_owned.get(); 3624 TextureIdAllocationTrackingContext* context = context_owned.get();
3717 3625 auto context_provider = TestContextProvider::Create(std::move(context_owned));
3718 FakeOutputSurfaceClient output_surface_client; 3626 auto shared_bitmap_manager = base::MakeUnique<TestSharedBitmapManager>();
3719 std::unique_ptr<OutputSurface> output_surface(
3720 FakeOutputSurface::Create3d(std::move(context_owned)));
3721 CHECK(output_surface->BindToClient(&output_surface_client));
3722 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
3723 new TestSharedBitmapManager());
3724 3627
3725 gfx::Size size(1, 1); 3628 gfx::Size size(1, 1);
3726 ResourceFormat format = RGBA_8888; 3629 ResourceFormat format = RGBA_8888;
3727 3630
3728 { 3631 {
3729 size_t kTextureAllocationChunkSize = 1; 3632 size_t kTextureAllocationChunkSize = 1;
3730 std::unique_ptr<ResourceProvider> resource_provider( 3633 std::unique_ptr<ResourceProvider> resource_provider(
3731 base::MakeUnique<ResourceProvider>( 3634 base::MakeUnique<ResourceProvider>(
3732 output_surface->context_provider(), shared_bitmap_manager.get(), 3635 context_provider.get(), shared_bitmap_manager.get(), nullptr,
3733 nullptr, nullptr, 0, kTextureAllocationChunkSize, 3636 nullptr, 0, kTextureAllocationChunkSize,
3734 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3637 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3735 kEnableColorCorrectRendering, 3638 kEnableColorCorrectRendering,
3736 DefaultBufferToTextureTargetMapForTesting())); 3639 DefaultBufferToTextureTargetMapForTesting()));
3737 3640
3738 ResourceId id = resource_provider->CreateResource( 3641 ResourceId id = resource_provider->CreateResource(
3739 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, 3642 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format,
3740 gfx::ColorSpace()); 3643 gfx::ColorSpace());
3741 resource_provider->AllocateForTesting(id); 3644 resource_provider->AllocateForTesting(id);
3742 Mock::VerifyAndClearExpectations(context); 3645 Mock::VerifyAndClearExpectations(context);
3743 3646
3744 DCHECK_EQ(2u, context->PeekTextureId()); 3647 DCHECK_EQ(2u, context->PeekTextureId());
3745 resource_provider->DeleteResource(id); 3648 resource_provider->DeleteResource(id);
3746 } 3649 }
3747 3650
3748 { 3651 {
3749 size_t kTextureAllocationChunkSize = 8; 3652 size_t kTextureAllocationChunkSize = 8;
3750 std::unique_ptr<ResourceProvider> resource_provider( 3653 std::unique_ptr<ResourceProvider> resource_provider(
3751 base::MakeUnique<ResourceProvider>( 3654 base::MakeUnique<ResourceProvider>(
3752 output_surface->context_provider(), shared_bitmap_manager.get(), 3655 context_provider.get(), shared_bitmap_manager.get(), nullptr,
3753 nullptr, nullptr, 0, kTextureAllocationChunkSize, 3656 nullptr, 0, kTextureAllocationChunkSize,
3754 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, 3657 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources,
3755 kEnableColorCorrectRendering, 3658 kEnableColorCorrectRendering,
3756 DefaultBufferToTextureTargetMapForTesting())); 3659 DefaultBufferToTextureTargetMapForTesting()));
3757 3660
3758 ResourceId id = resource_provider->CreateResource( 3661 ResourceId id = resource_provider->CreateResource(
3759 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, 3662 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format,
3760 gfx::ColorSpace()); 3663 gfx::ColorSpace());
3761 resource_provider->AllocateForTesting(id); 3664 resource_provider->AllocateForTesting(id);
3762 Mock::VerifyAndClearExpectations(context); 3665 Mock::VerifyAndClearExpectations(context);
3763 3666
3764 DCHECK_EQ(10u, context->PeekTextureId()); 3667 DCHECK_EQ(10u, context->PeekTextureId());
3765 resource_provider->DeleteResource(id); 3668 resource_provider->DeleteResource(id);
3766 } 3669 }
3767 } 3670 }
3768 3671
3769 } // namespace 3672 } // namespace
3770 } // namespace cc 3673 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698