| 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/resource_provider.h" | 5 #include "cc/resource_provider.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "cc/output_surface.h" | 8 #include "cc/output_surface.h" |
| 9 #include "cc/scoped_ptr_deque.h" | 9 #include "cc/scoped_ptr_deque.h" |
| 10 #include "cc/scoped_ptr_hash_map.h" | 10 #include "cc/scoped_ptr_hash_map.h" |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 gfx::Size size(1, 1); | 578 gfx::Size size(1, 1); |
| 579 WGC3Denum format = GL_RGBA; | 579 WGC3Denum format = GL_RGBA; |
| 580 int textureId = 1; | 580 int textureId = 1; |
| 581 | 581 |
| 582 // Check that the texture gets created with the right sampler settings. | 582 // Check that the texture gets created with the right sampler settings. |
| 583 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)); | 583 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)); |
| 584 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL
_LINEAR)); | 584 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL
_LINEAR)); |
| 585 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL
_LINEAR)); | 585 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL
_LINEAR)); |
| 586 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLA
MP_TO_EDGE)); | 586 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLA
MP_TO_EDGE)); |
| 587 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLA
MP_TO_EDGE)); | 587 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLA
MP_TO_EDGE)); |
| 588 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM,
GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); |
| 588 ResourceProvider::ResourceId id = resourceProvider->createResource(size, for
mat, ResourceProvider::TextureUsageAny); | 589 ResourceProvider::ResourceId id = resourceProvider->createResource(size, for
mat, ResourceProvider::TextureUsageAny); |
| 589 | 590 |
| 590 // Creating a sampler with the default filter should not change any texture | 591 // Creating a sampler with the default filter should not change any texture |
| 591 // parameters. | 592 // parameters. |
| 592 { | 593 { |
| 593 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)); | 594 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)); |
| 594 ResourceProvider::ScopedSamplerGL sampler(resourceProvider.get(), id, GL
_TEXTURE_2D, GL_LINEAR); | 595 ResourceProvider::ScopedSamplerGL sampler(resourceProvider.get(), id, GL
_TEXTURE_2D, GL_LINEAR); |
| 595 } | 596 } |
| 596 | 597 |
| 597 // Using a different filter should be reflected in the texture parameters. | 598 // Using a different filter should be reflected in the texture parameters. |
| 598 { | 599 { |
| 599 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)); | 600 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)); |
| 600 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER
, GL_NEAREST)); | 601 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER
, GL_NEAREST)); |
| 601 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER
, GL_NEAREST)); | 602 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER
, GL_NEAREST)); |
| 602 ResourceProvider::ScopedSamplerGL sampler(resourceProvider.get(), id, GL
_TEXTURE_2D, GL_NEAREST); | 603 ResourceProvider::ScopedSamplerGL sampler(resourceProvider.get(), id, GL
_TEXTURE_2D, GL_NEAREST); |
| 603 } | 604 } |
| 604 | 605 |
| 605 // Test resetting to the default filter. | 606 // Test resetting to the default filter. |
| 606 { | 607 { |
| 607 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)); | 608 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)); |
| 608 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER
, GL_LINEAR)); | 609 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER
, GL_LINEAR)); |
| 609 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER
, GL_LINEAR)); | 610 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER
, GL_LINEAR)); |
| 610 ResourceProvider::ScopedSamplerGL sampler(resourceProvider.get(), id, GL
_TEXTURE_2D, GL_LINEAR); | 611 ResourceProvider::ScopedSamplerGL sampler(resourceProvider.get(), id, GL
_TEXTURE_2D, GL_LINEAR); |
| 611 } | 612 } |
| 612 | 613 |
| 613 Mock::VerifyAndClearExpectations(context); | 614 Mock::VerifyAndClearExpectations(context); |
| 614 } | 615 } |
| 615 | 616 |
| 617 TEST_P(ResourceProviderTest, ManagedResource) |
| 618 { |
| 619 // Sampling is only supported for GL textures. |
| 620 if (GetParam() != ResourceProvider::GLTexture) |
| 621 return; |
| 622 |
| 623 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); |
| 624 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->Context3D()); |
| 625 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 626 |
| 627 gfx::Size size(1, 1); |
| 628 WGC3Denum format = GL_RGBA; |
| 629 int textureId = 1; |
| 630 |
| 631 // Check that the texture gets created with the right sampler settings. |
| 632 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)); |
| 633 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL
_LINEAR)); |
| 634 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL
_LINEAR)); |
| 635 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLA
MP_TO_EDGE)); |
| 636 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLA
MP_TO_EDGE)); |
| 637 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM,
GL_TEXTURE_POOL_MANAGED_CHROMIUM)); |
| 638 ResourceProvider::ResourceId id = resourceProvider->createManagedResource(si
ze, format, ResourceProvider::TextureUsageAny); |
| 639 |
| 640 Mock::VerifyAndClearExpectations(context); |
| 641 } |
| 642 |
| 616 INSTANTIATE_TEST_CASE_P(ResourceProviderTests, | 643 INSTANTIATE_TEST_CASE_P(ResourceProviderTests, |
| 617 ResourceProviderTest, | 644 ResourceProviderTest, |
| 618 ::testing::Values(ResourceProvider::GLTexture, | 645 ::testing::Values(ResourceProvider::GLTexture, |
| 619 ResourceProvider::Bitmap)); | 646 ResourceProvider::Bitmap)); |
| 620 | 647 |
| 621 } // namespace | 648 } // namespace |
| 622 } // namespace cc | 649 } // namespace cc |
| OLD | NEW |