Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: ui/gl/android/surface_texture.cc

Issue 191933002: This is initial API support required for enabling SurfaceTexture backed zero-copy for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sdk version check and comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/gl/android/surface_texture.h ('K') | « ui/gl/android/surface_texture.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/android/surface_texture.cc
diff --git a/ui/gl/android/surface_texture.cc b/ui/gl/android/surface_texture.cc
index 35f9b47288b6deb3ac9e865e826bed9edef872a2..95be7f717f622e7aa951f5474dfb56ab56e54e97 100644
--- a/ui/gl/android/surface_texture.cc
+++ b/ui/gl/android/surface_texture.cc
@@ -26,10 +26,19 @@ bool GlContextMethodsAvailable() {
namespace gfx {
-SurfaceTexture::SurfaceTexture(int texture_id) {
+SurfaceTexture* SurfaceTexture::Create(int texture_id) {
+ return new SurfaceTexture(texture_id, false);
+}
+
+SurfaceTexture* SurfaceTexture::CreateSingleBufferMode(int texture_id) {
+ DCHECK(IsSingleBufferModeSupported());
+ return new SurfaceTexture(texture_id, true);
+}
+
+SurfaceTexture::SurfaceTexture(int texture_id, bool single_buffer_mode) {
JNIEnv* env = base::android::AttachCurrentThread();
- j_surface_texture_.Reset(
- Java_SurfaceTexturePlatformWrapper_create(env, texture_id));
+ j_surface_texture_.Reset(Java_SurfaceTexturePlatformWrapper_create(
+ env, texture_id, single_buffer_mode));
}
SurfaceTexture::~SurfaceTexture() {
@@ -52,6 +61,13 @@ void SurfaceTexture::UpdateTexImage() {
j_surface_texture_.obj());
}
+void SurfaceTexture::ReleaseTexImage() {
+ DCHECK(IsSingleBufferModeSupported());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_SurfaceTexturePlatformWrapper_releaseTexImage(env,
+ j_surface_texture_.obj());
+}
+
void SurfaceTexture::GetTransformMatrix(float mtx[16]) {
JNIEnv* env = base::android::AttachCurrentThread();
@@ -109,6 +125,10 @@ ANativeWindow* SurfaceTexture::CreateSurface() {
}
// static
+bool SurfaceTexture::IsSingleBufferModeSupported() {
+ return base::android::BuildInfo::GetInstance()->sdk_int() >= 19;
+}
+
bool SurfaceTexture::RegisterSurfaceTexture(JNIEnv* env) {
return RegisterNativesImpl(env);
}
« ui/gl/android/surface_texture.h ('K') | « ui/gl/android/surface_texture.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698