diff options
author | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-24 08:00:11 +0000 |
---|---|---|
committer | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-24 08:00:11 +0000 |
commit | ac0c76228c92cbb338f17c1268fbfc801b11d73c (patch) | |
tree | 043d8a446e724ee353743857da14c117c9b13d9e /gpu | |
parent | 0b1a9c75d017d8d40eb183987ff934d74d718137 (diff) | |
download | chromium_src-ac0c76228c92cbb338f17c1268fbfc801b11d73c.zip chromium_src-ac0c76228c92cbb338f17c1268fbfc801b11d73c.tar.gz chromium_src-ac0c76228c92cbb338f17c1268fbfc801b11d73c.tar.bz2 |
Android: Move SurfaceTexture from content to ui/gl and add test.
This functionality needs to be exposed in places outside of content/, i.e. gpu/.
Review URL: https://chromiumcodereview.appspot.com/14366008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196086 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/tests/gl_manager.cc | 4 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_manager.h | 2 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_tests_main.cc | 9 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_unittests_android.cc | 64 | ||||
-rw-r--r-- | gpu/gpu.gyp | 1 |
5 files changed, 79 insertions, 1 deletions
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc index 85108c4..75a254a 100644 --- a/gpu/command_buffer/tests/gl_manager.cc +++ b/gpu/command_buffer/tests/gl_manager.cc @@ -228,6 +228,10 @@ void GLManager::MakeCurrent() { ::gles2::SetGLContext(gles2_implementation_.get()); } +void GLManager::SetSurface(gfx::GLSurface* surface) { + decoder_->SetSurface(surface); +} + void GLManager::Destroy() { if (gles2_implementation_.get()) { MakeCurrent(); diff --git a/gpu/command_buffer/tests/gl_manager.h b/gpu/command_buffer/tests/gl_manager.h index b293941..2ebe695 100644 --- a/gpu/command_buffer/tests/gl_manager.h +++ b/gpu/command_buffer/tests/gl_manager.h @@ -59,6 +59,8 @@ class GLManager { void MakeCurrent(); + void SetSurface(gfx::GLSurface* surface); + gles2::MailboxManager* mailbox_manager() const { return mailbox_manager_.get(); } diff --git a/gpu/command_buffer/tests/gl_tests_main.cc b/gpu/command_buffer/tests/gl_tests_main.cc index 3ade214..d585fde 100644 --- a/gpu/command_buffer/tests/gl_tests_main.cc +++ b/gpu/command_buffer/tests/gl_tests_main.cc @@ -12,12 +12,19 @@ #include "gpu/command_buffer/tests/gl_test_utils.h" #include "ui/gl/gl_surface.h" +#if defined(OS_ANDROID) +#include "base/android/jni_android.h" +#include "ui/gl/android/gl_jni_registrar.h" +#endif + #if defined(TOOLKIT_GTK) #include "ui/gfx/gtk_util.h" #endif int main(int argc, char** argv) { -#if !defined(OS_ANDROID) +#if defined(OS_ANDROID) + ui::gl::android::RegisterJni(base::android::AttachCurrentThread()); +#else base::AtExitManager exit_manager; #endif CommandLine::Init(argc, argv); diff --git a/gpu/command_buffer/tests/gl_unittests_android.cc b/gpu/command_buffer/tests/gl_unittests_android.cc new file mode 100644 index 0000000..f110d2c --- /dev/null +++ b/gpu/command_buffer/tests/gl_unittests_android.cc @@ -0,0 +1,64 @@ +// Copyright (c) 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 <GLES2/gl2.h> +#include <GLES2/gl2ext.h> + +#include <android/native_window_jni.h> + +#include "base/bind.h" +#include "base/logging.h" +#include "base/synchronization/waitable_event.h" +#include "gpu/command_buffer/tests/gl_manager.h" +#include "gpu/command_buffer/tests/gl_test_utils.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/gl/android/surface_texture_bridge.h" +#include "ui/gl/gl_surface.h" + +namespace gpu { + +class GLSurfaceTextureTest : public testing::Test { + protected: + virtual void SetUp() OVERRIDE { + gl_.Initialize(GLManager::Options()); + } + + virtual void TearDown() OVERRIDE { + gl_.Destroy(); + } + + GLManager gl_; +}; + +TEST_F(GLSurfaceTextureTest, SimpleTest) { + // TODO(sievers): Eliminate the need for this by using a client-side + // abstraction for the SurfaceTexture in this test. + GLuint texture = 0xFEEDBEEF; + + scoped_refptr<gfx::SurfaceTextureBridge> surface_texture( + new gfx::SurfaceTextureBridge(texture)); + gfx::AcceleratedWidget window = surface_texture->CreateSurface(); + EXPECT_TRUE(window != NULL); + + scoped_refptr<gfx::GLSurface> gl_surface = + gfx::GLSurface::CreateViewGLSurface(false, window); + EXPECT_TRUE(gl_surface.get() != NULL); + + gl_.SetSurface(gl_surface); + + glClearColor(0.0f, 1.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); +// glSwapBuffers(); + + surface_texture->UpdateTexImage(); + + GLTestHelper::CheckGLError("no errors", __LINE__); + + ANativeWindow_release(window); +} + +} // namespace gpu + diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index 540d51a..0492532 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -262,6 +262,7 @@ 'command_buffer/tests/gl_texture_mailbox_unittests.cc', 'command_buffer/tests/gl_texture_storage_unittests.cc', 'command_buffer/tests/gl_unittests.cc', + 'command_buffer/tests/gl_unittests_android.cc', 'command_buffer/tests/gl_virtual_contexts_unittests.cc', 'command_buffer/tests/occlusion_query_unittests.cc', ], |