diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-10 01:32:53 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-10 01:32:53 +0000 |
commit | 8e26f1db0f6923fd3ecb87853ecbd97567a9ab29 (patch) | |
tree | 4170977a49d4a0cb8775feea530fec77ab893ff0 /cc/gl_renderer_unittest.cc | |
parent | c0d02ed51a35a07abb205a54980d1bc3b3b87527 (diff) | |
download | chromium_src-8e26f1db0f6923fd3ecb87853ecbd97567a9ab29.zip chromium_src-8e26f1db0f6923fd3ecb87853ecbd97567a9ab29.tar.gz chromium_src-8e26f1db0f6923fd3ecb87853ecbd97567a9ab29.tar.bz2 |
Avoid setting activeTexture redundantly
We use GL_TEXTURE0 for nearly all operations, so it's cheaper to leave this as the default
for all draws and have quads that use other texture units reset to 0.
BUG=
Review URL: https://chromiumcodereview.appspot.com/11275222
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167030 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/gl_renderer_unittest.cc')
-rw-r--r-- | cc/gl_renderer_unittest.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc index 0967cec..5e1e978 100644 --- a/cc/gl_renderer_unittest.cc +++ b/cc/gl_renderer_unittest.cc @@ -12,6 +12,7 @@ #include "cc/test/fake_web_compositor_output_surface.h" #include "cc/test/fake_web_graphics_context_3d.h" #include "cc/test/test_common.h" +#include "cc/test/render_pass_test_common.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/khronos/GLES2/gl2.h" @@ -104,6 +105,8 @@ public: // Changing visibility to public. using GLRenderer::initialize; using GLRenderer::isFramebufferDiscarded; + using GLRenderer::drawQuad; + using GLRenderer::beginDrawingFrame; }; class GLRendererTest : public testing::Test { @@ -482,4 +485,56 @@ TEST(GLRendererTest2, visibilityChangeIsLastCall) EXPECT_TRUE(lastCallWasSetVisiblity); } + +class ActiveTextureTrackingContext : public FakeWebGraphicsContext3D { +public: + ActiveTextureTrackingContext() + : m_activeTexture(GL_INVALID_ENUM) + { + } + + virtual WebString getString(WGC3Denum name) + { + if (name == GL_EXTENSIONS) + return WebString("GL_OES_EGL_image_external"); + return WebString(); + } + + virtual void activeTexture(WGC3Denum texture) + { + EXPECT_NE(texture, m_activeTexture); + m_activeTexture = texture; + } + + WGC3Denum activeTexture() const { return m_activeTexture; } + +private: + WGC3Denum m_activeTexture; +}; + +TEST(GLRendererTest2, activeTextureState) +{ + FakeRendererClient fakeClient; + scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ActiveTextureTrackingContext))); + ActiveTextureTrackingContext* context = static_cast<ActiveTextureTrackingContext*>(outputSurface->context3D()); + scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); + FakeRendererGL renderer(&fakeClient, resourceProvider.get()); + + EXPECT_TRUE(renderer.initialize()); + + cc::RenderPass::Id id(1, 1); + scoped_ptr<TestRenderPass> pass = TestRenderPass::create(id, gfx::Rect(0, 0, 100, 100), WebTransformationMatrix()); + pass->appendOneOfEveryQuadType(resourceProvider.get()); + + cc::DirectRenderer::DrawingFrame drawingFrame; + renderer.beginDrawingFrame(drawingFrame); + EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); + + for (cc::QuadList::backToFrontIterator it = pass->quadList().backToFrontBegin(); + it != pass->quadList().backToFrontEnd(); ++it) { + renderer.drawQuad(drawingFrame, *it); + } + EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); +} + } // anonymous namespace |