summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/gl/android_native_window.cc26
-rw-r--r--ui/gfx/gl/android_native_window.h32
-rw-r--r--ui/gfx/gl/gl.gyp7
-rw-r--r--ui/gfx/gl/gl_surface.h4
-rw-r--r--ui/gfx/gl/gl_surface_android.cc6
-rw-r--r--ui/gfx/gl/gl_surface_android.h6
-rw-r--r--ui/gfx/gl/native_window_interface_android.h24
7 files changed, 71 insertions, 34 deletions
diff --git a/ui/gfx/gl/android_native_window.cc b/ui/gfx/gl/android_native_window.cc
new file mode 100644
index 0000000..c32444cf
--- /dev/null
+++ b/ui/gfx/gl/android_native_window.cc
@@ -0,0 +1,26 @@
+// 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 "ui/gfx/gl/android_native_window.h"
+
+#include <android/native_window.h>
+
+namespace gfx {
+
+AndroidNativeWindow::AndroidNativeWindow(ANativeWindow* window)
+ : window_(window) {
+ if (window_)
+ ANativeWindow_acquire(window_);
+}
+
+AndroidNativeWindow::~AndroidNativeWindow() {
+ if (window_)
+ ANativeWindow_release(window_);
+}
+
+ANativeWindow* AndroidNativeWindow::GetNativeHandle() const {
+ return window_;
+}
+
+} // namespace gfx
diff --git a/ui/gfx/gl/android_native_window.h b/ui/gfx/gl/android_native_window.h
new file mode 100644
index 0000000..4a8eab5
--- /dev/null
+++ b/ui/gfx/gl/android_native_window.h
@@ -0,0 +1,32 @@
+// 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 UI_GFX_GL_ANDROID_NATIVE_WINDOW_H_
+#define UI_GFX_GL_ANDROID_NATIVE_WINDOW_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+
+struct ANativeWindow;
+
+namespace gfx {
+
+// This class deals with the Android native window ref count.
+class AndroidNativeWindow {
+ public:
+ explicit AndroidNativeWindow(ANativeWindow* window);
+ ~AndroidNativeWindow();
+
+ ANativeWindow* GetNativeHandle() const;
+
+ private:
+ ANativeWindow* window_;
+
+ DISALLOW_COPY_AND_ASSIGN(AndroidNativeWindow);
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_GL_ANDROID_NATIVE_WINDOW_H_
diff --git a/ui/gfx/gl/gl.gyp b/ui/gfx/gl/gl.gyp
index e4e1a89..45fe1e2 100644
--- a/ui/gfx/gl/gl.gyp
+++ b/ui/gfx/gl/gl.gyp
@@ -76,7 +76,6 @@
'gl_surface_osmesa.h',
'gl_switches.cc',
'gl_switches.h',
- 'native_window_interface_android.h',
'scoped_make_current.cc',
'scoped_make_current.h',
'<(gl_binding_output_dir)/gl_bindings_autogen_gl.cc',
@@ -187,7 +186,11 @@
],
}],
['OS=="android"', {
- 'sources!': [
+ 'sources': [
+ 'android_native_window.cc',
+ 'android_native_window.h',
+ ],
+ 'sources!': [
'<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.cc',
'<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.h',
'system_monitor_posix.cc',
diff --git a/ui/gfx/gl/gl_surface.h b/ui/gfx/gl/gl_surface.h
index d6523a2..92a2d39 100644
--- a/ui/gfx/gl/gl_surface.h
+++ b/ui/gfx/gl/gl_surface.h
@@ -17,7 +17,7 @@ namespace gfx {
class GLContext;
#if defined(OS_ANDROID)
-class NativeWindowInterface;
+class AndroidNativeWindow;
#endif
// Encapsulates a surface that can be rendered to with GL, hiding platform
@@ -48,7 +48,7 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
virtual gfx::Size GetSize() = 0;
#if defined(OS_ANDROID)
- virtual void SetNativeWindow(NativeWindowInterface* window) { }
+ virtual void SetNativeWindow(AndroidNativeWindow* window) { }
#endif
// Get the underlying platform specific surface "handle".
diff --git a/ui/gfx/gl/gl_surface_android.cc b/ui/gfx/gl/gl_surface_android.cc
index fcb132d..7f66fd8 100644
--- a/ui/gfx/gl/gl_surface_android.cc
+++ b/ui/gfx/gl/gl_surface_android.cc
@@ -12,7 +12,7 @@
#include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_implementation.h"
-#include "ui/gfx/gl/native_window_interface_android.h"
+#include "ui/gfx/gl/android_native_window.h"
namespace gfx {
@@ -143,7 +143,7 @@ bool AndroidViewSurface::Resize(const gfx::Size& size) {
return true;
}
-bool AndroidViewSurface::CreateWindowSurface(NativeWindowInterface* window) {
+bool AndroidViewSurface::CreateWindowSurface(AndroidNativeWindow* window) {
DCHECK(window->GetNativeHandle());
window_ = window;
EGLSurface surface = eglCreateWindowSurface(GetDisplay(),
@@ -161,7 +161,7 @@ bool AndroidViewSurface::CreateWindowSurface(NativeWindowInterface* window) {
return true;
}
-void AndroidViewSurface::SetNativeWindow(NativeWindowInterface* window) {
+void AndroidViewSurface::SetNativeWindow(AndroidNativeWindow* window) {
if (window->GetNativeHandle()) {
DCHECK(pbuffer_surface_.get());
pbuffer_surface_->Destroy();
diff --git a/ui/gfx/gl/gl_surface_android.h b/ui/gfx/gl/gl_surface_android.h
index 38fd5c1..d46d9fd 100644
--- a/ui/gfx/gl/gl_surface_android.h
+++ b/ui/gfx/gl/gl_surface_android.h
@@ -29,12 +29,12 @@ class AndroidViewSurface : public NativeViewGLSurfaceEGL {
virtual bool SwapBuffers() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual EGLSurface GetHandle() OVERRIDE;
- virtual void SetNativeWindow(NativeWindowInterface* window) OVERRIDE;
+ virtual void SetNativeWindow(AndroidNativeWindow* window) OVERRIDE;
private:
- bool CreateWindowSurface(NativeWindowInterface* window);
+ bool CreateWindowSurface(AndroidNativeWindow* window);
scoped_refptr<PbufferGLSurfaceEGL> pbuffer_surface_;
- NativeWindowInterface* window_;
+ AndroidNativeWindow* window_;
DISALLOW_COPY_AND_ASSIGN(AndroidViewSurface);
};
diff --git a/ui/gfx/gl/native_window_interface_android.h b/ui/gfx/gl/native_window_interface_android.h
deleted file mode 100644
index 643a900..0000000
--- a/ui/gfx/gl/native_window_interface_android.h
+++ /dev/null
@@ -1,24 +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 UI_GFX_GL_NATIVE_WINDOW_INTERFACE_ANDROID_H_
-#define UI_GFX_GL_NATIVE_WINDOW_INTERFACE_ANDROID_H_
-#pragma once
-
-struct ANativeWindow;
-
-namespace gfx {
-
-// This is a wrapper object to pass ANativeWindow handles around when running
-// in SurfaceTexture more.
-class NativeWindowInterface {
- public:
- virtual ~NativeWindowInterface() {}
-
- virtual ANativeWindow* GetNativeHandle() const = 0;
-};
-
-} // namespace gfx
-
-#endif // UI_GFX_GL_NATIVE_WINDOW_INTERFACE_ANDROID_H_