Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_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
| |
| 10 | |
| 11 namespace gfx { | |
| 12 | |
| 13 GLImageEGL::GLImageEGL(const gfx::Size& size) | |
| 14 : 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.
| |
| 15 size_(size) { | |
| 16 } | |
| 17 | |
| 18 GLImageEGL::~GLImageEGL() { | |
|
reveman
2013/04/05 00:13:24
call Destroy() here for consistency.
kaanb
2013/04/05 01:02:52
Done.
| |
| 19 } | |
| 20 | |
| 21 bool GLImageEGL::Initialize(gfx::PixelBufferHandle buffer) { | |
| 22 EGLClientBuffer cbuf = static_cast<EGLClientBuffer>(buffer); | |
| 23 EGLint attrs[] = { | |
| 24 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, | |
| 25 EGL_NONE, | |
| 26 }; | |
| 27 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.
| |
| 28 EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_EGL, cbuf, attrs); | |
| 29 | |
| 30 if (egl_image_ == EGL_NO_IMAGE_KHR) { | |
| 31 EGLint error = eglGetError(); | |
| 32 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.
| |
| 33 << error; | |
| 34 return false; | |
| 35 } | |
| 36 | |
| 37 return true; | |
| 38 } | |
| 39 | |
| 40 bool GLImageEGL::BindTexImage() { | |
| 41 if (egl_image_ == EGL_NO_IMAGE_KHR) { | |
| 42 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.
| |
| 43 return false; | |
| 44 } | |
| 45 | |
| 46 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.
| |
| 47 | |
| 48 GLint error; | |
| 49 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.
| |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 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
| |
| 54 eglGetDisplay(EGL_DEFAULT_DISPLAY), egl_image_); | |
| 55 | |
| 56 if (success == EGL_FALSE) { | |
| 57 EGLint error = eglGetError(); | |
| 58 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.
| |
| 59 << error; | |
| 60 return false; | |
| 61 } | |
| 62 | |
| 63 egl_image_ = EGL_NO_IMAGE_KHR; | |
| 64 | |
| 65 return true; | |
| 66 } | |
| 67 | |
| 68 gfx::Size GLImageEGL::GetSize() { | |
| 69 return size_; | |
| 70 } | |
| 71 | |
| 72 void GLImageEGL::Destroy() { | |
| 73 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
| |
| 74 } | |
| 75 | |
| 76 void GLImageEGL::ReleaseTexImage() { | |
| 77 NOTREACHED(); | |
| 78 return; | |
|
reveman
2013/04/05 00:13:24
nit: "return" is redundant
kaanb
2013/04/05 01:02:52
Done.
| |
| 79 } | |
| 80 | |
| 81 } // namespace gfx | |
| OLD | NEW |