| OLD | NEW |
| 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 Loading... |
| 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 = | 433 context_provider_->BindToCurrentThread(); |
| 436 TestContextProvider::Create(std::move(context3d)); | |
| 437 | |
| 438 output_surface_ = FakeOutputSurface::Create3d(context_provider); | |
| 439 | 434 |
| 440 std::unique_ptr<ResourceProviderContext> child_context_owned = | 435 std::unique_ptr<ResourceProviderContext> child_context_owned = |
| 441 ResourceProviderContext::Create(shared_data_.get()); | 436 ResourceProviderContext::Create(shared_data_.get()); |
| 442 child_context_ = child_context_owned.get(); | 437 child_context_ = child_context_owned.get(); |
| 443 if (child_needs_sync_token) { | 438 child_context_provider_ = |
| 444 child_output_surface_ = | 439 TestContextProvider::Create(std::move(child_context_owned)); |
| 445 FakeOutputSurface::Create3d(std::move(child_context_owned)); | 440 child_context_provider_->BindToCurrentThread(); |
| 446 } else { | |
| 447 child_output_surface_ = FakeOutputSurface::CreateNoRequireSyncPoint( | |
| 448 std::move(child_context_owned)); | |
| 449 } | |
| 450 break; | 441 break; |
| 451 } | 442 } |
| 452 case ResourceProvider::RESOURCE_TYPE_BITMAP: | 443 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; | 444 break; |
| 458 } | 445 } |
| 459 CHECK(output_surface_->BindToClient(&output_surface_client_)); | |
| 460 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_)); | |
| 461 | 446 |
| 462 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 447 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
| 463 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); | 448 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); |
| 464 child_gpu_memory_buffer_manager_ = | 449 child_gpu_memory_buffer_manager_ = |
| 465 gpu_memory_buffer_manager_->CreateClientGpuMemoryBufferManager(); | 450 gpu_memory_buffer_manager_->CreateClientGpuMemoryBufferManager(); |
| 466 | 451 |
| 467 resource_provider_ = base::MakeUnique<ResourceProvider>( | 452 resource_provider_ = base::MakeUnique<ResourceProvider>( |
| 468 output_surface_->context_provider(), shared_bitmap_manager_.get(), | 453 context_provider_.get(), shared_bitmap_manager_.get(), |
| 469 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 1, | 454 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 1, |
| 470 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 455 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 471 kEnableColorCorrectRendering, | 456 kEnableColorCorrectRendering, |
| 472 DefaultBufferToTextureTargetMapForTesting()); | 457 DefaultBufferToTextureTargetMapForTesting()); |
| 473 child_resource_provider_ = base::MakeUnique<ResourceProvider>( | 458 child_resource_provider_ = base::MakeUnique<ResourceProvider>( |
| 474 child_output_surface_->context_provider(), shared_bitmap_manager_.get(), | 459 child_context_provider_.get(), shared_bitmap_manager_.get(), |
| 475 child_gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), | 460 child_gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), |
| 476 0, 1, | 461 0, 1, child_needs_sync_token, kUseGpuMemoryBufferResources, |
| 477 child_output_surface_->capabilities().delegated_sync_points_required, | 462 kEnableColorCorrectRendering, |
| 478 kUseGpuMemoryBufferResources, kEnableColorCorrectRendering, | |
| 479 DefaultBufferToTextureTargetMapForTesting()); | 463 DefaultBufferToTextureTargetMapForTesting()); |
| 480 } | 464 } |
| 481 | 465 |
| 482 ResourceProviderTest() : ResourceProviderTest(true) {} | 466 ResourceProviderTest() : ResourceProviderTest(true) {} |
| 483 | 467 |
| 484 static void CollectResources(ReturnedResourceArray* array, | 468 static void CollectResources(ReturnedResourceArray* array, |
| 485 const ReturnedResourceArray& returned, | 469 const ReturnedResourceArray& returned, |
| 486 BlockingTaskRunner* main_thread_task_runner) { | 470 BlockingTaskRunner* main_thread_task_runner) { |
| 487 array->insert(array->end(), returned.begin(), returned.end()); | 471 array->insert(array->end(), returned.begin(), returned.end()); |
| 488 } | 472 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 release_called, release_sync_token, lost_resource)); | 518 release_called, release_sync_token, lost_resource)); |
| 535 return child_resource_provider_->CreateResourceFromTextureMailbox( | 519 return child_resource_provider_->CreateResourceFromTextureMailbox( |
| 536 TextureMailbox(shared_bitmap_ptr, size), std::move(callback)); | 520 TextureMailbox(shared_bitmap_ptr, size), std::move(callback)); |
| 537 } | 521 } |
| 538 } | 522 } |
| 539 | 523 |
| 540 protected: | 524 protected: |
| 541 std::unique_ptr<ContextSharedData> shared_data_; | 525 std::unique_ptr<ContextSharedData> shared_data_; |
| 542 ResourceProviderContext* context3d_; | 526 ResourceProviderContext* context3d_; |
| 543 ResourceProviderContext* child_context_; | 527 ResourceProviderContext* child_context_; |
| 544 FakeOutputSurfaceClient output_surface_client_; | 528 scoped_refptr<TestContextProvider> context_provider_; |
| 545 FakeOutputSurfaceClient child_output_surface_client_; | 529 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_; | 530 std::unique_ptr<BlockingTaskRunner> main_thread_task_runner_; |
| 549 std::unique_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 531 std::unique_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 550 std::unique_ptr<ResourceProvider> resource_provider_; | 532 std::unique_ptr<ResourceProvider> resource_provider_; |
| 551 std::unique_ptr<TestGpuMemoryBufferManager> child_gpu_memory_buffer_manager_; | 533 std::unique_ptr<TestGpuMemoryBufferManager> child_gpu_memory_buffer_manager_; |
| 552 std::unique_ptr<ResourceProvider> child_resource_provider_; | 534 std::unique_ptr<ResourceProvider> child_resource_provider_; |
| 553 std::unique_ptr<TestSharedBitmapManager> shared_bitmap_manager_; | 535 std::unique_ptr<TestSharedBitmapManager> shared_bitmap_manager_; |
| 554 }; | 536 }; |
| 555 | 537 |
| 556 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, | 538 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, |
| 557 ResourceProvider* resource_provider, | 539 ResourceProvider* resource_provider, |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 for (size_t i = 0; i < list.size(); i++) { | 1237 for (size_t i = 0; i < list.size(); i++) { |
| 1256 unsigned parent_id = list[i].id; | 1238 unsigned parent_id = list[i].id; |
| 1257 resource_provider_->WaitSyncTokenIfNeeded(parent_id); | 1239 resource_provider_->WaitSyncTokenIfNeeded(parent_id); |
| 1258 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 1240 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), |
| 1259 parent_id); | 1241 parent_id); |
| 1260 } | 1242 } |
| 1261 } | 1243 } |
| 1262 EXPECT_EQ(0u, returned_to_child.size()); | 1244 EXPECT_EQ(0u, returned_to_child.size()); |
| 1263 | 1245 |
| 1264 EXPECT_EQ(2u, resource_provider_->num_resources()); | 1246 EXPECT_EQ(2u, resource_provider_->num_resources()); |
| 1265 resource_provider_->DidLoseOutputSurface(); | 1247 resource_provider_->DidLoseContextProvider(); |
| 1266 resource_provider_ = nullptr; | 1248 resource_provider_ = nullptr; |
| 1267 | 1249 |
| 1268 EXPECT_EQ(2u, returned_to_child.size()); | 1250 EXPECT_EQ(2u, returned_to_child.size()); |
| 1269 | 1251 |
| 1270 EXPECT_TRUE(returned_to_child[0].lost); | 1252 EXPECT_TRUE(returned_to_child[0].lost); |
| 1271 EXPECT_TRUE(returned_to_child[1].lost); | 1253 EXPECT_TRUE(returned_to_child[1].lost); |
| 1272 } | 1254 } |
| 1273 | 1255 |
| 1274 TEST_P(ResourceProviderTest, TransferSoftwareResources) { | 1256 TEST_P(ResourceProviderTest, TransferSoftwareResources) { |
| 1275 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) | 1257 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 EXPECT_EQ(expected_ids, returned_ids); | 1455 EXPECT_EQ(expected_ids, returned_ids); |
| 1474 EXPECT_FALSE(returned_to_child[0].lost); | 1456 EXPECT_FALSE(returned_to_child[0].lost); |
| 1475 EXPECT_FALSE(returned_to_child[1].lost); | 1457 EXPECT_FALSE(returned_to_child[1].lost); |
| 1476 EXPECT_FALSE(returned_to_child[2].lost); | 1458 EXPECT_FALSE(returned_to_child[2].lost); |
| 1477 } | 1459 } |
| 1478 | 1460 |
| 1479 TEST_P(ResourceProviderTest, TransferGLToSoftware) { | 1461 TEST_P(ResourceProviderTest, TransferGLToSoftware) { |
| 1480 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) | 1462 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) |
| 1481 return; | 1463 return; |
| 1482 | 1464 |
| 1483 std::unique_ptr<ResourceProviderContext> child_context_owned( | 1465 scoped_refptr<TestContextProvider> child_context_provider = |
| 1484 ResourceProviderContext::Create(shared_data_.get())); | 1466 TestContextProvider::Create( |
| 1485 | 1467 ResourceProviderContext::Create(shared_data_.get())); |
| 1486 FakeOutputSurfaceClient child_output_surface_client; | 1468 child_context_provider->BindToCurrentThread(); |
| 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 | 1469 |
| 1491 std::unique_ptr<ResourceProvider> child_resource_provider( | 1470 std::unique_ptr<ResourceProvider> child_resource_provider( |
| 1492 base::MakeUnique<ResourceProvider>( | 1471 base::MakeUnique<ResourceProvider>( |
| 1493 child_output_surface->context_provider(), | 1472 child_context_provider.get(), shared_bitmap_manager_.get(), |
| 1494 shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), | 1473 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 1495 nullptr, 0, 1, kDelegatedSyncPointsRequired, | 1474 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 1496 kUseGpuMemoryBufferResources, kEnableColorCorrectRendering, | 1475 kEnableColorCorrectRendering, |
| 1497 DefaultBufferToTextureTargetMapForTesting())); | 1476 DefaultBufferToTextureTargetMapForTesting())); |
| 1498 | 1477 |
| 1499 gfx::Size size(1, 1); | 1478 gfx::Size size(1, 1); |
| 1500 ResourceFormat format = RGBA_8888; | 1479 ResourceFormat format = RGBA_8888; |
| 1501 size_t pixel_size = TextureSizeBytes(size, format); | 1480 size_t pixel_size = TextureSizeBytes(size, format); |
| 1502 ASSERT_EQ(4U, pixel_size); | 1481 ASSERT_EQ(4U, pixel_size); |
| 1503 | 1482 |
| 1504 ResourceId id1 = child_resource_provider->CreateResource( | 1483 ResourceId id1 = child_resource_provider->CreateResource( |
| 1505 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, | 1484 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1506 gfx::ColorSpace()); | 1485 gfx::ColorSpace()); |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1999 } | 1978 } |
| 2000 } | 1979 } |
| 2001 | 1980 |
| 2002 class ResourceProviderTestTextureFilters : public ResourceProviderTest { | 1981 class ResourceProviderTestTextureFilters : public ResourceProviderTest { |
| 2003 public: | 1982 public: |
| 2004 static void RunTest(GLenum child_filter, GLenum parent_filter) { | 1983 static void RunTest(GLenum child_filter, GLenum parent_filter) { |
| 2005 std::unique_ptr<TextureStateTrackingContext> child_context_owned( | 1984 std::unique_ptr<TextureStateTrackingContext> child_context_owned( |
| 2006 new TextureStateTrackingContext); | 1985 new TextureStateTrackingContext); |
| 2007 TextureStateTrackingContext* child_context = child_context_owned.get(); | 1986 TextureStateTrackingContext* child_context = child_context_owned.get(); |
| 2008 | 1987 |
| 2009 FakeOutputSurfaceClient child_output_surface_client; | 1988 auto child_context_provider = |
| 2010 std::unique_ptr<OutputSurface> child_output_surface( | 1989 TestContextProvider::Create(std::move(child_context_owned)); |
| 2011 FakeOutputSurface::Create3d(std::move(child_context_owned))); | 1990 child_context_provider->BindToCurrentThread(); |
| 2012 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); | 1991 auto shared_bitmap_manager = base::MakeUnique<TestSharedBitmapManager>(); |
| 2013 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | |
| 2014 new TestSharedBitmapManager()); | |
| 2015 | 1992 |
| 2016 std::unique_ptr<ResourceProvider> child_resource_provider( | 1993 std::unique_ptr<ResourceProvider> child_resource_provider( |
| 2017 base::MakeUnique<ResourceProvider>( | 1994 base::MakeUnique<ResourceProvider>( |
| 2018 child_output_surface->context_provider(), | 1995 child_context_provider.get(), shared_bitmap_manager.get(), nullptr, |
| 2019 shared_bitmap_manager.get(), nullptr, nullptr, 0, 1, | 1996 nullptr, 0, 1, kDelegatedSyncPointsRequired, |
| 2020 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 1997 kUseGpuMemoryBufferResources, kEnableColorCorrectRendering, |
| 2021 kEnableColorCorrectRendering, | |
| 2022 DefaultBufferToTextureTargetMapForTesting())); | 1998 DefaultBufferToTextureTargetMapForTesting())); |
| 2023 | 1999 |
| 2024 std::unique_ptr<TextureStateTrackingContext> parent_context_owned( | 2000 std::unique_ptr<TextureStateTrackingContext> parent_context_owned( |
| 2025 new TextureStateTrackingContext); | 2001 new TextureStateTrackingContext); |
| 2026 TextureStateTrackingContext* parent_context = parent_context_owned.get(); | 2002 TextureStateTrackingContext* parent_context = parent_context_owned.get(); |
| 2027 | 2003 |
| 2028 FakeOutputSurfaceClient parent_output_surface_client; | 2004 auto parent_context_provider = |
| 2029 std::unique_ptr<OutputSurface> parent_output_surface( | 2005 TestContextProvider::Create(std::move(parent_context_owned)); |
| 2030 FakeOutputSurface::Create3d(std::move(parent_context_owned))); | 2006 parent_context_provider->BindToCurrentThread(); |
| 2031 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); | |
| 2032 | 2007 |
| 2033 std::unique_ptr<ResourceProvider> parent_resource_provider( | 2008 std::unique_ptr<ResourceProvider> parent_resource_provider( |
| 2034 base::MakeUnique<ResourceProvider>( | 2009 base::MakeUnique<ResourceProvider>( |
| 2035 parent_output_surface->context_provider(), | 2010 parent_context_provider.get(), shared_bitmap_manager.get(), nullptr, |
| 2036 shared_bitmap_manager.get(), nullptr, nullptr, 0, 1, | 2011 nullptr, 0, 1, kDelegatedSyncPointsRequired, |
| 2037 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2012 kUseGpuMemoryBufferResources, kEnableColorCorrectRendering, |
| 2038 kEnableColorCorrectRendering, | |
| 2039 DefaultBufferToTextureTargetMapForTesting())); | 2013 DefaultBufferToTextureTargetMapForTesting())); |
| 2040 | 2014 |
| 2041 gfx::Size size(1, 1); | 2015 gfx::Size size(1, 1); |
| 2042 ResourceFormat format = RGBA_8888; | 2016 ResourceFormat format = RGBA_8888; |
| 2043 int child_texture_id = 1; | 2017 int child_texture_id = 1; |
| 2044 int parent_texture_id = 2; | 2018 int parent_texture_id = 2; |
| 2045 | 2019 |
| 2046 size_t pixel_size = TextureSizeBytes(size, format); | 2020 size_t pixel_size = TextureSizeBytes(size, format); |
| 2047 ASSERT_EQ(4U, pixel_size); | 2021 ASSERT_EQ(4U, pixel_size); |
| 2048 | 2022 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2344 EXPECT_EQ(1u, list.size()); | 2318 EXPECT_EQ(1u, list.size()); |
| 2345 | 2319 |
| 2346 resource_provider_->ReceiveFromChild(child_id, list); | 2320 resource_provider_->ReceiveFromChild(child_id, list); |
| 2347 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 2321 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
| 2348 resource_ids_to_receive.insert(resource); | 2322 resource_ids_to_receive.insert(resource); |
| 2349 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 2323 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
| 2350 resource_ids_to_receive); | 2324 resource_ids_to_receive); |
| 2351 } | 2325 } |
| 2352 | 2326 |
| 2353 // Lose the output surface in the parent. | 2327 // Lose the output surface in the parent. |
| 2354 resource_provider_->DidLoseOutputSurface(); | 2328 resource_provider_->DidLoseContextProvider(); |
| 2355 | 2329 |
| 2356 { | 2330 { |
| 2357 EXPECT_EQ(0u, returned_to_child.size()); | 2331 EXPECT_EQ(0u, returned_to_child.size()); |
| 2358 | 2332 |
| 2359 // Transfer resources back from the parent to the child. Set no resources as | 2333 // Transfer resources back from the parent to the child. Set no resources as |
| 2360 // being in use. | 2334 // being in use. |
| 2361 ResourceProvider::ResourceIdSet no_resources; | 2335 ResourceProvider::ResourceIdSet no_resources; |
| 2362 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 2336 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
| 2363 | 2337 |
| 2364 // Expect a GL resource to be lost. | 2338 // Expect a GL resource to be lost. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2475 EXPECT_EQ(1u, list.size()); | 2449 EXPECT_EQ(1u, list.size()); |
| 2476 | 2450 |
| 2477 resource_provider_->ReceiveFromChild(child_id, list); | 2451 resource_provider_->ReceiveFromChild(child_id, list); |
| 2478 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 2452 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
| 2479 resource_ids_to_receive.insert(resource); | 2453 resource_ids_to_receive.insert(resource); |
| 2480 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 2454 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
| 2481 resource_ids_to_receive); | 2455 resource_ids_to_receive); |
| 2482 } | 2456 } |
| 2483 | 2457 |
| 2484 // Lose the output surface in the parent. | 2458 // Lose the output surface in the parent. |
| 2485 resource_provider_->DidLoseOutputSurface(); | 2459 resource_provider_->DidLoseContextProvider(); |
| 2486 | 2460 |
| 2487 { | 2461 { |
| 2488 EXPECT_EQ(0u, returned_to_child.size()); | 2462 EXPECT_EQ(0u, returned_to_child.size()); |
| 2489 | 2463 |
| 2490 // Transfer resources back from the parent to the child. Set no resources as | 2464 // Transfer resources back from the parent to the child. Set no resources as |
| 2491 // being in use. | 2465 // being in use. |
| 2492 ResourceProvider::ResourceIdSet no_resources; | 2466 ResourceProvider::ResourceIdSet no_resources; |
| 2493 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 2467 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
| 2494 | 2468 |
| 2495 ASSERT_EQ(1u, returned_to_child.size()); | 2469 ASSERT_EQ(1u, returned_to_child.size()); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 SingleReleaseCallbackImpl::Create( | 2616 SingleReleaseCallbackImpl::Create( |
| 2643 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource, | 2617 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource, |
| 2644 &main_thread_task_runner)); | 2618 &main_thread_task_runner)); |
| 2645 resource_provider_->CreateResourceFromTextureMailbox( | 2619 resource_provider_->CreateResourceFromTextureMailbox( |
| 2646 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), std::move(callback)); | 2620 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), std::move(callback)); |
| 2647 | 2621 |
| 2648 EXPECT_FALSE(release_sync_token.HasData()); | 2622 EXPECT_FALSE(release_sync_token.HasData()); |
| 2649 EXPECT_FALSE(lost_resource); | 2623 EXPECT_FALSE(lost_resource); |
| 2650 EXPECT_FALSE(main_thread_task_runner); | 2624 EXPECT_FALSE(main_thread_task_runner); |
| 2651 | 2625 |
| 2652 resource_provider_->DidLoseOutputSurface(); | 2626 resource_provider_->DidLoseContextProvider(); |
| 2653 resource_provider_ = nullptr; | 2627 resource_provider_ = nullptr; |
| 2654 | 2628 |
| 2655 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count()); | 2629 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count()); |
| 2656 EXPECT_TRUE(lost_resource); | 2630 EXPECT_TRUE(lost_resource); |
| 2657 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); | 2631 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); |
| 2658 } | 2632 } |
| 2659 | 2633 |
| 2660 TEST_P(ResourceProviderTest, ScopedSampler) { | 2634 TEST_P(ResourceProviderTest, ScopedSampler) { |
| 2661 // Sampling is only supported for GL textures. | 2635 // Sampling is only supported for GL textures. |
| 2662 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 2636 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 2663 return; | 2637 return; |
| 2664 | 2638 |
| 2665 std::unique_ptr<TextureStateTrackingContext> context_owned( | 2639 std::unique_ptr<TextureStateTrackingContext> context_owned( |
| 2666 new TextureStateTrackingContext); | 2640 new TextureStateTrackingContext); |
| 2667 TextureStateTrackingContext* context = context_owned.get(); | 2641 TextureStateTrackingContext* context = context_owned.get(); |
| 2668 | 2642 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 2669 FakeOutputSurfaceClient output_surface_client; | 2643 context_provider->BindToCurrentThread(); |
| 2670 std::unique_ptr<OutputSurface> output_surface( | |
| 2671 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 2672 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 2673 | 2644 |
| 2674 std::unique_ptr<ResourceProvider> resource_provider( | 2645 std::unique_ptr<ResourceProvider> resource_provider( |
| 2675 base::MakeUnique<ResourceProvider>( | 2646 base::MakeUnique<ResourceProvider>( |
| 2676 output_surface->context_provider(), shared_bitmap_manager_.get(), | 2647 context_provider.get(), shared_bitmap_manager_.get(), |
| 2677 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 2648 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 2678 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2649 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 2679 kEnableColorCorrectRendering, | 2650 kEnableColorCorrectRendering, |
| 2680 DefaultBufferToTextureTargetMapForTesting())); | 2651 DefaultBufferToTextureTargetMapForTesting())); |
| 2681 | 2652 |
| 2682 gfx::Size size(1, 1); | 2653 gfx::Size size(1, 1); |
| 2683 ResourceFormat format = RGBA_8888; | 2654 ResourceFormat format = RGBA_8888; |
| 2684 int texture_id = 1; | 2655 int texture_id = 1; |
| 2685 | 2656 |
| 2686 ResourceId id = resource_provider->CreateResource( | 2657 ResourceId id = resource_provider->CreateResource( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2741 } | 2712 } |
| 2742 | 2713 |
| 2743 TEST_P(ResourceProviderTest, ManagedResource) { | 2714 TEST_P(ResourceProviderTest, ManagedResource) { |
| 2744 // Sampling is only supported for GL textures. | 2715 // Sampling is only supported for GL textures. |
| 2745 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 2716 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 2746 return; | 2717 return; |
| 2747 | 2718 |
| 2748 std::unique_ptr<TextureStateTrackingContext> context_owned( | 2719 std::unique_ptr<TextureStateTrackingContext> context_owned( |
| 2749 new TextureStateTrackingContext); | 2720 new TextureStateTrackingContext); |
| 2750 TextureStateTrackingContext* context = context_owned.get(); | 2721 TextureStateTrackingContext* context = context_owned.get(); |
| 2751 | 2722 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 2752 FakeOutputSurfaceClient output_surface_client; | 2723 context_provider->BindToCurrentThread(); |
| 2753 std::unique_ptr<OutputSurface> output_surface( | |
| 2754 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 2755 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 2756 | 2724 |
| 2757 std::unique_ptr<ResourceProvider> resource_provider( | 2725 std::unique_ptr<ResourceProvider> resource_provider( |
| 2758 base::MakeUnique<ResourceProvider>( | 2726 base::MakeUnique<ResourceProvider>( |
| 2759 output_surface->context_provider(), shared_bitmap_manager_.get(), | 2727 context_provider.get(), shared_bitmap_manager_.get(), |
| 2760 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 2728 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 2761 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2729 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 2762 kEnableColorCorrectRendering, | 2730 kEnableColorCorrectRendering, |
| 2763 DefaultBufferToTextureTargetMapForTesting())); | 2731 DefaultBufferToTextureTargetMapForTesting())); |
| 2764 | 2732 |
| 2765 gfx::Size size(1, 1); | 2733 gfx::Size size(1, 1); |
| 2766 ResourceFormat format = RGBA_8888; | 2734 ResourceFormat format = RGBA_8888; |
| 2767 int texture_id = 1; | 2735 int texture_id = 1; |
| 2768 | 2736 |
| 2769 // Check that the texture gets created with the right sampler settings. | 2737 // Check that the texture gets created with the right sampler settings. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2788 } | 2756 } |
| 2789 | 2757 |
| 2790 TEST_P(ResourceProviderTest, TextureWrapMode) { | 2758 TEST_P(ResourceProviderTest, TextureWrapMode) { |
| 2791 // Sampling is only supported for GL textures. | 2759 // Sampling is only supported for GL textures. |
| 2792 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 2760 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 2793 return; | 2761 return; |
| 2794 | 2762 |
| 2795 std::unique_ptr<TextureStateTrackingContext> context_owned( | 2763 std::unique_ptr<TextureStateTrackingContext> context_owned( |
| 2796 new TextureStateTrackingContext); | 2764 new TextureStateTrackingContext); |
| 2797 TextureStateTrackingContext* context = context_owned.get(); | 2765 TextureStateTrackingContext* context = context_owned.get(); |
| 2798 | 2766 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 2799 FakeOutputSurfaceClient output_surface_client; | 2767 context_provider->BindToCurrentThread(); |
| 2800 std::unique_ptr<OutputSurface> output_surface( | |
| 2801 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 2802 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 2803 | 2768 |
| 2804 std::unique_ptr<ResourceProvider> resource_provider( | 2769 std::unique_ptr<ResourceProvider> resource_provider( |
| 2805 base::MakeUnique<ResourceProvider>( | 2770 base::MakeUnique<ResourceProvider>( |
| 2806 output_surface->context_provider(), shared_bitmap_manager_.get(), | 2771 context_provider.get(), shared_bitmap_manager_.get(), |
| 2807 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 2772 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 2808 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2773 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 2809 kEnableColorCorrectRendering, | 2774 kEnableColorCorrectRendering, |
| 2810 DefaultBufferToTextureTargetMapForTesting())); | 2775 DefaultBufferToTextureTargetMapForTesting())); |
| 2811 | 2776 |
| 2812 gfx::Size size(1, 1); | 2777 gfx::Size size(1, 1); |
| 2813 ResourceFormat format = RGBA_8888; | 2778 ResourceFormat format = RGBA_8888; |
| 2814 | 2779 |
| 2815 for (int texture_id = 1; texture_id <= 2; ++texture_id) { | 2780 for (int texture_id = 1; texture_id <= 2; ++texture_id) { |
| 2816 // Check that the texture gets created with the right sampler settings. | 2781 // Check that the texture gets created with the right sampler settings. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2836 TEST_P(ResourceProviderTest, TextureHint) { | 2801 TEST_P(ResourceProviderTest, TextureHint) { |
| 2837 // Sampling is only supported for GL textures. | 2802 // Sampling is only supported for GL textures. |
| 2838 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 2803 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 2839 return; | 2804 return; |
| 2840 | 2805 |
| 2841 std::unique_ptr<TextureStateTrackingContext> context_owned( | 2806 std::unique_ptr<TextureStateTrackingContext> context_owned( |
| 2842 new TextureStateTrackingContext); | 2807 new TextureStateTrackingContext); |
| 2843 TextureStateTrackingContext* context = context_owned.get(); | 2808 TextureStateTrackingContext* context = context_owned.get(); |
| 2844 context->set_support_texture_storage(true); | 2809 context->set_support_texture_storage(true); |
| 2845 context->set_support_texture_usage(true); | 2810 context->set_support_texture_usage(true); |
| 2846 | 2811 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 2847 FakeOutputSurfaceClient output_surface_client; | 2812 context_provider->BindToCurrentThread(); |
| 2848 std::unique_ptr<OutputSurface> output_surface( | |
| 2849 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 2850 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 2851 | 2813 |
| 2852 std::unique_ptr<ResourceProvider> resource_provider( | 2814 std::unique_ptr<ResourceProvider> resource_provider( |
| 2853 base::MakeUnique<ResourceProvider>( | 2815 base::MakeUnique<ResourceProvider>( |
| 2854 output_surface->context_provider(), shared_bitmap_manager_.get(), | 2816 context_provider.get(), shared_bitmap_manager_.get(), |
| 2855 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 2817 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 2856 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2818 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 2857 kEnableColorCorrectRendering, | 2819 kEnableColorCorrectRendering, |
| 2858 DefaultBufferToTextureTargetMapForTesting())); | 2820 DefaultBufferToTextureTargetMapForTesting())); |
| 2859 | 2821 |
| 2860 gfx::Size size(1, 1); | 2822 gfx::Size size(1, 1); |
| 2861 ResourceFormat format = RGBA_8888; | 2823 ResourceFormat format = RGBA_8888; |
| 2862 | 2824 |
| 2863 const ResourceProvider::TextureHint hints[4] = { | 2825 const ResourceProvider::TextureHint hints[4] = { |
| 2864 ResourceProvider::TEXTURE_HINT_DEFAULT, | 2826 ResourceProvider::TEXTURE_HINT_DEFAULT, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2898 | 2860 |
| 2899 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) { | 2861 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) { |
| 2900 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) | 2862 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) |
| 2901 return; | 2863 return; |
| 2902 | 2864 |
| 2903 gfx::Size size(64, 64); | 2865 gfx::Size size(64, 64); |
| 2904 const uint32_t kBadBeef = 0xbadbeef; | 2866 const uint32_t kBadBeef = 0xbadbeef; |
| 2905 std::unique_ptr<SharedBitmap> shared_bitmap( | 2867 std::unique_ptr<SharedBitmap> shared_bitmap( |
| 2906 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, kBadBeef)); | 2868 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, kBadBeef)); |
| 2907 | 2869 |
| 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( | 2870 std::unique_ptr<ResourceProvider> resource_provider( |
| 2915 base::MakeUnique<ResourceProvider>( | 2871 base::MakeUnique<ResourceProvider>( |
| 2916 output_surface->context_provider(), shared_bitmap_manager_.get(), | 2872 nullptr, shared_bitmap_manager_.get(), |
| 2917 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, | 2873 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, |
| 2918 1, kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2874 1, kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 2919 kEnableColorCorrectRendering, | 2875 kEnableColorCorrectRendering, |
| 2920 DefaultBufferToTextureTargetMapForTesting())); | 2876 DefaultBufferToTextureTargetMapForTesting())); |
| 2921 | 2877 |
| 2922 gpu::SyncToken release_sync_token; | 2878 gpu::SyncToken release_sync_token; |
| 2923 bool lost_resource = false; | 2879 bool lost_resource = false; |
| 2924 BlockingTaskRunner* main_thread_task_runner = nullptr; | 2880 BlockingTaskRunner* main_thread_task_runner = nullptr; |
| 2925 std::unique_ptr<SingleReleaseCallbackImpl> callback = | 2881 std::unique_ptr<SingleReleaseCallbackImpl> callback = |
| 2926 SingleReleaseCallbackImpl::Create( | 2882 SingleReleaseCallbackImpl::Create( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2950 : public ResourceProviderTest { | 2906 : public ResourceProviderTest { |
| 2951 public: | 2907 public: |
| 2952 static void RunTest(TestSharedBitmapManager* shared_bitmap_manager, | 2908 static void RunTest(TestSharedBitmapManager* shared_bitmap_manager, |
| 2953 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, | 2909 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 2954 BlockingTaskRunner* main_thread_task_runner, | 2910 BlockingTaskRunner* main_thread_task_runner, |
| 2955 bool mailbox_nearest_neighbor, | 2911 bool mailbox_nearest_neighbor, |
| 2956 GLenum sampler_filter) { | 2912 GLenum sampler_filter) { |
| 2957 std::unique_ptr<TextureStateTrackingContext> context_owned( | 2913 std::unique_ptr<TextureStateTrackingContext> context_owned( |
| 2958 new TextureStateTrackingContext); | 2914 new TextureStateTrackingContext); |
| 2959 TextureStateTrackingContext* context = context_owned.get(); | 2915 TextureStateTrackingContext* context = context_owned.get(); |
| 2960 | 2916 auto context_provider = |
| 2961 FakeOutputSurfaceClient output_surface_client; | 2917 TestContextProvider::Create(std::move(context_owned)); |
| 2962 std::unique_ptr<OutputSurface> output_surface( | 2918 context_provider->BindToCurrentThread(); |
| 2963 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 2964 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 2965 | 2919 |
| 2966 std::unique_ptr<ResourceProvider> resource_provider( | 2920 std::unique_ptr<ResourceProvider> resource_provider( |
| 2967 base::MakeUnique<ResourceProvider>( | 2921 base::MakeUnique<ResourceProvider>( |
| 2968 output_surface->context_provider(), shared_bitmap_manager, | 2922 context_provider.get(), shared_bitmap_manager, |
| 2969 gpu_memory_buffer_manager, main_thread_task_runner, 0, 1, | 2923 gpu_memory_buffer_manager, main_thread_task_runner, 0, 1, |
| 2970 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2924 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 2971 kEnableColorCorrectRendering, | 2925 kEnableColorCorrectRendering, |
| 2972 DefaultBufferToTextureTargetMapForTesting())); | 2926 DefaultBufferToTextureTargetMapForTesting())); |
| 2973 | 2927 |
| 2974 unsigned texture_id = 1; | 2928 unsigned texture_id = 1; |
| 2975 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, | 2929 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 2976 gpu::CommandBufferId::FromUnsafeValue(0x12), | 2930 gpu::CommandBufferId::FromUnsafeValue(0x12), |
| 2977 0x34); | 2931 0x34); |
| 2978 unsigned target = GL_TEXTURE_2D; | 2932 unsigned target = GL_TEXTURE_2D; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3098 } | 3052 } |
| 3099 | 3053 |
| 3100 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) { | 3054 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) { |
| 3101 // Mailboxing is only supported for GL textures. | 3055 // Mailboxing is only supported for GL textures. |
| 3102 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3056 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 3103 return; | 3057 return; |
| 3104 | 3058 |
| 3105 std::unique_ptr<TextureStateTrackingContext> context_owned( | 3059 std::unique_ptr<TextureStateTrackingContext> context_owned( |
| 3106 new TextureStateTrackingContext); | 3060 new TextureStateTrackingContext); |
| 3107 TextureStateTrackingContext* context = context_owned.get(); | 3061 TextureStateTrackingContext* context = context_owned.get(); |
| 3108 | 3062 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3109 FakeOutputSurfaceClient output_surface_client; | 3063 context_provider->BindToCurrentThread(); |
| 3110 std::unique_ptr<OutputSurface> output_surface( | |
| 3111 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 3112 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 3113 | 3064 |
| 3114 std::unique_ptr<ResourceProvider> resource_provider( | 3065 std::unique_ptr<ResourceProvider> resource_provider( |
| 3115 base::MakeUnique<ResourceProvider>( | 3066 base::MakeUnique<ResourceProvider>( |
| 3116 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3067 context_provider.get(), shared_bitmap_manager_.get(), |
| 3117 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3068 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3118 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3069 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3119 kEnableColorCorrectRendering, | 3070 kEnableColorCorrectRendering, |
| 3120 DefaultBufferToTextureTargetMapForTesting())); | 3071 DefaultBufferToTextureTargetMapForTesting())); |
| 3121 | 3072 |
| 3122 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, | 3073 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 3123 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); | 3074 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); |
| 3124 const GLuint64 current_fence_sync = context->GetNextFenceSync(); | 3075 const GLuint64 current_fence_sync = context->GetNextFenceSync(); |
| 3125 unsigned target = GL_TEXTURE_EXTERNAL_OES; | 3076 unsigned target = GL_TEXTURE_EXTERNAL_OES; |
| 3126 | 3077 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3171 | 3122 |
| 3172 TEST_P(ResourceProviderTest, | 3123 TEST_P(ResourceProviderTest, |
| 3173 TextureMailbox_WaitSyncTokenIfNeeded_WithSyncToken) { | 3124 TextureMailbox_WaitSyncTokenIfNeeded_WithSyncToken) { |
| 3174 // Mailboxing is only supported for GL textures. | 3125 // Mailboxing is only supported for GL textures. |
| 3175 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3126 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 3176 return; | 3127 return; |
| 3177 | 3128 |
| 3178 std::unique_ptr<TextureStateTrackingContext> context_owned( | 3129 std::unique_ptr<TextureStateTrackingContext> context_owned( |
| 3179 new TextureStateTrackingContext); | 3130 new TextureStateTrackingContext); |
| 3180 TextureStateTrackingContext* context = context_owned.get(); | 3131 TextureStateTrackingContext* context = context_owned.get(); |
| 3181 | 3132 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3182 FakeOutputSurfaceClient output_surface_client; | 3133 context_provider->BindToCurrentThread(); |
| 3183 std::unique_ptr<OutputSurface> output_surface( | |
| 3184 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 3185 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 3186 | 3134 |
| 3187 std::unique_ptr<ResourceProvider> resource_provider( | 3135 std::unique_ptr<ResourceProvider> resource_provider( |
| 3188 base::MakeUnique<ResourceProvider>( | 3136 base::MakeUnique<ResourceProvider>( |
| 3189 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3137 context_provider.get(), shared_bitmap_manager_.get(), |
| 3190 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3138 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3191 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3139 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3192 kEnableColorCorrectRendering, | 3140 kEnableColorCorrectRendering, |
| 3193 DefaultBufferToTextureTargetMapForTesting())); | 3141 DefaultBufferToTextureTargetMapForTesting())); |
| 3194 | 3142 |
| 3195 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, | 3143 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 3196 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); | 3144 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); |
| 3197 const GLuint64 current_fence_sync = context->GetNextFenceSync(); | 3145 const GLuint64 current_fence_sync = context->GetNextFenceSync(); |
| 3198 unsigned target = GL_TEXTURE_2D; | 3146 unsigned target = GL_TEXTURE_2D; |
| 3199 | 3147 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3230 } | 3178 } |
| 3231 | 3179 |
| 3232 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncTokenIfNeeded_NoSyncToken) { | 3180 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncTokenIfNeeded_NoSyncToken) { |
| 3233 // Mailboxing is only supported for GL textures. | 3181 // Mailboxing is only supported for GL textures. |
| 3234 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3182 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 3235 return; | 3183 return; |
| 3236 | 3184 |
| 3237 std::unique_ptr<TextureStateTrackingContext> context_owned( | 3185 std::unique_ptr<TextureStateTrackingContext> context_owned( |
| 3238 new TextureStateTrackingContext); | 3186 new TextureStateTrackingContext); |
| 3239 TextureStateTrackingContext* context = context_owned.get(); | 3187 TextureStateTrackingContext* context = context_owned.get(); |
| 3240 | 3188 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3241 FakeOutputSurfaceClient output_surface_client; | 3189 context_provider->BindToCurrentThread(); |
| 3242 std::unique_ptr<OutputSurface> output_surface( | |
| 3243 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 3244 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 3245 | 3190 |
| 3246 std::unique_ptr<ResourceProvider> resource_provider( | 3191 std::unique_ptr<ResourceProvider> resource_provider( |
| 3247 base::MakeUnique<ResourceProvider>( | 3192 base::MakeUnique<ResourceProvider>( |
| 3248 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3193 context_provider.get(), shared_bitmap_manager_.get(), |
| 3249 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3194 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3250 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3195 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3251 kEnableColorCorrectRendering, | 3196 kEnableColorCorrectRendering, |
| 3252 DefaultBufferToTextureTargetMapForTesting())); | 3197 DefaultBufferToTextureTargetMapForTesting())); |
| 3253 | 3198 |
| 3254 gpu::SyncToken sync_token; | 3199 gpu::SyncToken sync_token; |
| 3255 const GLuint64 current_fence_sync = context->GetNextFenceSync(); | 3200 const GLuint64 current_fence_sync = context->GetNextFenceSync(); |
| 3256 unsigned target = GL_TEXTURE_2D; | 3201 unsigned target = GL_TEXTURE_2D; |
| 3257 | 3202 |
| 3258 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 3203 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3355 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {} | 3300 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {} |
| 3356 }; | 3301 }; |
| 3357 | 3302 |
| 3358 TEST_P(ResourceProviderTest, TextureAllocation) { | 3303 TEST_P(ResourceProviderTest, TextureAllocation) { |
| 3359 // Only for GL textures. | 3304 // Only for GL textures. |
| 3360 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3305 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 3361 return; | 3306 return; |
| 3362 std::unique_ptr<AllocationTrackingContext3D> context_owned( | 3307 std::unique_ptr<AllocationTrackingContext3D> context_owned( |
| 3363 new StrictMock<AllocationTrackingContext3D>); | 3308 new StrictMock<AllocationTrackingContext3D>); |
| 3364 AllocationTrackingContext3D* context = context_owned.get(); | 3309 AllocationTrackingContext3D* context = context_owned.get(); |
| 3365 | 3310 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3366 FakeOutputSurfaceClient output_surface_client; | 3311 context_provider->BindToCurrentThread(); |
| 3367 std::unique_ptr<OutputSurface> output_surface( | |
| 3368 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 3369 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 3370 | 3312 |
| 3371 std::unique_ptr<ResourceProvider> resource_provider( | 3313 std::unique_ptr<ResourceProvider> resource_provider( |
| 3372 base::MakeUnique<ResourceProvider>( | 3314 base::MakeUnique<ResourceProvider>( |
| 3373 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3315 context_provider.get(), shared_bitmap_manager_.get(), |
| 3374 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3316 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3375 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3317 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3376 kEnableColorCorrectRendering, | 3318 kEnableColorCorrectRendering, |
| 3377 DefaultBufferToTextureTargetMapForTesting())); | 3319 DefaultBufferToTextureTargetMapForTesting())); |
| 3378 | 3320 |
| 3379 gfx::Size size(2, 2); | 3321 gfx::Size size(2, 2); |
| 3380 gfx::Vector2d offset(0, 0); | 3322 gfx::Vector2d offset(0, 0); |
| 3381 ResourceFormat format = RGBA_8888; | 3323 ResourceFormat format = RGBA_8888; |
| 3382 ResourceId id = 0; | 3324 ResourceId id = 0; |
| 3383 uint8_t pixels[16] = { 0 }; | 3325 uint8_t pixels[16] = { 0 }; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3416 | 3358 |
| 3417 TEST_P(ResourceProviderTest, TextureAllocationHint) { | 3359 TEST_P(ResourceProviderTest, TextureAllocationHint) { |
| 3418 // Only for GL textures. | 3360 // Only for GL textures. |
| 3419 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3361 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 3420 return; | 3362 return; |
| 3421 std::unique_ptr<AllocationTrackingContext3D> context_owned( | 3363 std::unique_ptr<AllocationTrackingContext3D> context_owned( |
| 3422 new StrictMock<AllocationTrackingContext3D>); | 3364 new StrictMock<AllocationTrackingContext3D>); |
| 3423 AllocationTrackingContext3D* context = context_owned.get(); | 3365 AllocationTrackingContext3D* context = context_owned.get(); |
| 3424 context->set_support_texture_storage(true); | 3366 context->set_support_texture_storage(true); |
| 3425 context->set_support_texture_usage(true); | 3367 context->set_support_texture_usage(true); |
| 3426 | 3368 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3427 FakeOutputSurfaceClient output_surface_client; | 3369 context_provider->BindToCurrentThread(); |
| 3428 std::unique_ptr<OutputSurface> output_surface( | |
| 3429 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 3430 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 3431 | 3370 |
| 3432 std::unique_ptr<ResourceProvider> resource_provider( | 3371 std::unique_ptr<ResourceProvider> resource_provider( |
| 3433 base::MakeUnique<ResourceProvider>( | 3372 base::MakeUnique<ResourceProvider>( |
| 3434 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3373 context_provider.get(), shared_bitmap_manager_.get(), |
| 3435 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3374 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3436 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3375 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3437 kEnableColorCorrectRendering, | 3376 kEnableColorCorrectRendering, |
| 3438 DefaultBufferToTextureTargetMapForTesting())); | 3377 DefaultBufferToTextureTargetMapForTesting())); |
| 3439 | 3378 |
| 3440 gfx::Size size(2, 2); | 3379 gfx::Size size(2, 2); |
| 3441 | 3380 |
| 3442 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; | 3381 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; |
| 3443 const ResourceProvider::TextureHint hints[4] = { | 3382 const ResourceProvider::TextureHint hints[4] = { |
| 3444 ResourceProvider::TEXTURE_HINT_DEFAULT, | 3383 ResourceProvider::TEXTURE_HINT_DEFAULT, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3475 TEST_P(ResourceProviderTest, TextureAllocationHint_BGRA) { | 3414 TEST_P(ResourceProviderTest, TextureAllocationHint_BGRA) { |
| 3476 // Only for GL textures. | 3415 // Only for GL textures. |
| 3477 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3416 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 3478 return; | 3417 return; |
| 3479 std::unique_ptr<AllocationTrackingContext3D> context_owned( | 3418 std::unique_ptr<AllocationTrackingContext3D> context_owned( |
| 3480 new StrictMock<AllocationTrackingContext3D>); | 3419 new StrictMock<AllocationTrackingContext3D>); |
| 3481 AllocationTrackingContext3D* context = context_owned.get(); | 3420 AllocationTrackingContext3D* context = context_owned.get(); |
| 3482 context->set_support_texture_format_bgra8888(true); | 3421 context->set_support_texture_format_bgra8888(true); |
| 3483 context->set_support_texture_storage(true); | 3422 context->set_support_texture_storage(true); |
| 3484 context->set_support_texture_usage(true); | 3423 context->set_support_texture_usage(true); |
| 3485 | 3424 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3486 FakeOutputSurfaceClient output_surface_client; | 3425 context_provider->BindToCurrentThread(); |
| 3487 std::unique_ptr<OutputSurface> output_surface( | |
| 3488 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 3489 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 3490 | 3426 |
| 3491 std::unique_ptr<ResourceProvider> resource_provider( | 3427 std::unique_ptr<ResourceProvider> resource_provider( |
| 3492 base::MakeUnique<ResourceProvider>( | 3428 base::MakeUnique<ResourceProvider>( |
| 3493 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3429 context_provider.get(), shared_bitmap_manager_.get(), |
| 3494 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3430 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3495 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3431 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3496 kEnableColorCorrectRendering, | 3432 kEnableColorCorrectRendering, |
| 3497 DefaultBufferToTextureTargetMapForTesting())); | 3433 DefaultBufferToTextureTargetMapForTesting())); |
| 3498 | 3434 |
| 3499 gfx::Size size(2, 2); | 3435 gfx::Size size(2, 2); |
| 3500 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; | 3436 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; |
| 3501 | 3437 |
| 3502 const ResourceProvider::TextureHint hints[4] = { | 3438 const ResourceProvider::TextureHint hints[4] = { |
| 3503 ResourceProvider::TEXTURE_HINT_DEFAULT, | 3439 ResourceProvider::TEXTURE_HINT_DEFAULT, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3529 } | 3465 } |
| 3530 } | 3466 } |
| 3531 | 3467 |
| 3532 TEST_P(ResourceProviderTest, Image_GLTexture) { | 3468 TEST_P(ResourceProviderTest, Image_GLTexture) { |
| 3533 // Only for GL textures. | 3469 // Only for GL textures. |
| 3534 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3470 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 3535 return; | 3471 return; |
| 3536 std::unique_ptr<AllocationTrackingContext3D> context_owned( | 3472 std::unique_ptr<AllocationTrackingContext3D> context_owned( |
| 3537 new StrictMock<AllocationTrackingContext3D>); | 3473 new StrictMock<AllocationTrackingContext3D>); |
| 3538 AllocationTrackingContext3D* context = context_owned.get(); | 3474 AllocationTrackingContext3D* context = context_owned.get(); |
| 3539 | 3475 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3540 FakeOutputSurfaceClient output_surface_client; | 3476 context_provider->BindToCurrentThread(); |
| 3541 std::unique_ptr<OutputSurface> output_surface( | |
| 3542 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 3543 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 3544 | 3477 |
| 3545 const int kWidth = 2; | 3478 const int kWidth = 2; |
| 3546 const int kHeight = 2; | 3479 const int kHeight = 2; |
| 3547 gfx::Size size(kWidth, kHeight); | 3480 gfx::Size size(kWidth, kHeight); |
| 3548 ResourceFormat format = RGBA_8888; | 3481 ResourceFormat format = RGBA_8888; |
| 3549 ResourceId id = 0; | 3482 ResourceId id = 0; |
| 3550 const unsigned kTextureId = 123u; | 3483 const unsigned kTextureId = 123u; |
| 3551 const unsigned kImageId = 234u; | 3484 const unsigned kImageId = 234u; |
| 3552 | 3485 |
| 3553 std::unique_ptr<ResourceProvider> resource_provider( | 3486 std::unique_ptr<ResourceProvider> resource_provider( |
| 3554 base::MakeUnique<ResourceProvider>( | 3487 base::MakeUnique<ResourceProvider>( |
| 3555 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3488 context_provider.get(), shared_bitmap_manager_.get(), |
| 3556 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3489 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3557 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3490 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3558 kEnableColorCorrectRendering, | 3491 kEnableColorCorrectRendering, |
| 3559 DefaultBufferToTextureTargetMapForTesting())); | 3492 DefaultBufferToTextureTargetMapForTesting())); |
| 3560 | 3493 |
| 3561 id = resource_provider->CreateResource( | 3494 id = resource_provider->CreateResource( |
| 3562 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, | 3495 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 3563 gfx::ColorSpace()); | 3496 gfx::ColorSpace()); |
| 3564 | 3497 |
| 3565 EXPECT_CALL(*context, NextTextureId()) | 3498 EXPECT_CALL(*context, NextTextureId()) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3618 } | 3551 } |
| 3619 | 3552 |
| 3620 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) { | 3553 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) { |
| 3621 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3554 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 3622 return; | 3555 return; |
| 3623 | 3556 |
| 3624 std::unique_ptr<AllocationTrackingContext3D> context_owned( | 3557 std::unique_ptr<AllocationTrackingContext3D> context_owned( |
| 3625 new AllocationTrackingContext3D); | 3558 new AllocationTrackingContext3D); |
| 3626 AllocationTrackingContext3D* context = context_owned.get(); | 3559 AllocationTrackingContext3D* context = context_owned.get(); |
| 3627 context_owned->set_support_compressed_texture_etc1(true); | 3560 context_owned->set_support_compressed_texture_etc1(true); |
| 3628 | 3561 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3629 FakeOutputSurfaceClient output_surface_client; | 3562 context_provider->BindToCurrentThread(); |
| 3630 std::unique_ptr<OutputSurface> output_surface( | |
| 3631 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 3632 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 3633 | 3563 |
| 3634 gfx::Size size(4, 4); | 3564 gfx::Size size(4, 4); |
| 3635 std::unique_ptr<ResourceProvider> resource_provider( | 3565 std::unique_ptr<ResourceProvider> resource_provider( |
| 3636 base::MakeUnique<ResourceProvider>( | 3566 base::MakeUnique<ResourceProvider>( |
| 3637 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3567 context_provider.get(), shared_bitmap_manager_.get(), |
| 3638 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3568 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3639 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3569 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3640 kEnableColorCorrectRendering, | 3570 kEnableColorCorrectRendering, |
| 3641 DefaultBufferToTextureTargetMapForTesting())); | 3571 DefaultBufferToTextureTargetMapForTesting())); |
| 3642 int texture_id = 123; | 3572 int texture_id = 123; |
| 3643 | 3573 |
| 3644 ResourceId id = resource_provider->CreateResource( | 3574 ResourceId id = resource_provider->CreateResource( |
| 3645 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace()); | 3575 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace()); |
| 3646 EXPECT_NE(0u, id); | 3576 EXPECT_NE(0u, id); |
| 3647 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 3577 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 3648 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 3578 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 3649 resource_provider->AllocateForTesting(id); | 3579 resource_provider->AllocateForTesting(id); |
| 3650 | 3580 |
| 3651 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); | 3581 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); |
| 3652 resource_provider->DeleteResource(id); | 3582 resource_provider->DeleteResource(id); |
| 3653 } | 3583 } |
| 3654 | 3584 |
| 3655 TEST_P(ResourceProviderTest, CompressedTextureETC1Upload) { | 3585 TEST_P(ResourceProviderTest, CompressedTextureETC1Upload) { |
| 3656 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3586 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 3657 return; | 3587 return; |
| 3658 | 3588 |
| 3659 std::unique_ptr<AllocationTrackingContext3D> context_owned( | 3589 std::unique_ptr<AllocationTrackingContext3D> context_owned( |
| 3660 new AllocationTrackingContext3D); | 3590 new AllocationTrackingContext3D); |
| 3661 AllocationTrackingContext3D* context = context_owned.get(); | 3591 AllocationTrackingContext3D* context = context_owned.get(); |
| 3662 context_owned->set_support_compressed_texture_etc1(true); | 3592 context_owned->set_support_compressed_texture_etc1(true); |
| 3663 | 3593 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3664 FakeOutputSurfaceClient output_surface_client; | 3594 context_provider->BindToCurrentThread(); |
| 3665 std::unique_ptr<OutputSurface> output_surface( | |
| 3666 FakeOutputSurface::Create3d(std::move(context_owned))); | |
| 3667 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 3668 | 3595 |
| 3669 gfx::Size size(4, 4); | 3596 gfx::Size size(4, 4); |
| 3670 std::unique_ptr<ResourceProvider> resource_provider( | 3597 std::unique_ptr<ResourceProvider> resource_provider( |
| 3671 base::MakeUnique<ResourceProvider>( | 3598 base::MakeUnique<ResourceProvider>( |
| 3672 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3599 context_provider.get(), shared_bitmap_manager_.get(), |
| 3673 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3600 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3674 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3601 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3675 kEnableColorCorrectRendering, | 3602 kEnableColorCorrectRendering, |
| 3676 DefaultBufferToTextureTargetMapForTesting())); | 3603 DefaultBufferToTextureTargetMapForTesting())); |
| 3677 int texture_id = 123; | 3604 int texture_id = 123; |
| 3678 uint8_t pixels[8]; | 3605 uint8_t pixels[8]; |
| 3679 | 3606 |
| 3680 ResourceId id = resource_provider->CreateResource( | 3607 ResourceId id = resource_provider->CreateResource( |
| 3681 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace()); | 3608 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace()); |
| 3682 EXPECT_NE(0u, id); | 3609 EXPECT_NE(0u, id); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3707 GLuint PeekTextureId() { | 3634 GLuint PeekTextureId() { |
| 3708 base::AutoLock lock(namespace_->lock); | 3635 base::AutoLock lock(namespace_->lock); |
| 3709 return namespace_->next_texture_id; | 3636 return namespace_->next_texture_id; |
| 3710 } | 3637 } |
| 3711 }; | 3638 }; |
| 3712 | 3639 |
| 3713 TEST(ResourceProviderTest, TextureAllocationChunkSize) { | 3640 TEST(ResourceProviderTest, TextureAllocationChunkSize) { |
| 3714 std::unique_ptr<TextureIdAllocationTrackingContext> context_owned( | 3641 std::unique_ptr<TextureIdAllocationTrackingContext> context_owned( |
| 3715 new TextureIdAllocationTrackingContext); | 3642 new TextureIdAllocationTrackingContext); |
| 3716 TextureIdAllocationTrackingContext* context = context_owned.get(); | 3643 TextureIdAllocationTrackingContext* context = context_owned.get(); |
| 3717 | 3644 auto context_provider = TestContextProvider::Create(std::move(context_owned)); |
| 3718 FakeOutputSurfaceClient output_surface_client; | 3645 context_provider->BindToCurrentThread(); |
| 3719 std::unique_ptr<OutputSurface> output_surface( | 3646 auto shared_bitmap_manager = base::MakeUnique<TestSharedBitmapManager>(); |
| 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 | 3647 |
| 3725 gfx::Size size(1, 1); | 3648 gfx::Size size(1, 1); |
| 3726 ResourceFormat format = RGBA_8888; | 3649 ResourceFormat format = RGBA_8888; |
| 3727 | 3650 |
| 3728 { | 3651 { |
| 3729 size_t kTextureAllocationChunkSize = 1; | 3652 size_t kTextureAllocationChunkSize = 1; |
| 3730 std::unique_ptr<ResourceProvider> resource_provider( | 3653 std::unique_ptr<ResourceProvider> resource_provider( |
| 3731 base::MakeUnique<ResourceProvider>( | 3654 base::MakeUnique<ResourceProvider>( |
| 3732 output_surface->context_provider(), shared_bitmap_manager.get(), | 3655 context_provider.get(), shared_bitmap_manager.get(), nullptr, |
| 3733 nullptr, nullptr, 0, kTextureAllocationChunkSize, | 3656 nullptr, 0, kTextureAllocationChunkSize, |
| 3734 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3657 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3735 kEnableColorCorrectRendering, | 3658 kEnableColorCorrectRendering, |
| 3736 DefaultBufferToTextureTargetMapForTesting())); | 3659 DefaultBufferToTextureTargetMapForTesting())); |
| 3737 | 3660 |
| 3738 ResourceId id = resource_provider->CreateResource( | 3661 ResourceId id = resource_provider->CreateResource( |
| 3739 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, | 3662 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 3740 gfx::ColorSpace()); | 3663 gfx::ColorSpace()); |
| 3741 resource_provider->AllocateForTesting(id); | 3664 resource_provider->AllocateForTesting(id); |
| 3742 Mock::VerifyAndClearExpectations(context); | 3665 Mock::VerifyAndClearExpectations(context); |
| 3743 | 3666 |
| 3744 DCHECK_EQ(2u, context->PeekTextureId()); | 3667 DCHECK_EQ(2u, context->PeekTextureId()); |
| 3745 resource_provider->DeleteResource(id); | 3668 resource_provider->DeleteResource(id); |
| 3746 } | 3669 } |
| 3747 | 3670 |
| 3748 { | 3671 { |
| 3749 size_t kTextureAllocationChunkSize = 8; | 3672 size_t kTextureAllocationChunkSize = 8; |
| 3750 std::unique_ptr<ResourceProvider> resource_provider( | 3673 std::unique_ptr<ResourceProvider> resource_provider( |
| 3751 base::MakeUnique<ResourceProvider>( | 3674 base::MakeUnique<ResourceProvider>( |
| 3752 output_surface->context_provider(), shared_bitmap_manager.get(), | 3675 context_provider.get(), shared_bitmap_manager.get(), nullptr, |
| 3753 nullptr, nullptr, 0, kTextureAllocationChunkSize, | 3676 nullptr, 0, kTextureAllocationChunkSize, |
| 3754 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3677 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3755 kEnableColorCorrectRendering, | 3678 kEnableColorCorrectRendering, |
| 3756 DefaultBufferToTextureTargetMapForTesting())); | 3679 DefaultBufferToTextureTargetMapForTesting())); |
| 3757 | 3680 |
| 3758 ResourceId id = resource_provider->CreateResource( | 3681 ResourceId id = resource_provider->CreateResource( |
| 3759 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, | 3682 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 3760 gfx::ColorSpace()); | 3683 gfx::ColorSpace()); |
| 3761 resource_provider->AllocateForTesting(id); | 3684 resource_provider->AllocateForTesting(id); |
| 3762 Mock::VerifyAndClearExpectations(context); | 3685 Mock::VerifyAndClearExpectations(context); |
| 3763 | 3686 |
| 3764 DCHECK_EQ(10u, context->PeekTextureId()); | 3687 DCHECK_EQ(10u, context->PeekTextureId()); |
| 3765 resource_provider->DeleteResource(id); | 3688 resource_provider->DeleteResource(id); |
| 3766 } | 3689 } |
| 3767 } | 3690 } |
| 3768 | 3691 |
| 3769 } // namespace | 3692 } // namespace |
| 3770 } // namespace cc | 3693 } // namespace cc |
| OLD | NEW |