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 #include <vector> | 10 #include <vector> |
(...skipping 2573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2584 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2584 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2585 output_surface.get(), shared_bitmap_manager_.get(), | 2585 output_surface.get(), shared_bitmap_manager_.get(), |
2586 gpu_memory_buffer_manager_.get(), NULL, 0, 1, | 2586 gpu_memory_buffer_manager_.get(), NULL, 0, 1, |
2587 use_image_texture_targets_)); | 2587 use_image_texture_targets_)); |
2588 | 2588 |
2589 gfx::Size size(1, 1); | 2589 gfx::Size size(1, 1); |
2590 ResourceFormat format = RGBA_8888; | 2590 ResourceFormat format = RGBA_8888; |
2591 int texture_id = 1; | 2591 int texture_id = 1; |
2592 | 2592 |
2593 // Check that the texture gets created with the right sampler settings. | 2593 // Check that the texture gets created with the right sampler settings. |
2594 ResourceId id = resource_provider->CreateManagedResource( | 2594 ResourceId id = resource_provider->CreateResourceWithTextureTarget( |
2595 size, GL_TEXTURE_2D, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 2595 size, GL_TEXTURE_2D, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
2596 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 2596 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
2597 EXPECT_CALL(*context, | 2597 EXPECT_CALL(*context, |
2598 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2598 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
2599 EXPECT_CALL(*context, | 2599 EXPECT_CALL(*context, |
2600 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2600 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
2601 EXPECT_CALL( | 2601 EXPECT_CALL( |
2602 *context, | 2602 *context, |
2603 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 2603 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
2604 EXPECT_CALL( | 2604 EXPECT_CALL( |
(...skipping 22 matching lines...) Expand all Loading... |
2627 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2627 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2628 output_surface.get(), shared_bitmap_manager_.get(), | 2628 output_surface.get(), shared_bitmap_manager_.get(), |
2629 gpu_memory_buffer_manager_.get(), NULL, 0, 1, | 2629 gpu_memory_buffer_manager_.get(), NULL, 0, 1, |
2630 use_image_texture_targets_)); | 2630 use_image_texture_targets_)); |
2631 | 2631 |
2632 gfx::Size size(1, 1); | 2632 gfx::Size size(1, 1); |
2633 ResourceFormat format = RGBA_8888; | 2633 ResourceFormat format = RGBA_8888; |
2634 | 2634 |
2635 for (int texture_id = 1; texture_id <= 2; ++texture_id) { | 2635 for (int texture_id = 1; texture_id <= 2; ++texture_id) { |
2636 // Check that the texture gets created with the right sampler settings. | 2636 // Check that the texture gets created with the right sampler settings. |
2637 ResourceId id = resource_provider->CreateGLTexture( | 2637 ResourceId id = resource_provider->CreateResource( |
2638 size, GL_TEXTURE_2D, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 2638 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
2639 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 2639 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
2640 EXPECT_CALL(*context, | 2640 EXPECT_CALL(*context, |
2641 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2641 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
2642 EXPECT_CALL(*context, | 2642 EXPECT_CALL(*context, |
2643 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2643 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
2644 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, | 2644 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, |
2645 GL_CLAMP_TO_EDGE)); | 2645 GL_CLAMP_TO_EDGE)); |
2646 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, | 2646 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, |
2647 GL_CLAMP_TO_EDGE)); | 2647 GL_CLAMP_TO_EDGE)); |
2648 resource_provider->CreateForTesting(id); | 2648 resource_provider->CreateForTesting(id); |
(...skipping 28 matching lines...) Expand all Loading... |
2677 ResourceFormat format = RGBA_8888; | 2677 ResourceFormat format = RGBA_8888; |
2678 | 2678 |
2679 const ResourceProvider::TextureHint hints[4] = { | 2679 const ResourceProvider::TextureHint hints[4] = { |
2680 ResourceProvider::TEXTURE_HINT_DEFAULT, | 2680 ResourceProvider::TEXTURE_HINT_DEFAULT, |
2681 ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 2681 ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
2682 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, | 2682 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, |
2683 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, | 2683 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, |
2684 }; | 2684 }; |
2685 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { | 2685 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { |
2686 // Check that the texture gets created with the right sampler settings. | 2686 // Check that the texture gets created with the right sampler settings. |
2687 ResourceId id = resource_provider->CreateGLTexture( | 2687 ResourceId id = |
2688 size, GL_TEXTURE_2D, hints[texture_id - 1], format); | 2688 resource_provider->CreateResource(size, hints[texture_id - 1], format); |
2689 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 2689 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
2690 EXPECT_CALL(*context, | 2690 EXPECT_CALL(*context, |
2691 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2691 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
2692 EXPECT_CALL(*context, | 2692 EXPECT_CALL(*context, |
2693 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2693 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
2694 EXPECT_CALL( | 2694 EXPECT_CALL( |
2695 *context, | 2695 *context, |
2696 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 2696 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
2697 EXPECT_CALL( | 2697 EXPECT_CALL( |
2698 *context, | 2698 *context, |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3529 resource_provider->AllocateForTesting(id); | 3529 resource_provider->AllocateForTesting(id); |
3530 Mock::VerifyAndClearExpectations(context); | 3530 Mock::VerifyAndClearExpectations(context); |
3531 | 3531 |
3532 DCHECK_EQ(10u, context->PeekTextureId()); | 3532 DCHECK_EQ(10u, context->PeekTextureId()); |
3533 resource_provider->DeleteResource(id); | 3533 resource_provider->DeleteResource(id); |
3534 } | 3534 } |
3535 } | 3535 } |
3536 | 3536 |
3537 } // namespace | 3537 } // namespace |
3538 } // namespace cc | 3538 } // namespace cc |
OLD | NEW |