Chromium Code Reviews| 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..c3547bdefd69b9b09fbab9c36d1ce653a2a60fa0 |
| --- /dev/null |
| +++ b/ui/gl/gl_image_egl.cc |
| @@ -0,0 +1,81 @@ |
| +// 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_EGL 0x3140 |
|
reveman
2013/04/05 00:13:24
Is this supposed to be EGL_NATIVE_BUFFER_ANDROID 0
kaanb
2013/04/05 01:02:52
Yes, do I need to make the change in a different r
reveman
2013/04/05 04:35:32
no, third_party/khronos/EGL/eglext.h is part of th
kaanb
2013/04/05 07:17:06
Actually this constant is already defined in third
reveman
2013/04/05 17:58:06
hm, I'm not sure, maybe we should be using third_p
|
| + |
| +namespace gfx { |
| + |
| +GLImageEGL::GLImageEGL(const gfx::Size& size) |
| + : egl_image_(NULL), |
|
reveman
2013/04/05 00:13:24
EGL_NO_IMAGE_KHR instead of NULL?
kaanb
2013/04/05 01:02:52
Done.
|
| + size_(size) { |
| +} |
| + |
| +GLImageEGL::~GLImageEGL() { |
|
reveman
2013/04/05 00:13:24
call Destroy() here for consistency.
kaanb
2013/04/05 01:02:52
Done.
|
| +} |
| + |
| +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), |
|
reveman
2013/04/05 00:13:24
nit: one argument per line if you can't fit them a
kaanb
2013/04/05 01:02:52
Done.
|
| + EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_EGL, cbuf, attrs); |
| + |
| + if (egl_image_ == EGL_NO_IMAGE_KHR) { |
| + EGLint error = eglGetError(); |
| + LOG(ERROR) << "GLImageEGL - error creating EGLImage: " |
|
reveman
2013/04/05 00:13:24
nit: "GLImageEGL::Initialize: Error cre..."
kaanb
2013/04/05 01:02:52
Done.
|
| + << error; |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +bool GLImageEGL::BindTexImage() { |
| + if (egl_image_ == EGL_NO_IMAGE_KHR) { |
| + LOG(ERROR) << "GLImageEGL - null EGLImage in BindTexImage"; |
|
reveman
2013/04/05 00:13:24
I don't think you need the GLImageEGL prefix here.
kaanb
2013/04/05 01:02:52
Done.
|
| + return false; |
| + } |
| + |
| + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); |
|
apatrick_chromium
2013/04/04 23:33:40
This could generate a GL error that should not be
kaanb
2013/04/05 01:02:52
Done.
|
| + |
| + GLint error; |
| + while ((error = glGetError()) != GL_NO_ERROR) { |
|
apatrick_chromium
2013/04/04 23:33:40
This will never iterate more than once. Again, may
kaanb
2013/04/05 01:02:52
Done.
|
| + return false; |
| + } |
| + |
| + EGLBoolean success = eglDestroyImageKHR( |
|
apatrick_chromium
2013/04/04 23:33:40
Why destroy it here rather than in GLImageEGL::Des
no sievers
2013/04/05 00:23:03
Yes please destroy it down there. We might want to
apatrick_chromium
2013/04/05 00:38:04
GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM is g
kaanb
2013/04/05 01:02:52
Good question, I don't know the answer.
kaanb
2013/04/05 01:02:52
Actually I realized epenner@ had suggested somethi
no sievers
2013/04/05 16:55:57
If I read the spec correctly (http://www.khronos.o
|
| + eglGetDisplay(EGL_DEFAULT_DISPLAY), egl_image_); |
| + |
| + if (success == EGL_FALSE) { |
| + EGLint error = eglGetError(); |
| + LOG(ERROR) << "GLImageEGL - error destroying EGLImage: " |
|
reveman
2013/04/05 00:13:24
I don't think you need the GLImageEGL prefix here.
kaanb
2013/04/05 01:02:52
Done.
|
| + << error; |
| + return false; |
| + } |
| + |
| + egl_image_ = EGL_NO_IMAGE_KHR; |
| + |
| + return true; |
| +} |
| + |
| +gfx::Size GLImageEGL::GetSize() { |
| + return size_; |
| +} |
| + |
| +void GLImageEGL::Destroy() { |
| + return; |
|
apatrick_chromium
2013/04/04 23:33:40
nit: redundant
reveman
2013/04/05 00:13:24
Can we add a DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image
kaanb
2013/04/05 01:02:52
Done.
kaanb
2013/04/05 01:02:52
DCHECK may fail when if we never called Destroy()
reveman
2013/04/05 04:35:32
My point was that you should either destroy the im
|
| +} |
| + |
| +void GLImageEGL::ReleaseTexImage() { |
| + NOTREACHED(); |
| + return; |
|
reveman
2013/04/05 00:13:24
nit: "return" is redundant
kaanb
2013/04/05 01:02:52
Done.
|
| +} |
| + |
| +} // namespace gfx |