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

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

Issue 1273163004: Revert of cc: Use worker context for one-copy tile initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/surfaces/display.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 414 }
415 CHECK(output_surface_->BindToClient(&output_surface_client_)); 415 CHECK(output_surface_->BindToClient(&output_surface_client_));
416 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_)); 416 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_));
417 417
418 shared_bitmap_manager_.reset(new TestSharedBitmapManager); 418 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
419 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); 419 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
420 420
421 resource_provider_ = ResourceProvider::Create( 421 resource_provider_ = ResourceProvider::Create(
422 output_surface_.get(), shared_bitmap_manager_.get(), 422 output_surface_.get(), shared_bitmap_manager_.get(),
423 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 423 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
424 false, 1); 424 false, 1, false);
425 child_resource_provider_ = ResourceProvider::Create( 425 child_resource_provider_ = ResourceProvider::Create(
426 child_output_surface_.get(), shared_bitmap_manager_.get(), 426 child_output_surface_.get(), shared_bitmap_manager_.get(),
427 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 427 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
428 false, 1); 428 false, 1, false);
429 } 429 }
430 430
431 ResourceProviderTest() : ResourceProviderTest(true) {} 431 ResourceProviderTest() : ResourceProviderTest(true) {}
432 432
433 static void CollectResources(ReturnedResourceArray* array, 433 static void CollectResources(ReturnedResourceArray* array,
434 const ReturnedResourceArray& returned, 434 const ReturnedResourceArray& returned,
435 BlockingTaskRunner* main_thread_task_runner) { 435 BlockingTaskRunner* main_thread_task_runner) {
436 array->insert(array->end(), returned.begin(), returned.end()); 436 array->insert(array->end(), returned.begin(), returned.end());
437 } 437 }
438 438
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 scoped_ptr<ResourceProviderContext> child_context_owned( 1360 scoped_ptr<ResourceProviderContext> child_context_owned(
1361 ResourceProviderContext::Create(shared_data_.get())); 1361 ResourceProviderContext::Create(shared_data_.get()));
1362 1362
1363 FakeOutputSurfaceClient child_output_surface_client; 1363 FakeOutputSurfaceClient child_output_surface_client;
1364 scoped_ptr<OutputSurface> child_output_surface( 1364 scoped_ptr<OutputSurface> child_output_surface(
1365 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1365 FakeOutputSurface::Create3d(child_context_owned.Pass()));
1366 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1366 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1367 1367
1368 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create( 1368 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create(
1369 child_output_surface.get(), shared_bitmap_manager_.get(), 1369 child_output_surface.get(), shared_bitmap_manager_.get(),
1370 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 1370 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
1371 1371
1372 gfx::Size size(1, 1); 1372 gfx::Size size(1, 1);
1373 ResourceFormat format = RGBA_8888; 1373 ResourceFormat format = RGBA_8888;
1374 size_t pixel_size = TextureSizeBytes(size, format); 1374 size_t pixel_size = TextureSizeBytes(size, format);
1375 ASSERT_EQ(4U, pixel_size); 1375 ASSERT_EQ(4U, pixel_size);
1376 1376
1377 ResourceId id1 = child_resource_provider->CreateResource( 1377 ResourceId id1 = child_resource_provider->CreateResource(
1378 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 1378 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
1379 uint8_t data1[4] = { 1, 2, 3, 4 }; 1379 uint8_t data1[4] = { 1, 2, 3, 4 };
1380 child_resource_provider->CopyToResource(id1, data1, size); 1380 child_resource_provider->CopyToResource(id1, data1, size);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 FakeOutputSurfaceClient child_output_surface_client; 1844 FakeOutputSurfaceClient child_output_surface_client;
1845 scoped_ptr<OutputSurface> child_output_surface( 1845 scoped_ptr<OutputSurface> child_output_surface(
1846 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1846 FakeOutputSurface::Create3d(child_context_owned.Pass()));
1847 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1847 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1848 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1848 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
1849 new TestSharedBitmapManager()); 1849 new TestSharedBitmapManager());
1850 1850
1851 scoped_ptr<ResourceProvider> child_resource_provider( 1851 scoped_ptr<ResourceProvider> child_resource_provider(
1852 ResourceProvider::Create(child_output_surface.get(), 1852 ResourceProvider::Create(child_output_surface.get(),
1853 shared_bitmap_manager.get(), NULL, NULL, 0, 1853 shared_bitmap_manager.get(), NULL, NULL, 0,
1854 false, 1)); 1854 false, 1, false));
1855 1855
1856 scoped_ptr<TextureStateTrackingContext> parent_context_owned( 1856 scoped_ptr<TextureStateTrackingContext> parent_context_owned(
1857 new TextureStateTrackingContext); 1857 new TextureStateTrackingContext);
1858 TextureStateTrackingContext* parent_context = parent_context_owned.get(); 1858 TextureStateTrackingContext* parent_context = parent_context_owned.get();
1859 1859
1860 FakeOutputSurfaceClient parent_output_surface_client; 1860 FakeOutputSurfaceClient parent_output_surface_client;
1861 scoped_ptr<OutputSurface> parent_output_surface( 1861 scoped_ptr<OutputSurface> parent_output_surface(
1862 FakeOutputSurface::Create3d(parent_context_owned.Pass())); 1862 FakeOutputSurface::Create3d(parent_context_owned.Pass()));
1863 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); 1863 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
1864 1864
1865 scoped_ptr<ResourceProvider> parent_resource_provider( 1865 scoped_ptr<ResourceProvider> parent_resource_provider(
1866 ResourceProvider::Create(parent_output_surface.get(), 1866 ResourceProvider::Create(parent_output_surface.get(),
1867 shared_bitmap_manager.get(), NULL, NULL, 0, 1867 shared_bitmap_manager.get(), NULL, NULL, 0,
1868 false, 1)); 1868 false, 1, false));
1869 1869
1870 gfx::Size size(1, 1); 1870 gfx::Size size(1, 1);
1871 ResourceFormat format = RGBA_8888; 1871 ResourceFormat format = RGBA_8888;
1872 int child_texture_id = 1; 1872 int child_texture_id = 1;
1873 int parent_texture_id = 2; 1873 int parent_texture_id = 2;
1874 1874
1875 size_t pixel_size = TextureSizeBytes(size, format); 1875 size_t pixel_size = TextureSizeBytes(size, format);
1876 ASSERT_EQ(4U, pixel_size); 1876 ASSERT_EQ(4U, pixel_size);
1877 1877
1878 ResourceId id = child_resource_provider->CreateResource( 1878 ResourceId id = child_resource_provider->CreateResource(
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2490 new TextureStateTrackingContext); 2490 new TextureStateTrackingContext);
2491 TextureStateTrackingContext* context = context_owned.get(); 2491 TextureStateTrackingContext* context = context_owned.get();
2492 2492
2493 FakeOutputSurfaceClient output_surface_client; 2493 FakeOutputSurfaceClient output_surface_client;
2494 scoped_ptr<OutputSurface> output_surface( 2494 scoped_ptr<OutputSurface> output_surface(
2495 FakeOutputSurface::Create3d(context_owned.Pass())); 2495 FakeOutputSurface::Create3d(context_owned.Pass()));
2496 CHECK(output_surface->BindToClient(&output_surface_client)); 2496 CHECK(output_surface->BindToClient(&output_surface_client));
2497 2497
2498 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2498 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2499 output_surface.get(), shared_bitmap_manager_.get(), 2499 output_surface.get(), shared_bitmap_manager_.get(),
2500 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 2500 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
2501 2501
2502 gfx::Size size(1, 1); 2502 gfx::Size size(1, 1);
2503 ResourceFormat format = RGBA_8888; 2503 ResourceFormat format = RGBA_8888;
2504 int texture_id = 1; 2504 int texture_id = 1;
2505 2505
2506 ResourceId id = resource_provider->CreateResource( 2506 ResourceId id = resource_provider->CreateResource(
2507 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 2507 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
2508 2508
2509 // Check that the texture gets created with the right sampler settings. 2509 // Check that the texture gets created with the right sampler settings.
2510 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) 2510 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id))
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2572 new TextureStateTrackingContext); 2572 new TextureStateTrackingContext);
2573 TextureStateTrackingContext* context = context_owned.get(); 2573 TextureStateTrackingContext* context = context_owned.get();
2574 2574
2575 FakeOutputSurfaceClient output_surface_client; 2575 FakeOutputSurfaceClient output_surface_client;
2576 scoped_ptr<OutputSurface> output_surface( 2576 scoped_ptr<OutputSurface> output_surface(
2577 FakeOutputSurface::Create3d(context_owned.Pass())); 2577 FakeOutputSurface::Create3d(context_owned.Pass()));
2578 CHECK(output_surface->BindToClient(&output_surface_client)); 2578 CHECK(output_surface->BindToClient(&output_surface_client));
2579 2579
2580 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2580 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2581 output_surface.get(), shared_bitmap_manager_.get(), 2581 output_surface.get(), shared_bitmap_manager_.get(),
2582 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 2582 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
2583 2583
2584 gfx::Size size(1, 1); 2584 gfx::Size size(1, 1);
2585 ResourceFormat format = RGBA_8888; 2585 ResourceFormat format = RGBA_8888;
2586 int texture_id = 1; 2586 int texture_id = 1;
2587 2587
2588 // Check that the texture gets created with the right sampler settings. 2588 // Check that the texture gets created with the right sampler settings.
2589 ResourceId id = resource_provider->CreateManagedResource( 2589 ResourceId id = resource_provider->CreateManagedResource(
2590 size, GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, 2590 size, GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,
2591 ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 2591 ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
2592 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); 2592 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id));
(...skipping 26 matching lines...) Expand all
2619 new TextureStateTrackingContext); 2619 new TextureStateTrackingContext);
2620 TextureStateTrackingContext* context = context_owned.get(); 2620 TextureStateTrackingContext* context = context_owned.get();
2621 2621
2622 FakeOutputSurfaceClient output_surface_client; 2622 FakeOutputSurfaceClient output_surface_client;
2623 scoped_ptr<OutputSurface> output_surface( 2623 scoped_ptr<OutputSurface> output_surface(
2624 FakeOutputSurface::Create3d(context_owned.Pass())); 2624 FakeOutputSurface::Create3d(context_owned.Pass()));
2625 CHECK(output_surface->BindToClient(&output_surface_client)); 2625 CHECK(output_surface->BindToClient(&output_surface_client));
2626 2626
2627 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2627 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2628 output_surface.get(), shared_bitmap_manager_.get(), 2628 output_surface.get(), shared_bitmap_manager_.get(),
2629 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 2629 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
2630 2630
2631 gfx::Size size(1, 1); 2631 gfx::Size size(1, 1);
2632 ResourceFormat format = RGBA_8888; 2632 ResourceFormat format = RGBA_8888;
2633 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2633 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2634 2634
2635 for (int texture_id = 1; texture_id <= 2; ++texture_id) { 2635 for (int texture_id = 1; texture_id <= 2; ++texture_id) {
2636 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT; 2636 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT;
2637 // Check that the texture gets created with the right sampler settings. 2637 // Check that the texture gets created with the right sampler settings.
2638 ResourceId id = resource_provider->CreateGLTexture( 2638 ResourceId id = resource_provider->CreateGLTexture(
2639 size, GL_TEXTURE_2D, texture_pool, wrap_mode, 2639 size, GL_TEXTURE_2D, texture_pool, wrap_mode,
(...skipping 29 matching lines...) Expand all
2669 context->set_support_texture_storage(true); 2669 context->set_support_texture_storage(true);
2670 context->set_support_texture_usage(true); 2670 context->set_support_texture_usage(true);
2671 2671
2672 FakeOutputSurfaceClient output_surface_client; 2672 FakeOutputSurfaceClient output_surface_client;
2673 scoped_ptr<OutputSurface> output_surface( 2673 scoped_ptr<OutputSurface> output_surface(
2674 FakeOutputSurface::Create3d(context_owned.Pass())); 2674 FakeOutputSurface::Create3d(context_owned.Pass()));
2675 CHECK(output_surface->BindToClient(&output_surface_client)); 2675 CHECK(output_surface->BindToClient(&output_surface_client));
2676 2676
2677 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2677 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2678 output_surface.get(), shared_bitmap_manager_.get(), 2678 output_surface.get(), shared_bitmap_manager_.get(),
2679 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 2679 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
2680 2680
2681 gfx::Size size(1, 1); 2681 gfx::Size size(1, 1);
2682 ResourceFormat format = RGBA_8888; 2682 ResourceFormat format = RGBA_8888;
2683 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2683 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2684 2684
2685 const ResourceProvider::TextureHint hints[4] = { 2685 const ResourceProvider::TextureHint hints[4] = {
2686 ResourceProvider::TEXTURE_HINT_DEFAULT, 2686 ResourceProvider::TEXTURE_HINT_DEFAULT,
2687 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 2687 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
2688 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, 2688 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER,
2689 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, 2689 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2734 2734
2735 FakeOutputSurfaceClient output_surface_client; 2735 FakeOutputSurfaceClient output_surface_client;
2736 scoped_ptr<OutputSurface> output_surface( 2736 scoped_ptr<OutputSurface> output_surface(
2737 FakeOutputSurface::CreateSoftware(make_scoped_ptr( 2737 FakeOutputSurface::CreateSoftware(make_scoped_ptr(
2738 new SoftwareOutputDevice))); 2738 new SoftwareOutputDevice)));
2739 CHECK(output_surface->BindToClient(&output_surface_client)); 2739 CHECK(output_surface->BindToClient(&output_surface_client));
2740 2740
2741 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2741 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2742 output_surface.get(), shared_bitmap_manager_.get(), 2742 output_surface.get(), shared_bitmap_manager_.get(),
2743 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 2743 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
2744 false, 1)); 2744 false, 1, false));
2745 2745
2746 uint32 release_sync_point = 0; 2746 uint32 release_sync_point = 0;
2747 bool lost_resource = false; 2747 bool lost_resource = false;
2748 BlockingTaskRunner* main_thread_task_runner = NULL; 2748 BlockingTaskRunner* main_thread_task_runner = NULL;
2749 scoped_ptr<SingleReleaseCallbackImpl> callback = 2749 scoped_ptr<SingleReleaseCallbackImpl> callback =
2750 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback, 2750 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback,
2751 &release_sync_point, 2751 &release_sync_point,
2752 &lost_resource, 2752 &lost_resource,
2753 &main_thread_task_runner)); 2753 &main_thread_task_runner));
2754 TextureMailbox mailbox(shared_bitmap.get(), size); 2754 TextureMailbox mailbox(shared_bitmap.get(), size);
(...skipping 28 matching lines...) Expand all
2783 new TextureStateTrackingContext); 2783 new TextureStateTrackingContext);
2784 TextureStateTrackingContext* context = context_owned.get(); 2784 TextureStateTrackingContext* context = context_owned.get();
2785 2785
2786 FakeOutputSurfaceClient output_surface_client; 2786 FakeOutputSurfaceClient output_surface_client;
2787 scoped_ptr<OutputSurface> output_surface( 2787 scoped_ptr<OutputSurface> output_surface(
2788 FakeOutputSurface::Create3d(context_owned.Pass())); 2788 FakeOutputSurface::Create3d(context_owned.Pass()));
2789 CHECK(output_surface->BindToClient(&output_surface_client)); 2789 CHECK(output_surface->BindToClient(&output_surface_client));
2790 2790
2791 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2791 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2792 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager, 2792 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager,
2793 main_thread_task_runner, 0, false, 1)); 2793 main_thread_task_runner, 0, false, 1, false));
2794 2794
2795 unsigned texture_id = 1; 2795 unsigned texture_id = 1;
2796 uint32 sync_point = 30; 2796 uint32 sync_point = 30;
2797 unsigned target = GL_TEXTURE_2D; 2797 unsigned target = GL_TEXTURE_2D;
2798 2798
2799 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2799 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2800 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2800 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2801 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2801 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2802 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 2802 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2803 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 2803 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2926 new TextureStateTrackingContext); 2926 new TextureStateTrackingContext);
2927 TextureStateTrackingContext* context = context_owned.get(); 2927 TextureStateTrackingContext* context = context_owned.get();
2928 2928
2929 FakeOutputSurfaceClient output_surface_client; 2929 FakeOutputSurfaceClient output_surface_client;
2930 scoped_ptr<OutputSurface> output_surface( 2930 scoped_ptr<OutputSurface> output_surface(
2931 FakeOutputSurface::Create3d(context_owned.Pass())); 2931 FakeOutputSurface::Create3d(context_owned.Pass()));
2932 CHECK(output_surface->BindToClient(&output_surface_client)); 2932 CHECK(output_surface->BindToClient(&output_surface_client));
2933 2933
2934 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2934 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2935 output_surface.get(), shared_bitmap_manager_.get(), 2935 output_surface.get(), shared_bitmap_manager_.get(),
2936 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 2936 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
2937 2937
2938 uint32 sync_point = 30; 2938 uint32 sync_point = 30;
2939 unsigned target = GL_TEXTURE_EXTERNAL_OES; 2939 unsigned target = GL_TEXTURE_EXTERNAL_OES;
2940 2940
2941 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2941 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2942 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2942 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2943 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2943 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2944 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 2944 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2945 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 2945 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
2946 2946
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 new TextureStateTrackingContext); 2995 new TextureStateTrackingContext);
2996 TextureStateTrackingContext* context = context_owned.get(); 2996 TextureStateTrackingContext* context = context_owned.get();
2997 2997
2998 FakeOutputSurfaceClient output_surface_client; 2998 FakeOutputSurfaceClient output_surface_client;
2999 scoped_ptr<OutputSurface> output_surface( 2999 scoped_ptr<OutputSurface> output_surface(
3000 FakeOutputSurface::Create3d(context_owned.Pass())); 3000 FakeOutputSurface::Create3d(context_owned.Pass()));
3001 CHECK(output_surface->BindToClient(&output_surface_client)); 3001 CHECK(output_surface->BindToClient(&output_surface_client));
3002 3002
3003 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3003 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3004 output_surface.get(), shared_bitmap_manager_.get(), 3004 output_surface.get(), shared_bitmap_manager_.get(),
3005 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3005 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3006 3006
3007 uint32 sync_point = 30; 3007 uint32 sync_point = 30;
3008 unsigned target = GL_TEXTURE_2D; 3008 unsigned target = GL_TEXTURE_2D;
3009 3009
3010 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3010 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3011 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 3011 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
3012 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 3012 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
3013 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3013 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3014 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3014 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
3015 3015
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3048 new TextureStateTrackingContext); 3048 new TextureStateTrackingContext);
3049 TextureStateTrackingContext* context = context_owned.get(); 3049 TextureStateTrackingContext* context = context_owned.get();
3050 3050
3051 FakeOutputSurfaceClient output_surface_client; 3051 FakeOutputSurfaceClient output_surface_client;
3052 scoped_ptr<OutputSurface> output_surface( 3052 scoped_ptr<OutputSurface> output_surface(
3053 FakeOutputSurface::Create3d(context_owned.Pass())); 3053 FakeOutputSurface::Create3d(context_owned.Pass()));
3054 CHECK(output_surface->BindToClient(&output_surface_client)); 3054 CHECK(output_surface->BindToClient(&output_surface_client));
3055 3055
3056 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3056 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3057 output_surface.get(), shared_bitmap_manager_.get(), 3057 output_surface.get(), shared_bitmap_manager_.get(),
3058 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3058 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3059 3059
3060 uint32 sync_point = 0; 3060 uint32 sync_point = 0;
3061 unsigned target = GL_TEXTURE_2D; 3061 unsigned target = GL_TEXTURE_2D;
3062 3062
3063 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3063 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3064 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 3064 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
3065 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 3065 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
3066 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3066 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3067 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3067 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
3068 3068
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 new StrictMock<AllocationTrackingContext3D>); 3168 new StrictMock<AllocationTrackingContext3D>);
3169 AllocationTrackingContext3D* context = context_owned.get(); 3169 AllocationTrackingContext3D* context = context_owned.get();
3170 3170
3171 FakeOutputSurfaceClient output_surface_client; 3171 FakeOutputSurfaceClient output_surface_client;
3172 scoped_ptr<OutputSurface> output_surface( 3172 scoped_ptr<OutputSurface> output_surface(
3173 FakeOutputSurface::Create3d(context_owned.Pass())); 3173 FakeOutputSurface::Create3d(context_owned.Pass()));
3174 CHECK(output_surface->BindToClient(&output_surface_client)); 3174 CHECK(output_surface->BindToClient(&output_surface_client));
3175 3175
3176 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3176 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3177 output_surface.get(), shared_bitmap_manager_.get(), 3177 output_surface.get(), shared_bitmap_manager_.get(),
3178 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3178 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3179 3179
3180 gfx::Size size(2, 2); 3180 gfx::Size size(2, 2);
3181 gfx::Vector2d offset(0, 0); 3181 gfx::Vector2d offset(0, 0);
3182 ResourceFormat format = RGBA_8888; 3182 ResourceFormat format = RGBA_8888;
3183 ResourceId id = 0; 3183 ResourceId id = 0;
3184 uint8_t pixels[16] = { 0 }; 3184 uint8_t pixels[16] = { 0 };
3185 int texture_id = 123; 3185 int texture_id = 123;
3186 3186
3187 // Lazy allocation. Don't allocate when creating the resource. 3187 // Lazy allocation. Don't allocate when creating the resource.
3188 id = resource_provider->CreateResource( 3188 id = resource_provider->CreateResource(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 context->set_support_texture_storage(true); 3242 context->set_support_texture_storage(true);
3243 context->set_support_texture_usage(true); 3243 context->set_support_texture_usage(true);
3244 3244
3245 FakeOutputSurfaceClient output_surface_client; 3245 FakeOutputSurfaceClient output_surface_client;
3246 scoped_ptr<OutputSurface> output_surface( 3246 scoped_ptr<OutputSurface> output_surface(
3247 FakeOutputSurface::Create3d(context_owned.Pass())); 3247 FakeOutputSurface::Create3d(context_owned.Pass()));
3248 CHECK(output_surface->BindToClient(&output_surface_client)); 3248 CHECK(output_surface->BindToClient(&output_surface_client));
3249 3249
3250 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3250 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3251 output_surface.get(), shared_bitmap_manager_.get(), 3251 output_surface.get(), shared_bitmap_manager_.get(),
3252 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3252 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3253 3253
3254 gfx::Size size(2, 2); 3254 gfx::Size size(2, 2);
3255 3255
3256 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3256 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3257 const ResourceProvider::TextureHint hints[4] = { 3257 const ResourceProvider::TextureHint hints[4] = {
3258 ResourceProvider::TEXTURE_HINT_DEFAULT, 3258 ResourceProvider::TEXTURE_HINT_DEFAULT,
3259 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3259 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3260 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, 3260 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER,
3261 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, 3261 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER,
3262 }; 3262 };
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3297 context->set_support_texture_storage(true); 3297 context->set_support_texture_storage(true);
3298 context->set_support_texture_usage(true); 3298 context->set_support_texture_usage(true);
3299 3299
3300 FakeOutputSurfaceClient output_surface_client; 3300 FakeOutputSurfaceClient output_surface_client;
3301 scoped_ptr<OutputSurface> output_surface( 3301 scoped_ptr<OutputSurface> output_surface(
3302 FakeOutputSurface::Create3d(context_owned.Pass())); 3302 FakeOutputSurface::Create3d(context_owned.Pass()));
3303 CHECK(output_surface->BindToClient(&output_surface_client)); 3303 CHECK(output_surface->BindToClient(&output_surface_client));
3304 3304
3305 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3305 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3306 output_surface.get(), shared_bitmap_manager_.get(), 3306 output_surface.get(), shared_bitmap_manager_.get(),
3307 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3307 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3308 3308
3309 gfx::Size size(2, 2); 3309 gfx::Size size(2, 2);
3310 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3310 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3311 3311
3312 const ResourceProvider::TextureHint hints[4] = { 3312 const ResourceProvider::TextureHint hints[4] = {
3313 ResourceProvider::TEXTURE_HINT_DEFAULT, 3313 ResourceProvider::TEXTURE_HINT_DEFAULT,
3314 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3314 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3315 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, 3315 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER,
3316 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, 3316 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER,
3317 }; 3317 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3351 FakeOutputSurface::Create3d(context_owned.Pass())); 3351 FakeOutputSurface::Create3d(context_owned.Pass()));
3352 CHECK(output_surface->BindToClient(&output_surface_client)); 3352 CHECK(output_surface->BindToClient(&output_surface_client));
3353 3353
3354 gfx::Size size(2, 2); 3354 gfx::Size size(2, 2);
3355 ResourceFormat format = RGBA_8888; 3355 ResourceFormat format = RGBA_8888;
3356 ResourceId id = 0; 3356 ResourceId id = 0;
3357 int texture_id = 123; 3357 int texture_id = 123;
3358 3358
3359 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3359 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3360 output_surface.get(), shared_bitmap_manager_.get(), 3360 output_surface.get(), shared_bitmap_manager_.get(),
3361 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3361 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3362 3362
3363 id = resource_provider->CreateResource( 3363 id = resource_provider->CreateResource(
3364 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3364 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3365 resource_provider->AcquirePixelBuffer(id); 3365 resource_provider->AcquirePixelBuffer(id);
3366 3366
3367 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3367 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3368 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3368 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3369 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) 3369 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
3370 .Times(1); 3370 .Times(1);
3371 resource_provider->BeginSetPixels(id); 3371 resource_provider->BeginSetPixels(id);
(...skipping 21 matching lines...) Expand all
3393 FakeOutputSurface::Create3d(context_owned.Pass())); 3393 FakeOutputSurface::Create3d(context_owned.Pass()));
3394 CHECK(output_surface->BindToClient(&output_surface_client)); 3394 CHECK(output_surface->BindToClient(&output_surface_client));
3395 3395
3396 gfx::Size size(2, 2); 3396 gfx::Size size(2, 2);
3397 ResourceFormat format = RGBA_8888; 3397 ResourceFormat format = RGBA_8888;
3398 ResourceId id = 0; 3398 ResourceId id = 0;
3399 int texture_id = 123; 3399 int texture_id = 123;
3400 3400
3401 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3401 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3402 output_surface.get(), shared_bitmap_manager_.get(), 3402 output_surface.get(), shared_bitmap_manager_.get(),
3403 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3403 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3404 3404
3405 id = resource_provider->CreateResource( 3405 id = resource_provider->CreateResource(
3406 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3406 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3407 resource_provider->AcquirePixelBuffer(id); 3407 resource_provider->AcquirePixelBuffer(id);
3408 3408
3409 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3409 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3410 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3410 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3411 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) 3411 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
3412 .Times(1); 3412 .Times(1);
3413 resource_provider->BeginSetPixels(id); 3413 resource_provider->BeginSetPixels(id);
(...skipping 21 matching lines...) Expand all
3435 FakeOutputSurface::Create3d(context_owned.Pass())); 3435 FakeOutputSurface::Create3d(context_owned.Pass()));
3436 CHECK(output_surface->BindToClient(&output_surface_client)); 3436 CHECK(output_surface->BindToClient(&output_surface_client));
3437 3437
3438 gfx::Size size(2, 2); 3438 gfx::Size size(2, 2);
3439 ResourceFormat format = RGBA_8888; 3439 ResourceFormat format = RGBA_8888;
3440 ResourceId id = 0; 3440 ResourceId id = 0;
3441 int texture_id = 123; 3441 int texture_id = 123;
3442 3442
3443 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3443 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3444 output_surface.get(), shared_bitmap_manager_.get(), 3444 output_surface.get(), shared_bitmap_manager_.get(),
3445 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3445 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3446 3446
3447 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); 3447 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id));
3448 3448
3449 id = resource_provider->CreateResource( 3449 id = resource_provider->CreateResource(
3450 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3450 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3451 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 3451 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
3452 GL_INNOCENT_CONTEXT_RESET_ARB); 3452 GL_INNOCENT_CONTEXT_RESET_ARB);
3453 3453
3454 resource_provider->AcquirePixelBuffer(id); 3454 resource_provider->AcquirePixelBuffer(id);
3455 int stride; 3455 int stride;
(...skipping 19 matching lines...) Expand all
3475 const int kWidth = 2; 3475 const int kWidth = 2;
3476 const int kHeight = 2; 3476 const int kHeight = 2;
3477 gfx::Size size(kWidth, kHeight); 3477 gfx::Size size(kWidth, kHeight);
3478 ResourceFormat format = RGBA_8888; 3478 ResourceFormat format = RGBA_8888;
3479 ResourceId id = 0; 3479 ResourceId id = 0;
3480 const unsigned kTextureId = 123u; 3480 const unsigned kTextureId = 123u;
3481 const unsigned kImageId = 234u; 3481 const unsigned kImageId = 234u;
3482 3482
3483 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3483 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3484 output_surface.get(), shared_bitmap_manager_.get(), 3484 output_surface.get(), shared_bitmap_manager_.get(),
3485 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3485 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3486 3486
3487 id = resource_provider->CreateResource( 3487 id = resource_provider->CreateResource(
3488 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3488 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3489 3489
3490 EXPECT_CALL(*context, NextTextureId()) 3490 EXPECT_CALL(*context, NextTextureId())
3491 .WillOnce(Return(kTextureId)) 3491 .WillOnce(Return(kTextureId))
3492 .RetiresOnSaturation(); 3492 .RetiresOnSaturation();
3493 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)) 3493 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId))
3494 .Times(1) 3494 .Times(1)
3495 .RetiresOnSaturation(); 3495 .RetiresOnSaturation();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3535 ResourceProvider::ScopedSamplerGL lock_gl( 3535 ResourceProvider::ScopedSamplerGL lock_gl(
3536 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); 3536 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
3537 EXPECT_EQ(kTextureId, lock_gl.texture_id()); 3537 EXPECT_EQ(kTextureId, lock_gl.texture_id());
3538 } 3538 }
3539 3539
3540 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId)) 3540 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId))
3541 .Times(1) 3541 .Times(1)
3542 .RetiresOnSaturation(); 3542 .RetiresOnSaturation();
3543 } 3543 }
3544 3544
3545 TEST_P(ResourceProviderTest, CopyResource_GLTexture) {
3546 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3547 return;
3548 scoped_ptr<AllocationTrackingContext3D> context_owned(
3549 new StrictMock<AllocationTrackingContext3D>);
3550 AllocationTrackingContext3D* context = context_owned.get();
3551 context_owned->set_support_sync_query(true);
3552
3553 FakeOutputSurfaceClient output_surface_client;
3554 scoped_ptr<OutputSurface> output_surface(
3555 FakeOutputSurface::Create3d(context_owned.Pass()));
3556 ASSERT_TRUE(output_surface->BindToClient(&output_surface_client));
3557
3558 const int kWidth = 2;
3559 const int kHeight = 2;
3560 gfx::Size size(kWidth, kHeight);
3561 ResourceFormat format = RGBA_8888;
3562 ResourceId source_id = 0;
3563 ResourceId dest_id = 0;
3564 const unsigned kSourceTextureId = 123u;
3565 const unsigned kDestTextureId = 321u;
3566 const unsigned kImageId = 234u;
3567
3568 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3569 output_surface.get(), shared_bitmap_manager_.get(),
3570 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3571
3572 source_id = resource_provider->CreateResource(
3573 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3574
3575 EXPECT_CALL(*context, NextTextureId())
3576 .WillOnce(Return(kSourceTextureId))
3577 .RetiresOnSaturation();
3578 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kSourceTextureId))
3579 .Times(1)
3580 .RetiresOnSaturation();
3581 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
3582 .WillOnce(Return(kImageId))
3583 .RetiresOnSaturation();
3584 {
3585 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3586 resource_provider.get(), source_id);
3587 EXPECT_TRUE(lock.GetGpuMemoryBuffer());
3588 }
3589 Mock::VerifyAndClearExpectations(context);
3590
3591 dest_id = resource_provider->CreateResource(
3592 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3593
3594 EXPECT_CALL(*context, NextTextureId())
3595 .WillOnce(Return(kDestTextureId))
3596 .RetiresOnSaturation();
3597 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId))
3598 .Times(2)
3599 .RetiresOnSaturation();
3600 EXPECT_CALL(*context, texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA,
3601 GL_UNSIGNED_BYTE, nullptr))
3602 .Times(1)
3603 .RetiresOnSaturation();
3604 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kSourceTextureId))
3605 .Times(1)
3606 .RetiresOnSaturation();
3607 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3608 .Times(1)
3609 .RetiresOnSaturation();
3610 resource_provider->CopyResource(source_id, dest_id, gfx::Rect(size));
3611 Mock::VerifyAndClearExpectations(context);
3612
3613 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId))
3614 .Times(1)
3615 .RetiresOnSaturation();
3616 EXPECT_CALL(*context, RetireTextureId(kSourceTextureId))
3617 .Times(1)
3618 .RetiresOnSaturation();
3619 EXPECT_CALL(*context, RetireTextureId(kDestTextureId))
3620 .Times(1)
3621 .RetiresOnSaturation();
3622 resource_provider->DeleteResource(source_id);
3623 resource_provider->DeleteResource(dest_id);
3624 }
3625
3545 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) { 3626 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) {
3546 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3627 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3547 return; 3628 return;
3548 3629
3549 scoped_ptr<AllocationTrackingContext3D> context_owned( 3630 scoped_ptr<AllocationTrackingContext3D> context_owned(
3550 new AllocationTrackingContext3D); 3631 new AllocationTrackingContext3D);
3551 AllocationTrackingContext3D* context = context_owned.get(); 3632 AllocationTrackingContext3D* context = context_owned.get();
3552 context_owned->set_support_compressed_texture_etc1(true); 3633 context_owned->set_support_compressed_texture_etc1(true);
3553 3634
3554 FakeOutputSurfaceClient output_surface_client; 3635 FakeOutputSurfaceClient output_surface_client;
3555 scoped_ptr<OutputSurface> output_surface( 3636 scoped_ptr<OutputSurface> output_surface(
3556 FakeOutputSurface::Create3d(context_owned.Pass())); 3637 FakeOutputSurface::Create3d(context_owned.Pass()));
3557 CHECK(output_surface->BindToClient(&output_surface_client)); 3638 CHECK(output_surface->BindToClient(&output_surface_client));
3558 3639
3559 gfx::Size size(4, 4); 3640 gfx::Size size(4, 4);
3560 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3641 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3561 output_surface.get(), shared_bitmap_manager_.get(), 3642 output_surface.get(), shared_bitmap_manager_.get(),
3562 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3643 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3563 int texture_id = 123; 3644 int texture_id = 123;
3564 3645
3565 ResourceId id = resource_provider->CreateResource( 3646 ResourceId id = resource_provider->CreateResource(
3566 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); 3647 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1);
3567 EXPECT_NE(0u, id); 3648 EXPECT_NE(0u, id);
3568 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3649 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3569 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3650 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3570 resource_provider->AllocateForTesting(id); 3651 resource_provider->AllocateForTesting(id);
3571 3652
3572 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); 3653 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
(...skipping 10 matching lines...) Expand all
3583 context_owned->set_support_compressed_texture_etc1(true); 3664 context_owned->set_support_compressed_texture_etc1(true);
3584 3665
3585 FakeOutputSurfaceClient output_surface_client; 3666 FakeOutputSurfaceClient output_surface_client;
3586 scoped_ptr<OutputSurface> output_surface( 3667 scoped_ptr<OutputSurface> output_surface(
3587 FakeOutputSurface::Create3d(context_owned.Pass())); 3668 FakeOutputSurface::Create3d(context_owned.Pass()));
3588 CHECK(output_surface->BindToClient(&output_surface_client)); 3669 CHECK(output_surface->BindToClient(&output_surface_client));
3589 3670
3590 gfx::Size size(4, 4); 3671 gfx::Size size(4, 4);
3591 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3672 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3592 output_surface.get(), shared_bitmap_manager_.get(), 3673 output_surface.get(), shared_bitmap_manager_.get(),
3593 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1)); 3674 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false));
3594 int texture_id = 123; 3675 int texture_id = 123;
3595 uint8_t pixels[8]; 3676 uint8_t pixels[8];
3596 3677
3597 ResourceId id = resource_provider->CreateResource( 3678 ResourceId id = resource_provider->CreateResource(
3598 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); 3679 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1);
3599 EXPECT_NE(0u, id); 3680 EXPECT_NE(0u, id);
3600 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3681 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3601 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); 3682 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3);
3602 EXPECT_CALL(*context, 3683 EXPECT_CALL(*context,
3603 compressedTexImage2D( 3684 compressedTexImage2D(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3639 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 3720 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
3640 new TestSharedBitmapManager()); 3721 new TestSharedBitmapManager());
3641 3722
3642 gfx::Size size(1, 1); 3723 gfx::Size size(1, 1);
3643 ResourceFormat format = RGBA_8888; 3724 ResourceFormat format = RGBA_8888;
3644 3725
3645 { 3726 {
3646 size_t kTextureAllocationChunkSize = 1; 3727 size_t kTextureAllocationChunkSize = 1;
3647 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3728 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3648 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false, 3729 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
3649 kTextureAllocationChunkSize)); 3730 kTextureAllocationChunkSize, false));
3650 3731
3651 ResourceId id = resource_provider->CreateResource( 3732 ResourceId id = resource_provider->CreateResource(
3652 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3733 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3653 format); 3734 format);
3654 resource_provider->AllocateForTesting(id); 3735 resource_provider->AllocateForTesting(id);
3655 Mock::VerifyAndClearExpectations(context); 3736 Mock::VerifyAndClearExpectations(context);
3656 3737
3657 DCHECK_EQ(2u, context->PeekTextureId()); 3738 DCHECK_EQ(2u, context->PeekTextureId());
3658 resource_provider->DeleteResource(id); 3739 resource_provider->DeleteResource(id);
3659 } 3740 }
3660 3741
3661 { 3742 {
3662 size_t kTextureAllocationChunkSize = 8; 3743 size_t kTextureAllocationChunkSize = 8;
3663 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3744 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3664 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false, 3745 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
3665 kTextureAllocationChunkSize)); 3746 kTextureAllocationChunkSize, false));
3666 3747
3667 ResourceId id = resource_provider->CreateResource( 3748 ResourceId id = resource_provider->CreateResource(
3668 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3749 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3669 format); 3750 format);
3670 resource_provider->AllocateForTesting(id); 3751 resource_provider->AllocateForTesting(id);
3671 Mock::VerifyAndClearExpectations(context); 3752 Mock::VerifyAndClearExpectations(context);
3672 3753
3673 DCHECK_EQ(10u, context->PeekTextureId()); 3754 DCHECK_EQ(10u, context->PeekTextureId());
3674 resource_provider->DeleteResource(id); 3755 resource_provider->DeleteResource(id);
3675 } 3756 }
3676 } 3757 }
3677 3758
3678 } // namespace 3759 } // namespace
3679 } // namespace cc 3760 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/surfaces/display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698