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

Unified Diff: ui/gl/gl_image_egl.cc

Issue 13543007: GLImage support for Android zero-copy pixel buffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix minor indentation issue Created 7 years, 8 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
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_glx.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_egl.cc
diff --git a/ui/gl/gl_image_egl.cc b/ui/gl/gl_image_egl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6e7adec6863bb981a25654d5bae4c68c724d9c5c
--- /dev/null
+++ b/ui/gl/gl_image_egl.cc
@@ -0,0 +1,79 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gl/gl_image_egl.h"
+
+#include "ui/gl/gl_bindings.h"
+
+#define EGL_NATIVE_BUFFER_ANDROID 0x3140
+
+namespace gfx {
+
+GLImageEGL::GLImageEGL(const gfx::Size& size)
+ : egl_image_(EGL_NO_IMAGE_KHR),
+ size_(size) {
+}
+
+GLImageEGL::~GLImageEGL() {
+ Destroy();
+}
+
+bool GLImageEGL::Initialize(gfx::PixelBufferHandle buffer) {
+ EGLClientBuffer cbuf = static_cast<EGLClientBuffer>(buffer);
+ EGLint attrs[] = {
+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
+ EGL_NONE,
+ };
+ egl_image_ = eglCreateImageKHR(
+ eglGetDisplay(EGL_DEFAULT_DISPLAY),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_BUFFER_ANDROID,
+ cbuf,
+ attrs);
+
+ if (egl_image_ == EGL_NO_IMAGE_KHR) {
+ EGLint error = eglGetError();
+ LOG(ERROR) << "Error creating EGLImage: " << error;
+ return false;
+ }
+
+ return true;
+}
+
+bool GLImageEGL::BindTexImage() {
+ if (egl_image_ == EGL_NO_IMAGE_KHR) {
+ LOG(ERROR) << "NULL EGLImage in BindTexImage";
+ return false;
+ }
+
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_);
no sievers 2013/04/05 22:16:34 Call glGetError() and return false here if not GL_
kaanb 2013/04/08 15:48:11 Done.
+
+ return true;
+}
+
+gfx::Size GLImageEGL::GetSize() {
+ return size_;
+}
+
+void GLImageEGL::Destroy() {
+ if (egl_image_ == EGL_NO_IMAGE_KHR)
+ return;
+
+ EGLBoolean success = eglDestroyImageKHR(
+ eglGetDisplay(EGL_DEFAULT_DISPLAY), egl_image_);
+
+ if (success == EGL_FALSE) {
+ EGLint error = eglGetError();
+ LOG(ERROR) << "Error destroying EGLImage: " << error;
+ }
+
+ egl_image_ = EGL_NO_IMAGE_KHR;
+}
+
+void GLImageEGL::ReleaseTexImage() {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ NULL);
+}
+
+} // namespace gfx
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_glx.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698