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

Unified Diff: cc/gl_renderer_unittest.cc

Issue 11275222: Avoid setting activeTexture redundantly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase for r166988 Created 8 years, 1 month 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/gl_renderer.cc ('k') | cc/test/render_pass_test_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/gl_renderer_unittest.cc
diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc
index 0967ceceaed155bf53d76e70cb5d28f755011886..5e1e978a457ebda73060970b23c37bea11b841ab 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
« no previous file with comments | « cc/gl_renderer.cc ('k') | cc/test/render_pass_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698