OLD | NEW |
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 Loading... |
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 Loading... |
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( |
| 2922 *context, |
| 2923 createImageCHROMIUM( |
| 2924 kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_CPU_READ_WRITE_CHROMIUM)) |
2922 .WillOnce(Return(kImageId)) | 2925 .WillOnce(Return(kImageId)) |
2923 .RetiresOnSaturation(); | 2926 .RetiresOnSaturation(); |
2924 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, | 2927 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, |
2925 GL_IMAGE_ROWBYTES_CHROMIUM, | 2928 GL_IMAGE_ROWBYTES_CHROMIUM, |
2926 _)) | 2929 _)) |
2927 .WillOnce(SetArgPointee<2>(kStride)) | 2930 .WillOnce(SetArgPointee<2>(kStride)) |
2928 .RetiresOnSaturation(); | 2931 .RetiresOnSaturation(); |
2929 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId, GL_READ_WRITE)) | 2932 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) |
2930 .WillOnce(Return(dummy_mapped_buffer_address)) | 2933 .WillOnce(Return(dummy_mapped_buffer_address)) |
2931 .RetiresOnSaturation(); | 2934 .RetiresOnSaturation(); |
2932 resource_provider->MapImageRasterBuffer(id); | 2935 resource_provider->MapImageRasterBuffer(id); |
2933 | 2936 |
2934 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) | 2937 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) |
2935 .Times(1) | 2938 .Times(1) |
2936 .RetiresOnSaturation(); | 2939 .RetiresOnSaturation(); |
2937 resource_provider->UnmapImageRasterBuffer(id); | 2940 resource_provider->UnmapImageRasterBuffer(id); |
2938 | 2941 |
2939 EXPECT_CALL(*context, NextTextureId()) | 2942 EXPECT_CALL(*context, NextTextureId()) |
2940 .WillOnce(Return(kTextureId)) | 2943 .WillOnce(Return(kTextureId)) |
2941 .RetiresOnSaturation(); | 2944 .RetiresOnSaturation(); |
2942 // Once in CreateTextureId and once in BindForSampling | 2945 // Once in CreateTextureId and once in BindForSampling |
2943 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) | 2946 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) |
2944 .RetiresOnSaturation(); | 2947 .RetiresOnSaturation(); |
2945 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 2948 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
2946 .Times(1) | 2949 .Times(1) |
2947 .RetiresOnSaturation(); | 2950 .RetiresOnSaturation(); |
2948 { | 2951 { |
2949 ResourceProvider::ScopedSamplerGL lock_gl( | 2952 ResourceProvider::ScopedSamplerGL lock_gl( |
2950 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); | 2953 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); |
2951 EXPECT_EQ(kTextureId, lock_gl.texture_id()); | 2954 EXPECT_EQ(kTextureId, lock_gl.texture_id()); |
2952 } | 2955 } |
2953 | 2956 |
2954 EXPECT_CALL( | 2957 EXPECT_CALL( |
2955 *context, | 2958 *context, |
2956 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) | 2959 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) |
2957 .WillOnce(SetArgPointee<2>(kStride)) | 2960 .WillOnce(SetArgPointee<2>(kStride)) |
2958 .RetiresOnSaturation(); | 2961 .RetiresOnSaturation(); |
2959 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId, GL_READ_WRITE)) | 2962 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) |
2960 .WillOnce(Return(dummy_mapped_buffer_address)) | 2963 .WillOnce(Return(dummy_mapped_buffer_address)) |
2961 .RetiresOnSaturation(); | 2964 .RetiresOnSaturation(); |
2962 resource_provider->MapImageRasterBuffer(id); | 2965 resource_provider->MapImageRasterBuffer(id); |
2963 | 2966 |
2964 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) | 2967 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) |
2965 .Times(1) | 2968 .Times(1) |
2966 .RetiresOnSaturation(); | 2969 .RetiresOnSaturation(); |
2967 resource_provider->UnmapImageRasterBuffer(id); | 2970 resource_provider->UnmapImageRasterBuffer(id); |
2968 | 2971 |
2969 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) | 2972 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3051 const unsigned kImageId = 234u; | 3054 const unsigned kImageId = 234u; |
3052 | 3055 |
3053 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 3056 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
3054 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); | 3057 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1)); |
3055 | 3058 |
3056 source_id = resource_provider->CreateResource( | 3059 source_id = resource_provider->CreateResource( |
3057 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3060 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
3058 | 3061 |
3059 const int kStride = 4; | 3062 const int kStride = 4; |
3060 void* dummy_mapped_buffer_address = NULL; | 3063 void* dummy_mapped_buffer_address = NULL; |
3061 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) | 3064 EXPECT_CALL( |
| 3065 *context, |
| 3066 createImageCHROMIUM( |
| 3067 kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_CPU_READ_WRITE_CHROMIUM)) |
3062 .WillOnce(Return(kImageId)) | 3068 .WillOnce(Return(kImageId)) |
3063 .RetiresOnSaturation(); | 3069 .RetiresOnSaturation(); |
3064 EXPECT_CALL( | 3070 EXPECT_CALL( |
3065 *context, | 3071 *context, |
3066 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) | 3072 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) |
3067 .WillOnce(SetArgPointee<2>(kStride)) | 3073 .WillOnce(SetArgPointee<2>(kStride)) |
3068 .RetiresOnSaturation(); | 3074 .RetiresOnSaturation(); |
3069 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId, GL_READ_WRITE)) | 3075 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) |
3070 .WillOnce(Return(dummy_mapped_buffer_address)) | 3076 .WillOnce(Return(dummy_mapped_buffer_address)) |
3071 .RetiresOnSaturation(); | 3077 .RetiresOnSaturation(); |
3072 resource_provider->MapImageRasterBuffer(source_id); | 3078 resource_provider->MapImageRasterBuffer(source_id); |
3073 Mock::VerifyAndClearExpectations(context); | 3079 Mock::VerifyAndClearExpectations(context); |
3074 | 3080 |
3075 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) | 3081 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) |
3076 .Times(1) | 3082 .Times(1) |
3077 .RetiresOnSaturation(); | 3083 .RetiresOnSaturation(); |
3078 resource_provider->UnmapImageRasterBuffer(source_id); | 3084 resource_provider->UnmapImageRasterBuffer(source_id); |
3079 Mock::VerifyAndClearExpectations(context); | 3085 Mock::VerifyAndClearExpectations(context); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3339 resource_provider->AllocateForTesting(id); | 3345 resource_provider->AllocateForTesting(id); |
3340 Mock::VerifyAndClearExpectations(context); | 3346 Mock::VerifyAndClearExpectations(context); |
3341 | 3347 |
3342 DCHECK_EQ(10u, context->PeekTextureId()); | 3348 DCHECK_EQ(10u, context->PeekTextureId()); |
3343 resource_provider->DeleteResource(id); | 3349 resource_provider->DeleteResource(id); |
3344 } | 3350 } |
3345 } | 3351 } |
3346 | 3352 |
3347 } // namespace | 3353 } // namespace |
3348 } // namespace cc | 3354 } // namespace cc |
OLD | NEW |