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

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

Issue 27973002: cc: Adding ETC1 support to UIResourceBitmap and ResourceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed latest comments, rebased Created 7 years, 2 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 | Annotate | Revision Log
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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 MOCK_METHOD9(asyncTexSubImage2DCHROMIUM, 2401 MOCK_METHOD9(asyncTexSubImage2DCHROMIUM,
2402 void(WGC3Denum target, 2402 void(WGC3Denum target,
2403 WGC3Dint level, 2403 WGC3Dint level,
2404 WGC3Dint xoffset, 2404 WGC3Dint xoffset,
2405 WGC3Dint yoffset, 2405 WGC3Dint yoffset,
2406 WGC3Dsizei width, 2406 WGC3Dsizei width,
2407 WGC3Dsizei height, 2407 WGC3Dsizei height,
2408 WGC3Denum format, 2408 WGC3Denum format,
2409 WGC3Denum type, 2409 WGC3Denum type,
2410 const void* pixels)); 2410 const void* pixels));
2411 MOCK_METHOD8(compressedTexImage2D,
2412 void(WGC3Denum target,
2413 WGC3Dint level,
2414 WGC3Denum internalformat,
2415 WGC3Dsizei width,
2416 WGC3Dsizei height,
2417 WGC3Dint border,
2418 WGC3Dsizei image_size,
2419 const void* data));
2420 MOCK_METHOD9(compressedTexSubImage2D,
2421 void(WGC3Denum target,
2422 WGC3Dint level,
2423 WGC3Dint xoffset,
2424 WGC3Dint yoffset,
2425 WGC3Dsizei width,
2426 WGC3Dsizei height,
2427 WGC3Denum format,
2428 WGC3Dsizei image_size,
2429 const void* data));
2411 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(WGC3Denum)); 2430 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(WGC3Denum));
2412 MOCK_METHOD3(createImageCHROMIUM, WGC3Duint(WGC3Dsizei, WGC3Dsizei, 2431 MOCK_METHOD3(createImageCHROMIUM, WGC3Duint(WGC3Dsizei, WGC3Dsizei,
2413 WGC3Denum)); 2432 WGC3Denum));
2414 MOCK_METHOD1(destroyImageCHROMIUM, void(WGC3Duint)); 2433 MOCK_METHOD1(destroyImageCHROMIUM, void(WGC3Duint));
2415 MOCK_METHOD2(mapImageCHROMIUM, void*(WGC3Duint, WGC3Denum)); 2434 MOCK_METHOD2(mapImageCHROMIUM, void*(WGC3Duint, WGC3Denum));
2416 MOCK_METHOD3(getImageParameterivCHROMIUM, void(WGC3Duint, WGC3Denum, 2435 MOCK_METHOD3(getImageParameterivCHROMIUM, void(WGC3Duint, WGC3Denum,
2417 GLint*)); 2436 GLint*));
2418 MOCK_METHOD1(unmapImageCHROMIUM, void(WGC3Duint)); 2437 MOCK_METHOD1(unmapImageCHROMIUM, void(WGC3Duint));
2419 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(WGC3Denum, WGC3Dint)); 2438 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(WGC3Denum, WGC3Dint));
2420 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(WGC3Denum, WGC3Dint)); 2439 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(WGC3Denum, WGC3Dint));
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 2844
2826 resource_provider->InitializeSoftware(); 2845 resource_provider->InitializeSoftware();
2827 output_surface->ReleaseGL(); 2846 output_surface->ReleaseGL();
2828 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); 2847 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL);
2829 2848
2830 InitializeGLAndCheck(shared_data.get(), 2849 InitializeGLAndCheck(shared_data.get(),
2831 resource_provider.get(), 2850 resource_provider.get(),
2832 output_surface.get()); 2851 output_surface.get());
2833 } 2852 }
2834 2853
2854 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) {
2855 if (GetParam() != ResourceProvider::GLTexture)
2856 return;
2857
2858 scoped_ptr<AllocationTrackingContext3D> context_owned(
2859 new AllocationTrackingContext3D);
2860 AllocationTrackingContext3D* context = context_owned.get();
2861 context_owned->set_support_compressed_texture_etc1(true);
2862
2863 FakeOutputSurfaceClient output_surface_client;
2864 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2865 context_owned.PassAs<TestWebGraphicsContext3D>()));
2866 CHECK(output_surface->BindToClient(&output_surface_client));
2867
2868 gfx::Size size(4, 4);
2869 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2870 output_surface.get(), shared_bitmap_manager_.get(), 0, false));
2871 int texture_id = 123;
2872
2873 ResourceProvider::ResourceId id = resource_provider->CreateResource(
2874 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, ETC1);
2875 EXPECT_NE(0u, id);
2876 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
2877 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
2878 EXPECT_CALL(*context,
2879 compressedTexImage2D(
2880 _, 0, _, size.width(), size.height(), _, _, _)).Times(1);
2881 resource_provider->AllocateForTesting(id);
2882
2883 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
2884 resource_provider->DeleteResource(id);
2885 }
2886
2887 TEST_P(ResourceProviderTest, CompressedTextureETC1SetPixels) {
2888 if (GetParam() != ResourceProvider::GLTexture)
2889 return;
2890
2891 scoped_ptr<AllocationTrackingContext3D> context_owned(
2892 new AllocationTrackingContext3D);
2893 AllocationTrackingContext3D* context = context_owned.get();
2894 context_owned->set_support_compressed_texture_etc1(true);
2895
2896 FakeOutputSurfaceClient output_surface_client;
2897 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2898 context_owned.PassAs<TestWebGraphicsContext3D>()));
2899 CHECK(output_surface->BindToClient(&output_surface_client));
2900
2901 gfx::Size size(4, 4);
2902 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2903 output_surface.get(), shared_bitmap_manager_.get(), 0, false));
2904 int texture_id = 123;
2905 uint8_t pixels[8];
2906
2907 ResourceProvider::ResourceId id = resource_provider->CreateResource(
2908 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, ETC1);
2909 EXPECT_NE(0u, id);
2910 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
2911 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3);
2912 EXPECT_CALL(*context,
2913 compressedTexImage2D(
2914 _, 0, _, size.width(), size.height(), _, _, _)).Times(2);
2915 resource_provider->SetPixels(
2916 id, pixels, gfx::Rect(size), gfx::Rect(size), gfx::Vector2d(0, 0));
2917
2918 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
2919 resource_provider->DeleteResource(id);
2920 }
2921
2835 INSTANTIATE_TEST_CASE_P( 2922 INSTANTIATE_TEST_CASE_P(
2836 ResourceProviderTests, 2923 ResourceProviderTests,
2837 ResourceProviderTest, 2924 ResourceProviderTest,
2838 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); 2925 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap));
2839 2926
2840 } // namespace 2927 } // namespace
2841 } // namespace cc 2928 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698