Home | History | Annotate | Download | only in gl
      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.
      4 
      5 #include "ui/gl/gl_image_egl.h"
      6 
      7 #include "ui/gl/gl_surface_egl.h"
      8 
      9 namespace gfx {
     10 
     11 GLImageEGL::GLImageEGL(const gfx::Size& size)
     12     : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {
     13 }
     14 
     15 GLImageEGL::~GLImageEGL() {
     16   DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
     17 }
     18 
     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;
     32   }
     33 
     34   return true;
     35 }
     36 
     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;
     41   }
     42 }
     43 
     44 gfx::Size GLImageEGL::GetSize() { return size_; }
     45 
     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;
     51 }
     52 
     53 bool GLImageEGL::CopyTexImage(unsigned target) {
     54   return false;
     55 }
     56 
     57 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
     58                                       int z_order,
     59                                       OverlayTransform transform,
     60                                       const Rect& bounds_rect,
     61                                       const RectF& crop_rect) {
     62   return false;
     63 }
     64 
     65 }  // namespace gfx
     66