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 single_buffered) { |
reveman
2014/03/08 14:10:20
s/single_buffered/singleBufferMode/
sohanjg
2014/03/08 14:20:15
Done.
| |
25 return new SurfaceTexture(textureId); | 25 return new SurfaceTexture(textureId, single_buffered); |
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) { | |
reveman
2014/03/08 14:10:20
nit: no need for a space between "TexImage" and "(
sohanjg
2014/03/08 14:20:15
Done.
| |
52 surfaceTexture.releaseTexImage(); | |
53 } | |
54 | |
55 @CalledByNative | |
51 private static void setDefaultBufferSize(SurfaceTexture surfaceTexture, int width, | 56 private static void setDefaultBufferSize(SurfaceTexture surfaceTexture, int width, |
52 int height) { | 57 int height) { |
53 surfaceTexture.setDefaultBufferSize(width, height); | 58 surfaceTexture.setDefaultBufferSize(width, height); |
54 } | 59 } |
55 | 60 |
56 @CalledByNative | 61 @CalledByNative |
57 private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[ ] matrix) { | 62 private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[ ] matrix) { |
58 surfaceTexture.getTransformMatrix(matrix); | 63 surfaceTexture.getTransformMatrix(matrix); |
59 } | 64 } |
60 | 65 |
61 @CalledByNative | 66 @CalledByNative |
62 private static void attachToGLContext(SurfaceTexture surfaceTexture, int tex Name) { | 67 private static void attachToGLContext(SurfaceTexture surfaceTexture, int tex Name) { |
63 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; | 68 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
64 surfaceTexture.attachToGLContext(texName); | 69 surfaceTexture.attachToGLContext(texName); |
65 } | 70 } |
66 | 71 |
67 @CalledByNative | 72 @CalledByNative |
68 private static void detachFromGLContext(SurfaceTexture surfaceTexture) { | 73 private static void detachFromGLContext(SurfaceTexture surfaceTexture) { |
69 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; | 74 assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
70 surfaceTexture.detachFromGLContext(); | 75 surfaceTexture.detachFromGLContext(); |
71 } | 76 } |
72 } | 77 } |
OLD | NEW |