OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 package org.chromium.ui.gl; | 5 package org.chromium.ui.gl; |
6 | 6 |
7 import android.graphics.SurfaceTexture; | 7 import android.graphics.SurfaceTexture; |
8 import android.os.Build; | 8 import android.os.Build; |
9 import android.util.Log; | 9 import android.util.Log; |
10 | 10 |
11 import org.chromium.base.CalledByNative; | 11 import org.chromium.base.CalledByNative; |
12 import org.chromium.base.JNINamespace; | 12 import org.chromium.base.JNINamespace; |
13 | 13 |
14 /** | 14 /** |
15 * Wrapper class for the underlying platform's SurfaceTexture in order to | 15 * Wrapper class for the underlying platform's SurfaceTexture in order to |
16 * provide a stable JNI API. | 16 * provide a stable JNI API. |
17 */ | 17 */ |
18 @JNINamespace("gfx") | 18 @JNINamespace("gfx") |
19 class SurfaceTexturePlatformWrapper { | 19 class SurfaceTexturePlatformWrapper { |
20 | 20 |
21 private static final String TAG = "SurfaceTexturePlatformWrapper"; | 21 private static final String TAG = "SurfaceTexturePlatformWrapper"; |
22 | 22 |
23 @CalledByNative | 23 @CalledByNative |
24 private static SurfaceTexture create(int textureId) { | 24 private static SurfaceTexture create(int textureId, boolean singleBufferMode ) { |
25 return new SurfaceTexture(textureId); | 25 return new SurfaceTexture(textureId, singleBufferMode); |
reveman
2014/03/10 16:16:58
you'll need to add a createSingleBuffered as this
epennerAtGoogle
2014/03/10 18:54:07
Would something like this work? Unless we want mor
reveman
2014/03/10 19:02:14
It would work but I prefer if we only branch once
| |
26 } | 26 } |
27 | 27 |
28 @CalledByNative | 28 @CalledByNative |
29 private static void destroy(SurfaceTexture surfaceTexture) { | 29 private static void destroy(SurfaceTexture surfaceTexture) { |
30 surfaceTexture.setOnFrameAvailableListener(null); | 30 surfaceTexture.setOnFrameAvailableListener(null); |
31 surfaceTexture.release(); | 31 surfaceTexture.release(); |
32 } | 32 } |
33 | 33 |
34 @CalledByNative | 34 @CalledByNative |
35 private static void setFrameAvailableCallback(SurfaceTexture surfaceTexture, | 35 private static void setFrameAvailableCallback(SurfaceTexture surfaceTexture, |
36 long nativeSurfaceTextureListener) { | 36 long nativeSurfaceTextureListener) { |
37 surfaceTexture.setOnFrameAvailableListener( | 37 surfaceTexture.setOnFrameAvailableListener( |
38 new SurfaceTextureListener(nativeSurfaceTextureListener)); | 38 new SurfaceTextureListener(nativeSurfaceTextureListener)); |
39 } | 39 } |
40 | 40 |
41 @CalledByNative | 41 @CalledByNative |
42 private static void updateTexImage(SurfaceTexture surfaceTexture) { | 42 private static void updateTexImage(SurfaceTexture surfaceTexture) { |
43 try { | 43 try { |
44 surfaceTexture.updateTexImage(); | 44 surfaceTexture.updateTexImage(); |
45 } catch (RuntimeException e) { | 45 } catch (RuntimeException e) { |
46 Log.e(TAG, "Error calling updateTexImage", e); | 46 Log.e(TAG, "Error calling updateTexImage", e); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 @CalledByNative | 50 @CalledByNative |
51 private static void releaseTexImage(SurfaceTexture surfaceTexture) { | |
52 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; | |
53 surfaceTexture.releaseTexImage(); | |
54 } | |
55 | |
56 @CalledByNative | |
51 private static void setDefaultBufferSize(SurfaceTexture surfaceTexture, int width, | 57 private static void setDefaultBufferSize(SurfaceTexture surfaceTexture, int width, |
52 int height) { | 58 int height) { |
53 surfaceTexture.setDefaultBufferSize(width, height); | 59 surfaceTexture.setDefaultBufferSize(width, height); |
54 } | 60 } |
55 | 61 |
56 @CalledByNative | 62 @CalledByNative |
57 private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[ ] matrix) { | 63 private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[ ] matrix) { |
58 surfaceTexture.getTransformMatrix(matrix); | 64 surfaceTexture.getTransformMatrix(matrix); |
59 } | 65 } |
60 | 66 |
61 @CalledByNative | 67 @CalledByNative |
62 private static void attachToGLContext(SurfaceTexture surfaceTexture, int tex Name) { | 68 private static void attachToGLContext(SurfaceTexture surfaceTexture, int tex Name) { |
63 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; | 69 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
64 surfaceTexture.attachToGLContext(texName); | 70 surfaceTexture.attachToGLContext(texName); |
65 } | 71 } |
66 | 72 |
67 @CalledByNative | 73 @CalledByNative |
68 private static void detachFromGLContext(SurfaceTexture surfaceTexture) { | 74 private static void detachFromGLContext(SurfaceTexture surfaceTexture) { |
69 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; | 75 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
70 surfaceTexture.detachFromGLContext(); | 76 surfaceTexture.detachFromGLContext(); |
71 } | 77 } |
72 } | 78 } |
OLD | NEW |