| 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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 gfx::Rect rect(size); | 602 gfx::Rect rect(size); |
| 603 child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); | 603 child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); |
| 604 | 604 |
| 605 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( | 605 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( |
| 606 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 606 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 607 uint8_t data2[4] = { 5, 5, 5, 5 }; | 607 uint8_t data2[4] = { 5, 5, 5, 5 }; |
| 608 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); | 608 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); |
| 609 | 609 |
| 610 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( | 610 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( |
| 611 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 611 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 612 child_resource_provider_->MapImageRasterBuffer(id3); | 612 child_resource_provider_->AcquireImageRasterBuffer(id3); |
| 613 child_resource_provider_->UnmapImageRasterBuffer(id3); | 613 child_resource_provider_->ReleaseImageRasterBuffer(id3); |
| 614 | 614 |
| 615 GLuint external_texture_id = child_context_->createExternalTexture(); | 615 GLuint external_texture_id = child_context_->createExternalTexture(); |
| 616 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); | 616 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); |
| 617 | 617 |
| 618 gpu::Mailbox external_mailbox; | 618 gpu::Mailbox external_mailbox; |
| 619 child_context_->genMailboxCHROMIUM(external_mailbox.name); | 619 child_context_->genMailboxCHROMIUM(external_mailbox.name); |
| 620 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, | 620 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, |
| 621 external_mailbox.name); | 621 external_mailbox.name); |
| 622 const GLuint external_sync_point = child_context_->insertSyncPoint(); | 622 const GLuint external_sync_point = child_context_->insertSyncPoint(); |
| 623 ResourceProvider::ResourceId id4 = | 623 ResourceProvider::ResourceId id4 = |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 | 945 |
| 946 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( | 946 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( |
| 947 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 947 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 948 uint8_t data2[4] = { 5, 5, 5, 5 }; | 948 uint8_t data2[4] = { 5, 5, 5, 5 }; |
| 949 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); | 949 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); |
| 950 | 950 |
| 951 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( | 951 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( |
| 952 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 952 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 953 uint8_t data3[4] = { 6, 7, 8, 9 }; | 953 uint8_t data3[4] = { 6, 7, 8, 9 }; |
| 954 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); | 954 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); |
| 955 SkCanvas* raster_canvas = child_resource_provider_->MapImageRasterBuffer(id3); | 955 RasterBuffer* raster_buffer = |
| 956 raster_canvas->writePixels(info, data3, info.minRowBytes(), 0, 0); | 956 child_resource_provider_->AcquireImageRasterBuffer(id3); |
| 957 child_resource_provider_->UnmapImageRasterBuffer(id3); | 957 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 958 canvas->writePixels(info, data3, info.minRowBytes(), 0, 0); |
| 959 raster_buffer->ReleaseSkCanvas(canvas); |
| 960 canvas.clear(); |
| 961 child_resource_provider_->ReleaseImageRasterBuffer(id3); |
| 958 | 962 |
| 959 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); | 963 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); |
| 960 shared_memory->CreateAndMapAnonymous(1); | 964 shared_memory->CreateAndMapAnonymous(1); |
| 961 base::SharedMemory* shared_memory_ptr = shared_memory.get(); | 965 base::SharedMemory* shared_memory_ptr = shared_memory.get(); |
| 962 ResourceProvider::ResourceId id4 = | 966 ResourceProvider::ResourceId id4 = |
| 963 child_resource_provider_->CreateResourceFromTextureMailbox( | 967 child_resource_provider_->CreateResourceFromTextureMailbox( |
| 964 TextureMailbox(shared_memory_ptr, gfx::Size(1, 1)), | 968 TextureMailbox(shared_memory_ptr, gfx::Size(1, 1)), |
| 965 SingleReleaseCallback::Create(base::Bind( | 969 SingleReleaseCallback::Create(base::Bind( |
| 966 &SharedMemoryReleaseCallback, base::Passed(&shared_memory)))); | 970 &SharedMemoryReleaseCallback, base::Passed(&shared_memory)))); |
| 967 | 971 |
| (...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2727 resource_provider->SetPixels(id, pixels, rect, rect, offset); | 2731 resource_provider->SetPixels(id, pixels, rect, rect, offset); |
| 2728 | 2732 |
| 2729 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); | 2733 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); |
| 2730 resource_provider->DeleteResource(id); | 2734 resource_provider->DeleteResource(id); |
| 2731 | 2735 |
| 2732 Mock::VerifyAndClearExpectations(context); | 2736 Mock::VerifyAndClearExpectations(context); |
| 2733 | 2737 |
| 2734 // Same for async version. | 2738 // Same for async version. |
| 2735 id = resource_provider->CreateResource( | 2739 id = resource_provider->CreateResource( |
| 2736 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2740 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2737 resource_provider->AcquirePixelRasterBuffer(id); | 2741 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id); |
| 2742 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 2743 raster_buffer->ReleaseSkCanvas(canvas); |
| 2744 canvas.clear(); |
| 2738 | 2745 |
| 2739 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 2746 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 2740 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 2747 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 2741 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 2748 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
| 2742 .Times(1); | 2749 .Times(1); |
| 2743 resource_provider->BeginSetPixels(id); | 2750 resource_provider->BeginSetPixels(id); |
| 2744 ASSERT_TRUE(resource_provider->DidSetPixelsComplete(id)); | 2751 ASSERT_TRUE(resource_provider->DidSetPixelsComplete(id)); |
| 2745 | 2752 |
| 2746 resource_provider->ReleasePixelRasterBuffer(id); | 2753 resource_provider->ReleasePixelRasterBuffer(id); |
| 2747 | 2754 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2843 gfx::Size size(2, 2); | 2850 gfx::Size size(2, 2); |
| 2844 ResourceFormat format = RGBA_8888; | 2851 ResourceFormat format = RGBA_8888; |
| 2845 ResourceProvider::ResourceId id = 0; | 2852 ResourceProvider::ResourceId id = 0; |
| 2846 int texture_id = 123; | 2853 int texture_id = 123; |
| 2847 | 2854 |
| 2848 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2855 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2849 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); | 2856 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 2850 | 2857 |
| 2851 id = resource_provider->CreateResource( | 2858 id = resource_provider->CreateResource( |
| 2852 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2859 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2853 resource_provider->AcquirePixelRasterBuffer(id); | 2860 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id); |
| 2861 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 2862 raster_buffer->ReleaseSkCanvas(canvas); |
| 2863 canvas.clear(); |
| 2854 | 2864 |
| 2855 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 2865 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 2856 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 2866 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 2857 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 2867 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
| 2858 .Times(1); | 2868 .Times(1); |
| 2859 resource_provider->BeginSetPixels(id); | 2869 resource_provider->BeginSetPixels(id); |
| 2860 | 2870 |
| 2861 EXPECT_TRUE(resource_provider->DidSetPixelsComplete(id)); | 2871 EXPECT_TRUE(resource_provider->DidSetPixelsComplete(id)); |
| 2862 | 2872 |
| 2863 resource_provider->ReleasePixelRasterBuffer(id); | 2873 resource_provider->ReleasePixelRasterBuffer(id); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2884 gfx::Size size(2, 2); | 2894 gfx::Size size(2, 2); |
| 2885 ResourceFormat format = RGBA_8888; | 2895 ResourceFormat format = RGBA_8888; |
| 2886 ResourceProvider::ResourceId id = 0; | 2896 ResourceProvider::ResourceId id = 0; |
| 2887 int texture_id = 123; | 2897 int texture_id = 123; |
| 2888 | 2898 |
| 2889 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2899 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2890 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); | 2900 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 2891 | 2901 |
| 2892 id = resource_provider->CreateResource( | 2902 id = resource_provider->CreateResource( |
| 2893 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2903 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2894 resource_provider->AcquirePixelRasterBuffer(id); | 2904 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id); |
| 2905 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 2906 raster_buffer->ReleaseSkCanvas(canvas); |
| 2907 canvas.clear(); |
| 2895 | 2908 |
| 2896 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 2909 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 2897 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 2910 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 2898 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 2911 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
| 2899 .Times(1); | 2912 .Times(1); |
| 2900 resource_provider->BeginSetPixels(id); | 2913 resource_provider->BeginSetPixels(id); |
| 2901 | 2914 |
| 2902 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); | 2915 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); |
| 2903 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); | 2916 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); |
| 2904 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1); | 2917 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2930 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2943 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2931 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); | 2944 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 2932 | 2945 |
| 2933 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); | 2946 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); |
| 2934 | 2947 |
| 2935 id = resource_provider->CreateResource( | 2948 id = resource_provider->CreateResource( |
| 2936 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2949 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2937 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 2950 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 2938 GL_INNOCENT_CONTEXT_RESET_ARB); | 2951 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 2939 | 2952 |
| 2940 resource_provider->AcquirePixelRasterBuffer(id); | 2953 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id); |
| 2941 SkCanvas* raster_canvas = resource_provider->MapPixelRasterBuffer(id); | 2954 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 2942 EXPECT_TRUE(raster_canvas == NULL); | 2955 EXPECT_TRUE(canvas.get() == NULL); |
| 2943 resource_provider->UnmapPixelRasterBuffer(id); | 2956 raster_buffer->ReleaseSkCanvas(canvas); |
| 2957 canvas.clear(); |
| 2944 resource_provider->ReleasePixelRasterBuffer(id); | 2958 resource_provider->ReleasePixelRasterBuffer(id); |
| 2945 Mock::VerifyAndClearExpectations(context); | 2959 Mock::VerifyAndClearExpectations(context); |
| 2946 } | 2960 } |
| 2947 | 2961 |
| 2948 TEST_P(ResourceProviderTest, Image_GLTexture) { | 2962 TEST_P(ResourceProviderTest, Image_GLTexture) { |
| 2949 // Only for GL textures. | 2963 // Only for GL textures. |
| 2950 if (GetParam() != ResourceProvider::GLTexture) | 2964 if (GetParam() != ResourceProvider::GLTexture) |
| 2951 return; | 2965 return; |
| 2952 scoped_ptr<AllocationTrackingContext3D> context_owned( | 2966 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 2953 new StrictMock<AllocationTrackingContext3D>); | 2967 new StrictMock<AllocationTrackingContext3D>); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2980 .WillOnce(Return(kImageId)) | 2994 .WillOnce(Return(kImageId)) |
| 2981 .RetiresOnSaturation(); | 2995 .RetiresOnSaturation(); |
| 2982 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, | 2996 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, |
| 2983 GL_IMAGE_ROWBYTES_CHROMIUM, | 2997 GL_IMAGE_ROWBYTES_CHROMIUM, |
| 2984 _)) | 2998 _)) |
| 2985 .WillOnce(SetArgPointee<2>(kStride)) | 2999 .WillOnce(SetArgPointee<2>(kStride)) |
| 2986 .RetiresOnSaturation(); | 3000 .RetiresOnSaturation(); |
| 2987 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) | 3001 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) |
| 2988 .WillOnce(Return(dummy_mapped_buffer_address)) | 3002 .WillOnce(Return(dummy_mapped_buffer_address)) |
| 2989 .RetiresOnSaturation(); | 3003 .RetiresOnSaturation(); |
| 2990 resource_provider->MapImageRasterBuffer(id); | 3004 resource_provider->AcquireImageRasterBuffer(id); |
| 2991 | 3005 resource_provider->ReleaseImageRasterBuffer(id); |
| 2992 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) | |
| 2993 .Times(1) | |
| 2994 .RetiresOnSaturation(); | |
| 2995 resource_provider->UnmapImageRasterBuffer(id); | |
| 2996 | 3006 |
| 2997 EXPECT_CALL(*context, NextTextureId()) | 3007 EXPECT_CALL(*context, NextTextureId()) |
| 2998 .WillOnce(Return(kTextureId)) | 3008 .WillOnce(Return(kTextureId)) |
| 2999 .RetiresOnSaturation(); | 3009 .RetiresOnSaturation(); |
| 3000 // Once in CreateTextureId and once in BindForSampling | 3010 // Once in CreateTextureId and once in BindForSampling |
| 3001 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) | 3011 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) |
| 3002 .RetiresOnSaturation(); | 3012 .RetiresOnSaturation(); |
| 3003 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3013 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
| 3004 .Times(1) | 3014 .Times(1) |
| 3005 .RetiresOnSaturation(); | 3015 .RetiresOnSaturation(); |
| 3006 { | 3016 { |
| 3007 ResourceProvider::ScopedSamplerGL lock_gl( | 3017 ResourceProvider::ScopedSamplerGL lock_gl( |
| 3008 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); | 3018 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); |
| 3009 EXPECT_EQ(kTextureId, lock_gl.texture_id()); | 3019 EXPECT_EQ(kTextureId, lock_gl.texture_id()); |
| 3010 } | 3020 } |
| 3011 | 3021 |
| 3012 EXPECT_CALL( | 3022 EXPECT_CALL( |
| 3013 *context, | 3023 *context, |
| 3014 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) | 3024 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) |
| 3015 .WillOnce(SetArgPointee<2>(kStride)) | 3025 .WillOnce(SetArgPointee<2>(kStride)) |
| 3016 .RetiresOnSaturation(); | 3026 .RetiresOnSaturation(); |
| 3017 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) | 3027 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) |
| 3018 .WillOnce(Return(dummy_mapped_buffer_address)) | 3028 .WillOnce(Return(dummy_mapped_buffer_address)) |
| 3019 .RetiresOnSaturation(); | 3029 .RetiresOnSaturation(); |
| 3020 resource_provider->MapImageRasterBuffer(id); | 3030 resource_provider->AcquireImageRasterBuffer(id); |
| 3021 | 3031 resource_provider->ReleaseImageRasterBuffer(id); |
| 3022 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) | |
| 3023 .Times(1) | |
| 3024 .RetiresOnSaturation(); | |
| 3025 resource_provider->UnmapImageRasterBuffer(id); | |
| 3026 | 3032 |
| 3027 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) | 3033 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) |
| 3028 .RetiresOnSaturation(); | 3034 .RetiresOnSaturation(); |
| 3029 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3035 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
| 3030 .Times(1) | 3036 .Times(1) |
| 3031 .RetiresOnSaturation(); | 3037 .RetiresOnSaturation(); |
| 3032 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3038 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
| 3033 .Times(1) | 3039 .Times(1) |
| 3034 .RetiresOnSaturation(); | 3040 .RetiresOnSaturation(); |
| 3035 EXPECT_CALL(*context, RetireTextureId(kTextureId)) | 3041 EXPECT_CALL(*context, RetireTextureId(kTextureId)) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3062 | 3068 |
| 3063 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 3069 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 3064 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); | 3070 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 3065 | 3071 |
| 3066 id = resource_provider->CreateResource( | 3072 id = resource_provider->CreateResource( |
| 3067 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3073 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3068 | 3074 |
| 3069 SkBitmap bitmap; | 3075 SkBitmap bitmap; |
| 3070 bitmap.allocN32Pixels(size.width(), size.height()); | 3076 bitmap.allocN32Pixels(size.width(), size.height()); |
| 3071 *(bitmap.getAddr32(0, 0)) = kBadBeef; | 3077 *(bitmap.getAddr32(0, 0)) = kBadBeef; |
| 3072 SkCanvas* canvas = resource_provider->MapImageRasterBuffer(id); | 3078 RasterBuffer* raster_buffer = resource_provider->AcquireImageRasterBuffer(id); |
| 3079 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 3073 ASSERT_TRUE(!!canvas); | 3080 ASSERT_TRUE(!!canvas); |
| 3074 canvas->writePixels(bitmap, 0, 0); | 3081 canvas->writePixels(bitmap, 0, 0); |
| 3075 resource_provider->UnmapImageRasterBuffer(id); | 3082 raster_buffer->ReleaseSkCanvas(canvas); |
| 3083 canvas.clear(); |
| 3084 resource_provider->ReleaseImageRasterBuffer(id); |
| 3076 | 3085 |
| 3077 { | 3086 { |
| 3078 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id); | 3087 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id); |
| 3079 const SkBitmap* sk_bitmap = lock.sk_bitmap(); | 3088 const SkBitmap* sk_bitmap = lock.sk_bitmap(); |
| 3080 EXPECT_EQ(sk_bitmap->width(), size.width()); | 3089 EXPECT_EQ(sk_bitmap->width(), size.width()); |
| 3081 EXPECT_EQ(sk_bitmap->height(), size.height()); | 3090 EXPECT_EQ(sk_bitmap->height(), size.height()); |
| 3082 EXPECT_EQ(*sk_bitmap->getAddr32(0, 0), kBadBeef); | 3091 EXPECT_EQ(*sk_bitmap->getAddr32(0, 0), kBadBeef); |
| 3083 } | 3092 } |
| 3084 | 3093 |
| 3085 resource_provider->DeleteResource(id); | 3094 resource_provider->DeleteResource(id); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3122 .WillOnce(Return(kImageId)) | 3131 .WillOnce(Return(kImageId)) |
| 3123 .RetiresOnSaturation(); | 3132 .RetiresOnSaturation(); |
| 3124 EXPECT_CALL( | 3133 EXPECT_CALL( |
| 3125 *context, | 3134 *context, |
| 3126 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) | 3135 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) |
| 3127 .WillOnce(SetArgPointee<2>(kStride)) | 3136 .WillOnce(SetArgPointee<2>(kStride)) |
| 3128 .RetiresOnSaturation(); | 3137 .RetiresOnSaturation(); |
| 3129 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) | 3138 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) |
| 3130 .WillOnce(Return(dummy_mapped_buffer_address)) | 3139 .WillOnce(Return(dummy_mapped_buffer_address)) |
| 3131 .RetiresOnSaturation(); | 3140 .RetiresOnSaturation(); |
| 3132 resource_provider->MapImageRasterBuffer(source_id); | 3141 resource_provider->AcquireImageRasterBuffer(source_id); |
| 3133 Mock::VerifyAndClearExpectations(context); | 3142 resource_provider->ReleaseImageRasterBuffer(source_id); |
| 3134 | |
| 3135 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) | |
| 3136 .Times(1) | |
| 3137 .RetiresOnSaturation(); | |
| 3138 resource_provider->UnmapImageRasterBuffer(source_id); | |
| 3139 Mock::VerifyAndClearExpectations(context); | 3143 Mock::VerifyAndClearExpectations(context); |
| 3140 | 3144 |
| 3141 dest_id = resource_provider->CreateResource( | 3145 dest_id = resource_provider->CreateResource( |
| 3142 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3146 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3143 | 3147 |
| 3144 EXPECT_CALL(*context, NextTextureId()) | 3148 EXPECT_CALL(*context, NextTextureId()) |
| 3145 .WillOnce(Return(kDestTextureId)) | 3149 .WillOnce(Return(kDestTextureId)) |
| 3146 .RetiresOnSaturation(); | 3150 .RetiresOnSaturation(); |
| 3147 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId)) | 3151 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId)) |
| 3148 .Times(1) | 3152 .Times(1) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3188 | 3192 |
| 3189 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 3193 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 3190 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); | 3194 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 3191 | 3195 |
| 3192 source_id = resource_provider->CreateResource( | 3196 source_id = resource_provider->CreateResource( |
| 3193 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3197 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3194 | 3198 |
| 3195 SkBitmap bitmap; | 3199 SkBitmap bitmap; |
| 3196 bitmap.allocN32Pixels(size.width(), size.height()); | 3200 bitmap.allocN32Pixels(size.width(), size.height()); |
| 3197 *(bitmap.getAddr32(0, 0)) = kBadBeef; | 3201 *(bitmap.getAddr32(0, 0)) = kBadBeef; |
| 3198 SkCanvas* canvas = resource_provider->MapImageRasterBuffer(source_id); | 3202 RasterBuffer* raster_buffer = |
| 3203 resource_provider->AcquireImageRasterBuffer(source_id); |
| 3204 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 3199 ASSERT_TRUE(!!canvas); | 3205 ASSERT_TRUE(!!canvas); |
| 3200 canvas->writePixels(bitmap, 0, 0); | 3206 canvas->writePixels(bitmap, 0, 0); |
| 3201 resource_provider->UnmapImageRasterBuffer(source_id); | 3207 raster_buffer->ReleaseSkCanvas(canvas); |
| 3208 canvas.clear(); |
| 3209 resource_provider->ReleaseImageRasterBuffer(source_id); |
| 3202 | 3210 |
| 3203 dest_id = resource_provider->CreateResource( | 3211 dest_id = resource_provider->CreateResource( |
| 3204 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3212 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3205 | 3213 |
| 3206 resource_provider->CopyResource(source_id, dest_id); | 3214 resource_provider->CopyResource(source_id, dest_id); |
| 3207 | 3215 |
| 3208 { | 3216 { |
| 3209 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), | 3217 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), |
| 3210 dest_id); | 3218 dest_id); |
| 3211 const SkBitmap* sk_bitmap = lock.sk_bitmap(); | 3219 const SkBitmap* sk_bitmap = lock.sk_bitmap(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3405 resource_provider->AllocateForTesting(id); | 3413 resource_provider->AllocateForTesting(id); |
| 3406 Mock::VerifyAndClearExpectations(context); | 3414 Mock::VerifyAndClearExpectations(context); |
| 3407 | 3415 |
| 3408 DCHECK_EQ(10u, context->PeekTextureId()); | 3416 DCHECK_EQ(10u, context->PeekTextureId()); |
| 3409 resource_provider->DeleteResource(id); | 3417 resource_provider->DeleteResource(id); |
| 3410 } | 3418 } |
| 3411 } | 3419 } |
| 3412 | 3420 |
| 3413 } // namespace | 3421 } // namespace |
| 3414 } // namespace cc | 3422 } // namespace cc |
| OLD | NEW |