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) { |
25 return new SurfaceTexture(textureId); | 25 return new SurfaceTexture(textureId); |
26 } | 26 } |
27 | 27 |
28 @CalledByNative | 28 @CalledByNative |
| 29 private static SurfaceTexture createSingleBuffered(int textureId) { |
| 30 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; |
| 31 return new SurfaceTexture(textureId, true); |
| 32 } |
| 33 |
| 34 @CalledByNative |
29 private static void destroy(SurfaceTexture surfaceTexture) { | 35 private static void destroy(SurfaceTexture surfaceTexture) { |
30 surfaceTexture.setOnFrameAvailableListener(null); | 36 surfaceTexture.setOnFrameAvailableListener(null); |
31 surfaceTexture.release(); | 37 surfaceTexture.release(); |
32 } | 38 } |
33 | 39 |
34 @CalledByNative | 40 @CalledByNative |
35 private static void setFrameAvailableCallback(SurfaceTexture surfaceTexture, | 41 private static void setFrameAvailableCallback(SurfaceTexture surfaceTexture, |
36 long nativeSurfaceTextureListener) { | 42 long nativeSurfaceTextureListener) { |
37 surfaceTexture.setOnFrameAvailableListener( | 43 surfaceTexture.setOnFrameAvailableListener( |
38 new SurfaceTextureListener(nativeSurfaceTextureListener)); | 44 new SurfaceTextureListener(nativeSurfaceTextureListener)); |
39 } | 45 } |
40 | 46 |
41 @CalledByNative | 47 @CalledByNative |
42 private static void updateTexImage(SurfaceTexture surfaceTexture) { | 48 private static void updateTexImage(SurfaceTexture surfaceTexture) { |
43 try { | 49 try { |
44 surfaceTexture.updateTexImage(); | 50 surfaceTexture.updateTexImage(); |
45 } catch (RuntimeException e) { | 51 } catch (RuntimeException e) { |
46 Log.e(TAG, "Error calling updateTexImage", e); | 52 Log.e(TAG, "Error calling updateTexImage", e); |
47 } | 53 } |
48 } | 54 } |
49 | 55 |
50 @CalledByNative | 56 @CalledByNative |
| 57 private static void releaseTexImage(SurfaceTexture surfaceTexture) { |
| 58 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; |
| 59 surfaceTexture.releaseTexImage(); |
| 60 } |
| 61 |
| 62 @CalledByNative |
51 private static void setDefaultBufferSize(SurfaceTexture surfaceTexture, int
width, | 63 private static void setDefaultBufferSize(SurfaceTexture surfaceTexture, int
width, |
52 int height) { | 64 int height) { |
53 surfaceTexture.setDefaultBufferSize(width, height); | 65 surfaceTexture.setDefaultBufferSize(width, height); |
54 } | 66 } |
55 | 67 |
56 @CalledByNative | 68 @CalledByNative |
57 private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[
] matrix) { | 69 private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[
] matrix) { |
58 surfaceTexture.getTransformMatrix(matrix); | 70 surfaceTexture.getTransformMatrix(matrix); |
59 } | 71 } |
60 | 72 |
61 @CalledByNative | 73 @CalledByNative |
62 private static void attachToGLContext(SurfaceTexture surfaceTexture, int tex
Name) { | 74 private static void attachToGLContext(SurfaceTexture surfaceTexture, int tex
Name) { |
63 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; | 75 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
64 surfaceTexture.attachToGLContext(texName); | 76 surfaceTexture.attachToGLContext(texName); |
65 } | 77 } |
66 | 78 |
67 @CalledByNative | 79 @CalledByNative |
68 private static void detachFromGLContext(SurfaceTexture surfaceTexture) { | 80 private static void detachFromGLContext(SurfaceTexture surfaceTexture) { |
69 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; | 81 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
70 surfaceTexture.detachFromGLContext(); | 82 surfaceTexture.detachFromGLContext(); |
71 } | 83 } |
72 } | 84 } |
OLD | NEW |