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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 3455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3466 std::unique_ptr<ResourceProvider> resource_provider( | 3466 std::unique_ptr<ResourceProvider> resource_provider( |
3467 base::MakeUnique<ResourceProvider>( | 3467 base::MakeUnique<ResourceProvider>( |
3468 context_provider.get(), shared_bitmap_manager_.get(), | 3468 context_provider.get(), shared_bitmap_manager_.get(), |
3469 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3469 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
3470 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3470 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
3471 kEnableColorCorrectRendering, | 3471 kEnableColorCorrectRendering, |
3472 DefaultBufferToTextureTargetMapForTesting())); | 3472 DefaultBufferToTextureTargetMapForTesting())); |
3473 | 3473 |
3474 gfx::Size size(2, 2); | 3474 gfx::Size size(2, 2); |
3475 | 3475 |
3476 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; | 3476 const ResourceFormat formats[3] = {RGBA_8888, BGRA_8888, RGBA_F16}; |
3477 const ResourceProvider::TextureHint hints[4] = { | 3477 const ResourceProvider::TextureHint hints[4] = { |
3478 ResourceProvider::TEXTURE_HINT_DEFAULT, | 3478 ResourceProvider::TEXTURE_HINT_DEFAULT, |
3479 ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 3479 ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
3480 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, | 3480 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, |
3481 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, | 3481 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, |
3482 }; | 3482 }; |
3483 for (size_t i = 0; i < arraysize(formats); ++i) { | 3483 for (size_t i = 0; i < arraysize(formats); ++i) { |
3484 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { | 3484 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { |
3485 // Lazy allocation. Don't allocate when creating the resource. | 3485 // Lazy allocation. Don't allocate when creating the resource. |
3486 ResourceId id = resource_provider->CreateResource( | 3486 ResourceId id = resource_provider->CreateResource( |
3487 size, hints[texture_id - 1], formats[i], gfx::ColorSpace()); | 3487 size, hints[texture_id - 1], formats[i], gfx::ColorSpace()); |
3488 | 3488 |
3489 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 3489 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
3490 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 3490 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
3491 bool is_immutable_hint = | 3491 bool is_immutable_hint = |
3492 hints[texture_id - 1] & ResourceProvider::TEXTURE_HINT_IMMUTABLE; | 3492 hints[texture_id - 1] & ResourceProvider::TEXTURE_HINT_IMMUTABLE; |
3493 bool support_immutable_texture = | 3493 bool support_immutable_texture = |
3494 is_immutable_hint && formats[i] == RGBA_8888; | 3494 is_immutable_hint && formats[i] != BGRA_8888; |
3495 EXPECT_CALL(*context, texStorage2DEXT(_, _, _, 2, 2)) | 3495 EXPECT_CALL(*context, texStorage2DEXT(_, _, _, 2, 2)) |
3496 .Times(support_immutable_texture ? 1 : 0); | 3496 .Times(support_immutable_texture ? 1 : 0); |
3497 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)) | 3497 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)) |
3498 .Times(support_immutable_texture ? 0 : 1); | 3498 .Times(support_immutable_texture ? 0 : 1); |
3499 resource_provider->AllocateForTesting(id); | 3499 resource_provider->AllocateForTesting(id); |
3500 | 3500 |
3501 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); | 3501 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); |
3502 resource_provider->DeleteResource(id); | 3502 resource_provider->DeleteResource(id); |
3503 | 3503 |
3504 Mock::VerifyAndClearExpectations(context); | 3504 Mock::VerifyAndClearExpectations(context); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3809 lock.set_sync_token(token); | 3809 lock.set_sync_token(token); |
3810 } | 3810 } |
3811 | 3811 |
3812 gpu::SyncToken last_token = | 3812 gpu::SyncToken last_token = |
3813 resource_provider_->GetSyncTokenForResources(array); | 3813 resource_provider_->GetSyncTokenForResources(array); |
3814 EXPECT_EQ(last_token.release_count(), 10u); | 3814 EXPECT_EQ(last_token.release_count(), 10u); |
3815 } | 3815 } |
3816 | 3816 |
3817 } // namespace | 3817 } // namespace |
3818 } // namespace cc | 3818 } // namespace cc |
OLD | NEW |