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

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: latest comments 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
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/ui_resource_bitmap.h » ('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 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));
2411 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(WGC3Denum)); 2420 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(WGC3Denum));
2412 MOCK_METHOD3(createImageCHROMIUM, WGC3Duint(WGC3Dsizei, WGC3Dsizei, 2421 MOCK_METHOD3(createImageCHROMIUM, WGC3Duint(WGC3Dsizei, WGC3Dsizei,
2413 WGC3Denum)); 2422 WGC3Denum));
2414 MOCK_METHOD1(destroyImageCHROMIUM, void(WGC3Duint)); 2423 MOCK_METHOD1(destroyImageCHROMIUM, void(WGC3Duint));
2415 MOCK_METHOD2(mapImageCHROMIUM, void*(WGC3Duint, WGC3Denum)); 2424 MOCK_METHOD2(mapImageCHROMIUM, void*(WGC3Duint, WGC3Denum));
2416 MOCK_METHOD3(getImageParameterivCHROMIUM, void(WGC3Duint, WGC3Denum, 2425 MOCK_METHOD3(getImageParameterivCHROMIUM, void(WGC3Duint, WGC3Denum,
2417 GLint*)); 2426 GLint*));
2418 MOCK_METHOD1(unmapImageCHROMIUM, void(WGC3Duint)); 2427 MOCK_METHOD1(unmapImageCHROMIUM, void(WGC3Duint));
2419 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(WGC3Denum, WGC3Dint)); 2428 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(WGC3Denum, WGC3Dint));
2420 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(WGC3Denum, WGC3Dint)); 2429 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(WGC3Denum, WGC3Dint));
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 2834
2826 resource_provider->InitializeSoftware(); 2835 resource_provider->InitializeSoftware();
2827 output_surface->ReleaseGL(); 2836 output_surface->ReleaseGL();
2828 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); 2837 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL);
2829 2838
2830 InitializeGLAndCheck(shared_data.get(), 2839 InitializeGLAndCheck(shared_data.get(),
2831 resource_provider.get(), 2840 resource_provider.get(),
2832 output_surface.get()); 2841 output_surface.get());
2833 } 2842 }
2834 2843
2844 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) {
2845 if (GetParam() != ResourceProvider::GLTexture)
2846 return;
2847
2848 scoped_ptr<AllocationTrackingContext3D> context_owned(
2849 new AllocationTrackingContext3D);
2850 AllocationTrackingContext3D* context = context_owned.get();
2851 context_owned->set_support_compressed_texture_etc1(true);
2852
2853 FakeOutputSurfaceClient output_surface_client;
2854 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2855 context_owned.PassAs<TestWebGraphicsContext3D>()));
2856 CHECK(output_surface->BindToClient(&output_surface_client));
2857
2858 gfx::Size size(4, 4);
2859 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2860 output_surface.get(), shared_bitmap_manager_.get(), 0, false));
2861 int texture_id = 123;
2862
2863 ResourceProvider::ResourceId id = resource_provider->CreateResource(
2864 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, ETC1);
2865 EXPECT_NE(0u, id);
2866 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
2867 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
2868 resource_provider->AllocateForTesting(id);
2869
2870 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
2871 resource_provider->DeleteResource(id);
2872 }
2873
2874 TEST_P(ResourceProviderTest, CompressedTextureETC1SetPixels) {
2875 if (GetParam() != ResourceProvider::GLTexture)
2876 return;
2877
2878 scoped_ptr<AllocationTrackingContext3D> context_owned(
2879 new AllocationTrackingContext3D);
2880 AllocationTrackingContext3D* context = context_owned.get();
2881 context_owned->set_support_compressed_texture_etc1(true);
2882
2883 FakeOutputSurfaceClient output_surface_client;
2884 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2885 context_owned.PassAs<TestWebGraphicsContext3D>()));
2886 CHECK(output_surface->BindToClient(&output_surface_client));
2887
2888 gfx::Size size(4, 4);
2889 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2890 output_surface.get(), shared_bitmap_manager_.get(), 0, false));
2891 int texture_id = 123;
2892 uint8_t pixels[8];
2893
2894 ResourceProvider::ResourceId id = resource_provider->CreateResource(
2895 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, ETC1);
2896 EXPECT_NE(0u, id);
2897 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
2898 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3);
2899 EXPECT_CALL(*context,
2900 compressedTexImage2D(
2901 _, 0, _, size.width(), size.height(), _, _, _)).Times(1);
2902 resource_provider->SetPixels(
2903 id, pixels, gfx::Rect(size), gfx::Rect(size), gfx::Vector2d(0, 0));
2904
2905 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
2906 resource_provider->DeleteResource(id);
2907 }
2908
2835 INSTANTIATE_TEST_CASE_P( 2909 INSTANTIATE_TEST_CASE_P(
2836 ResourceProviderTests, 2910 ResourceProviderTests,
2837 ResourceProviderTest, 2911 ResourceProviderTest,
2838 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); 2912 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap));
2839 2913
2840 } // namespace 2914 } // namespace
2841 } // namespace cc 2915 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/ui_resource_bitmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698