summaryrefslogtreecommitdiffstats
path: root/content/app/android
diff options
context:
space:
mode:
authorsievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 03:58:18 +0000
committersievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 03:58:18 +0000
commitccf558a6e8f20d21f71d98d9f3e8986edcdc25d0 (patch)
tree723cab80ee3372de04f78e938d2d4f9a65cf907e /content/app/android
parentd5844d155e15c84f4e88285ee0a74d2c85794ae9 (diff)
downloadchromium_src-ccf558a6e8f20d21f71d98d9f3e8986edcdc25d0.zip
chromium_src-ccf558a6e8f20d21f71d98d9f3e8986edcdc25d0.tar.gz
chromium_src-ccf558a6e8f20d21f71d98d9f3e8986edcdc25d0.tar.bz2
Android: Support GPU process
This supports running the GPU thread in its own process outside the browser (which is really the default mode). This changes the browser compositor API to pass a Java Surface instead of ANativeWindow. (Needed to pass the surface handle over to the other process). It implements a synchronous API from the GPU thread to the browser to retrieve the surface, which is safe since this ends up on a binder thread different from the main thread. This is enabled by removing kInProcessGpu from content_startup_flags.cc Review URL: https://chromiumcodereview.appspot.com/12390077 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186606 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/app/android')
-rw-r--r--content/app/android/sandboxed_process_service.cc38
1 files changed, 31 insertions, 7 deletions
diff --git a/content/app/android/sandboxed_process_service.cc b/content/app/android/sandboxed_process_service.cc
index e7118ff..2f0d5bc 100644
--- a/content/app/android/sandboxed_process_service.cc
+++ b/content/app/android/sandboxed_process_service.cc
@@ -4,14 +4,17 @@
#include "content/app/android/sandboxed_process_service.h"
+#include <android/native_window_jni.h>
#include <cpu-features.h>
#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"
+#include "content/common/gpu/gpu_surface_lookup.h"
#include "content/public/app/android_library_loader_hooks.h"
#include "content/public/common/content_descriptors.h"
#include "ipc/ipc_descriptors.h"
@@ -21,17 +24,23 @@ using base::android::AttachCurrentThread;
using base::android::CheckException;
using base::android::JavaIntArrayToIntVector;
+namespace content {
+
namespace {
-class SurfaceTexturePeerSandboxedImpl : public content::SurfaceTexturePeer {
+class SurfaceTexturePeerSandboxedImpl : public content::SurfaceTexturePeer,
+ public content::GpuSurfaceLookup {
public:
// |service| is the instance of
// org.chromium.content.app.SandboxedProcessService.
- SurfaceTexturePeerSandboxedImpl(jobject service)
+ explicit SurfaceTexturePeerSandboxedImpl(
+ const base::android::ScopedJavaLocalRef<jobject>& service)
: service_(service) {
+ GpuSurfaceLookup::InitInstance(this);
}
virtual ~SurfaceTexturePeerSandboxedImpl() {
+ GpuSurfaceLookup::InitInstance(NULL);
}
virtual void EstablishSurfaceTexturePeer(
@@ -41,15 +50,30 @@ class SurfaceTexturePeerSandboxedImpl : public content::SurfaceTexturePeer {
int secondary_id) {
JNIEnv* env = base::android::AttachCurrentThread();
content::Java_SandboxedProcessService_establishSurfaceTexturePeer(
- env, service_, pid,
+ env, service_.obj(), pid,
surface_texture_bridge->j_surface_texture().obj(), primary_id,
secondary_id);
CheckException(env);
}
+ virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) OVERRIDE {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaSurface surface(
+ content::Java_SandboxedProcessService_getViewSurface(
+ env, service_.obj(), surface_id));
+
+ if (surface.j_surface().is_null())
+ return NULL;
+
+ ANativeWindow* native_window = ANativeWindow_fromSurface(
+ env, surface.j_surface().obj());
+
+ return native_window;
+ }
+
private:
// The instance of org.chromium.content.app.SandboxedProcessService.
- jobject service_;
+ base::android::ScopedJavaGlobalRef<jobject> service_;
DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl);
};
@@ -61,9 +85,11 @@ void InternalInitSandboxedProcess(const std::vector<int>& file_ids,
JNIEnv* env,
jclass clazz,
jobject context,
- jobject service,
+ jobject service_in,
jint cpu_count,
jlong cpu_features) {
+ base::android::ScopedJavaLocalRef<jobject> service(env, service_in);
+
// Set the CPU properties.
android_setCpu(cpu_count, cpu_features);
// Register the file descriptors.
@@ -84,8 +110,6 @@ void QuitSandboxMainThreadMessageLoop() {
} // namespace <anonymous>
-namespace content {
-
void InitSandboxedProcess(JNIEnv* env,
jclass clazz,
jobject context,