| 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 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2930 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2934 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2931 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); | 2935 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 2932 | 2936 |
| 2933 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); | 2937 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); |
| 2934 | 2938 |
| 2935 id = resource_provider->CreateResource( | 2939 id = resource_provider->CreateResource( |
| 2936 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 2940 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 2937 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 2941 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 2938 GL_INNOCENT_CONTEXT_RESET_ARB); | 2942 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 2939 | 2943 |
| 2940 resource_provider->AcquirePixelRasterBuffer(id); | 2944 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id); |
| 2941 SkCanvas* raster_canvas = resource_provider->MapPixelRasterBuffer(id); | 2945 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 2942 EXPECT_TRUE(raster_canvas == NULL); | 2946 EXPECT_TRUE(canvas.get() == NULL); |
| 2943 resource_provider->UnmapPixelRasterBuffer(id); | 2947 raster_buffer->ReleaseSkCanvas(canvas); |
| 2948 canvas.clear(); |
| 2944 resource_provider->ReleasePixelRasterBuffer(id); | 2949 resource_provider->ReleasePixelRasterBuffer(id); |
| 2945 Mock::VerifyAndClearExpectations(context); | 2950 Mock::VerifyAndClearExpectations(context); |
| 2946 } | 2951 } |
| 2947 | 2952 |
| 2948 TEST_P(ResourceProviderTest, Image_GLTexture) { | 2953 TEST_P(ResourceProviderTest, Image_GLTexture) { |
| 2949 // Only for GL textures. | 2954 // Only for GL textures. |
| 2950 if (GetParam() != ResourceProvider::GLTexture) | 2955 if (GetParam() != ResourceProvider::GLTexture) |
| 2951 return; | 2956 return; |
| 2952 scoped_ptr<AllocationTrackingContext3D> context_owned( | 2957 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 2953 new StrictMock<AllocationTrackingContext3D>); | 2958 new StrictMock<AllocationTrackingContext3D>); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2980 .WillOnce(Return(kImageId)) | 2985 .WillOnce(Return(kImageId)) |
| 2981 .RetiresOnSaturation(); | 2986 .RetiresOnSaturation(); |
| 2982 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, | 2987 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, |
| 2983 GL_IMAGE_ROWBYTES_CHROMIUM, | 2988 GL_IMAGE_ROWBYTES_CHROMIUM, |
| 2984 _)) | 2989 _)) |
| 2985 .WillOnce(SetArgPointee<2>(kStride)) | 2990 .WillOnce(SetArgPointee<2>(kStride)) |
| 2986 .RetiresOnSaturation(); | 2991 .RetiresOnSaturation(); |
| 2987 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) | 2992 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) |
| 2988 .WillOnce(Return(dummy_mapped_buffer_address)) | 2993 .WillOnce(Return(dummy_mapped_buffer_address)) |
| 2989 .RetiresOnSaturation(); | 2994 .RetiresOnSaturation(); |
| 2990 resource_provider->MapImageRasterBuffer(id); | 2995 resource_provider->AcquireImageRasterBuffer(id); |
| 2991 | 2996 |
| 2992 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) | 2997 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) |
| 2993 .Times(1) | 2998 .Times(1) |
| 2994 .RetiresOnSaturation(); | 2999 .RetiresOnSaturation(); |
| 2995 resource_provider->UnmapImageRasterBuffer(id); | 3000 resource_provider->ReleaseImageRasterBuffer(id); |
| 2996 | 3001 |
| 2997 EXPECT_CALL(*context, NextTextureId()) | 3002 EXPECT_CALL(*context, NextTextureId()) |
| 2998 .WillOnce(Return(kTextureId)) | 3003 .WillOnce(Return(kTextureId)) |
| 2999 .RetiresOnSaturation(); | 3004 .RetiresOnSaturation(); |
| 3000 // Once in CreateTextureId and once in BindForSampling | 3005 // Once in CreateTextureId and once in BindForSampling |
| 3001 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) | 3006 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) |
| 3002 .RetiresOnSaturation(); | 3007 .RetiresOnSaturation(); |
| 3003 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3008 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
| 3004 .Times(1) | 3009 .Times(1) |
| 3005 .RetiresOnSaturation(); | 3010 .RetiresOnSaturation(); |
| 3006 { | 3011 { |
| 3007 ResourceProvider::ScopedSamplerGL lock_gl( | 3012 ResourceProvider::ScopedSamplerGL lock_gl( |
| 3008 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); | 3013 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); |
| 3009 EXPECT_EQ(kTextureId, lock_gl.texture_id()); | 3014 EXPECT_EQ(kTextureId, lock_gl.texture_id()); |
| 3010 } | 3015 } |
| 3011 | 3016 |
| 3012 EXPECT_CALL( | 3017 EXPECT_CALL( |
| 3013 *context, | 3018 *context, |
| 3014 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) | 3019 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) |
| 3015 .WillOnce(SetArgPointee<2>(kStride)) | 3020 .WillOnce(SetArgPointee<2>(kStride)) |
| 3016 .RetiresOnSaturation(); | 3021 .RetiresOnSaturation(); |
| 3017 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) | 3022 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) |
| 3018 .WillOnce(Return(dummy_mapped_buffer_address)) | 3023 .WillOnce(Return(dummy_mapped_buffer_address)) |
| 3019 .RetiresOnSaturation(); | 3024 .RetiresOnSaturation(); |
| 3020 resource_provider->MapImageRasterBuffer(id); | 3025 resource_provider->AcquireImageRasterBuffer(id); |
| 3021 | 3026 |
| 3022 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) | 3027 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) |
| 3023 .Times(1) | 3028 .Times(1) |
| 3024 .RetiresOnSaturation(); | 3029 .RetiresOnSaturation(); |
| 3025 resource_provider->UnmapImageRasterBuffer(id); | 3030 resource_provider->ReleaseImageRasterBuffer(id); |
| 3026 | 3031 |
| 3027 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) | 3032 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) |
| 3028 .RetiresOnSaturation(); | 3033 .RetiresOnSaturation(); |
| 3029 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3034 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
| 3030 .Times(1) | 3035 .Times(1) |
| 3031 .RetiresOnSaturation(); | 3036 .RetiresOnSaturation(); |
| 3032 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3037 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
| 3033 .Times(1) | 3038 .Times(1) |
| 3034 .RetiresOnSaturation(); | 3039 .RetiresOnSaturation(); |
| 3035 EXPECT_CALL(*context, RetireTextureId(kTextureId)) | 3040 EXPECT_CALL(*context, RetireTextureId(kTextureId)) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3062 | 3067 |
| 3063 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 3068 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 3064 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); | 3069 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 3065 | 3070 |
| 3066 id = resource_provider->CreateResource( | 3071 id = resource_provider->CreateResource( |
| 3067 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3072 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3068 | 3073 |
| 3069 SkBitmap bitmap; | 3074 SkBitmap bitmap; |
| 3070 bitmap.allocN32Pixels(size.width(), size.height()); | 3075 bitmap.allocN32Pixels(size.width(), size.height()); |
| 3071 *(bitmap.getAddr32(0, 0)) = kBadBeef; | 3076 *(bitmap.getAddr32(0, 0)) = kBadBeef; |
| 3072 SkCanvas* canvas = resource_provider->MapImageRasterBuffer(id); | 3077 RasterBuffer* raster_buffer = resource_provider->AcquireImageRasterBuffer(id); |
| 3078 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 3073 ASSERT_TRUE(!!canvas); | 3079 ASSERT_TRUE(!!canvas); |
| 3074 canvas->writePixels(bitmap, 0, 0); | 3080 canvas->writePixels(bitmap, 0, 0); |
| 3075 resource_provider->UnmapImageRasterBuffer(id); | 3081 raster_buffer->ReleaseSkCanvas(canvas); |
| 3082 canvas.clear(); |
| 3083 resource_provider->ReleaseImageRasterBuffer(id); |
| 3076 | 3084 |
| 3077 { | 3085 { |
| 3078 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id); | 3086 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id); |
| 3079 const SkBitmap* sk_bitmap = lock.sk_bitmap(); | 3087 const SkBitmap* sk_bitmap = lock.sk_bitmap(); |
| 3080 EXPECT_EQ(sk_bitmap->width(), size.width()); | 3088 EXPECT_EQ(sk_bitmap->width(), size.width()); |
| 3081 EXPECT_EQ(sk_bitmap->height(), size.height()); | 3089 EXPECT_EQ(sk_bitmap->height(), size.height()); |
| 3082 EXPECT_EQ(*sk_bitmap->getAddr32(0, 0), kBadBeef); | 3090 EXPECT_EQ(*sk_bitmap->getAddr32(0, 0), kBadBeef); |
| 3083 } | 3091 } |
| 3084 | 3092 |
| 3085 resource_provider->DeleteResource(id); | 3093 resource_provider->DeleteResource(id); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3122 .WillOnce(Return(kImageId)) | 3130 .WillOnce(Return(kImageId)) |
| 3123 .RetiresOnSaturation(); | 3131 .RetiresOnSaturation(); |
| 3124 EXPECT_CALL( | 3132 EXPECT_CALL( |
| 3125 *context, | 3133 *context, |
| 3126 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) | 3134 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) |
| 3127 .WillOnce(SetArgPointee<2>(kStride)) | 3135 .WillOnce(SetArgPointee<2>(kStride)) |
| 3128 .RetiresOnSaturation(); | 3136 .RetiresOnSaturation(); |
| 3129 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) | 3137 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId)) |
| 3130 .WillOnce(Return(dummy_mapped_buffer_address)) | 3138 .WillOnce(Return(dummy_mapped_buffer_address)) |
| 3131 .RetiresOnSaturation(); | 3139 .RetiresOnSaturation(); |
| 3132 resource_provider->MapImageRasterBuffer(source_id); | 3140 resource_provider->AcquireImageRasterBuffer(source_id); |
| 3133 Mock::VerifyAndClearExpectations(context); | 3141 Mock::VerifyAndClearExpectations(context); |
| 3134 | 3142 |
| 3135 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) | 3143 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) |
| 3136 .Times(1) | 3144 .Times(1) |
| 3137 .RetiresOnSaturation(); | 3145 .RetiresOnSaturation(); |
| 3138 resource_provider->UnmapImageRasterBuffer(source_id); | 3146 resource_provider->ReleaseImageRasterBuffer(source_id); |
| 3139 Mock::VerifyAndClearExpectations(context); | 3147 Mock::VerifyAndClearExpectations(context); |
| 3140 | 3148 |
| 3141 dest_id = resource_provider->CreateResource( | 3149 dest_id = resource_provider->CreateResource( |
| 3142 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3150 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3143 | 3151 |
| 3144 EXPECT_CALL(*context, NextTextureId()) | 3152 EXPECT_CALL(*context, NextTextureId()) |
| 3145 .WillOnce(Return(kDestTextureId)) | 3153 .WillOnce(Return(kDestTextureId)) |
| 3146 .RetiresOnSaturation(); | 3154 .RetiresOnSaturation(); |
| 3147 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId)) | 3155 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId)) |
| 3148 .Times(1) | 3156 .Times(1) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3188 | 3196 |
| 3189 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 3197 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 3190 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); | 3198 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 3191 | 3199 |
| 3192 source_id = resource_provider->CreateResource( | 3200 source_id = resource_provider->CreateResource( |
| 3193 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3201 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3194 | 3202 |
| 3195 SkBitmap bitmap; | 3203 SkBitmap bitmap; |
| 3196 bitmap.allocN32Pixels(size.width(), size.height()); | 3204 bitmap.allocN32Pixels(size.width(), size.height()); |
| 3197 *(bitmap.getAddr32(0, 0)) = kBadBeef; | 3205 *(bitmap.getAddr32(0, 0)) = kBadBeef; |
| 3198 SkCanvas* canvas = resource_provider->MapImageRasterBuffer(source_id); | 3206 RasterBuffer* raster_buffer = |
| 3207 resource_provider->AcquireImageRasterBuffer(source_id); |
| 3208 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); |
| 3199 ASSERT_TRUE(!!canvas); | 3209 ASSERT_TRUE(!!canvas); |
| 3200 canvas->writePixels(bitmap, 0, 0); | 3210 canvas->writePixels(bitmap, 0, 0); |
| 3201 resource_provider->UnmapImageRasterBuffer(source_id); | 3211 raster_buffer->ReleaseSkCanvas(canvas); |
| 3212 canvas.clear(); |
| 3213 resource_provider->ReleaseImageRasterBuffer(source_id); |
| 3202 | 3214 |
| 3203 dest_id = resource_provider->CreateResource( | 3215 dest_id = resource_provider->CreateResource( |
| 3204 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); | 3216 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 3205 | 3217 |
| 3206 resource_provider->CopyResource(source_id, dest_id); | 3218 resource_provider->CopyResource(source_id, dest_id); |
| 3207 | 3219 |
| 3208 { | 3220 { |
| 3209 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), | 3221 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), |
| 3210 dest_id); | 3222 dest_id); |
| 3211 const SkBitmap* sk_bitmap = lock.sk_bitmap(); | 3223 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); | 3417 resource_provider->AllocateForTesting(id); |
| 3406 Mock::VerifyAndClearExpectations(context); | 3418 Mock::VerifyAndClearExpectations(context); |
| 3407 | 3419 |
| 3408 DCHECK_EQ(10u, context->PeekTextureId()); | 3420 DCHECK_EQ(10u, context->PeekTextureId()); |
| 3409 resource_provider->DeleteResource(id); | 3421 resource_provider->DeleteResource(id); |
| 3410 } | 3422 } |
| 3411 } | 3423 } |
| 3412 | 3424 |
| 3413 } // namespace | 3425 } // namespace |
| 3414 } // namespace cc | 3426 } // namespace cc |
| OLD | NEW |