summaryrefslogtreecommitdiffstats
path: root/cc/test
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-08 22:14:11 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-08 22:14:11 +0000
commita99d82fff6f153284981a7c44b2f9303de31e012 (patch)
treeca979dfb00ce009718da7f837b13a3cdc7eaf118 /cc/test
parent18aa701dea5ef746a52ef43ee7f209abedb78182 (diff)
downloadchromium_src-a99d82fff6f153284981a7c44b2f9303de31e012.zip
chromium_src-a99d82fff6f153284981a7c44b2f9303de31e012.tar.gz
chromium_src-a99d82fff6f153284981a7c44b2f9303de31e012.tar.bz2
Use GLES2Interface for shaders and programs
This uses the gpu::gles2::GLES2Interface type in the gl renderer's shader and program code instead of WebGraphicsContext3D. For production code, the GLES2Interface is a direct interface to the real command buffer in use. For cc_unittests, the GLES2Interface is a stub that wraps TestWebGraphicsContext3D so we can continue to use the same stubs/mocks for now. Once we port all of the production code over to using GLES2Interface we should port the test context classes over to the new base interface. BUG=181120 Review URL: https://codereview.chromium.org/93433004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test')
-rw-r--r--cc/test/test_context_provider.cc4
-rw-r--r--cc/test/test_context_provider.h3
-rw-r--r--cc/test/test_gles2_interface.cc51
-rw-r--r--cc/test/test_gles2_interface.h36
4 files changed, 92 insertions, 2 deletions
diff --git a/cc/test/test_context_provider.cc b/cc/test/test_context_provider.cc
index 8484b38..501570b 100644
--- a/cc/test/test_context_provider.cc
+++ b/cc/test/test_context_provider.cc
@@ -11,6 +11,7 @@
#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/strings/string_split.h"
+#include "cc/test/test_gles2_interface.h"
#include "cc/test/test_web_graphics_context_3d.h"
namespace cc {
@@ -72,6 +73,7 @@ scoped_refptr<TestContextProvider> TestContextProvider::Create(
TestContextProvider::TestContextProvider(
scoped_ptr<TestWebGraphicsContext3D> context)
: context3d_(context.Pass()),
+ context_gl_(new TestGLES2Interface(context3d_.get())),
bound_(false),
destroyed_(false) {
DCHECK(main_thread_checker_.CalledOnValidThread());
@@ -125,7 +127,7 @@ gpu::gles2::GLES2Interface* TestContextProvider::ContextGL() {
DCHECK(bound_);
DCHECK(context_thread_checker_.CalledOnValidThread());
- return &context_gl_stub_;
+ return context_gl_.get();
}
gpu::ContextSupport* TestContextProvider::ContextSupport() {
diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h
index 6997f85..1f086001 100644
--- a/cc/test/test_context_provider.h
+++ b/cc/test/test_context_provider.h
@@ -17,6 +17,7 @@ namespace blink { class WebGraphicsContext3D; }
namespace cc {
class TestWebGraphicsContext3D;
+class TestGLES2Interface;
class TestContextProvider : public cc::ContextProvider {
public:
@@ -66,7 +67,7 @@ class TestContextProvider : public cc::ContextProvider {
TestContextSupport support_;
scoped_ptr<TestWebGraphicsContext3D> context3d_;
- gpu::gles2::GLES2InterfaceStub context_gl_stub_;
+ scoped_ptr<TestGLES2Interface> context_gl_;
bool bound_;
base::ThreadChecker main_thread_checker_;
diff --git a/cc/test/test_gles2_interface.cc b/cc/test/test_gles2_interface.cc
new file mode 100644
index 0000000..c9502d5
--- /dev/null
+++ b/cc/test/test_gles2_interface.cc
@@ -0,0 +1,51 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/test/test_gles2_interface.h"
+
+#include "base/logging.h"
+#include "cc/test/test_web_graphics_context_3d.h"
+
+namespace cc {
+
+TestGLES2Interface::TestGLES2Interface(TestWebGraphicsContext3D* test_context)
+ : test_context_(test_context) {
+ DCHECK(test_context_);
+}
+
+TestGLES2Interface::~TestGLES2Interface() {}
+
+GLuint TestGLES2Interface::CreateShader(GLenum type) {
+ return test_context_->createShader(type);
+}
+
+GLuint TestGLES2Interface::CreateProgram() {
+ return test_context_->createProgram();
+}
+
+void TestGLES2Interface::GetShaderiv(GLuint shader,
+ GLenum pname,
+ GLint* params) {
+ test_context_->getShaderiv(shader, pname, params);
+}
+
+void TestGLES2Interface::GetProgramiv(GLuint program,
+ GLenum pname,
+ GLint* params) {
+ test_context_->getProgramiv(program, pname, params);
+}
+
+void TestGLES2Interface::GetShaderPrecisionFormat(GLenum shadertype,
+ GLenum precisiontype,
+ GLint* range,
+ GLint* precision) {
+ test_context_->getShaderPrecisionFormat(
+ shadertype, precisiontype, range, precision);
+}
+
+void TestGLES2Interface::UseProgram(GLuint program) {
+ test_context_->useProgram(program);
+}
+
+} // namespace cc
diff --git a/cc/test/test_gles2_interface.h b/cc/test/test_gles2_interface.h
new file mode 100644
index 0000000..c7f0637
--- /dev/null
+++ b/cc/test/test_gles2_interface.h
@@ -0,0 +1,36 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_TEST_TEST_GLES2_INTERFACE_H_
+#define CC_TEST_TEST_GLES2_INTERFACE_H_
+
+#include "gpu/command_buffer/client/gles2_interface_stub.h"
+
+namespace cc {
+class TestWebGraphicsContext3D;
+
+class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
+ public:
+ explicit TestGLES2Interface(TestWebGraphicsContext3D* test_context);
+ virtual ~TestGLES2Interface();
+
+ virtual GLuint CreateShader(GLenum type) OVERRIDE;
+ virtual GLuint CreateProgram() OVERRIDE;
+ virtual void GetShaderiv(GLuint shader, GLenum pname, GLint* params) OVERRIDE;
+ virtual void GetProgramiv(GLuint program,
+ GLenum pname,
+ GLint* params) OVERRIDE;
+ virtual void GetShaderPrecisionFormat(GLenum shadertype,
+ GLenum precisiontype,
+ GLint* range,
+ GLint* precision) OVERRIDE;
+ virtual void UseProgram(GLuint program) OVERRIDE;
+
+ private:
+ TestWebGraphicsContext3D* test_context_;
+};
+
+} // namespace cc
+
+#endif // CC_TEST_TEST_GLES2_INTERFACE_H_