diff options
author | skyostil@chromium.org <skyostil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 12:18:30 +0000 |
---|---|---|
committer | skyostil@chromium.org <skyostil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 12:18:30 +0000 |
commit | d1a56f05be296acedfab104659f042395804c0b2 (patch) | |
tree | 0f6f04d4e736c79080ade2db6722045b014274ab /cc/gl_renderer_unittest.cc | |
parent | 364aaef8112e73e370b759e7a45bb0bd6164ada1 (diff) | |
download | chromium_src-d1a56f05be296acedfab104659f042395804c0b2.zip chromium_src-d1a56f05be296acedfab104659f042395804c0b2.tar.gz chromium_src-d1a56f05be296acedfab104659f042395804c0b2.tar.bz2 |
Use nearest neighbor filtering for non-translated quads
Draw tiled layer quads that only have a translation transformation
component using nearest neighbor filtering instead of bilinear
filtering. This has two advantages:
1. On some GPUs this can reduce memory bandwidth usage due to increased
texture cache hit rate.
2. Linear filtering is known to give slightly different results on
different GPUs because of differences in the texture sampling
hardware. Avoiding bilinear filtering in the common case (i.e., when
CSS transformation aren't used) makes WebKit layout test pixel dumps
better comparable across different devices.
TEST=ResourceProviderTest.ScopedSampler, GLRendererTest2.activeTextureState, manual testing with composited websites.
BUG=
Review URL: https://chromiumcodereview.appspot.com/11358181
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170944 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/gl_renderer_unittest.cc')
-rw-r--r-- | cc/gl_renderer_unittest.cc | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc index 919c4d5..3dda6e6 100644 --- a/cc/gl_renderer_unittest.cc +++ b/cc/gl_renderer_unittest.cc @@ -18,6 +18,11 @@ using namespace WebKit; using namespace WebKitTests; +using testing::_; +using testing::AnyNumber; +using testing::InSequence; +using testing::Mock; + namespace cc { namespace { @@ -481,12 +486,10 @@ TEST(GLRendererTest2, visibilityChangeIsLastCall) EXPECT_TRUE(lastCallWasSetVisiblity); } - class TextureStateTrackingContext : public FakeWebGraphicsContext3D { public: TextureStateTrackingContext() : m_activeTexture(GL_INVALID_ENUM) - , m_inDraw(false) { } @@ -497,15 +500,8 @@ public: return WebString(); } - // We shouldn't set any texture parameters during the draw sequence, although - // we might when creating the quads. - void setInDraw() { m_inDraw = true; } - - virtual void texParameteri(WGC3Denum target, WGC3Denum pname, WGC3Dint param) - { - if (m_inDraw) - ADD_FAILURE(); - } + MOCK_METHOD3(texParameteri, void(WGC3Denum target, WGC3Denum pname, WGC3Dint param)); + MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset)); virtual void activeTexture(WGC3Denum texture) { @@ -516,7 +512,6 @@ public: WGC3Denum activeTexture() const { return m_activeTexture; } private: - bool m_inDraw; WGC3Denum m_activeTexture; }; @@ -528,6 +523,8 @@ TEST(GLRendererTest2, activeTextureState) scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&fakeClient, resourceProvider.get()); + // During initialization we are allowed to set any texture parameters. + EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); EXPECT_TRUE(renderer.initialize()); cc::RenderPass::Id id(1, 1); @@ -535,7 +532,33 @@ TEST(GLRendererTest2, activeTextureState) pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), gfx::Transform()); pass->AppendOneOfEveryQuadType(resourceProvider.get()); - context->setInDraw(); + // Set up expected texture filter state transitions that match the quads + // created in AppendOneOfEveryQuadType(). + Mock::VerifyAndClearExpectations(context); + { + InSequence sequence; + + // yuv_quad is drawn with the default filter. + EXPECT_CALL(*context, drawElements(_, _, _, _)); + + // tile_quad is drawn with GL_NEAREST because it is not transformed or + // scaled. + 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)); + EXPECT_CALL(*context, drawElements(_, _, _, _)); + + // transformed_tile_quad uses GL_LINEAR. + 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, drawElements(_, _, _, _)); + + // scaled_tile_quad also uses GL_LINEAR. + EXPECT_CALL(*context, drawElements(_, _, _, _)); + + // The remaining quads also use GL_LINEAR because nearest neighbor + // filtering is currently only used with tile quads. + EXPECT_CALL(*context, drawElements(_, _, _, _)).Times(6); + } cc::DirectRenderer::DrawingFrame drawingFrame; renderer.beginDrawingFrame(drawingFrame); @@ -547,6 +570,7 @@ TEST(GLRendererTest2, activeTextureState) } renderer.finishDrawingQuadList(); EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); + Mock::VerifyAndClearExpectations(context); } } // namespace |