[Android] Add a reset_usb utility script (RELAND).
[chromium-blink-merge.git] / ui / gl / gl_image_egl.cc
blob0ebd7ccac909fef1c5e74d8a147e808d274271c5
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/egl_util.h"
8 #include "ui/gl/gl_surface_egl.h"
10 namespace gfx {
12 GLImageEGL::GLImageEGL(const gfx::Size& size)
13 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {
16 GLImageEGL::~GLImageEGL() {
17 DCHECK(thread_checker_.CalledOnValidThread());
18 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
21 bool GLImageEGL::Initialize(EGLenum target,
22 EGLClientBuffer buffer,
23 const EGLint* attrs) {
24 DCHECK(thread_checker_.CalledOnValidThread());
25 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
26 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
27 EGL_NO_CONTEXT,
28 target,
29 buffer,
30 attrs);
31 if (egl_image_ == EGL_NO_IMAGE_KHR) {
32 DLOG(ERROR) << "Error creating EGLImage: " << ui::GetLastEGLErrorString();
33 return false;
36 return true;
39 void GLImageEGL::Destroy(bool have_context) {
40 DCHECK(thread_checker_.CalledOnValidThread());
41 if (egl_image_ != EGL_NO_IMAGE_KHR) {
42 EGLBoolean result =
43 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
44 if (result == EGL_FALSE) {
45 DLOG(ERROR) << "Error destroying EGLImage: "
46 << ui::GetLastEGLErrorString();
48 egl_image_ = EGL_NO_IMAGE_KHR;
52 gfx::Size GLImageEGL::GetSize() { return size_; }
54 unsigned GLImageEGL::GetInternalFormat() { return GL_RGBA; }
56 bool GLImageEGL::BindTexImage(unsigned target) {
57 DCHECK(thread_checker_.CalledOnValidThread());
58 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
59 glEGLImageTargetTexture2DOES(target, egl_image_);
60 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
61 return true;
64 bool GLImageEGL::CopyTexSubImage(unsigned target,
65 const Point& offset,
66 const Rect& rect) {
67 return false;
70 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
71 int z_order,
72 OverlayTransform transform,
73 const Rect& bounds_rect,
74 const RectF& crop_rect) {
75 return false;
78 } // namespace gfx