| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gl/gl_image_egl.h" | 5 #include "ui/gl/gl_image_egl.h" |
| 6 | 6 |
| 7 #include "ui/gl/gl_bindings.h" | 7 #include "ui/gl/gl_bindings.h" |
| 8 #include "ui/gl/gl_surface_egl.h" | 8 #include "ui/gl/gl_surface_egl.h" |
| 9 | 9 |
| 10 namespace gfx { | 10 namespace gfx { |
| 11 | 11 |
| 12 GLImageEGL::GLImageEGL(gfx::Size size) | 12 GLImageEGL::GLImageEGL(gfx::Size size) |
| 13 : egl_image_(EGL_NO_IMAGE_KHR), | 13 : egl_image_(EGL_NO_IMAGE_KHR), |
| 14 size_(size) { | 14 size_(size) { |
| 15 } | 15 } |
| 16 | 16 |
| 17 GLImageEGL::~GLImageEGL() { | 17 GLImageEGL::~GLImageEGL() { |
| 18 Destroy(); | 18 Destroy(); |
| 19 } | 19 } |
| 20 | 20 |
| 21 bool GLImageEGL::Initialize(gfx::GpuMemoryBufferHandle buffer) { | 21 bool GLImageEGL::Initialize(gfx::GpuMemoryBufferHandle buffer) { |
| 22 EGLClientBuffer cbuf = static_cast<EGLClientBuffer>(buffer); | 22 DCHECK(buffer.native_buffer); |
| 23 EGLint attrs[] = { | 23 EGLint attrs[] = { |
| 24 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, | 24 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, |
| 25 EGL_NONE, | 25 EGL_NONE, |
| 26 }; | 26 }; |
| 27 egl_image_ = eglCreateImageKHR( | 27 egl_image_ = eglCreateImageKHR( |
| 28 GLSurfaceEGL::GetHardwareDisplay(), | 28 GLSurfaceEGL::GetHardwareDisplay(), |
| 29 EGL_NO_CONTEXT, | 29 EGL_NO_CONTEXT, |
| 30 EGL_NATIVE_BUFFER_ANDROID, | 30 EGL_NATIVE_BUFFER_ANDROID, |
| 31 cbuf, | 31 buffer.native_buffer, |
| 32 attrs); | 32 attrs); |
| 33 | 33 |
| 34 if (egl_image_ == EGL_NO_IMAGE_KHR) { | 34 if (egl_image_ == EGL_NO_IMAGE_KHR) { |
| 35 EGLint error = eglGetError(); | 35 EGLint error = eglGetError(); |
| 36 LOG(ERROR) << "Error creating EGLImage: " << error; | 36 LOG(ERROR) << "Error creating EGLImage: " << error; |
| 37 return false; | 37 return false; |
| 38 } | 38 } |
| 39 | 39 |
| 40 return true; | 40 return true; |
| 41 } | 41 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 egl_image_ = EGL_NO_IMAGE_KHR; | 74 egl_image_ = EGL_NO_IMAGE_KHR; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void GLImageEGL::ReleaseTexImage() { | 77 void GLImageEGL::ReleaseTexImage() { |
| 78 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 78 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 79 NULL); | 79 NULL); |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace gfx | 82 } // namespace gfx |
| OLD | NEW |