Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1049)

Unified Diff: content/browser/gpu/gpu_surface_tracker.cc

Issue 10795058: Add GL surface creation for Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/gpu/gpu_surface_tracker.cc
diff --git a/content/browser/gpu/gpu_surface_tracker.cc b/content/browser/gpu/gpu_surface_tracker.cc
index 4b828f80dc9f15cf9f5f656e619892e18b6d064d..3f089aac0a2ea6b1ef3b4b5068a2069eae91e28f 100644
--- a/content/browser/gpu/gpu_surface_tracker.cc
+++ b/content/browser/gpu/gpu_surface_tracker.cc
@@ -6,11 +6,26 @@
#include "base/logging.h"
+#if defined(OS_ANDROID)
+#include "base/command_line.h"
+#include "content/public/common/content_switches.h"
+#include <android/native_window_jni.h>
+#endif
+
GpuSurfaceTracker::GpuSurfaceTracker()
: next_surface_id_(1) {
}
GpuSurfaceTracker::~GpuSurfaceTracker() {
+#if defined(OS_ANDROID)
+ // Handles should have been inserted with an extra ref, so release those now.
+ for (SurfaceMap::iterator it = surface_map_.begin(); it != surface_map_.end();
+ ++it) {
+ const SurfaceInfo& info = it->second;
+ if (info.native_widget)
+ ANativeWindow_release(info.native_widget);
+ }
+#endif
}
GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() {
@@ -94,3 +109,18 @@ gfx::PluginWindowHandle GpuSurfaceTracker::GetSurfaceWindowHandle(
return gfx::kNullPluginWindow;
return it->second.handle.handle;
}
+
+gfx::AcceleratedWidget GpuSurfaceTracker::GetNativeWidget(int surface_id) {
+ GpuSurfaceTracker* tracker = GpuSurfaceTracker::GetInstance();
apatrick_chromium 2012/07/24 18:34:16 This member function is not static. Why is it gett
no sievers 2012/07/26 21:21:17 Done.
+ base::AutoLock lock(tracker->lock_);
+ DCHECK(tracker->surface_map_.find(surface_id) != tracker->surface_map_.end());
+ return tracker->surface_map_[surface_id].native_widget;
apatrick_chromium 2012/07/24 18:34:16 How exactly does this differ from the handle retur
no sievers 2012/07/26 21:21:17 The native AcceleratedWidget on Android is a point
+}
+
+#if defined(OS_ANDROID)
+gfx::AcceleratedWidget GetNativeWidgetAndroid(int surface_id) {
+ DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU));
+ GpuSurfaceTracker* tracker = GpuSurfaceTracker::GetInstance();
+ return tracker->GetNativeWidget(surface_id);
+}
+#endif

Powered by Google App Engine
This is Rietveld 408576698