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(const gfx::Size
& size
)
12 : egl_image_(EGL_NO_IMAGE_KHR
), size_(size
) {
15 GLImageEGL::~GLImageEGL() {
16 DCHECK_EQ(EGL_NO_IMAGE_KHR
, egl_image_
);
19 bool GLImageEGL::Initialize(EGLenum target
,
20 EGLClientBuffer buffer
,
21 const EGLint
* attrs
) {
22 DCHECK_EQ(EGL_NO_IMAGE_KHR
, egl_image_
);
23 egl_image_
= eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
28 if (egl_image_
== EGL_NO_IMAGE_KHR
) {
29 EGLint error
= eglGetError();
30 LOG(ERROR
) << "Error creating EGLImage: " << error
;
37 void GLImageEGL::Destroy(bool have_context
) {
38 if (egl_image_
!= EGL_NO_IMAGE_KHR
) {
39 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_
);
40 egl_image_
= EGL_NO_IMAGE_KHR
;
44 gfx::Size
GLImageEGL::GetSize() { return size_
; }
46 bool GLImageEGL::BindTexImage(unsigned target
) {
47 DCHECK_NE(EGL_NO_IMAGE_KHR
, egl_image_
);
48 glEGLImageTargetTexture2DOES(target
, egl_image_
);
49 DCHECK_EQ(static_cast<GLenum
>(GL_NO_ERROR
), glGetError());
53 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget
,
55 OverlayTransform transform
,
56 const Rect
& bounds_rect
,
57 const RectF
& crop_rect
) {