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

Side by Side 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: s/window/buffer/ 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_glx.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gl/gl_image_egl.h"
6
7 #include "ui/gl/gl_bindings.h"
8
9 #define EGL_NATIVE_BUFFER_ANDROID 0x3140
10
11 namespace gfx {
12
13 GLImageEGL::GLImageEGL(const gfx::Size& size)
14 : egl_image_(EGL_NO_IMAGE_KHR),
reveman 2013/04/05 04:35:33 nit: indent 4 spaces here
15 size_(size) {
16 }
17
18 GLImageEGL::~GLImageEGL() {
19 Destroy();
20 }
21
22 bool GLImageEGL::Initialize(gfx::PixelBufferHandle buffer) {
23 EGLClientBuffer cbuf = static_cast<EGLClientBuffer>(buffer);
24 EGLint attrs[] = {
25 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
26 EGL_NONE,
27 };
28 egl_image_ = eglCreateImageKHR(
29 eglGetDisplay(EGL_DEFAULT_DISPLAY),
30 EGL_NO_CONTEXT,
31 EGL_NATIVE_BUFFER_ANDROID,
32 cbuf,
33 attrs);
34
35 if (egl_image_ == EGL_NO_IMAGE_KHR) {
36 EGLint error = eglGetError();
37 LOG(ERROR) << "Error creating EGLImage: " << error;
38 return false;
39 }
40
41 return true;
42 }
43
44 bool GLImageEGL::BindTexImage() {
45 if (egl_image_ == EGL_NO_IMAGE_KHR) {
46 LOG(ERROR) << "NULL EGLImage in BindTexImage";
47 return false;
48 }
49
50 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_);
51
52 return true;
53 }
54
55 gfx::Size GLImageEGL::GetSize() {
56 return size_;
57 }
58
59 void GLImageEGL::Destroy() {
60 if (egl_image_ == EGL_NO_IMAGE_KHR)
61 return;
62
63 EGLBoolean success = eglDestroyImageKHR(
64 eglGetDisplay(EGL_DEFAULT_DISPLAY), egl_image_);
65
66 if (success == EGL_FALSE) {
67 EGLint error = eglGetError();
68 LOG(ERROR) << "Error destroying EGLImage: " << error;
69 }
70
71 egl_image_ = EGL_NO_IMAGE_KHR;
72 }
73
74 void GLImageEGL::ReleaseTexImage() {
75 NOTREACHED();
76 }
77
78 } // namespace gfx
OLDNEW
« 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