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.
5 #include "ui/gl/gl_image_egl.h"
7 #include "ui/gl/gl_surface_egl.h"
11 GLImageEGL::GLImageEGL(gfx::Size size
)
12 : egl_image_(EGL_NO_IMAGE_KHR
), size_(size
) {}
14 GLImageEGL::~GLImageEGL() { Destroy(); }
16 bool GLImageEGL::Initialize(EGLenum target
,
17 EGLClientBuffer buffer
,
18 const EGLint
* attrs
) {
19 DCHECK_EQ(EGL_NO_IMAGE_KHR
, egl_image_
);
20 egl_image_
= eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
25 if (egl_image_
== EGL_NO_IMAGE_KHR
) {
26 EGLint error
= eglGetError();
27 LOG(ERROR
) << "Error creating EGLImage: " << error
;
34 void GLImageEGL::Destroy() {
35 if (egl_image_
!= EGL_NO_IMAGE_KHR
) {
36 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_
);
37 egl_image_
= EGL_NO_IMAGE_KHR
;
41 gfx::Size
GLImageEGL::GetSize() { return size_
; }
43 bool GLImageEGL::BindTexImage(unsigned target
) {
44 DCHECK_NE(EGL_NO_IMAGE_KHR
, egl_image_
);
45 glEGLImageTargetTexture2DOES(target
, egl_image_
);
46 DCHECK_EQ(static_cast<GLenum
>(GL_NO_ERROR
), glGetError());