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

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

Issue 1230203007: Re-land: cc: Use worker context for one-copy tile initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 #include <vector> 10 #include <vector>
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 415 }
416 CHECK(output_surface_->BindToClient(&output_surface_client_)); 416 CHECK(output_surface_->BindToClient(&output_surface_client_));
417 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_)); 417 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_));
418 418
419 shared_bitmap_manager_.reset(new TestSharedBitmapManager); 419 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
420 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); 420 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
421 421
422 resource_provider_ = ResourceProvider::Create( 422 resource_provider_ = ResourceProvider::Create(
423 output_surface_.get(), shared_bitmap_manager_.get(), 423 output_surface_.get(), shared_bitmap_manager_.get(),
424 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 424 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
425 false, 1, false, use_image_texture_targets_); 425 false, 1, use_image_texture_targets_);
426 child_resource_provider_ = ResourceProvider::Create( 426 child_resource_provider_ = ResourceProvider::Create(
427 child_output_surface_.get(), shared_bitmap_manager_.get(), 427 child_output_surface_.get(), shared_bitmap_manager_.get(),
428 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 428 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
429 false, 1, false, use_image_texture_targets_); 429 false, 1, use_image_texture_targets_);
430 } 430 }
431 431
432 ResourceProviderTest() : ResourceProviderTest(true) {} 432 ResourceProviderTest() : ResourceProviderTest(true) {}
433 433
434 static void CollectResources(ReturnedResourceArray* array, 434 static void CollectResources(ReturnedResourceArray* array,
435 const ReturnedResourceArray& returned, 435 const ReturnedResourceArray& returned,
436 BlockingTaskRunner* main_thread_task_runner) { 436 BlockingTaskRunner* main_thread_task_runner) {
437 array->insert(array->end(), returned.begin(), returned.end()); 437 array->insert(array->end(), returned.begin(), returned.end());
438 } 438 }
439 439
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 scoped_ptr<ResourceProviderContext> child_context_owned( 1371 scoped_ptr<ResourceProviderContext> child_context_owned(
1372 ResourceProviderContext::Create(shared_data_.get())); 1372 ResourceProviderContext::Create(shared_data_.get()));
1373 1373
1374 FakeOutputSurfaceClient child_output_surface_client; 1374 FakeOutputSurfaceClient child_output_surface_client;
1375 scoped_ptr<OutputSurface> child_output_surface( 1375 scoped_ptr<OutputSurface> child_output_surface(
1376 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1376 FakeOutputSurface::Create3d(child_context_owned.Pass()));
1377 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1377 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1378 1378
1379 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create( 1379 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create(
1380 child_output_surface.get(), shared_bitmap_manager_.get(), 1380 child_output_surface.get(), shared_bitmap_manager_.get(),
1381 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 1381 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
1382 use_image_texture_targets_)); 1382 use_image_texture_targets_));
1383 1383
1384 gfx::Size size(1, 1); 1384 gfx::Size size(1, 1);
1385 ResourceFormat format = RGBA_8888; 1385 ResourceFormat format = RGBA_8888;
1386 size_t pixel_size = TextureSizeBytes(size, format); 1386 size_t pixel_size = TextureSizeBytes(size, format);
1387 ASSERT_EQ(4U, pixel_size); 1387 ASSERT_EQ(4U, pixel_size);
1388 1388
1389 ResourceId id1 = child_resource_provider->CreateResource( 1389 ResourceId id1 = child_resource_provider->CreateResource(
1390 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 1390 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
1391 uint8_t data1[4] = { 1, 2, 3, 4 }; 1391 uint8_t data1[4] = { 1, 2, 3, 4 };
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 FakeOutputSurfaceClient child_output_surface_client; 1856 FakeOutputSurfaceClient child_output_surface_client;
1857 scoped_ptr<OutputSurface> child_output_surface( 1857 scoped_ptr<OutputSurface> child_output_surface(
1858 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1858 FakeOutputSurface::Create3d(child_context_owned.Pass()));
1859 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1859 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1860 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1860 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
1861 new TestSharedBitmapManager()); 1861 new TestSharedBitmapManager());
1862 1862
1863 scoped_ptr<ResourceProvider> child_resource_provider( 1863 scoped_ptr<ResourceProvider> child_resource_provider(
1864 ResourceProvider::Create(child_output_surface.get(), 1864 ResourceProvider::Create(child_output_surface.get(),
1865 shared_bitmap_manager.get(), NULL, NULL, 0, 1865 shared_bitmap_manager.get(), NULL, NULL, 0,
1866 false, 1, false, use_image_texture_targets_)); 1866 false, 1, use_image_texture_targets_));
1867 1867
1868 scoped_ptr<TextureStateTrackingContext> parent_context_owned( 1868 scoped_ptr<TextureStateTrackingContext> parent_context_owned(
1869 new TextureStateTrackingContext); 1869 new TextureStateTrackingContext);
1870 TextureStateTrackingContext* parent_context = parent_context_owned.get(); 1870 TextureStateTrackingContext* parent_context = parent_context_owned.get();
1871 1871
1872 FakeOutputSurfaceClient parent_output_surface_client; 1872 FakeOutputSurfaceClient parent_output_surface_client;
1873 scoped_ptr<OutputSurface> parent_output_surface( 1873 scoped_ptr<OutputSurface> parent_output_surface(
1874 FakeOutputSurface::Create3d(parent_context_owned.Pass())); 1874 FakeOutputSurface::Create3d(parent_context_owned.Pass()));
1875 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); 1875 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
1876 1876
1877 scoped_ptr<ResourceProvider> parent_resource_provider( 1877 scoped_ptr<ResourceProvider> parent_resource_provider(
1878 ResourceProvider::Create(parent_output_surface.get(), 1878 ResourceProvider::Create(parent_output_surface.get(),
1879 shared_bitmap_manager.get(), NULL, NULL, 0, 1879 shared_bitmap_manager.get(), NULL, NULL, 0,
1880 false, 1, false, use_image_texture_targets_)); 1880 false, 1, use_image_texture_targets_));
1881 1881
1882 gfx::Size size(1, 1); 1882 gfx::Size size(1, 1);
1883 ResourceFormat format = RGBA_8888; 1883 ResourceFormat format = RGBA_8888;
1884 int child_texture_id = 1; 1884 int child_texture_id = 1;
1885 int parent_texture_id = 2; 1885 int parent_texture_id = 2;
1886 1886
1887 size_t pixel_size = TextureSizeBytes(size, format); 1887 size_t pixel_size = TextureSizeBytes(size, format);
1888 ASSERT_EQ(4U, pixel_size); 1888 ASSERT_EQ(4U, pixel_size);
1889 1889
1890 ResourceId id = child_resource_provider->CreateResource( 1890 ResourceId id = child_resource_provider->CreateResource(
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 new TextureStateTrackingContext); 2502 new TextureStateTrackingContext);
2503 TextureStateTrackingContext* context = context_owned.get(); 2503 TextureStateTrackingContext* context = context_owned.get();
2504 2504
2505 FakeOutputSurfaceClient output_surface_client; 2505 FakeOutputSurfaceClient output_surface_client;
2506 scoped_ptr<OutputSurface> output_surface( 2506 scoped_ptr<OutputSurface> output_surface(
2507 FakeOutputSurface::Create3d(context_owned.Pass())); 2507 FakeOutputSurface::Create3d(context_owned.Pass()));
2508 CHECK(output_surface->BindToClient(&output_surface_client)); 2508 CHECK(output_surface->BindToClient(&output_surface_client));
2509 2509
2510 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2510 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2511 output_surface.get(), shared_bitmap_manager_.get(), 2511 output_surface.get(), shared_bitmap_manager_.get(),
2512 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 2512 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
2513 use_image_texture_targets_)); 2513 use_image_texture_targets_));
2514 2514
2515 gfx::Size size(1, 1); 2515 gfx::Size size(1, 1);
2516 ResourceFormat format = RGBA_8888; 2516 ResourceFormat format = RGBA_8888;
2517 int texture_id = 1; 2517 int texture_id = 1;
2518 2518
2519 ResourceId id = resource_provider->CreateResource( 2519 ResourceId id = resource_provider->CreateResource(
2520 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 2520 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
2521 2521
2522 // Check that the texture gets created with the right sampler settings. 2522 // Check that the texture gets created with the right sampler settings.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 new TextureStateTrackingContext); 2585 new TextureStateTrackingContext);
2586 TextureStateTrackingContext* context = context_owned.get(); 2586 TextureStateTrackingContext* context = context_owned.get();
2587 2587
2588 FakeOutputSurfaceClient output_surface_client; 2588 FakeOutputSurfaceClient output_surface_client;
2589 scoped_ptr<OutputSurface> output_surface( 2589 scoped_ptr<OutputSurface> output_surface(
2590 FakeOutputSurface::Create3d(context_owned.Pass())); 2590 FakeOutputSurface::Create3d(context_owned.Pass()));
2591 CHECK(output_surface->BindToClient(&output_surface_client)); 2591 CHECK(output_surface->BindToClient(&output_surface_client));
2592 2592
2593 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2593 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2594 output_surface.get(), shared_bitmap_manager_.get(), 2594 output_surface.get(), shared_bitmap_manager_.get(),
2595 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 2595 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
2596 use_image_texture_targets_)); 2596 use_image_texture_targets_));
2597 2597
2598 gfx::Size size(1, 1); 2598 gfx::Size size(1, 1);
2599 ResourceFormat format = RGBA_8888; 2599 ResourceFormat format = RGBA_8888;
2600 int texture_id = 1; 2600 int texture_id = 1;
2601 2601
2602 // Check that the texture gets created with the right sampler settings. 2602 // Check that the texture gets created with the right sampler settings.
2603 ResourceId id = resource_provider->CreateManagedResource( 2603 ResourceId id = resource_provider->CreateManagedResource(
2604 size, GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, 2604 size, GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,
2605 ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 2605 ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
(...skipping 27 matching lines...) Expand all
2633 new TextureStateTrackingContext); 2633 new TextureStateTrackingContext);
2634 TextureStateTrackingContext* context = context_owned.get(); 2634 TextureStateTrackingContext* context = context_owned.get();
2635 2635
2636 FakeOutputSurfaceClient output_surface_client; 2636 FakeOutputSurfaceClient output_surface_client;
2637 scoped_ptr<OutputSurface> output_surface( 2637 scoped_ptr<OutputSurface> output_surface(
2638 FakeOutputSurface::Create3d(context_owned.Pass())); 2638 FakeOutputSurface::Create3d(context_owned.Pass()));
2639 CHECK(output_surface->BindToClient(&output_surface_client)); 2639 CHECK(output_surface->BindToClient(&output_surface_client));
2640 2640
2641 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2641 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2642 output_surface.get(), shared_bitmap_manager_.get(), 2642 output_surface.get(), shared_bitmap_manager_.get(),
2643 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 2643 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
2644 use_image_texture_targets_)); 2644 use_image_texture_targets_));
2645 2645
2646 gfx::Size size(1, 1); 2646 gfx::Size size(1, 1);
2647 ResourceFormat format = RGBA_8888; 2647 ResourceFormat format = RGBA_8888;
2648 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2648 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2649 2649
2650 for (int texture_id = 1; texture_id <= 2; ++texture_id) { 2650 for (int texture_id = 1; texture_id <= 2; ++texture_id) {
2651 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT; 2651 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT;
2652 // Check that the texture gets created with the right sampler settings. 2652 // Check that the texture gets created with the right sampler settings.
2653 ResourceId id = resource_provider->CreateGLTexture( 2653 ResourceId id = resource_provider->CreateGLTexture(
(...skipping 30 matching lines...) Expand all
2684 context->set_support_texture_storage(true); 2684 context->set_support_texture_storage(true);
2685 context->set_support_texture_usage(true); 2685 context->set_support_texture_usage(true);
2686 2686
2687 FakeOutputSurfaceClient output_surface_client; 2687 FakeOutputSurfaceClient output_surface_client;
2688 scoped_ptr<OutputSurface> output_surface( 2688 scoped_ptr<OutputSurface> output_surface(
2689 FakeOutputSurface::Create3d(context_owned.Pass())); 2689 FakeOutputSurface::Create3d(context_owned.Pass()));
2690 CHECK(output_surface->BindToClient(&output_surface_client)); 2690 CHECK(output_surface->BindToClient(&output_surface_client));
2691 2691
2692 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2692 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2693 output_surface.get(), shared_bitmap_manager_.get(), 2693 output_surface.get(), shared_bitmap_manager_.get(),
2694 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 2694 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
2695 use_image_texture_targets_)); 2695 use_image_texture_targets_));
2696 2696
2697 gfx::Size size(1, 1); 2697 gfx::Size size(1, 1);
2698 ResourceFormat format = RGBA_8888; 2698 ResourceFormat format = RGBA_8888;
2699 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2699 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2700 2700
2701 const ResourceProvider::TextureHint hints[4] = { 2701 const ResourceProvider::TextureHint hints[4] = {
2702 ResourceProvider::TEXTURE_HINT_DEFAULT, 2702 ResourceProvider::TEXTURE_HINT_DEFAULT,
2703 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 2703 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
2704 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, 2704 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2750 2750
2751 FakeOutputSurfaceClient output_surface_client; 2751 FakeOutputSurfaceClient output_surface_client;
2752 scoped_ptr<OutputSurface> output_surface( 2752 scoped_ptr<OutputSurface> output_surface(
2753 FakeOutputSurface::CreateSoftware(make_scoped_ptr( 2753 FakeOutputSurface::CreateSoftware(make_scoped_ptr(
2754 new SoftwareOutputDevice))); 2754 new SoftwareOutputDevice)));
2755 CHECK(output_surface->BindToClient(&output_surface_client)); 2755 CHECK(output_surface->BindToClient(&output_surface_client));
2756 2756
2757 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2757 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2758 output_surface.get(), shared_bitmap_manager_.get(), 2758 output_surface.get(), shared_bitmap_manager_.get(),
2759 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 2759 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
2760 false, 1, false, use_image_texture_targets_)); 2760 false, 1, use_image_texture_targets_));
2761 2761
2762 uint32 release_sync_point = 0; 2762 uint32 release_sync_point = 0;
2763 bool lost_resource = false; 2763 bool lost_resource = false;
2764 BlockingTaskRunner* main_thread_task_runner = NULL; 2764 BlockingTaskRunner* main_thread_task_runner = NULL;
2765 scoped_ptr<SingleReleaseCallbackImpl> callback = 2765 scoped_ptr<SingleReleaseCallbackImpl> callback =
2766 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback, 2766 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback,
2767 &release_sync_point, 2767 &release_sync_point,
2768 &lost_resource, 2768 &lost_resource,
2769 &main_thread_task_runner)); 2769 &main_thread_task_runner));
2770 TextureMailbox mailbox(shared_bitmap.get(), size); 2770 TextureMailbox mailbox(shared_bitmap.get(), size);
(...skipping 28 matching lines...) Expand all
2799 new TextureStateTrackingContext); 2799 new TextureStateTrackingContext);
2800 TextureStateTrackingContext* context = context_owned.get(); 2800 TextureStateTrackingContext* context = context_owned.get();
2801 2801
2802 FakeOutputSurfaceClient output_surface_client; 2802 FakeOutputSurfaceClient output_surface_client;
2803 scoped_ptr<OutputSurface> output_surface( 2803 scoped_ptr<OutputSurface> output_surface(
2804 FakeOutputSurface::Create3d(context_owned.Pass())); 2804 FakeOutputSurface::Create3d(context_owned.Pass()));
2805 CHECK(output_surface->BindToClient(&output_surface_client)); 2805 CHECK(output_surface->BindToClient(&output_surface_client));
2806 2806
2807 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2807 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2808 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager, 2808 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager,
2809 main_thread_task_runner, 0, false, 1, false, 2809 main_thread_task_runner, 0, false, 1, use_image_texture_targets_));
2810 use_image_texture_targets_));
2811 2810
2812 unsigned texture_id = 1; 2811 unsigned texture_id = 1;
2813 uint32 sync_point = 30; 2812 uint32 sync_point = 30;
2814 unsigned target = GL_TEXTURE_2D; 2813 unsigned target = GL_TEXTURE_2D;
2815 2814
2816 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2815 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2817 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2816 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2818 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2817 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2819 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 2818 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2820 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 2819 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 new TextureStateTrackingContext); 2942 new TextureStateTrackingContext);
2944 TextureStateTrackingContext* context = context_owned.get(); 2943 TextureStateTrackingContext* context = context_owned.get();
2945 2944
2946 FakeOutputSurfaceClient output_surface_client; 2945 FakeOutputSurfaceClient output_surface_client;
2947 scoped_ptr<OutputSurface> output_surface( 2946 scoped_ptr<OutputSurface> output_surface(
2948 FakeOutputSurface::Create3d(context_owned.Pass())); 2947 FakeOutputSurface::Create3d(context_owned.Pass()));
2949 CHECK(output_surface->BindToClient(&output_surface_client)); 2948 CHECK(output_surface->BindToClient(&output_surface_client));
2950 2949
2951 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2950 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2952 output_surface.get(), shared_bitmap_manager_.get(), 2951 output_surface.get(), shared_bitmap_manager_.get(),
2953 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 2952 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
2954 use_image_texture_targets_)); 2953 use_image_texture_targets_));
2955 2954
2956 uint32 sync_point = 30; 2955 uint32 sync_point = 30;
2957 unsigned target = GL_TEXTURE_EXTERNAL_OES; 2956 unsigned target = GL_TEXTURE_EXTERNAL_OES;
2958 2957
2959 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2958 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2960 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2959 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2961 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2960 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2962 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 2961 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2963 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 2962 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3013 new TextureStateTrackingContext); 3012 new TextureStateTrackingContext);
3014 TextureStateTrackingContext* context = context_owned.get(); 3013 TextureStateTrackingContext* context = context_owned.get();
3015 3014
3016 FakeOutputSurfaceClient output_surface_client; 3015 FakeOutputSurfaceClient output_surface_client;
3017 scoped_ptr<OutputSurface> output_surface( 3016 scoped_ptr<OutputSurface> output_surface(
3018 FakeOutputSurface::Create3d(context_owned.Pass())); 3017 FakeOutputSurface::Create3d(context_owned.Pass()));
3019 CHECK(output_surface->BindToClient(&output_surface_client)); 3018 CHECK(output_surface->BindToClient(&output_surface_client));
3020 3019
3021 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3020 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3022 output_surface.get(), shared_bitmap_manager_.get(), 3021 output_surface.get(), shared_bitmap_manager_.get(),
3023 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3022 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3024 use_image_texture_targets_)); 3023 use_image_texture_targets_));
3025 3024
3026 uint32 sync_point = 30; 3025 uint32 sync_point = 30;
3027 unsigned target = GL_TEXTURE_2D; 3026 unsigned target = GL_TEXTURE_2D;
3028 3027
3029 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3028 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3030 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 3029 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
3031 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 3030 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
3032 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3031 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3033 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3032 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3067 new TextureStateTrackingContext); 3066 new TextureStateTrackingContext);
3068 TextureStateTrackingContext* context = context_owned.get(); 3067 TextureStateTrackingContext* context = context_owned.get();
3069 3068
3070 FakeOutputSurfaceClient output_surface_client; 3069 FakeOutputSurfaceClient output_surface_client;
3071 scoped_ptr<OutputSurface> output_surface( 3070 scoped_ptr<OutputSurface> output_surface(
3072 FakeOutputSurface::Create3d(context_owned.Pass())); 3071 FakeOutputSurface::Create3d(context_owned.Pass()));
3073 CHECK(output_surface->BindToClient(&output_surface_client)); 3072 CHECK(output_surface->BindToClient(&output_surface_client));
3074 3073
3075 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3074 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3076 output_surface.get(), shared_bitmap_manager_.get(), 3075 output_surface.get(), shared_bitmap_manager_.get(),
3077 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3076 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3078 use_image_texture_targets_)); 3077 use_image_texture_targets_));
3079 3078
3080 uint32 sync_point = 0; 3079 uint32 sync_point = 0;
3081 unsigned target = GL_TEXTURE_2D; 3080 unsigned target = GL_TEXTURE_2D;
3082 3081
3083 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3082 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3084 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 3083 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
3085 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 3084 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
3086 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3085 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3087 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3086 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 new StrictMock<AllocationTrackingContext3D>); 3187 new StrictMock<AllocationTrackingContext3D>);
3189 AllocationTrackingContext3D* context = context_owned.get(); 3188 AllocationTrackingContext3D* context = context_owned.get();
3190 3189
3191 FakeOutputSurfaceClient output_surface_client; 3190 FakeOutputSurfaceClient output_surface_client;
3192 scoped_ptr<OutputSurface> output_surface( 3191 scoped_ptr<OutputSurface> output_surface(
3193 FakeOutputSurface::Create3d(context_owned.Pass())); 3192 FakeOutputSurface::Create3d(context_owned.Pass()));
3194 CHECK(output_surface->BindToClient(&output_surface_client)); 3193 CHECK(output_surface->BindToClient(&output_surface_client));
3195 3194
3196 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3195 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3197 output_surface.get(), shared_bitmap_manager_.get(), 3196 output_surface.get(), shared_bitmap_manager_.get(),
3198 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3197 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3199 use_image_texture_targets_)); 3198 use_image_texture_targets_));
3200 3199
3201 gfx::Size size(2, 2); 3200 gfx::Size size(2, 2);
3202 gfx::Vector2d offset(0, 0); 3201 gfx::Vector2d offset(0, 0);
3203 ResourceFormat format = RGBA_8888; 3202 ResourceFormat format = RGBA_8888;
3204 ResourceId id = 0; 3203 ResourceId id = 0;
3205 uint8_t pixels[16] = { 0 }; 3204 uint8_t pixels[16] = { 0 };
3206 int texture_id = 123; 3205 int texture_id = 123;
3207 3206
3208 // Lazy allocation. Don't allocate when creating the resource. 3207 // Lazy allocation. Don't allocate when creating the resource.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3263 context->set_support_texture_storage(true); 3262 context->set_support_texture_storage(true);
3264 context->set_support_texture_usage(true); 3263 context->set_support_texture_usage(true);
3265 3264
3266 FakeOutputSurfaceClient output_surface_client; 3265 FakeOutputSurfaceClient output_surface_client;
3267 scoped_ptr<OutputSurface> output_surface( 3266 scoped_ptr<OutputSurface> output_surface(
3268 FakeOutputSurface::Create3d(context_owned.Pass())); 3267 FakeOutputSurface::Create3d(context_owned.Pass()));
3269 CHECK(output_surface->BindToClient(&output_surface_client)); 3268 CHECK(output_surface->BindToClient(&output_surface_client));
3270 3269
3271 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3270 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3272 output_surface.get(), shared_bitmap_manager_.get(), 3271 output_surface.get(), shared_bitmap_manager_.get(),
3273 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3272 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3274 use_image_texture_targets_)); 3273 use_image_texture_targets_));
3275 3274
3276 gfx::Size size(2, 2); 3275 gfx::Size size(2, 2);
3277 3276
3278 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3277 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3279 const ResourceProvider::TextureHint hints[4] = { 3278 const ResourceProvider::TextureHint hints[4] = {
3280 ResourceProvider::TEXTURE_HINT_DEFAULT, 3279 ResourceProvider::TEXTURE_HINT_DEFAULT,
3281 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3280 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3282 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, 3281 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER,
3283 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, 3282 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3319 context->set_support_texture_storage(true); 3318 context->set_support_texture_storage(true);
3320 context->set_support_texture_usage(true); 3319 context->set_support_texture_usage(true);
3321 3320
3322 FakeOutputSurfaceClient output_surface_client; 3321 FakeOutputSurfaceClient output_surface_client;
3323 scoped_ptr<OutputSurface> output_surface( 3322 scoped_ptr<OutputSurface> output_surface(
3324 FakeOutputSurface::Create3d(context_owned.Pass())); 3323 FakeOutputSurface::Create3d(context_owned.Pass()));
3325 CHECK(output_surface->BindToClient(&output_surface_client)); 3324 CHECK(output_surface->BindToClient(&output_surface_client));
3326 3325
3327 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3326 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3328 output_surface.get(), shared_bitmap_manager_.get(), 3327 output_surface.get(), shared_bitmap_manager_.get(),
3329 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3328 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3330 use_image_texture_targets_)); 3329 use_image_texture_targets_));
3331 3330
3332 gfx::Size size(2, 2); 3331 gfx::Size size(2, 2);
3333 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3332 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3334 3333
3335 const ResourceProvider::TextureHint hints[4] = { 3334 const ResourceProvider::TextureHint hints[4] = {
3336 ResourceProvider::TEXTURE_HINT_DEFAULT, 3335 ResourceProvider::TEXTURE_HINT_DEFAULT,
3337 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3336 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3338 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, 3337 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER,
3339 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, 3338 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3374 FakeOutputSurface::Create3d(context_owned.Pass())); 3373 FakeOutputSurface::Create3d(context_owned.Pass()));
3375 CHECK(output_surface->BindToClient(&output_surface_client)); 3374 CHECK(output_surface->BindToClient(&output_surface_client));
3376 3375
3377 gfx::Size size(2, 2); 3376 gfx::Size size(2, 2);
3378 ResourceFormat format = RGBA_8888; 3377 ResourceFormat format = RGBA_8888;
3379 ResourceId id = 0; 3378 ResourceId id = 0;
3380 int texture_id = 123; 3379 int texture_id = 123;
3381 3380
3382 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3381 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3383 output_surface.get(), shared_bitmap_manager_.get(), 3382 output_surface.get(), shared_bitmap_manager_.get(),
3384 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3383 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3385 use_image_texture_targets_)); 3384 use_image_texture_targets_));
3386 3385
3387 id = resource_provider->CreateResource( 3386 id = resource_provider->CreateResource(
3388 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3387 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3389 resource_provider->AcquirePixelBuffer(id); 3388 resource_provider->AcquirePixelBuffer(id);
3390 3389
3391 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3390 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3392 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3391 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3393 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) 3392 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
3394 .Times(1); 3393 .Times(1);
(...skipping 22 matching lines...) Expand all
3417 FakeOutputSurface::Create3d(context_owned.Pass())); 3416 FakeOutputSurface::Create3d(context_owned.Pass()));
3418 CHECK(output_surface->BindToClient(&output_surface_client)); 3417 CHECK(output_surface->BindToClient(&output_surface_client));
3419 3418
3420 gfx::Size size(2, 2); 3419 gfx::Size size(2, 2);
3421 ResourceFormat format = RGBA_8888; 3420 ResourceFormat format = RGBA_8888;
3422 ResourceId id = 0; 3421 ResourceId id = 0;
3423 int texture_id = 123; 3422 int texture_id = 123;
3424 3423
3425 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3424 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3426 output_surface.get(), shared_bitmap_manager_.get(), 3425 output_surface.get(), shared_bitmap_manager_.get(),
3427 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3426 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3428 use_image_texture_targets_)); 3427 use_image_texture_targets_));
3429 3428
3430 id = resource_provider->CreateResource( 3429 id = resource_provider->CreateResource(
3431 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3430 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3432 resource_provider->AcquirePixelBuffer(id); 3431 resource_provider->AcquirePixelBuffer(id);
3433 3432
3434 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3433 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3435 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3434 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3436 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) 3435 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
3437 .Times(1); 3436 .Times(1);
(...skipping 22 matching lines...) Expand all
3460 FakeOutputSurface::Create3d(context_owned.Pass())); 3459 FakeOutputSurface::Create3d(context_owned.Pass()));
3461 CHECK(output_surface->BindToClient(&output_surface_client)); 3460 CHECK(output_surface->BindToClient(&output_surface_client));
3462 3461
3463 gfx::Size size(2, 2); 3462 gfx::Size size(2, 2);
3464 ResourceFormat format = RGBA_8888; 3463 ResourceFormat format = RGBA_8888;
3465 ResourceId id = 0; 3464 ResourceId id = 0;
3466 int texture_id = 123; 3465 int texture_id = 123;
3467 3466
3468 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3467 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3469 output_surface.get(), shared_bitmap_manager_.get(), 3468 output_surface.get(), shared_bitmap_manager_.get(),
3470 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3469 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3471 use_image_texture_targets_)); 3470 use_image_texture_targets_));
3472 3471
3473 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); 3472 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id));
3474 3473
3475 id = resource_provider->CreateResource( 3474 id = resource_provider->CreateResource(
3476 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3475 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3477 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 3476 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
3478 GL_INNOCENT_CONTEXT_RESET_ARB); 3477 GL_INNOCENT_CONTEXT_RESET_ARB);
3479 3478
3480 resource_provider->AcquirePixelBuffer(id); 3479 resource_provider->AcquirePixelBuffer(id);
(...skipping 20 matching lines...) Expand all
3501 const int kWidth = 2; 3500 const int kWidth = 2;
3502 const int kHeight = 2; 3501 const int kHeight = 2;
3503 gfx::Size size(kWidth, kHeight); 3502 gfx::Size size(kWidth, kHeight);
3504 ResourceFormat format = RGBA_8888; 3503 ResourceFormat format = RGBA_8888;
3505 ResourceId id = 0; 3504 ResourceId id = 0;
3506 const unsigned kTextureId = 123u; 3505 const unsigned kTextureId = 123u;
3507 const unsigned kImageId = 234u; 3506 const unsigned kImageId = 234u;
3508 3507
3509 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3508 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3510 output_surface.get(), shared_bitmap_manager_.get(), 3509 output_surface.get(), shared_bitmap_manager_.get(),
3511 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3510 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3512 use_image_texture_targets_)); 3511 use_image_texture_targets_));
3513 3512
3514 id = resource_provider->CreateResource( 3513 id = resource_provider->CreateResource(
3515 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3514 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3516 3515
3517 EXPECT_CALL(*context, NextTextureId()) 3516 EXPECT_CALL(*context, NextTextureId())
3518 .WillOnce(Return(kTextureId)) 3517 .WillOnce(Return(kTextureId))
3519 .RetiresOnSaturation(); 3518 .RetiresOnSaturation();
3520 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)) 3519 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId))
3521 .Times(1) 3520 .Times(1)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3562 ResourceProvider::ScopedSamplerGL lock_gl( 3561 ResourceProvider::ScopedSamplerGL lock_gl(
3563 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); 3562 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
3564 EXPECT_EQ(kTextureId, lock_gl.texture_id()); 3563 EXPECT_EQ(kTextureId, lock_gl.texture_id());
3565 } 3564 }
3566 3565
3567 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId)) 3566 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId))
3568 .Times(1) 3567 .Times(1)
3569 .RetiresOnSaturation(); 3568 .RetiresOnSaturation();
3570 } 3569 }
3571 3570
3572 TEST_P(ResourceProviderTest, CopyResource_GLTexture) {
3573 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3574 return;
3575 scoped_ptr<AllocationTrackingContext3D> context_owned(
3576 new StrictMock<AllocationTrackingContext3D>);
3577 AllocationTrackingContext3D* context = context_owned.get();
3578 context_owned->set_support_sync_query(true);
3579
3580 FakeOutputSurfaceClient output_surface_client;
3581 scoped_ptr<OutputSurface> output_surface(
3582 FakeOutputSurface::Create3d(context_owned.Pass()));
3583 ASSERT_TRUE(output_surface->BindToClient(&output_surface_client));
3584
3585 const int kWidth = 2;
3586 const int kHeight = 2;
3587 gfx::Size size(kWidth, kHeight);
3588 ResourceFormat format = RGBA_8888;
3589 ResourceId source_id = 0;
3590 ResourceId dest_id = 0;
3591 const unsigned kSourceTextureId = 123u;
3592 const unsigned kDestTextureId = 321u;
3593 const unsigned kImageId = 234u;
3594
3595 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3596 output_surface.get(), shared_bitmap_manager_.get(),
3597 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3598 std::vector<unsigned>(static_cast<size_t>(gfx::BufferFormat::LAST) + 1,
3599 GL_TEXTURE_2D)));
3600
3601 source_id = resource_provider->CreateResource(
3602 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3603
3604 EXPECT_CALL(*context, NextTextureId())
3605 .WillOnce(Return(kSourceTextureId))
3606 .RetiresOnSaturation();
3607 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kSourceTextureId))
3608 .Times(1)
3609 .RetiresOnSaturation();
3610 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
3611 .WillOnce(Return(kImageId))
3612 .RetiresOnSaturation();
3613 {
3614 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3615 resource_provider.get(), source_id);
3616 EXPECT_TRUE(lock.GetGpuMemoryBuffer());
3617 }
3618 Mock::VerifyAndClearExpectations(context);
3619
3620 dest_id = resource_provider->CreateResource(
3621 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3622
3623 EXPECT_CALL(*context, NextTextureId())
3624 .WillOnce(Return(kDestTextureId))
3625 .RetiresOnSaturation();
3626 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId))
3627 .Times(2)
3628 .RetiresOnSaturation();
3629 EXPECT_CALL(*context, texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA,
3630 GL_UNSIGNED_BYTE, nullptr))
3631 .Times(1)
3632 .RetiresOnSaturation();
3633 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kSourceTextureId))
3634 .Times(1)
3635 .RetiresOnSaturation();
3636 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3637 .Times(1)
3638 .RetiresOnSaturation();
3639 resource_provider->CopyResource(source_id, dest_id, gfx::Rect(size));
3640 Mock::VerifyAndClearExpectations(context);
3641
3642 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId))
3643 .Times(1)
3644 .RetiresOnSaturation();
3645 EXPECT_CALL(*context, RetireTextureId(kSourceTextureId))
3646 .Times(1)
3647 .RetiresOnSaturation();
3648 EXPECT_CALL(*context, RetireTextureId(kDestTextureId))
3649 .Times(1)
3650 .RetiresOnSaturation();
3651 resource_provider->DeleteResource(source_id);
3652 resource_provider->DeleteResource(dest_id);
3653 }
3654
3655 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) { 3571 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) {
3656 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3572 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3657 return; 3573 return;
3658 3574
3659 scoped_ptr<AllocationTrackingContext3D> context_owned( 3575 scoped_ptr<AllocationTrackingContext3D> context_owned(
3660 new AllocationTrackingContext3D); 3576 new AllocationTrackingContext3D);
3661 AllocationTrackingContext3D* context = context_owned.get(); 3577 AllocationTrackingContext3D* context = context_owned.get();
3662 context_owned->set_support_compressed_texture_etc1(true); 3578 context_owned->set_support_compressed_texture_etc1(true);
3663 3579
3664 FakeOutputSurfaceClient output_surface_client; 3580 FakeOutputSurfaceClient output_surface_client;
3665 scoped_ptr<OutputSurface> output_surface( 3581 scoped_ptr<OutputSurface> output_surface(
3666 FakeOutputSurface::Create3d(context_owned.Pass())); 3582 FakeOutputSurface::Create3d(context_owned.Pass()));
3667 CHECK(output_surface->BindToClient(&output_surface_client)); 3583 CHECK(output_surface->BindToClient(&output_surface_client));
3668 3584
3669 gfx::Size size(4, 4); 3585 gfx::Size size(4, 4);
3670 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3586 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3671 output_surface.get(), shared_bitmap_manager_.get(), 3587 output_surface.get(), shared_bitmap_manager_.get(),
3672 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3588 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3673 use_image_texture_targets_)); 3589 use_image_texture_targets_));
3674 int texture_id = 123; 3590 int texture_id = 123;
3675 3591
3676 ResourceId id = resource_provider->CreateResource( 3592 ResourceId id = resource_provider->CreateResource(
3677 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); 3593 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1);
3678 EXPECT_NE(0u, id); 3594 EXPECT_NE(0u, id);
3679 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3595 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3680 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3596 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3681 resource_provider->AllocateForTesting(id); 3597 resource_provider->AllocateForTesting(id);
3682 3598
(...skipping 11 matching lines...) Expand all
3694 context_owned->set_support_compressed_texture_etc1(true); 3610 context_owned->set_support_compressed_texture_etc1(true);
3695 3611
3696 FakeOutputSurfaceClient output_surface_client; 3612 FakeOutputSurfaceClient output_surface_client;
3697 scoped_ptr<OutputSurface> output_surface( 3613 scoped_ptr<OutputSurface> output_surface(
3698 FakeOutputSurface::Create3d(context_owned.Pass())); 3614 FakeOutputSurface::Create3d(context_owned.Pass()));
3699 CHECK(output_surface->BindToClient(&output_surface_client)); 3615 CHECK(output_surface->BindToClient(&output_surface_client));
3700 3616
3701 gfx::Size size(4, 4); 3617 gfx::Size size(4, 4);
3702 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3618 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3703 output_surface.get(), shared_bitmap_manager_.get(), 3619 output_surface.get(), shared_bitmap_manager_.get(),
3704 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false, 3620 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
3705 use_image_texture_targets_)); 3621 use_image_texture_targets_));
3706 int texture_id = 123; 3622 int texture_id = 123;
3707 uint8_t pixels[8]; 3623 uint8_t pixels[8];
3708 3624
3709 ResourceId id = resource_provider->CreateResource( 3625 ResourceId id = resource_provider->CreateResource(
3710 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); 3626 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1);
3711 EXPECT_NE(0u, id); 3627 EXPECT_NE(0u, id);
3712 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3628 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3713 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); 3629 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3);
3714 EXPECT_CALL(*context, 3630 EXPECT_CALL(*context,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3751 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 3667 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
3752 new TestSharedBitmapManager()); 3668 new TestSharedBitmapManager());
3753 3669
3754 gfx::Size size(1, 1); 3670 gfx::Size size(1, 1);
3755 ResourceFormat format = RGBA_8888; 3671 ResourceFormat format = RGBA_8888;
3756 3672
3757 { 3673 {
3758 size_t kTextureAllocationChunkSize = 1; 3674 size_t kTextureAllocationChunkSize = 1;
3759 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3675 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3760 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false, 3676 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
3761 kTextureAllocationChunkSize, false, 3677 kTextureAllocationChunkSize,
3762 ResourceProviderTest::use_image_texture_targets())); 3678 ResourceProviderTest::use_image_texture_targets()));
3763 3679
3764 ResourceId id = resource_provider->CreateResource( 3680 ResourceId id = resource_provider->CreateResource(
3765 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3681 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3766 format); 3682 format);
3767 resource_provider->AllocateForTesting(id); 3683 resource_provider->AllocateForTesting(id);
3768 Mock::VerifyAndClearExpectations(context); 3684 Mock::VerifyAndClearExpectations(context);
3769 3685
3770 DCHECK_EQ(2u, context->PeekTextureId()); 3686 DCHECK_EQ(2u, context->PeekTextureId());
3771 resource_provider->DeleteResource(id); 3687 resource_provider->DeleteResource(id);
3772 } 3688 }
3773 3689
3774 { 3690 {
3775 size_t kTextureAllocationChunkSize = 8; 3691 size_t kTextureAllocationChunkSize = 8;
3776 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3692 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3777 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false, 3693 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
3778 kTextureAllocationChunkSize, false, 3694 kTextureAllocationChunkSize,
3779 ResourceProviderTest::use_image_texture_targets())); 3695 ResourceProviderTest::use_image_texture_targets()));
3780 3696
3781 ResourceId id = resource_provider->CreateResource( 3697 ResourceId id = resource_provider->CreateResource(
3782 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3698 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3783 format); 3699 format);
3784 resource_provider->AllocateForTesting(id); 3700 resource_provider->AllocateForTesting(id);
3785 Mock::VerifyAndClearExpectations(context); 3701 Mock::VerifyAndClearExpectations(context);
3786 3702
3787 DCHECK_EQ(10u, context->PeekTextureId()); 3703 DCHECK_EQ(10u, context->PeekTextureId());
3788 resource_provider->DeleteResource(id); 3704 resource_provider->DeleteResource(id);
3789 } 3705 }
3790 } 3706 }
3791 3707
3792 } // namespace 3708 } // namespace
3793 } // namespace cc 3709 } // 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