| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/app/android/child_process_service.h" | 5 #include "content/app/android/child_process_service.h" |
| 6 | 6 |
| 7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 8 #include <cpu-features.h> | 8 #include <cpu-features.h> |
| 9 | 9 |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 virtual ~SurfaceTexturePeerChildImpl() { | 46 virtual ~SurfaceTexturePeerChildImpl() { |
| 47 GpuSurfaceLookup::InitInstance(NULL); | 47 GpuSurfaceLookup::InitInstance(NULL); |
| 48 SurfaceTextureLookup::InitInstance(NULL); | 48 SurfaceTextureLookup::InitInstance(NULL); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Overridden from SurfaceTexturePeer: | 51 // Overridden from SurfaceTexturePeer: |
| 52 virtual void EstablishSurfaceTexturePeer( | 52 virtual void EstablishSurfaceTexturePeer( |
| 53 base::ProcessHandle pid, | 53 base::ProcessHandle pid, |
| 54 scoped_refptr<gfx::SurfaceTexture> surface_texture, | 54 scoped_refptr<gfx::SurfaceTexture> surface_texture, |
| 55 int primary_id, | 55 int primary_id, |
| 56 int secondary_id) OVERRIDE { | 56 int secondary_id) override { |
| 57 JNIEnv* env = base::android::AttachCurrentThread(); | 57 JNIEnv* env = base::android::AttachCurrentThread(); |
| 58 content::Java_ChildProcessService_establishSurfaceTexturePeer( | 58 content::Java_ChildProcessService_establishSurfaceTexturePeer( |
| 59 env, service_.obj(), pid, | 59 env, service_.obj(), pid, |
| 60 surface_texture->j_surface_texture().obj(), primary_id, | 60 surface_texture->j_surface_texture().obj(), primary_id, |
| 61 secondary_id); | 61 secondary_id); |
| 62 CheckException(env); | 62 CheckException(env); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Overridden from GpuSurfaceLookup: | 65 // Overridden from GpuSurfaceLookup: |
| 66 virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) OVERRIDE { | 66 virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) override { |
| 67 JNIEnv* env = base::android::AttachCurrentThread(); | 67 JNIEnv* env = base::android::AttachCurrentThread(); |
| 68 gfx::ScopedJavaSurface surface( | 68 gfx::ScopedJavaSurface surface( |
| 69 content::Java_ChildProcessService_getViewSurface( | 69 content::Java_ChildProcessService_getViewSurface( |
| 70 env, service_.obj(), surface_id)); | 70 env, service_.obj(), surface_id)); |
| 71 | 71 |
| 72 if (surface.j_surface().is_null()) | 72 if (surface.j_surface().is_null()) |
| 73 return NULL; | 73 return NULL; |
| 74 | 74 |
| 75 // Note: This ensures that any local references used by | 75 // Note: This ensures that any local references used by |
| 76 // ANativeWindow_fromSurface are released immediately. This is needed as a | 76 // ANativeWindow_fromSurface are released immediately. This is needed as a |
| 77 // workaround for https://code.google.com/p/android/issues/detail?id=68174 | 77 // workaround for https://code.google.com/p/android/issues/detail?id=68174 |
| 78 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); | 78 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); |
| 79 ANativeWindow* native_window = | 79 ANativeWindow* native_window = |
| 80 ANativeWindow_fromSurface(env, surface.j_surface().obj()); | 80 ANativeWindow_fromSurface(env, surface.j_surface().obj()); |
| 81 | 81 |
| 82 return native_window; | 82 return native_window; |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Overridden from SurfaceTextureLookup: | 85 // Overridden from SurfaceTextureLookup: |
| 86 virtual gfx::AcceleratedWidget AcquireNativeWidget(int primary_id, | 86 virtual gfx::AcceleratedWidget AcquireNativeWidget(int primary_id, |
| 87 int secondary_id) | 87 int secondary_id) |
| 88 OVERRIDE { | 88 override { |
| 89 JNIEnv* env = base::android::AttachCurrentThread(); | 89 JNIEnv* env = base::android::AttachCurrentThread(); |
| 90 gfx::ScopedJavaSurface surface( | 90 gfx::ScopedJavaSurface surface( |
| 91 content::Java_ChildProcessService_getSurfaceTextureSurface( | 91 content::Java_ChildProcessService_getSurfaceTextureSurface( |
| 92 env, service_.obj(), primary_id, secondary_id)); | 92 env, service_.obj(), primary_id, secondary_id)); |
| 93 | 93 |
| 94 if (surface.j_surface().is_null()) | 94 if (surface.j_surface().is_null()) |
| 95 return NULL; | 95 return NULL; |
| 96 | 96 |
| 97 // Note: This ensures that any local references used by | 97 // Note: This ensures that any local references used by |
| 98 // ANativeWindow_fromSurface are released immediately. This is needed as a | 98 // ANativeWindow_fromSurface are released immediately. This is needed as a |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 bool RegisterChildProcessService(JNIEnv* env) { | 170 bool RegisterChildProcessService(JNIEnv* env) { |
| 171 return RegisterNativesImpl(env); | 171 return RegisterNativesImpl(env); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ShutdownMainThread(JNIEnv* env, jobject obj) { | 174 void ShutdownMainThread(JNIEnv* env, jobject obj) { |
| 175 ChildThread::ShutdownThread(); | 175 ChildThread::ShutdownThread(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace content | 178 } // namespace content |
| OLD | NEW |