summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorsievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-24 08:00:11 +0000
committersievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-24 08:00:11 +0000
commitac0c76228c92cbb338f17c1268fbfc801b11d73c (patch)
tree043d8a446e724ee353743857da14c117c9b13d9e /content
parent0b1a9c75d017d8d40eb183987ff934d74d718137 (diff)
downloadchromium_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 'content')
-rw-r--r--content/app/android/child_process_service.cc6
-rw-r--r--content/app/android/library_loader_hooks.cc4
-rw-r--r--content/browser/android/child_process_launcher_android.cc4
-rw-r--r--content/browser/android/surface_texture_peer_browser_impl.cc8
-rw-r--r--content/browser/android/surface_texture_peer_browser_impl.h2
-rw-r--r--content/browser/renderer_host/surface_texture_transport_client_android.cc8
-rw-r--r--content/browser/renderer_host/surface_texture_transport_client_android.h7
-rw-r--r--content/common/android/common_jni_registrar.cc3
-rw-r--r--content/common/android/scoped_java_surface.cc54
-rw-r--r--content/common/android/scoped_java_surface.h42
-rw-r--r--content/common/android/surface_texture_bridge.cc147
-rw-r--r--content/common/android/surface_texture_bridge.h77
-rw-r--r--content/common/android/surface_texture_listener.cc53
-rw-r--r--content/common/android/surface_texture_listener.h51
-rw-r--r--content/common/android/surface_texture_peer.h4
-rw-r--r--content/common/gpu/media/android_video_decode_accelerator.cc6
-rw-r--r--content/common/gpu/media/android_video_decode_accelerator.h8
-rw-r--r--content/common/gpu/stream_texture_manager_android.cc4
-rw-r--r--content/common/gpu/stream_texture_manager_android.h7
-rw-r--r--content/content.gyp20
-rw-r--r--content/content_common.gypi6
-rw-r--r--content/content_jni.gypi1
-rw-r--r--content/public/android/java/src/org/chromium/content/common/SurfaceTextureListener.java46
-rw-r--r--content/public/test/content_test_suite_base.cc1
24 files changed, 39 insertions, 530 deletions
diff --git a/content/app/android/child_process_service.cc b/content/app/android/child_process_service.cc
index c0deb83..2a12aa4 100644
--- a/content/app/android/child_process_service.cc
+++ b/content/app/android/child_process_service.cc
@@ -10,7 +10,6 @@
#include "base/android/jni_array.h"
#include "base/logging.h"
#include "base/posix/global_descriptors.h"
-#include "content/common/android/scoped_java_surface.h"
#include "content/common/android/surface_texture_peer.h"
#include "content/common/child_process.h"
#include "content/common/child_thread.h"
@@ -19,6 +18,7 @@
#include "content/public/common/content_descriptors.h"
#include "ipc/ipc_descriptors.h"
#include "jni/ChildProcessService_jni.h"
+#include "ui/gl/android/scoped_java_surface.h"
using base::android::AttachCurrentThread;
using base::android::CheckException;
@@ -45,7 +45,7 @@ class SurfaceTexturePeerChildImpl : public content::SurfaceTexturePeer,
virtual void EstablishSurfaceTexturePeer(
base::ProcessHandle pid,
- scoped_refptr<content::SurfaceTextureBridge> surface_texture_bridge,
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_bridge,
int primary_id,
int secondary_id) {
JNIEnv* env = base::android::AttachCurrentThread();
@@ -58,7 +58,7 @@ class SurfaceTexturePeerChildImpl : public content::SurfaceTexturePeer,
virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) OVERRIDE {
JNIEnv* env = base::android::AttachCurrentThread();
- ScopedJavaSurface surface(
+ gfx::ScopedJavaSurface surface(
content::Java_ChildProcessService_getViewSurface(
env, service_.obj(), surface_id));
diff --git a/content/app/android/library_loader_hooks.cc b/content/app/android/library_loader_hooks.cc
index f97db8d..3d0cb9c 100644
--- a/content/app/android/library_loader_hooks.cc
+++ b/content/app/android/library_loader_hooks.cc
@@ -27,6 +27,7 @@
#include "media/base/android/media_jni_registrar.h"
#include "net/android/net_jni_registrar.h"
#include "ui/android/ui_jni_registrar.h"
+#include "ui/gl/android/gl_jni_registrar.h"
#include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h"
namespace {
@@ -80,6 +81,9 @@ static jint LibraryLoaded(JNIEnv* env, jclass clazz,
if (!ui::android::RegisterJni(env))
return RESULT_CODE_FAILED_TO_REGISTER_JNI;
+ if (!ui::gl::android::RegisterJni(env))
+ return RESULT_CODE_FAILED_TO_REGISTER_JNI;
+
if (!ui::shell_dialogs::RegisterJni(env))
return RESULT_CODE_FAILED_TO_REGISTER_JNI;
diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc
index 3a954dc..8c855ec 100644
--- a/content/browser/android/child_process_launcher_android.cc
+++ b/content/browser/android/child_process_launcher_android.cc
@@ -11,11 +11,11 @@
#include "content/browser/android/media_player_manager_android.h"
#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/common/android/scoped_java_surface.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "jni/ChildProcessLauncher_jni.h"
#include "media/base/android/media_player_bridge.h"
+#include "ui/gl/android/scoped_java_surface.h"
using base::android::AttachCurrentThread;
using base::android::ToJavaArrayOfStrings;
@@ -52,7 +52,7 @@ static void SetSurfacePeer(
host->media_player_manager()->GetPlayer(player_id);
if (player &&
player != host->media_player_manager()->GetFullscreenPlayer()) {
- ScopedJavaSurface scoped_surface(surface);
+ gfx::ScopedJavaSurface scoped_surface(surface);
player->SetVideoSurface(scoped_surface.j_surface().obj());
}
}
diff --git a/content/browser/android/surface_texture_peer_browser_impl.cc b/content/browser/android/surface_texture_peer_browser_impl.cc
index afd999b..d73f93e 100644
--- a/content/browser/android/surface_texture_peer_browser_impl.cc
+++ b/content/browser/android/surface_texture_peer_browser_impl.cc
@@ -6,10 +6,10 @@
#include "content/browser/android/media_player_manager_android.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/common/android/scoped_java_surface.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "media/base/android/media_player_bridge.h"
+#include "ui/gl/android/scoped_java_surface.h"
namespace content {
@@ -18,7 +18,7 @@ namespace {
// Pass a java surface object to the MediaPlayerBridge object
// identified by render process handle, render view ID and player ID.
static void SetSurfacePeer(
- scoped_refptr<SurfaceTextureBridge> surface_texture_bridge,
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_bridge,
base::ProcessHandle render_process_handle,
int render_view_id,
int player_id) {
@@ -40,7 +40,7 @@ static void SetSurfacePeer(
host->media_player_manager()->GetPlayer(player_id);
if (player &&
player != host->media_player_manager()->GetFullscreenPlayer()) {
- ScopedJavaSurface surface(surface_texture_bridge.get());
+ gfx::ScopedJavaSurface surface(surface_texture_bridge.get());
player->SetVideoSurface(surface.j_surface().obj());
}
}
@@ -57,7 +57,7 @@ SurfaceTexturePeerBrowserImpl::~SurfaceTexturePeerBrowserImpl() {
void SurfaceTexturePeerBrowserImpl::EstablishSurfaceTexturePeer(
base::ProcessHandle render_process_handle,
- scoped_refptr<SurfaceTextureBridge> surface_texture_bridge,
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_bridge,
int render_view_id,
int player_id) {
if (!surface_texture_bridge)
diff --git a/content/browser/android/surface_texture_peer_browser_impl.h b/content/browser/android/surface_texture_peer_browser_impl.h
index 5ebe141..644bf2c 100644
--- a/content/browser/android/surface_texture_peer_browser_impl.h
+++ b/content/browser/android/surface_texture_peer_browser_impl.h
@@ -24,7 +24,7 @@ class SurfaceTexturePeerBrowserImpl : public SurfaceTexturePeer {
// SurfaceTexturePeer implementation.
virtual void EstablishSurfaceTexturePeer(
base::ProcessHandle render_process_handle,
- scoped_refptr<SurfaceTextureBridge> surface_texture_bridge,
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_bridge,
int render_view_id,
int player_id) OVERRIDE;
diff --git a/content/browser/renderer_host/surface_texture_transport_client_android.cc b/content/browser/renderer_host/surface_texture_transport_client_android.cc
index d6d5735..5f6607b 100644
--- a/content/browser/renderer_host/surface_texture_transport_client_android.cc
+++ b/content/browser/renderer_host/surface_texture_transport_client_android.cc
@@ -11,8 +11,8 @@
#include "content/browser/gpu/gpu_surface_tracker.h"
#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/browser/renderer_host/image_transport_factory_android.h"
-#include "content/common/android/surface_texture_bridge.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
+#include "ui/gl/android/surface_texture_bridge.h"
#include "webkit/compositor_bindings/web_compositor_support_impl.h"
namespace content {
@@ -24,7 +24,7 @@ static const uint32 kGLTextureExternalOES = 0x8D65;
class SurfaceRefAndroid : public GpuSurfaceTracker::SurfaceRef {
public:
SurfaceRefAndroid(
- const scoped_refptr<SurfaceTextureBridge>& surface,
+ const scoped_refptr<gfx::SurfaceTextureBridge>& surface,
ANativeWindow* window)
: surface_(surface),
window_(window) {
@@ -37,7 +37,7 @@ class SurfaceRefAndroid : public GpuSurfaceTracker::SurfaceRef {
ANativeWindow_release(window_);
}
- scoped_refptr<SurfaceTextureBridge> surface_;
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_;
ANativeWindow* window_;
};
@@ -56,7 +56,7 @@ scoped_refptr<cc::Layer> SurfaceTextureTransportClient::Initialize() {
// Use a SurfaceTexture to stream frames to the UI thread.
video_layer_ = cc::VideoLayer::Create(this);
- surface_texture_ = new SurfaceTextureBridge(0);
+ surface_texture_ = new gfx::SurfaceTextureBridge(0);
surface_texture_->SetFrameAvailableCallback(
base::Bind(
&SurfaceTextureTransportClient::OnSurfaceTextureFrameAvailable,
diff --git a/content/browser/renderer_host/surface_texture_transport_client_android.h b/content/browser/renderer_host/surface_texture_transport_client_android.h
index d2540e1..2190994 100644
--- a/content/browser/renderer_host/surface_texture_transport_client_android.h
+++ b/content/browser/renderer_host/surface_texture_transport_client_android.h
@@ -18,8 +18,11 @@ class Layer;
class VideoLayer;
}
-namespace content {
+namespace gfx {
class SurfaceTextureBridge;
+}
+
+namespace content {
class SurfaceTextureTransportClient : public cc::VideoFrameProvider {
public:
@@ -40,7 +43,7 @@ class SurfaceTextureTransportClient : public cc::VideoFrameProvider {
void OnSurfaceTextureFrameAvailable();
scoped_refptr<cc::VideoLayer> video_layer_;
- scoped_refptr<SurfaceTextureBridge> surface_texture_;
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_;
ANativeWindow* window_;
scoped_refptr<media::VideoFrame> video_frame_;
uint32 texture_id_;
diff --git a/content/common/android/common_jni_registrar.cc b/content/common/android/common_jni_registrar.cc
index bf774e6..fd7f2a6 100644
--- a/content/common/android/common_jni_registrar.cc
+++ b/content/common/android/common_jni_registrar.cc
@@ -9,7 +9,6 @@
#include "content/common/android/command_line.h"
#include "content/common/android/device_telephony_info.h"
#include "content/common/android/hash_set.h"
-#include "content/common/android/surface_texture_listener.h"
#include "content/common/android/trace_event_binding.h"
#include "webkit/glue/fling_animator_impl_android.h"
@@ -20,8 +19,6 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
content::DeviceTelephonyInfo::RegisterDeviceTelephonyInfo },
{ "FlingAnimator", webkit_glue::FlingAnimatorImpl::RegisterJni },
{ "HashSet", content::RegisterHashSet },
- { "SurfaceTextureListener",
- content::SurfaceTextureListener::RegisterSurfaceTextureListener },
{ "TraceEvent", RegisterTraceEvent },
};
diff --git a/content/common/android/scoped_java_surface.cc b/content/common/android/scoped_java_surface.cc
deleted file mode 100644
index ca84f72..0000000
--- a/content/common/android/scoped_java_surface.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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 "content/common/android/scoped_java_surface.h"
-
-#include "base/logging.h"
-#include "content/common/android/surface_texture_bridge.h"
-#include "jni/Surface_jni.h"
-
-namespace {
-
-bool g_jni_initialized = false;
-
-void RegisterNativesIfNeeded(JNIEnv* env) {
- if (!g_jni_initialized) {
- JNI_Surface::RegisterNativesImpl(env);
- g_jni_initialized = true;
- }
-}
-
-} // anonymous namespace
-
-namespace content {
-
-ScopedJavaSurface::ScopedJavaSurface() {
-}
-
-ScopedJavaSurface::ScopedJavaSurface(
- const base::android::JavaRef<jobject>& surface) {
- JNIEnv* env = base::android::AttachCurrentThread();
- RegisterNativesIfNeeded(env);
- DCHECK(env->IsInstanceOf(surface.obj(), g_Surface_clazz));
- j_surface_.Reset(surface);
-}
-
-ScopedJavaSurface::ScopedJavaSurface(
- const SurfaceTextureBridge* surface_texture) {
- JNIEnv* env = base::android::AttachCurrentThread();
- RegisterNativesIfNeeded(env);
- ScopedJavaLocalRef<jobject> tmp(JNI_Surface::Java_Surface_Constructor(
- env, surface_texture->j_surface_texture().obj()));
- DCHECK(!tmp.is_null());
- j_surface_.Reset(tmp);
-}
-
-ScopedJavaSurface::~ScopedJavaSurface() {
- if (!j_surface_.is_null()) {
- JNIEnv* env = base::android::AttachCurrentThread();
- JNI_Surface::Java_Surface_release(env, j_surface_.obj());
- }
-}
-
-} // namespace content
diff --git a/content/common/android/scoped_java_surface.h b/content/common/android/scoped_java_surface.h
deleted file mode 100644
index de0b673..0000000
--- a/content/common/android/scoped_java_surface.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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.
-
-#ifndef CONTENT_COMMON_ANDROID_SCOPED_JAVA_SURFACE_H_
-#define CONTENT_COMMON_ANDROID_SCOPED_JAVA_SURFACE_H_
-
-#include <jni.h>
-
-#include "base/android/scoped_java_ref.h"
-
-namespace content {
-
-class SurfaceTextureBridge;
-
-// A helper class for holding a scoped reference to a Java Surface instance.
-// When going out of scope, Surface.release() is called on the Java object to
-// make sure server-side references (esp. wrt graphics memory) are released.
-class ScopedJavaSurface {
- public:
- ScopedJavaSurface();
-
- // Wraps an existing Java Surface object in a ScopedJavaSurface.
- explicit ScopedJavaSurface(const base::android::JavaRef<jobject>& surface);
-
- // Creates a Java Surface from a SurfaceTexture and wraps it in a
- // ScopedJavaSurface.
- explicit ScopedJavaSurface(const SurfaceTextureBridge* surface_texture);
-
- ~ScopedJavaSurface();
-
- const base::android::JavaRef<jobject>& j_surface() const {
- return j_surface_;
- }
-
- private:
- base::android::ScopedJavaGlobalRef<jobject> j_surface_;
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_ANDROID_SCOPED_JAVA_SURFACE_H_
diff --git a/content/common/android/surface_texture_bridge.cc b/content/common/android/surface_texture_bridge.cc
deleted file mode 100644
index 7f9d710..0000000
--- a/content/common/android/surface_texture_bridge.cc
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (c) 2012 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 "content/common/android/surface_texture_bridge.h"
-
-#include <android/native_window_jni.h>
-
-// TODO(boliu): Remove this include when we move off ICS.
-#include "base/android/build_info.h"
-#include "base/android/jni_android.h"
-#include "base/logging.h"
-#include "content/common/android/scoped_java_surface.h"
-#include "content/common/android/surface_texture_listener.h"
-#include "jni/SurfaceTexture_jni.h"
-
-using base::android::AttachCurrentThread;
-using base::android::CheckException;
-using base::android::GetClass;
-using base::android::ScopedJavaLocalRef;
-
-namespace {
-bool g_jni_initialized = false;
-
-void RegisterNativesIfNeeded(JNIEnv* env) {
- if (!g_jni_initialized) {
- JNI_SurfaceTexture::RegisterNativesImpl(env);
- g_jni_initialized = true;
- }
-}
-
-// TODO(boliu): Remove this method when when we move off ICS. See
-// http://crbug.com/161864.
-bool GlContextMethodsAvailable() {
- bool available = base::android::BuildInfo::GetInstance()->sdk_int() >= 16;
- if (!available)
- LOG(WARNING) << "Running on unsupported device: rendering may not work";
- return available;
-}
-
-} // namespace
-
-namespace content {
-
-SurfaceTextureBridge::SurfaceTextureBridge(int texture_id)
- : texture_id_(texture_id) {
- JNIEnv* env = AttachCurrentThread();
- CHECK(env);
- RegisterNativesIfNeeded(env);
-
- ScopedJavaLocalRef<jobject> tmp(
- JNI_SurfaceTexture::Java_SurfaceTexture_Constructor(
- env, texture_id));
- DCHECK(!tmp.is_null());
- j_surface_texture_.Reset(tmp);
-}
-
-SurfaceTextureBridge::~SurfaceTextureBridge() {
- JNIEnv* env = AttachCurrentThread();
- CHECK(env);
-
- // Release the listener.
- JNI_SurfaceTexture::Java_SurfaceTexture_setOnFrameAvailableListener(
- env, j_surface_texture_.obj(), NULL);
-
- // Release graphics memory.
- JNI_SurfaceTexture::Java_SurfaceTexture_release(
- env, j_surface_texture_.obj());
-}
-
-void SurfaceTextureBridge::SetFrameAvailableCallback(
- const base::Closure& callback) {
- JNIEnv* env = AttachCurrentThread();
- CHECK(env);
-
- // Since the listener is owned by the Java SurfaceTexture object, setting
- // a new listener here will release an existing one at the same time.
- ScopedJavaLocalRef<jobject> j_listener(
- env,
- SurfaceTextureListener::CreateSurfaceTextureListener(env, callback));
- DCHECK(!j_listener.is_null());
-
- // Set it as the onFrameAvailableListener for our SurfaceTexture instance.
- JNI_SurfaceTexture::Java_SurfaceTexture_setOnFrameAvailableListener(
- env, j_surface_texture_.obj(), j_listener.obj());
-}
-
-void SurfaceTextureBridge::UpdateTexImage() {
- JNIEnv* env = AttachCurrentThread();
- CHECK(env);
-
- JNI_SurfaceTexture::Java_SurfaceTexture_updateTexImage(
- env, j_surface_texture_.obj());
-}
-
-void SurfaceTextureBridge::GetTransformMatrix(float mtx[16]) {
- JNIEnv* env = AttachCurrentThread();
- CHECK(env);
-
- ScopedJavaLocalRef<jfloatArray> jmatrix(env, env->NewFloatArray(16));
- JNI_SurfaceTexture::Java_SurfaceTexture_getTransformMatrix(
- env, j_surface_texture_.obj(), jmatrix.obj());
-
- jboolean is_copy;
- jfloat* elements = env->GetFloatArrayElements(jmatrix.obj(), &is_copy);
- for (int i = 0; i < 16; ++i) {
- mtx[i] = static_cast<float>(elements[i]);
- }
- env->ReleaseFloatArrayElements(jmatrix.obj(), elements, JNI_ABORT);
-}
-
-void SurfaceTextureBridge::SetDefaultBufferSize(int width, int height) {
- JNIEnv* env = AttachCurrentThread();
- CHECK(env);
-
- JNI_SurfaceTexture::Java_SurfaceTexture_setDefaultBufferSize(
- env, j_surface_texture_.obj(), static_cast<jint>(width),
- static_cast<jint>(height));
-}
-
-void SurfaceTextureBridge::AttachToGLContext(int texture_id) {
- if (GlContextMethodsAvailable()) {
- JNIEnv* env = AttachCurrentThread();
- // Note: This method is only available on JB and greater.
- JNI_SurfaceTexture::Java_SurfaceTexture_attachToGLContext(
- env, j_surface_texture_.obj(), texture_id);
- }
-}
-
-void SurfaceTextureBridge::DetachFromGLContext() {
- if (GlContextMethodsAvailable()) {
- JNIEnv* env = AttachCurrentThread();
- // Note: This method is only available on JB and greater.
- JNI_SurfaceTexture::Java_SurfaceTexture_detachFromGLContext(
- env, j_surface_texture_.obj());
- }
-}
-
-ANativeWindow* SurfaceTextureBridge::CreateSurface() {
- JNIEnv* env = AttachCurrentThread();
- ScopedJavaSurface surface(this);
- ANativeWindow* native_window =
- ANativeWindow_fromSurface(env, surface.j_surface().obj());
- return native_window;
-}
-
-} // namespace content
diff --git a/content/common/android/surface_texture_bridge.h b/content/common/android/surface_texture_bridge.h
deleted file mode 100644
index 0779196..0000000
--- a/content/common/android/surface_texture_bridge.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2012 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 CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_BRIDGE_H_
-#define CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_BRIDGE_H_
-
-#include <jni.h>
-
-#include "base/android/scoped_java_ref.h"
-#include "base/callback.h"
-#include "base/memory/ref_counted.h"
-
-struct ANativeWindow;
-
-namespace content {
-
-// This class serves as a bridge for native code to call java functions inside
-// android SurfaceTexture class.
-class SurfaceTextureBridge
- : public base::RefCountedThreadSafe<SurfaceTextureBridge>{
- public:
- explicit SurfaceTextureBridge(int texture_id);
-
- // Set the listener callback, which will be invoked on the same thread that
- // is being called from here for registration.
- // Note: Since callbacks come in from Java objects that might outlive objects
- // being referenced from the callback, the only robust way here is to create
- // the callback from a weak pointer to your object.
- void SetFrameAvailableCallback(const base::Closure& callback);
-
- // Update the texture image to the most recent frame from the image stream.
- void UpdateTexImage();
-
- // Retrieve the 4x4 texture coordinate transform matrix associated with the
- // texture image set by the most recent call to updateTexImage.
- void GetTransformMatrix(float mtx[16]);
-
- // Set the default size of the image buffers.
- void SetDefaultBufferSize(int width, int height);
-
- // Attach the SurfaceTexture to the given texture in the GL context that is
- // current on the calling thread.
- void AttachToGLContext(int texture_id);
-
- // Detaches the SurfaceTexture from the context that owns its current GL
- // texture. Must be called with that context current on the calling thread.
- void DetachFromGLContext();
-
- // Creates a native render surface for this surface texture.
- // The caller must release the underlying reference when done with the handle
- // by calling ANativeWindow_release().
- ANativeWindow* CreateSurface();
-
- int texture_id() const {
- return texture_id_;
- }
-
- const base::android::JavaRef<jobject>& j_surface_texture() const {
- return j_surface_texture_;
- }
-
- private:
- friend class base::RefCountedThreadSafe<SurfaceTextureBridge>;
- ~SurfaceTextureBridge();
-
- const int texture_id_;
-
- // Java SurfaceTexture instance.
- base::android::ScopedJavaGlobalRef<jobject> j_surface_texture_;
-
- DISALLOW_COPY_AND_ASSIGN(SurfaceTextureBridge);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_BRIDGE_H_
diff --git a/content/common/android/surface_texture_listener.cc b/content/common/android/surface_texture_listener.cc
deleted file mode 100644
index 4440c5c..0000000
--- a/content/common/android/surface_texture_listener.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2012 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 "content/common/android/surface_texture_listener.h"
-
-#include "base/location.h"
-#include "base/logging.h"
-#include "base/message_loop_proxy.h"
-#include "content/common/android/surface_texture_bridge.h"
-#include "jni/SurfaceTextureListener_jni.h"
-
-namespace content {
-
-// static
-jobject SurfaceTextureListener::CreateSurfaceTextureListener(
- JNIEnv* env,
- const base::Closure& callback) {
- // The java listener object owns and releases the native instance.
- // This is necessary to avoid races with incoming notifications.
- ScopedJavaLocalRef<jobject> listener(Java_SurfaceTextureListener_create(env,
- reinterpret_cast<int>(new SurfaceTextureListener(callback))));
-
- DCHECK(!listener.is_null());
- return listener.Release();
-}
-
-SurfaceTextureListener::SurfaceTextureListener(const base::Closure& callback)
- : callback_(callback),
- browser_loop_(base::MessageLoopProxy::current()) {
-}
-
-SurfaceTextureListener::~SurfaceTextureListener() {
-}
-
-void SurfaceTextureListener::Destroy(JNIEnv* env, jobject obj) {
- delete this;
-}
-
-void SurfaceTextureListener::FrameAvailable(JNIEnv* env, jobject obj) {
- if (!browser_loop_->BelongsToCurrentThread()) {
- browser_loop_->PostTask(FROM_HERE, callback_);
- } else {
- callback_.Run();
- }
-}
-
-// static
-bool SurfaceTextureListener::RegisterSurfaceTextureListener(JNIEnv* env) {
- return RegisterNativesImpl(env);
-}
-
-} // namespace content
diff --git a/content/common/android/surface_texture_listener.h b/content/common/android/surface_texture_listener.h
deleted file mode 100644
index 32cad7f..0000000
--- a/content/common/android/surface_texture_listener.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2012 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 CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_LISTENER_H_
-#define CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_LISTENER_H_
-
-#include <jni.h>
-#include "base/callback.h"
-#include "base/memory/ref_counted.h"
-
-namespace base {
-class MessageLoopProxy;
-}
-
-namespace content {
-
-// Listener class for all the callbacks from android SurfaceTexture.
-class SurfaceTextureListener {
-public:
- // Destroy this listener.
- void Destroy(JNIEnv* env, jobject obj);
-
- // A new frame is available to consume.
- void FrameAvailable(JNIEnv* env, jobject obj);
-
- static bool RegisterSurfaceTextureListener(JNIEnv* env);
-
-private:
- SurfaceTextureListener(const base::Closure& callback);
- ~SurfaceTextureListener();
-
- friend class SurfaceTextureBridge;
-
- // Static factory method for the creation of a SurfaceTextureListener.
- // The native code should not hold any reference to the returned object,
- // but only use it to pass it up to Java for being referenced by a
- // SurfaceTexture instance.
- static jobject CreateSurfaceTextureListener(JNIEnv* env,
- const base::Closure& callback);
-
- base::Closure callback_;
-
- scoped_refptr<base::MessageLoopProxy> browser_loop_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(SurfaceTextureListener);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_LISTENER_H_
diff --git a/content/common/android/surface_texture_peer.h b/content/common/android/surface_texture_peer.h
index 921ff4c..0e1fbcc 100644
--- a/content/common/android/surface_texture_peer.h
+++ b/content/common/android/surface_texture_peer.h
@@ -6,7 +6,7 @@
#define CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_PEER_H_
#include "base/process.h"
-#include "content/common/android/surface_texture_bridge.h"
+#include "ui/gl/android/surface_texture_bridge.h"
namespace content {
@@ -20,7 +20,7 @@ class SurfaceTexturePeer {
// process.
virtual void EstablishSurfaceTexturePeer(
base::ProcessHandle pid,
- scoped_refptr<SurfaceTextureBridge> surface_texture_bridge,
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_bridge,
int primary_id,
int secondary_id) = 0;
diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc
index f04461a..3e2ab83 100644
--- a/content/common/gpu/media/android_video_decode_accelerator.cc
+++ b/content/common/gpu/media/android_video_decode_accelerator.cc
@@ -7,12 +7,12 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
-#include "content/common/android/scoped_java_surface.h"
#include "content/common/gpu/gpu_channel.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "media/base/bitstream_buffer.h"
#include "media/base/limits.h"
#include "media/video/picture.h"
+#include "ui/gl/android/scoped_java_surface.h"
#include "ui/gl/gl_bindings.h"
namespace content {
@@ -102,7 +102,7 @@ bool AndroidVideoDecodeAccelerator::Initialize(
gl_decoder_->RestoreTextureUnitBindings(0);
gl_decoder_->RestoreActiveTexture();
- surface_texture_ = new SurfaceTextureBridge(surface_texture_id_);
+ surface_texture_ = new gfx::SurfaceTextureBridge(surface_texture_id_);
ConfigureMediaCodec();
@@ -381,7 +381,7 @@ void AndroidVideoDecodeAccelerator::ConfigureMediaCodec() {
media_codec_.reset(new media::MediaCodecBridge(codec_));
- ScopedJavaSurface surface(surface_texture_.get());
+ gfx::ScopedJavaSurface surface(surface_texture_.get());
// VDA does not pass the container indicated resolution in the initialization
// phase. Here, we set 720p by default.
// TODO(dwkang): find out a way to remove the following hard-coded value.
diff --git a/content/common/gpu/media/android_video_decode_accelerator.h b/content/common/gpu/media/android_video_decode_accelerator.h
index 6ddd7f0..86ffb68 100644
--- a/content/common/gpu/media/android_video_decode_accelerator.h
+++ b/content/common/gpu/media/android_video_decode_accelerator.h
@@ -20,9 +20,11 @@
#include "media/base/android/media_codec_bridge.h"
#include "media/video/video_decode_accelerator.h"
-namespace content {
-
+namespace gfx {
class SurfaceTextureBridge;
+}
+
+namespace content {
// A VideoDecodeAccelerator implementation for Android.
// This class decodes the input encoded stream by using Android's MediaCodec
@@ -126,7 +128,7 @@ class CONTENT_EXPORT AndroidVideoDecodeAccelerator :
scoped_ptr<media::MediaCodecBridge> media_codec_;
// A container of texture. Used to set a texture to |media_codec_|.
- scoped_refptr<SurfaceTextureBridge> surface_texture_;
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_;
// The texture id which is set to |surface_texture_|.
uint32 surface_texture_id_;
diff --git a/content/common/gpu/stream_texture_manager_android.cc b/content/common/gpu/stream_texture_manager_android.cc
index 6eb7a10..8b663a9 100644
--- a/content/common/gpu/stream_texture_manager_android.cc
+++ b/content/common/gpu/stream_texture_manager_android.cc
@@ -5,17 +5,17 @@
#include "content/common/gpu/stream_texture_manager_android.h"
#include "base/bind.h"
-#include "content/common/android/surface_texture_bridge.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_messages.h"
#include "gpu/command_buffer/service/stream_texture.h"
#include "ui/gfx/size.h"
+#include "ui/gl/android/surface_texture_bridge.h"
namespace content {
StreamTextureManagerAndroid::StreamTextureAndroid::StreamTextureAndroid(
GpuChannel* channel, int service_id)
- : surface_texture_bridge_(new SurfaceTextureBridge(service_id)),
+ : surface_texture_bridge_(new gfx::SurfaceTextureBridge(service_id)),
has_updated_(false),
channel_(channel) {
memset(current_matrix_, 0, sizeof(current_matrix_));
diff --git a/content/common/gpu/stream_texture_manager_android.h b/content/common/gpu/stream_texture_manager_android.h
index e514fc9..0f7dea9 100644
--- a/content/common/gpu/stream_texture_manager_android.h
+++ b/content/common/gpu/stream_texture_manager_android.h
@@ -17,13 +17,12 @@ struct GpuStreamTextureMsg_MatrixChanged_Params;
namespace gfx {
class Size;
+class SurfaceTextureBridge;
}
namespace content {
class GpuChannel;
-class SurfaceTextureBridge;
-
// Class for managing the stream texture.
class StreamTextureManagerAndroid : public gpu::StreamTextureManager {
public:
@@ -57,7 +56,7 @@ class StreamTextureManagerAndroid : public gpu::StreamTextureManager {
virtual void Update() OVERRIDE;
- scoped_refptr<SurfaceTextureBridge> surface_texture_bridge() {
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_bridge() {
return surface_texture_bridge_;
}
@@ -75,7 +74,7 @@ class StreamTextureManagerAndroid : public gpu::StreamTextureManager {
}
private:
- scoped_refptr<SurfaceTextureBridge> surface_texture_bridge_;
+ scoped_refptr<gfx::SurfaceTextureBridge> surface_texture_bridge_;
// Current transform matrix of the surface texture.
float current_matrix_[16];
diff --git a/content/content.gyp b/content/content.gyp
index 6f7104f..f790279 100644
--- a/content/content.gyp
+++ b/content/content.gyp
@@ -372,24 +372,6 @@
'includes': [ '../build/android/java_cpp_template.gypi' ],
},
{
- 'target_name': 'surface_texture_jni_headers',
- 'type': 'none',
- 'variables': {
- 'jni_gen_package': 'content',
- 'input_java_class': 'android/graphics/SurfaceTexture.class',
- },
- 'includes': [ '../build/jar_file_jni_generator.gypi' ],
- },
- {
- 'target_name': 'surface_jni_headers',
- 'type': 'none',
- 'variables': {
- 'jni_gen_package': 'content',
- 'input_java_class': 'android/view/Surface.class',
- },
- 'includes': [ '../build/jar_file_jni_generator.gypi' ],
- },
- {
'target_name': 'java_set_jni_headers',
'type': 'none',
'variables': {
@@ -404,8 +386,6 @@
'type': 'none',
'dependencies': [
'java_set_jni_headers',
- 'surface_texture_jni_headers',
- 'surface_jni_headers',
],
'direct_dependent_settings': {
'include_dirs': [
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 965361d..989c384 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -114,12 +114,6 @@
'common/android/device_telephony_info.h',
'common/android/hash_set.cc',
'common/android/hash_set.h',
- 'common/android/scoped_java_surface.cc',
- 'common/android/scoped_java_surface.h',
- 'common/android/surface_texture_bridge.cc',
- 'common/android/surface_texture_bridge.h',
- 'common/android/surface_texture_listener.cc',
- 'common/android/surface_texture_listener.h',
'common/android/surface_texture_peer.cc',
'common/android/surface_texture_peer.h',
'common/android/trace_event_binding.cc',
diff --git a/content/content_jni.gypi b/content/content_jni.gypi
index b52eaa3..7dac8ee 100644
--- a/content/content_jni.gypi
+++ b/content/content_jni.gypi
@@ -31,7 +31,6 @@
'public/android/java/src/org/chromium/content/browser/WebContentsObserverAndroid.java',
'public/android/java/src/org/chromium/content/common/CommandLine.java',
'public/android/java/src/org/chromium/content/common/DeviceTelephonyInfo.java',
- 'public/android/java/src/org/chromium/content/common/SurfaceTextureListener.java',
'public/android/java/src/org/chromium/content/common/TraceEvent.java',
],
'variables': {
diff --git a/content/public/android/java/src/org/chromium/content/common/SurfaceTextureListener.java b/content/public/android/java/src/org/chromium/content/common/SurfaceTextureListener.java
deleted file mode 100644
index d6ed16f..0000000
--- a/content/public/android/java/src/org/chromium/content/common/SurfaceTextureListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2012 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.
-
-package org.chromium.content.common;
-
-import android.graphics.SurfaceTexture;
-
-import org.chromium.base.CalledByNative;
-import org.chromium.base.JNINamespace;
-
-/**
- * Listener to an android SurfaceTexture object for frame availability.
- */
-@JNINamespace("content")
-class SurfaceTextureListener implements SurfaceTexture.OnFrameAvailableListener {
- // Used to determine the class instance to dispatch the native call to.
- private int mNativeSurfaceTextureListener = 0;
-
- private SurfaceTextureListener(int nativeSurfaceTextureListener) {
- assert nativeSurfaceTextureListener != 0;
- mNativeSurfaceTextureListener = nativeSurfaceTextureListener;
- }
-
- @Override
- public void onFrameAvailable(SurfaceTexture surfaceTexture) {
- nativeFrameAvailable(mNativeSurfaceTextureListener);
- }
-
- @Override
- protected void finalize() throws Throwable {
- try {
- nativeDestroy(mNativeSurfaceTextureListener);
- } finally {
- super.finalize();
- }
- }
-
- @CalledByNative
- private static SurfaceTextureListener create(int nativeSurfaceTextureListener) {
- return new SurfaceTextureListener(nativeSurfaceTextureListener);
- }
-
- private native void nativeFrameAvailable(int nativeSurfaceTextureListener);
- private native void nativeDestroy(int nativeSurfaceTextureListener);
-}
diff --git a/content/public/test/content_test_suite_base.cc b/content/public/test/content_test_suite_base.cc
index ea83b47..046b94f 100644
--- a/content/public/test/content_test_suite_base.cc
+++ b/content/public/test/content_test_suite_base.cc
@@ -24,6 +24,7 @@
#include "content/common/android/common_jni_registrar.h"
#include "net/android/net_jni_registrar.h"
#include "ui/android/ui_jni_registrar.h"
+#include "ui/gl/android/gl_jni_registrar.h"
#include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h"
#endif