| 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/egl_util.h" | 7 #include "ui/gl/egl_util.h" |
| 8 #include "ui/gl/gl_surface_egl.h" | 8 #include "ui/gl/gl_surface_egl.h" |
| 9 | 9 |
| 10 namespace gl { | 10 namespace gl { |
| 11 | 11 |
| 12 GLImageEGL::GLImageEGL(const gfx::Size& size) | 12 GLImageEGL::GLImageEGL(const gfx::Size& size) |
| 13 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {} | 13 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {} |
| 14 | 14 |
| 15 GLImageEGL::~GLImageEGL() { | 15 GLImageEGL::~GLImageEGL() { |
| 16 DCHECK(thread_checker_.CalledOnValidThread()); | 16 DCHECK(thread_checker_.CalledOnValidThread()); |
| 17 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); | 17 if (egl_image_ != EGL_NO_IMAGE_KHR) { |
| 18 EGLBoolean result = |
| 19 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); |
| 20 if (result == EGL_FALSE) { |
| 21 DLOG(ERROR) << "Error destroying EGLImage: " |
| 22 << ui::GetLastEGLErrorString(); |
| 23 } |
| 24 } |
| 18 } | 25 } |
| 19 | 26 |
| 20 bool GLImageEGL::Initialize(EGLenum target, | 27 bool GLImageEGL::Initialize(EGLenum target, |
| 21 EGLClientBuffer buffer, | 28 EGLClientBuffer buffer, |
| 22 const EGLint* attrs) { | 29 const EGLint* attrs) { |
| 23 DCHECK(thread_checker_.CalledOnValidThread()); | 30 DCHECK(thread_checker_.CalledOnValidThread()); |
| 24 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); | 31 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); |
| 25 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(), | 32 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(), |
| 26 EGL_NO_CONTEXT, target, buffer, attrs); | 33 EGL_NO_CONTEXT, target, buffer, attrs); |
| 27 if (egl_image_ == EGL_NO_IMAGE_KHR) { | 34 if (egl_image_ == EGL_NO_IMAGE_KHR) { |
| 28 DLOG(ERROR) << "Error creating EGLImage: " << ui::GetLastEGLErrorString(); | 35 DLOG(ERROR) << "Error creating EGLImage: " << ui::GetLastEGLErrorString(); |
| 29 return false; | 36 return false; |
| 30 } | 37 } |
| 31 | 38 |
| 32 return true; | 39 return true; |
| 33 } | 40 } |
| 34 | 41 |
| 35 void GLImageEGL::Destroy(bool have_context) { | |
| 36 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 37 if (egl_image_ != EGL_NO_IMAGE_KHR) { | |
| 38 EGLBoolean result = | |
| 39 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); | |
| 40 if (result == EGL_FALSE) { | |
| 41 DLOG(ERROR) << "Error destroying EGLImage: " | |
| 42 << ui::GetLastEGLErrorString(); | |
| 43 } | |
| 44 egl_image_ = EGL_NO_IMAGE_KHR; | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 gfx::Size GLImageEGL::GetSize() { | 42 gfx::Size GLImageEGL::GetSize() { |
| 49 return size_; | 43 return size_; |
| 50 } | 44 } |
| 51 | 45 |
| 52 unsigned GLImageEGL::GetInternalFormat() { return GL_RGBA; } | 46 unsigned GLImageEGL::GetInternalFormat() { return GL_RGBA; } |
| 53 | 47 |
| 54 bool GLImageEGL::BindTexImage(unsigned target) { | 48 bool GLImageEGL::BindTexImage(unsigned target) { |
| 55 DCHECK(thread_checker_.CalledOnValidThread()); | 49 DCHECK(thread_checker_.CalledOnValidThread()); |
| 56 if (egl_image_ == EGL_NO_IMAGE_KHR) | 50 if (egl_image_ == EGL_NO_IMAGE_KHR) |
| 57 return false; | 51 return false; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 73 | 67 |
| 74 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 68 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 75 int z_order, | 69 int z_order, |
| 76 gfx::OverlayTransform transform, | 70 gfx::OverlayTransform transform, |
| 77 const gfx::Rect& bounds_rect, | 71 const gfx::Rect& bounds_rect, |
| 78 const gfx::RectF& crop_rect) { | 72 const gfx::RectF& crop_rect) { |
| 79 return false; | 73 return false; |
| 80 } | 74 } |
| 81 | 75 |
| 82 } // namespace gl | 76 } // namespace gl |
| OLD | NEW |