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

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

Issue 1336703002: Revert of Re-land: 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, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« 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, use_image_texture_targets_); 425 false, 1, false, 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, use_image_texture_targets_); 429 false, 1, false, 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, 1381 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
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, use_image_texture_targets_)); 1866 false, 1, false, 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, use_image_texture_targets_)); 1880 false, 1, false, 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, 2512 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
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, 2595 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
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, 2643 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
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, 2694 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
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, use_image_texture_targets_)); 2760 false, 1, false, 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, use_image_texture_targets_)); 2809 main_thread_task_runner, 0, false, 1, false,
2810 use_image_texture_targets_));
2810 2811
2811 unsigned texture_id = 1; 2812 unsigned texture_id = 1;
2812 uint32 sync_point = 30; 2813 uint32 sync_point = 30;
2813 unsigned target = GL_TEXTURE_2D; 2814 unsigned target = GL_TEXTURE_2D;
2814 2815
2815 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2816 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2816 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2817 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2817 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2818 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2818 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 2819 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2819 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 2820 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2942 new TextureStateTrackingContext); 2943 new TextureStateTrackingContext);
2943 TextureStateTrackingContext* context = context_owned.get(); 2944 TextureStateTrackingContext* context = context_owned.get();
2944 2945
2945 FakeOutputSurfaceClient output_surface_client; 2946 FakeOutputSurfaceClient output_surface_client;
2946 scoped_ptr<OutputSurface> output_surface( 2947 scoped_ptr<OutputSurface> output_surface(
2947 FakeOutputSurface::Create3d(context_owned.Pass())); 2948 FakeOutputSurface::Create3d(context_owned.Pass()));
2948 CHECK(output_surface->BindToClient(&output_surface_client)); 2949 CHECK(output_surface->BindToClient(&output_surface_client));
2949 2950
2950 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2951 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2951 output_surface.get(), shared_bitmap_manager_.get(), 2952 output_surface.get(), shared_bitmap_manager_.get(),
2952 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 2953 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
2953 use_image_texture_targets_)); 2954 use_image_texture_targets_));
2954 2955
2955 uint32 sync_point = 30; 2956 uint32 sync_point = 30;
2956 unsigned target = GL_TEXTURE_EXTERNAL_OES; 2957 unsigned target = GL_TEXTURE_EXTERNAL_OES;
2957 2958
2958 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2959 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2959 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2960 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2960 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2961 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2961 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 2962 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2962 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 2963 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3012 new TextureStateTrackingContext); 3013 new TextureStateTrackingContext);
3013 TextureStateTrackingContext* context = context_owned.get(); 3014 TextureStateTrackingContext* context = context_owned.get();
3014 3015
3015 FakeOutputSurfaceClient output_surface_client; 3016 FakeOutputSurfaceClient output_surface_client;
3016 scoped_ptr<OutputSurface> output_surface( 3017 scoped_ptr<OutputSurface> output_surface(
3017 FakeOutputSurface::Create3d(context_owned.Pass())); 3018 FakeOutputSurface::Create3d(context_owned.Pass()));
3018 CHECK(output_surface->BindToClient(&output_surface_client)); 3019 CHECK(output_surface->BindToClient(&output_surface_client));
3019 3020
3020 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3021 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3021 output_surface.get(), shared_bitmap_manager_.get(), 3022 output_surface.get(), shared_bitmap_manager_.get(),
3022 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3023 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3023 use_image_texture_targets_)); 3024 use_image_texture_targets_));
3024 3025
3025 uint32 sync_point = 30; 3026 uint32 sync_point = 30;
3026 unsigned target = GL_TEXTURE_2D; 3027 unsigned target = GL_TEXTURE_2D;
3027 3028
3028 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3029 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3029 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 3030 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
3030 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 3031 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
3031 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3032 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3032 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3033 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 new TextureStateTrackingContext); 3067 new TextureStateTrackingContext);
3067 TextureStateTrackingContext* context = context_owned.get(); 3068 TextureStateTrackingContext* context = context_owned.get();
3068 3069
3069 FakeOutputSurfaceClient output_surface_client; 3070 FakeOutputSurfaceClient output_surface_client;
3070 scoped_ptr<OutputSurface> output_surface( 3071 scoped_ptr<OutputSurface> output_surface(
3071 FakeOutputSurface::Create3d(context_owned.Pass())); 3072 FakeOutputSurface::Create3d(context_owned.Pass()));
3072 CHECK(output_surface->BindToClient(&output_surface_client)); 3073 CHECK(output_surface->BindToClient(&output_surface_client));
3073 3074
3074 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3075 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3075 output_surface.get(), shared_bitmap_manager_.get(), 3076 output_surface.get(), shared_bitmap_manager_.get(),
3076 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3077 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3077 use_image_texture_targets_)); 3078 use_image_texture_targets_));
3078 3079
3079 uint32 sync_point = 0; 3080 uint32 sync_point = 0;
3080 unsigned target = GL_TEXTURE_2D; 3081 unsigned target = GL_TEXTURE_2D;
3081 3082
3082 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3083 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3083 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 3084 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
3084 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 3085 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
3085 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3086 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3086 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3087 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3187 new StrictMock<AllocationTrackingContext3D>); 3188 new StrictMock<AllocationTrackingContext3D>);
3188 AllocationTrackingContext3D* context = context_owned.get(); 3189 AllocationTrackingContext3D* context = context_owned.get();
3189 3190
3190 FakeOutputSurfaceClient output_surface_client; 3191 FakeOutputSurfaceClient output_surface_client;
3191 scoped_ptr<OutputSurface> output_surface( 3192 scoped_ptr<OutputSurface> output_surface(
3192 FakeOutputSurface::Create3d(context_owned.Pass())); 3193 FakeOutputSurface::Create3d(context_owned.Pass()));
3193 CHECK(output_surface->BindToClient(&output_surface_client)); 3194 CHECK(output_surface->BindToClient(&output_surface_client));
3194 3195
3195 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3196 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3196 output_surface.get(), shared_bitmap_manager_.get(), 3197 output_surface.get(), shared_bitmap_manager_.get(),
3197 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3198 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3198 use_image_texture_targets_)); 3199 use_image_texture_targets_));
3199 3200
3200 gfx::Size size(2, 2); 3201 gfx::Size size(2, 2);
3201 gfx::Vector2d offset(0, 0); 3202 gfx::Vector2d offset(0, 0);
3202 ResourceFormat format = RGBA_8888; 3203 ResourceFormat format = RGBA_8888;
3203 ResourceId id = 0; 3204 ResourceId id = 0;
3204 uint8_t pixels[16] = { 0 }; 3205 uint8_t pixels[16] = { 0 };
3205 int texture_id = 123; 3206 int texture_id = 123;
3206 3207
3207 // Lazy allocation. Don't allocate when creating the resource. 3208 // Lazy allocation. Don't allocate when creating the resource.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 context->set_support_texture_storage(true); 3263 context->set_support_texture_storage(true);
3263 context->set_support_texture_usage(true); 3264 context->set_support_texture_usage(true);
3264 3265
3265 FakeOutputSurfaceClient output_surface_client; 3266 FakeOutputSurfaceClient output_surface_client;
3266 scoped_ptr<OutputSurface> output_surface( 3267 scoped_ptr<OutputSurface> output_surface(
3267 FakeOutputSurface::Create3d(context_owned.Pass())); 3268 FakeOutputSurface::Create3d(context_owned.Pass()));
3268 CHECK(output_surface->BindToClient(&output_surface_client)); 3269 CHECK(output_surface->BindToClient(&output_surface_client));
3269 3270
3270 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3271 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3271 output_surface.get(), shared_bitmap_manager_.get(), 3272 output_surface.get(), shared_bitmap_manager_.get(),
3272 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3273 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3273 use_image_texture_targets_)); 3274 use_image_texture_targets_));
3274 3275
3275 gfx::Size size(2, 2); 3276 gfx::Size size(2, 2);
3276 3277
3277 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3278 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3278 const ResourceProvider::TextureHint hints[4] = { 3279 const ResourceProvider::TextureHint hints[4] = {
3279 ResourceProvider::TEXTURE_HINT_DEFAULT, 3280 ResourceProvider::TEXTURE_HINT_DEFAULT,
3280 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3281 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3281 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, 3282 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER,
3282 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, 3283 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3318 context->set_support_texture_storage(true); 3319 context->set_support_texture_storage(true);
3319 context->set_support_texture_usage(true); 3320 context->set_support_texture_usage(true);
3320 3321
3321 FakeOutputSurfaceClient output_surface_client; 3322 FakeOutputSurfaceClient output_surface_client;
3322 scoped_ptr<OutputSurface> output_surface( 3323 scoped_ptr<OutputSurface> output_surface(
3323 FakeOutputSurface::Create3d(context_owned.Pass())); 3324 FakeOutputSurface::Create3d(context_owned.Pass()));
3324 CHECK(output_surface->BindToClient(&output_surface_client)); 3325 CHECK(output_surface->BindToClient(&output_surface_client));
3325 3326
3326 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3327 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3327 output_surface.get(), shared_bitmap_manager_.get(), 3328 output_surface.get(), shared_bitmap_manager_.get(),
3328 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3329 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3329 use_image_texture_targets_)); 3330 use_image_texture_targets_));
3330 3331
3331 gfx::Size size(2, 2); 3332 gfx::Size size(2, 2);
3332 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3333 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3333 3334
3334 const ResourceProvider::TextureHint hints[4] = { 3335 const ResourceProvider::TextureHint hints[4] = {
3335 ResourceProvider::TEXTURE_HINT_DEFAULT, 3336 ResourceProvider::TEXTURE_HINT_DEFAULT,
3336 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3337 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3337 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, 3338 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER,
3338 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, 3339 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 FakeOutputSurface::Create3d(context_owned.Pass())); 3374 FakeOutputSurface::Create3d(context_owned.Pass()));
3374 CHECK(output_surface->BindToClient(&output_surface_client)); 3375 CHECK(output_surface->BindToClient(&output_surface_client));
3375 3376
3376 gfx::Size size(2, 2); 3377 gfx::Size size(2, 2);
3377 ResourceFormat format = RGBA_8888; 3378 ResourceFormat format = RGBA_8888;
3378 ResourceId id = 0; 3379 ResourceId id = 0;
3379 int texture_id = 123; 3380 int texture_id = 123;
3380 3381
3381 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3382 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3382 output_surface.get(), shared_bitmap_manager_.get(), 3383 output_surface.get(), shared_bitmap_manager_.get(),
3383 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3384 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3384 use_image_texture_targets_)); 3385 use_image_texture_targets_));
3385 3386
3386 id = resource_provider->CreateResource( 3387 id = resource_provider->CreateResource(
3387 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3388 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3388 resource_provider->AcquirePixelBuffer(id); 3389 resource_provider->AcquirePixelBuffer(id);
3389 3390
3390 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3391 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3391 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3392 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3392 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) 3393 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
3393 .Times(1); 3394 .Times(1);
(...skipping 22 matching lines...) Expand all
3416 FakeOutputSurface::Create3d(context_owned.Pass())); 3417 FakeOutputSurface::Create3d(context_owned.Pass()));
3417 CHECK(output_surface->BindToClient(&output_surface_client)); 3418 CHECK(output_surface->BindToClient(&output_surface_client));
3418 3419
3419 gfx::Size size(2, 2); 3420 gfx::Size size(2, 2);
3420 ResourceFormat format = RGBA_8888; 3421 ResourceFormat format = RGBA_8888;
3421 ResourceId id = 0; 3422 ResourceId id = 0;
3422 int texture_id = 123; 3423 int texture_id = 123;
3423 3424
3424 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3425 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3425 output_surface.get(), shared_bitmap_manager_.get(), 3426 output_surface.get(), shared_bitmap_manager_.get(),
3426 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3427 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3427 use_image_texture_targets_)); 3428 use_image_texture_targets_));
3428 3429
3429 id = resource_provider->CreateResource( 3430 id = resource_provider->CreateResource(
3430 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3431 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3431 resource_provider->AcquirePixelBuffer(id); 3432 resource_provider->AcquirePixelBuffer(id);
3432 3433
3433 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3434 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3434 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3435 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3435 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) 3436 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
3436 .Times(1); 3437 .Times(1);
(...skipping 22 matching lines...) Expand all
3459 FakeOutputSurface::Create3d(context_owned.Pass())); 3460 FakeOutputSurface::Create3d(context_owned.Pass()));
3460 CHECK(output_surface->BindToClient(&output_surface_client)); 3461 CHECK(output_surface->BindToClient(&output_surface_client));
3461 3462
3462 gfx::Size size(2, 2); 3463 gfx::Size size(2, 2);
3463 ResourceFormat format = RGBA_8888; 3464 ResourceFormat format = RGBA_8888;
3464 ResourceId id = 0; 3465 ResourceId id = 0;
3465 int texture_id = 123; 3466 int texture_id = 123;
3466 3467
3467 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3468 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3468 output_surface.get(), shared_bitmap_manager_.get(), 3469 output_surface.get(), shared_bitmap_manager_.get(),
3469 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3470 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3470 use_image_texture_targets_)); 3471 use_image_texture_targets_));
3471 3472
3472 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); 3473 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id));
3473 3474
3474 id = resource_provider->CreateResource( 3475 id = resource_provider->CreateResource(
3475 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3476 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3476 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 3477 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
3477 GL_INNOCENT_CONTEXT_RESET_ARB); 3478 GL_INNOCENT_CONTEXT_RESET_ARB);
3478 3479
3479 resource_provider->AcquirePixelBuffer(id); 3480 resource_provider->AcquirePixelBuffer(id);
(...skipping 20 matching lines...) Expand all
3500 const int kWidth = 2; 3501 const int kWidth = 2;
3501 const int kHeight = 2; 3502 const int kHeight = 2;
3502 gfx::Size size(kWidth, kHeight); 3503 gfx::Size size(kWidth, kHeight);
3503 ResourceFormat format = RGBA_8888; 3504 ResourceFormat format = RGBA_8888;
3504 ResourceId id = 0; 3505 ResourceId id = 0;
3505 const unsigned kTextureId = 123u; 3506 const unsigned kTextureId = 123u;
3506 const unsigned kImageId = 234u; 3507 const unsigned kImageId = 234u;
3507 3508
3508 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3509 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3509 output_surface.get(), shared_bitmap_manager_.get(), 3510 output_surface.get(), shared_bitmap_manager_.get(),
3510 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3511 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3511 use_image_texture_targets_)); 3512 use_image_texture_targets_));
3512 3513
3513 id = resource_provider->CreateResource( 3514 id = resource_provider->CreateResource(
3514 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3515 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3515 3516
3516 EXPECT_CALL(*context, NextTextureId()) 3517 EXPECT_CALL(*context, NextTextureId())
3517 .WillOnce(Return(kTextureId)) 3518 .WillOnce(Return(kTextureId))
3518 .RetiresOnSaturation(); 3519 .RetiresOnSaturation();
3519 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)) 3520 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId))
3520 .Times(1) 3521 .Times(1)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 ResourceProvider::ScopedSamplerGL lock_gl( 3562 ResourceProvider::ScopedSamplerGL lock_gl(
3562 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); 3563 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
3563 EXPECT_EQ(kTextureId, lock_gl.texture_id()); 3564 EXPECT_EQ(kTextureId, lock_gl.texture_id());
3564 } 3565 }
3565 3566
3566 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId)) 3567 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId))
3567 .Times(1) 3568 .Times(1)
3568 .RetiresOnSaturation(); 3569 .RetiresOnSaturation();
3569 } 3570 }
3570 3571
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
3571 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) { 3655 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) {
3572 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3656 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3573 return; 3657 return;
3574 3658
3575 scoped_ptr<AllocationTrackingContext3D> context_owned( 3659 scoped_ptr<AllocationTrackingContext3D> context_owned(
3576 new AllocationTrackingContext3D); 3660 new AllocationTrackingContext3D);
3577 AllocationTrackingContext3D* context = context_owned.get(); 3661 AllocationTrackingContext3D* context = context_owned.get();
3578 context_owned->set_support_compressed_texture_etc1(true); 3662 context_owned->set_support_compressed_texture_etc1(true);
3579 3663
3580 FakeOutputSurfaceClient output_surface_client; 3664 FakeOutputSurfaceClient output_surface_client;
3581 scoped_ptr<OutputSurface> output_surface( 3665 scoped_ptr<OutputSurface> output_surface(
3582 FakeOutputSurface::Create3d(context_owned.Pass())); 3666 FakeOutputSurface::Create3d(context_owned.Pass()));
3583 CHECK(output_surface->BindToClient(&output_surface_client)); 3667 CHECK(output_surface->BindToClient(&output_surface_client));
3584 3668
3585 gfx::Size size(4, 4); 3669 gfx::Size size(4, 4);
3586 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3670 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3587 output_surface.get(), shared_bitmap_manager_.get(), 3671 output_surface.get(), shared_bitmap_manager_.get(),
3588 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3672 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3589 use_image_texture_targets_)); 3673 use_image_texture_targets_));
3590 int texture_id = 123; 3674 int texture_id = 123;
3591 3675
3592 ResourceId id = resource_provider->CreateResource( 3676 ResourceId id = resource_provider->CreateResource(
3593 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); 3677 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1);
3594 EXPECT_NE(0u, id); 3678 EXPECT_NE(0u, id);
3595 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3679 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3596 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3680 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3597 resource_provider->AllocateForTesting(id); 3681 resource_provider->AllocateForTesting(id);
3598 3682
(...skipping 11 matching lines...) Expand all
3610 context_owned->set_support_compressed_texture_etc1(true); 3694 context_owned->set_support_compressed_texture_etc1(true);
3611 3695
3612 FakeOutputSurfaceClient output_surface_client; 3696 FakeOutputSurfaceClient output_surface_client;
3613 scoped_ptr<OutputSurface> output_surface( 3697 scoped_ptr<OutputSurface> output_surface(
3614 FakeOutputSurface::Create3d(context_owned.Pass())); 3698 FakeOutputSurface::Create3d(context_owned.Pass()));
3615 CHECK(output_surface->BindToClient(&output_surface_client)); 3699 CHECK(output_surface->BindToClient(&output_surface_client));
3616 3700
3617 gfx::Size size(4, 4); 3701 gfx::Size size(4, 4);
3618 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3702 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3619 output_surface.get(), shared_bitmap_manager_.get(), 3703 output_surface.get(), shared_bitmap_manager_.get(),
3620 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, 3704 gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
3621 use_image_texture_targets_)); 3705 use_image_texture_targets_));
3622 int texture_id = 123; 3706 int texture_id = 123;
3623 uint8_t pixels[8]; 3707 uint8_t pixels[8];
3624 3708
3625 ResourceId id = resource_provider->CreateResource( 3709 ResourceId id = resource_provider->CreateResource(
3626 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); 3710 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1);
3627 EXPECT_NE(0u, id); 3711 EXPECT_NE(0u, id);
3628 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3712 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3629 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); 3713 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3);
3630 EXPECT_CALL(*context, 3714 EXPECT_CALL(*context,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3667 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 3751 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
3668 new TestSharedBitmapManager()); 3752 new TestSharedBitmapManager());
3669 3753
3670 gfx::Size size(1, 1); 3754 gfx::Size size(1, 1);
3671 ResourceFormat format = RGBA_8888; 3755 ResourceFormat format = RGBA_8888;
3672 3756
3673 { 3757 {
3674 size_t kTextureAllocationChunkSize = 1; 3758 size_t kTextureAllocationChunkSize = 1;
3675 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3759 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3676 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false, 3760 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
3677 kTextureAllocationChunkSize, 3761 kTextureAllocationChunkSize, false,
3678 ResourceProviderTest::use_image_texture_targets())); 3762 ResourceProviderTest::use_image_texture_targets()));
3679 3763
3680 ResourceId id = resource_provider->CreateResource( 3764 ResourceId id = resource_provider->CreateResource(
3681 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3765 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3682 format); 3766 format);
3683 resource_provider->AllocateForTesting(id); 3767 resource_provider->AllocateForTesting(id);
3684 Mock::VerifyAndClearExpectations(context); 3768 Mock::VerifyAndClearExpectations(context);
3685 3769
3686 DCHECK_EQ(2u, context->PeekTextureId()); 3770 DCHECK_EQ(2u, context->PeekTextureId());
3687 resource_provider->DeleteResource(id); 3771 resource_provider->DeleteResource(id);
3688 } 3772 }
3689 3773
3690 { 3774 {
3691 size_t kTextureAllocationChunkSize = 8; 3775 size_t kTextureAllocationChunkSize = 8;
3692 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3776 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3693 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false, 3777 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
3694 kTextureAllocationChunkSize, 3778 kTextureAllocationChunkSize, false,
3695 ResourceProviderTest::use_image_texture_targets())); 3779 ResourceProviderTest::use_image_texture_targets()));
3696 3780
3697 ResourceId id = resource_provider->CreateResource( 3781 ResourceId id = resource_provider->CreateResource(
3698 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3782 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
3699 format); 3783 format);
3700 resource_provider->AllocateForTesting(id); 3784 resource_provider->AllocateForTesting(id);
3701 Mock::VerifyAndClearExpectations(context); 3785 Mock::VerifyAndClearExpectations(context);
3702 3786
3703 DCHECK_EQ(10u, context->PeekTextureId()); 3787 DCHECK_EQ(10u, context->PeekTextureId());
3704 resource_provider->DeleteResource(id); 3788 resource_provider->DeleteResource(id);
3705 } 3789 }
3706 } 3790 }
3707 3791
3708 } // namespace 3792 } // namespace
3709 } // namespace cc 3793 } // 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