| 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 #include "ui/gl/android/surface_texture.h" | 5 #include "ui/gl/android/surface_texture.h" |
| 6 | 6 |
| 7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 8 | 8 |
| 9 // TODO(boliu): Remove this include when we move off ICS. | 9 // TODO(boliu): Remove this include when we move off ICS. |
| 10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 env, j_surface_texture_.obj(), jmatrix.obj()); | 80 env, j_surface_texture_.obj(), jmatrix.obj()); |
| 81 | 81 |
| 82 jboolean is_copy; | 82 jboolean is_copy; |
| 83 jfloat* elements = env->GetFloatArrayElements(jmatrix.obj(), &is_copy); | 83 jfloat* elements = env->GetFloatArrayElements(jmatrix.obj(), &is_copy); |
| 84 for (int i = 0; i < 16; ++i) { | 84 for (int i = 0; i < 16; ++i) { |
| 85 mtx[i] = static_cast<float>(elements[i]); | 85 mtx[i] = static_cast<float>(elements[i]); |
| 86 } | 86 } |
| 87 env->ReleaseFloatArrayElements(jmatrix.obj(), elements, JNI_ABORT); | 87 env->ReleaseFloatArrayElements(jmatrix.obj(), elements, JNI_ABORT); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void SurfaceTexture::SetDefaultBufferSize(int width, int height) { | |
| 91 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 92 | |
| 93 if (width > 0 && height > 0) { | |
| 94 Java_SurfaceTexturePlatformWrapper_setDefaultBufferSize( | |
| 95 env, j_surface_texture_.obj(), static_cast<jint>(width), | |
| 96 static_cast<jint>(height)); | |
| 97 } else { | |
| 98 LOG(WARNING) << "Not setting surface texture buffer size - " | |
| 99 "width or height is 0"; | |
| 100 } | |
| 101 } | |
| 102 | |
| 103 void SurfaceTexture::AttachToGLContext() { | 90 void SurfaceTexture::AttachToGLContext() { |
| 104 if (GlContextMethodsAvailable()) { | 91 if (GlContextMethodsAvailable()) { |
| 105 int texture_id; | 92 int texture_id; |
| 106 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id); | 93 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id); |
| 107 DCHECK(texture_id); | 94 DCHECK(texture_id); |
| 108 JNIEnv* env = base::android::AttachCurrentThread(); | 95 JNIEnv* env = base::android::AttachCurrentThread(); |
| 109 Java_SurfaceTexturePlatformWrapper_attachToGLContext( | 96 Java_SurfaceTexturePlatformWrapper_attachToGLContext( |
| 110 env, j_surface_texture_.obj(), texture_id); | 97 env, j_surface_texture_.obj(), texture_id); |
| 111 } | 98 } |
| 112 } | 99 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 134 // static | 121 // static |
| 135 bool SurfaceTexture::IsSingleBufferModeSupported() { | 122 bool SurfaceTexture::IsSingleBufferModeSupported() { |
| 136 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; | 123 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; |
| 137 } | 124 } |
| 138 | 125 |
| 139 bool SurfaceTexture::RegisterSurfaceTexture(JNIEnv* env) { | 126 bool SurfaceTexture::RegisterSurfaceTexture(JNIEnv* env) { |
| 140 return RegisterNativesImpl(env); | 127 return RegisterNativesImpl(env); |
| 141 } | 128 } |
| 142 | 129 |
| 143 } // namespace gfx | 130 } // namespace gfx |
| OLD | NEW |