| Index: content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
|
| index 286afbca7d4a2eef71388924b3238c1e225a8bab..e12f13aedbd932b7e54ffbf4f589e011568d3129 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
|
| @@ -257,17 +257,45 @@ public class ChildProcessLauncher {
|
| sViewSurfaceMap.remove(surfaceId);
|
| }
|
|
|
| + private static void registerSurfaceTextureSurface(
|
| + int surfaceTextureId, int clientId, Surface surface) {
|
| + Pair<Integer, Integer> key = new Pair<Integer, Integer>(surfaceTextureId, clientId);
|
| + sSurfaceTextureSurfaceMap.put(key, surface);
|
| + }
|
| +
|
| + private static void unregisterSurfaceTextureSurface(int surfaceTextureId, int clientId) {
|
| + Pair<Integer, Integer> key = new Pair<Integer, Integer>(surfaceTextureId, clientId);
|
| + Surface surface = sSurfaceTextureSurfaceMap.remove(key);
|
| + if (surface == null)
|
| + return;
|
| +
|
| + assert surface.isValid();
|
| + surface.release();
|
| + }
|
| +
|
| @CalledByNative
|
| - private static void registerSurfaceTexture(
|
| - int surfaceTextureId, int childProcessId, SurfaceTexture surfaceTexture) {
|
| - Pair<Integer, Integer> key = new Pair<Integer, Integer>(surfaceTextureId, childProcessId);
|
| - sSurfaceTextureSurfaceMap.put(key, new Surface(surfaceTexture));
|
| + private static void createSurfaceTextureSurface(
|
| + int surfaceTextureId, int clientId, SurfaceTexture surfaceTexture) {
|
| + registerSurfaceTextureSurface(surfaceTextureId, clientId, new Surface(surfaceTexture));
|
| }
|
|
|
| @CalledByNative
|
| - private static void unregisterSurfaceTexture(int surfaceTextureId, int childProcessId) {
|
| - Pair<Integer, Integer> key = new Pair<Integer, Integer>(surfaceTextureId, childProcessId);
|
| - sSurfaceTextureSurfaceMap.remove(key);
|
| + private static void destroySurfaceTextureSurface(int surfaceTextureId, int clientId) {
|
| + unregisterSurfaceTextureSurface(surfaceTextureId, clientId);
|
| + }
|
| +
|
| + @CalledByNative
|
| + private static SurfaceWrapper getSurfaceTextureSurface(
|
| + int surfaceTextureId, int clientId) {
|
| + Pair<Integer, Integer> key = new Pair<Integer, Integer>(surfaceTextureId, clientId);
|
| +
|
| + Surface surface = sSurfaceTextureSurfaceMap.get(key);
|
| + if (surface == null) {
|
| + Log.e(TAG, "Invalid Id for surface texture.");
|
| + return null;
|
| + }
|
| + assert surface.isValid();
|
| + return new SurfaceWrapper(surface);
|
| }
|
|
|
| /**
|
| @@ -487,26 +515,41 @@ public class ChildProcessLauncher {
|
| }
|
|
|
| @Override
|
| - public SurfaceWrapper getSurfaceTextureSurface(int primaryId, int secondaryId) {
|
| + public void registerSurfaceTextureSurface(
|
| + int surfaceTextureId, int clientId, Surface surface) {
|
| + if (callbackType != CALLBACK_FOR_GPU_PROCESS) {
|
| + Log.e(TAG, "Illegal callback for non-GPU process.");
|
| + return;
|
| + }
|
| +
|
| + ChildProcessLauncher.registerSurfaceTextureSurface(surfaceTextureId, clientId,
|
| + surface);
|
| + }
|
| +
|
| + @Override
|
| + public void unregisterSurfaceTextureSurface(
|
| + int surfaceTextureId, int clientId) {
|
| + if (callbackType != CALLBACK_FOR_GPU_PROCESS) {
|
| + Log.e(TAG, "Illegal callback for non-GPU process.");
|
| + return;
|
| + }
|
| +
|
| + ChildProcessLauncher.unregisterSurfaceTextureSurface(surfaceTextureId, clientId);
|
| + }
|
| +
|
| + @Override
|
| + public SurfaceWrapper getSurfaceTextureSurface(int surfaceTextureId, int clientId) {
|
| if (callbackType != CALLBACK_FOR_RENDERER_PROCESS) {
|
| Log.e(TAG, "Illegal callback for non-renderer process.");
|
| return null;
|
| }
|
|
|
| - if (secondaryId != childProcessId) {
|
| + if (clientId != childProcessId) {
|
| Log.e(TAG, "Illegal secondaryId for renderer process.");
|
| return null;
|
| }
|
|
|
| - Pair<Integer, Integer> key = new Pair<Integer, Integer>(primaryId, secondaryId);
|
| - // Note: This removes the surface and passes the ownership to the caller.
|
| - Surface surface = sSurfaceTextureSurfaceMap.remove(key);
|
| - if (surface == null) {
|
| - Log.e(TAG, "Invalid Id for surface texture.");
|
| - return null;
|
| - }
|
| - assert surface.isValid();
|
| - return new SurfaceWrapper(surface);
|
| + return ChildProcessLauncher.getSurfaceTextureSurface(surfaceTextureId, clientId);
|
| }
|
| };
|
| }
|
|
|