Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / gl / gl_image_egl.cc
blob7e313726d571cb0ee459b32c6e6141499213f75a
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"
9 namespace gfx {
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(),
24 EGL_NO_CONTEXT,
25 target,
26 buffer,
27 attrs);
28 if (egl_image_ == EGL_NO_IMAGE_KHR) {
29 EGLint error = eglGetError();
30 LOG(ERROR) << "Error creating EGLImage: " << error;
31 return false;
34 return true;
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());
50 return true;
53 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
54 int z_order,
55 OverlayTransform transform,
56 const Rect& bounds_rect,
57 const RectF& crop_rect) {
58 return false;
61 } // namespace gfx