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