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

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

Issue 255713008: Change glimage to accept a type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no ozone Created 6 years, 7 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 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 2591 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 MOCK_METHOD8(compressedTexImage2D, 2602 MOCK_METHOD8(compressedTexImage2D,
2603 void(GLenum target, 2603 void(GLenum target,
2604 GLint level, 2604 GLint level,
2605 GLenum internalformat, 2605 GLenum internalformat,
2606 GLsizei width, 2606 GLsizei width,
2607 GLsizei height, 2607 GLsizei height,
2608 GLint border, 2608 GLint border,
2609 GLsizei image_size, 2609 GLsizei image_size,
2610 const void* data)); 2610 const void* data));
2611 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(GLenum)); 2611 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(GLenum));
2612 MOCK_METHOD3(createImageCHROMIUM, GLuint(GLsizei, GLsizei, GLenum)); 2612 MOCK_METHOD4(createImageCHROMIUM, GLuint(GLsizei, GLsizei, GLenum, GLenum));
2613 MOCK_METHOD1(destroyImageCHROMIUM, void(GLuint)); 2613 MOCK_METHOD1(destroyImageCHROMIUM, void(GLuint));
2614 MOCK_METHOD2(mapImageCHROMIUM, void*(GLuint, GLenum)); 2614 MOCK_METHOD1(mapImageCHROMIUM, void*(GLuint));
2615 MOCK_METHOD3(getImageParameterivCHROMIUM, void(GLuint, GLenum, GLint*)); 2615 MOCK_METHOD3(getImageParameterivCHROMIUM, void(GLuint, GLenum, GLint*));
2616 MOCK_METHOD1(unmapImageCHROMIUM, void(GLuint)); 2616 MOCK_METHOD1(unmapImageCHROMIUM, void(GLuint));
2617 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(GLenum, GLint)); 2617 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(GLenum, GLint));
2618 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(GLenum, GLint)); 2618 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(GLenum, GLint));
2619 2619
2620 // We're mocking bindTexture, so we override 2620 // We're mocking bindTexture, so we override
2621 // TestWebGraphicsContext3D::texParameteri to avoid assertions related to the 2621 // TestWebGraphicsContext3D::texParameteri to avoid assertions related to the
2622 // currently bound texture. 2622 // currently bound texture.
2623 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {} 2623 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {}
2624 }; 2624 };
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 const unsigned kImageId = 234u; 2911 const unsigned kImageId = 234u;
2912 2912
2913 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2913 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2914 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); 2914 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1));
2915 2915
2916 id = resource_provider->CreateResource( 2916 id = resource_provider->CreateResource(
2917 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); 2917 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
2918 2918
2919 const int kStride = 4; 2919 const int kStride = 4;
2920 void* dummy_mapped_buffer_address = NULL; 2920 void* dummy_mapped_buffer_address = NULL;
2921 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) 2921 EXPECT_CALL(*context,
2922 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_READ_WRITE))
2922 .WillOnce(Return(kImageId)) 2923 .WillOnce(Return(kImageId))
2923 .RetiresOnSaturation(); 2924 .RetiresOnSaturation();
2924 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, 2925 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId,
2925 GL_IMAGE_ROWBYTES_CHROMIUM, 2926 GL_IMAGE_ROWBYTES_CHROMIUM,
2926 _)) 2927 _))
2927 .WillOnce(SetArgPointee<2>(kStride)) 2928 .WillOnce(SetArgPointee<2>(kStride))
2928 .RetiresOnSaturation(); 2929 .RetiresOnSaturation();
2929 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId, GL_READ_WRITE)) 2930 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
2930 .WillOnce(Return(dummy_mapped_buffer_address)) 2931 .WillOnce(Return(dummy_mapped_buffer_address))
2931 .RetiresOnSaturation(); 2932 .RetiresOnSaturation();
2932 resource_provider->MapImageRasterBuffer(id); 2933 resource_provider->MapImageRasterBuffer(id);
2933 2934
2934 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) 2935 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
2935 .Times(1) 2936 .Times(1)
2936 .RetiresOnSaturation(); 2937 .RetiresOnSaturation();
2937 resource_provider->UnmapImageRasterBuffer(id); 2938 resource_provider->UnmapImageRasterBuffer(id);
2938 2939
2939 EXPECT_CALL(*context, NextTextureId()) 2940 EXPECT_CALL(*context, NextTextureId())
2940 .WillOnce(Return(kTextureId)) 2941 .WillOnce(Return(kTextureId))
2941 .RetiresOnSaturation(); 2942 .RetiresOnSaturation();
2942 // Once in CreateTextureId and once in BindForSampling 2943 // Once in CreateTextureId and once in BindForSampling
2943 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) 2944 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2)
2944 .RetiresOnSaturation(); 2945 .RetiresOnSaturation();
2945 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 2946 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
2946 .Times(1) 2947 .Times(1)
2947 .RetiresOnSaturation(); 2948 .RetiresOnSaturation();
2948 { 2949 {
2949 ResourceProvider::ScopedSamplerGL lock_gl( 2950 ResourceProvider::ScopedSamplerGL lock_gl(
2950 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); 2951 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
2951 EXPECT_EQ(kTextureId, lock_gl.texture_id()); 2952 EXPECT_EQ(kTextureId, lock_gl.texture_id());
2952 } 2953 }
2953 2954
2954 EXPECT_CALL( 2955 EXPECT_CALL(
2955 *context, 2956 *context,
2956 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) 2957 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _))
2957 .WillOnce(SetArgPointee<2>(kStride)) 2958 .WillOnce(SetArgPointee<2>(kStride))
2958 .RetiresOnSaturation(); 2959 .RetiresOnSaturation();
2959 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId, GL_READ_WRITE)) 2960 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
2960 .WillOnce(Return(dummy_mapped_buffer_address)) 2961 .WillOnce(Return(dummy_mapped_buffer_address))
2961 .RetiresOnSaturation(); 2962 .RetiresOnSaturation();
2962 resource_provider->MapImageRasterBuffer(id); 2963 resource_provider->MapImageRasterBuffer(id);
2963 2964
2964 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) 2965 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
2965 .Times(1) 2966 .Times(1)
2966 .RetiresOnSaturation(); 2967 .RetiresOnSaturation();
2967 resource_provider->UnmapImageRasterBuffer(id); 2968 resource_provider->UnmapImageRasterBuffer(id);
2968 2969
2969 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) 2970 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3051 const unsigned kImageId = 234u; 3052 const unsigned kImageId = 234u;
3052 3053
3053 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3054 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3054 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); 3055 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1));
3055 3056
3056 source_id = resource_provider->CreateResource( 3057 source_id = resource_provider->CreateResource(
3057 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); 3058 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
3058 3059
3059 const int kStride = 4; 3060 const int kStride = 4;
3060 void* dummy_mapped_buffer_address = NULL; 3061 void* dummy_mapped_buffer_address = NULL;
3061 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) 3062 EXPECT_CALL(*context,
3063 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_READ_WRITE))
3062 .WillOnce(Return(kImageId)) 3064 .WillOnce(Return(kImageId))
3063 .RetiresOnSaturation(); 3065 .RetiresOnSaturation();
3064 EXPECT_CALL( 3066 EXPECT_CALL(
3065 *context, 3067 *context,
3066 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) 3068 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _))
3067 .WillOnce(SetArgPointee<2>(kStride)) 3069 .WillOnce(SetArgPointee<2>(kStride))
3068 .RetiresOnSaturation(); 3070 .RetiresOnSaturation();
3069 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId, GL_READ_WRITE)) 3071 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3070 .WillOnce(Return(dummy_mapped_buffer_address)) 3072 .WillOnce(Return(dummy_mapped_buffer_address))
3071 .RetiresOnSaturation(); 3073 .RetiresOnSaturation();
3072 resource_provider->MapImageRasterBuffer(source_id); 3074 resource_provider->MapImageRasterBuffer(source_id);
3073 Mock::VerifyAndClearExpectations(context); 3075 Mock::VerifyAndClearExpectations(context);
3074 3076
3075 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) 3077 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
3076 .Times(1) 3078 .Times(1)
3077 .RetiresOnSaturation(); 3079 .RetiresOnSaturation();
3078 resource_provider->UnmapImageRasterBuffer(source_id); 3080 resource_provider->UnmapImageRasterBuffer(source_id);
3079 Mock::VerifyAndClearExpectations(context); 3081 Mock::VerifyAndClearExpectations(context);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
3339 resource_provider->AllocateForTesting(id); 3341 resource_provider->AllocateForTesting(id);
3340 Mock::VerifyAndClearExpectations(context); 3342 Mock::VerifyAndClearExpectations(context);
3341 3343
3342 DCHECK_EQ(10u, context->PeekTextureId()); 3344 DCHECK_EQ(10u, context->PeekTextureId());
3343 resource_provider->DeleteResource(id); 3345 resource_provider->DeleteResource(id);
3344 } 3346 }
3345 } 3347 }
3346 3348
3347 } // namespace 3349 } // namespace
3348 } // namespace cc 3350 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698