Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1964)

Unified Diff: cc/resource_provider_unittest.cc

Issue 11358181: Use nearest neighbor filtering for non-translated quads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Change CHECK() into DCHECK(). Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/test/render_pass_test_common.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resource_provider_unittest.cc
diff --git a/cc/resource_provider_unittest.cc b/cc/resource_provider_unittest.cc
index 851144c9dcfefb6d0e69eda000b2e683449f8d26..71912b30d055f14a322f8c1c7c795ba74d6dd5c4 100644
--- a/cc/resource_provider_unittest.cc
+++ b/cc/resource_provider_unittest.cc
@@ -10,6 +10,7 @@
#include "cc/scoped_ptr_hash_map.h"
#include "cc/test/compositor_fake_web_graphics_context_3d.h"
#include "cc/test/fake_web_compositor_output_surface.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
@@ -18,6 +19,8 @@
using namespace WebKit;
+using testing::Mock;
+
namespace cc {
namespace {
@@ -580,6 +583,61 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources)
EXPECT_EQ(0u, childResourceProvider->numResources());
}
+class TextureStateTrackingContext : public FakeWebGraphicsContext3D {
+public:
+ MOCK_METHOD2(bindTexture, void(WGC3Denum target, WebGLId texture));
+ MOCK_METHOD3(texParameteri, void(WGC3Denum target, WGC3Denum pname, WGC3Dint param));
+};
+
+TEST_P(ResourceProviderTest, ScopedSampler)
+{
+ // Sampling is only supported for GL textures.
+ if (GetParam() != ResourceProvider::GLTexture)
+ return;
+
+ scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)));
+ TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3D());
+ scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
+
+ gfx::Size size(1, 1);
+ WGC3Denum format = GL_RGBA;
+ int pool = 1;
+ int textureId = 1;
+
+ // Check that the texture gets created with the right sampler settings.
+ EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId));
+ EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
+ EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
+ EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
+ EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
+ ResourceProvider::ResourceId id = resourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
+
+ // Creating a sampler with the default filter should not change any texture
+ // parameters.
+ {
+ EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId));
+ ResourceProvider::ScopedSamplerGL sampler(resourceProvider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
+ }
+
+ // Using a different filter should be reflected in the texture parameters.
+ {
+ EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId));
+ EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
+ EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
+ ResourceProvider::ScopedSamplerGL sampler(resourceProvider.get(), id, GL_TEXTURE_2D, GL_NEAREST);
+ }
+
+ // Test resetting to the default filter.
+ {
+ EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId));
+ EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
+ EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
+ ResourceProvider::ScopedSamplerGL sampler(resourceProvider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
+ }
+
+ Mock::VerifyAndClearExpectations(context);
+}
+
INSTANTIATE_TEST_CASE_P(ResourceProviderTests,
ResourceProviderTest,
::testing::Values(ResourceProvider::GLTexture,
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/test/render_pass_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698