summaryrefslogtreecommitdiff
path: root/chromium/ui/gl
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/gl')
-rw-r--r--chromium/ui/gl/android/gl_jni_registrar.cc3
-rw-r--r--chromium/ui/gl/android/surface_texture_bridge.cc99
-rw-r--r--chromium/ui/gl/android/surface_texture_bridge.h2
-rw-r--r--chromium/ui/gl/android/surface_texture_listener.cc13
-rw-r--r--chromium/ui/gl/android/surface_texture_listener.h13
-rw-r--r--chromium/ui/gl/gl.gyp11
-rw-r--r--chromium/ui/gl/gl_implementation_win.cc51
7 files changed, 39 insertions, 153 deletions
diff --git a/chromium/ui/gl/android/gl_jni_registrar.cc b/chromium/ui/gl/android/gl_jni_registrar.cc
index 997268cc540..cba90cef77d 100644
--- a/chromium/ui/gl/android/gl_jni_registrar.cc
+++ b/chromium/ui/gl/android/gl_jni_registrar.cc
@@ -6,6 +6,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
+#include "ui/gl/android/surface_texture_bridge.h"
#include "ui/gl/android/surface_texture_listener.h"
namespace ui {
@@ -13,6 +14,8 @@ namespace gl {
namespace android {
static base::android::RegistrationMethod kGLRegisteredMethods[] = {
+ { "SurfaceTextureBridge",
+ gfx::SurfaceTextureBridge::RegisterSurfaceTextureBridge },
{ "SurfaceTextureListener",
gfx::SurfaceTextureListener::RegisterSurfaceTextureListener },
};
diff --git a/chromium/ui/gl/android/surface_texture_bridge.cc b/chromium/ui/gl/android/surface_texture_bridge.cc
index c4206a983e6..9f2a3372e84 100644
--- a/chromium/ui/gl/android/surface_texture_bridge.cc
+++ b/chromium/ui/gl/android/surface_texture_bridge.cc
@@ -10,26 +10,11 @@
#include "base/android/build_info.h"
#include "base/android/jni_android.h"
#include "base/logging.h"
-#include "jni/SurfaceTexture_jni.h"
+#include "jni/SurfaceTextureBridge_jni.h"
#include "ui/gl/android/scoped_java_surface.h"
#include "ui/gl/android/surface_texture_listener.h"
#include "ui/gl/gl_bindings.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() {
@@ -39,66 +24,38 @@ bool GlContextMethodsAvailable() {
return available;
}
-} // namespace
-
namespace gfx {
SurfaceTextureBridge::SurfaceTextureBridge(int 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);
+ JNIEnv* env = base::android::AttachCurrentThread();
+ j_surface_texture_.Reset(Java_SurfaceTextureBridge_create(env, texture_id));
}
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());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_SurfaceTextureBridge_destroy(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(
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_SurfaceTextureBridge_setFrameAvailableCallback(
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());
+ j_surface_texture_.obj(),
+ reinterpret_cast<int>(new SurfaceTextureListener(callback)));
}
void SurfaceTextureBridge::UpdateTexImage() {
- JNIEnv* env = AttachCurrentThread();
- CHECK(env);
-
- JNI_SurfaceTexture::Java_SurfaceTexture_updateTexImage(
- env, j_surface_texture_.obj());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_SurfaceTextureBridge_updateTexImage(env, j_surface_texture_.obj());
}
void SurfaceTextureBridge::GetTransformMatrix(float mtx[16]) {
- JNIEnv* env = AttachCurrentThread();
- CHECK(env);
+ JNIEnv* env = base::android::AttachCurrentThread();
- ScopedJavaLocalRef<jfloatArray> jmatrix(env, env->NewFloatArray(16));
- JNI_SurfaceTexture::Java_SurfaceTexture_getTransformMatrix(
+ base::android::ScopedJavaLocalRef<jfloatArray> jmatrix(
+ env, env->NewFloatArray(16));
+ Java_SurfaceTextureBridge_getTransformMatrix(
env, j_surface_texture_.obj(), jmatrix.obj());
jboolean is_copy;
@@ -110,11 +67,10 @@ void SurfaceTextureBridge::GetTransformMatrix(float mtx[16]) {
}
void SurfaceTextureBridge::SetDefaultBufferSize(int width, int height) {
- JNIEnv* env = AttachCurrentThread();
- CHECK(env);
+ JNIEnv* env = base::android::AttachCurrentThread();
if (width > 0 && height > 0) {
- JNI_SurfaceTexture::Java_SurfaceTexture_setDefaultBufferSize(
+ Java_SurfaceTextureBridge_setDefaultBufferSize(
env, j_surface_texture_.obj(), static_cast<jint>(width),
static_cast<jint>(height));
} else {
@@ -128,28 +84,31 @@ void SurfaceTextureBridge::AttachToGLContext() {
int texture_id;
glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id);
DCHECK(texture_id);
- JNIEnv* env = AttachCurrentThread();
- // Note: This method is only available on JB and greater.
- JNI_SurfaceTexture::Java_SurfaceTexture_attachToGLContext(
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_SurfaceTextureBridge_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(
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_SurfaceTextureBridge_detachFromGLContext(
env, j_surface_texture_.obj());
}
}
ANativeWindow* SurfaceTextureBridge::CreateSurface() {
- JNIEnv* env = AttachCurrentThread();
+ JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaSurface surface(this);
- ANativeWindow* native_window =
- ANativeWindow_fromSurface(env, surface.j_surface().obj());
+ ANativeWindow* native_window = ANativeWindow_fromSurface(
+ env, surface.j_surface().obj());
return native_window;
}
+// static
+bool SurfaceTextureBridge::RegisterSurfaceTextureBridge(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
} // namespace gfx
diff --git a/chromium/ui/gl/android/surface_texture_bridge.h b/chromium/ui/gl/android/surface_texture_bridge.h
index fc7fb5416ac..474f0c22d39 100644
--- a/chromium/ui/gl/android/surface_texture_bridge.h
+++ b/chromium/ui/gl/android/surface_texture_bridge.h
@@ -57,6 +57,8 @@ class GL_EXPORT SurfaceTextureBridge
return j_surface_texture_;
}
+ static bool RegisterSurfaceTextureBridge(JNIEnv* env);
+
private:
friend class base::RefCountedThreadSafe<SurfaceTextureBridge>;
~SurfaceTextureBridge();
diff --git a/chromium/ui/gl/android/surface_texture_listener.cc b/chromium/ui/gl/android/surface_texture_listener.cc
index 0547720202c..39d8468dd4a 100644
--- a/chromium/ui/gl/android/surface_texture_listener.cc
+++ b/chromium/ui/gl/android/surface_texture_listener.cc
@@ -12,19 +12,6 @@
namespace gfx {
-// 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()) {
diff --git a/chromium/ui/gl/android/surface_texture_listener.h b/chromium/ui/gl/android/surface_texture_listener.h
index faab6be1eb1..60103aad97d 100644
--- a/chromium/ui/gl/android/surface_texture_listener.h
+++ b/chromium/ui/gl/android/surface_texture_listener.h
@@ -18,7 +18,7 @@ namespace gfx {
// Listener class for all the callbacks from android SurfaceTexture.
class GL_EXPORT SurfaceTextureListener {
-public:
+ public:
// Destroy this listener.
void Destroy(JNIEnv* env, jobject obj);
@@ -27,19 +27,14 @@ public:
static bool RegisterSurfaceTextureListener(JNIEnv* env);
-private:
+ private:
+ // Native code should not hold any reference to this object, and instead pass
+ // it up to Java for being referenced by a SurfaceTexture instance.
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_;
diff --git a/chromium/ui/gl/gl.gyp b/chromium/ui/gl/gl.gyp
index 940578beeb7..139a88f2626 100644
--- a/chromium/ui/gl/gl.gyp
+++ b/chromium/ui/gl/gl.gyp
@@ -313,15 +313,6 @@
['OS=="android"' , {
'targets': [
{
- 'target_name': 'surface_texture_jni_headers',
- 'type': 'none',
- 'variables': {
- 'jni_gen_package': 'ui/gl',
- 'input_java_class': 'android/graphics/SurfaceTexture.class',
- },
- 'includes': [ '../../build/jar_file_jni_generator.gypi' ],
- },
- {
'target_name': 'surface_jni_headers',
'type': 'none',
'variables': {
@@ -334,10 +325,10 @@
'target_name': 'gl_jni_headers',
'type': 'none',
'dependencies': [
- 'surface_texture_jni_headers',
'surface_jni_headers',
],
'sources': [
+ '../android/java/src/org/chromium/ui/gfx/SurfaceTextureBridge.java',
'../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java',
],
'variables': {
diff --git a/chromium/ui/gl/gl_implementation_win.cc b/chromium/ui/gl/gl_implementation_win.cc
index 87328a306f8..c98c3c01314 100644
--- a/chromium/ui/gl/gl_implementation_win.cc
+++ b/chromium/ui/gl/gl_implementation_win.cc
@@ -8,7 +8,6 @@
#include "base/base_paths.h"
#include "base/bind.h"
#include "base/command_line.h"
-#include "base/debug/trace_event.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/native_library.h"
@@ -59,45 +58,6 @@ bool LoadD3DXLibrary(const base::FilePath& module_path,
return true;
}
-const unsigned char* AngleGetTraceCategoryEnabledFlag(const char* name) {
- return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(name);
-}
-
-void AngleAddTraceEvent(char phase,
- const unsigned char* category_group_enabled,
- const char* name,
- unsigned long long id,
- int num_args,
- const char** arg_names,
- const unsigned char* arg_types,
- const unsigned long long* arg_values,
- unsigned char flags) {
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase,
- category_group_enabled,
- name,
- id,
- num_args,
- arg_names,
- arg_types,
- arg_values,
- NULL,
- flags);
-}
-
-typedef const unsigned char* (*GetCategoryEnabledFlagFunc)(const char* name);
-typedef void (*AddTraceEventFunc)(char phase,
- const unsigned char* categoryGroupEnabled,
- const char* name,
- unsigned long long id,
- int numArgs,
- const char** argNames,
- const unsigned char* argTypes,
- const unsigned long long* argValues,
- unsigned char flags);
-typedef void (__stdcall *SetTraceFunctionPointersFunc)(
- GetCategoryEnabledFlagFunc get_category_enabled_flag,
- AddTraceEventFunc add_trace_event_func);
-
} // namespace
void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
@@ -207,17 +167,6 @@ bool InitializeGLBindings(GLImplementation implementation) {
}
#endif
- if (!using_swift_shader) {
- SetTraceFunctionPointersFunc set_trace_function_pointers =
- reinterpret_cast<SetTraceFunctionPointersFunc>(
- base::GetFunctionPointerFromNativeLibrary(
- gles_library, "SetTraceFunctionPointers"));
- if (set_trace_function_pointers) {
- set_trace_function_pointers(&AngleGetTraceCategoryEnabledFlag,
- &AngleAddTraceEvent);
- }
- }
-
GLGetProcAddressProc get_proc_address =
reinterpret_cast<GLGetProcAddressProc>(
base::GetFunctionPointerFromNativeLibrary(