OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gl/gl_image_android_native_buffer.h" | 5 #include "ui/gl/gl_image_android_native_buffer.h" |
6 | 6 |
7 #include "ui/gl/gl_surface_egl.h" | 7 #include "ui/gl/gl_surface_egl.h" |
8 #include "ui/gl/scoped_binders.h" | 8 #include "ui/gl/scoped_binders.h" |
9 | 9 |
10 namespace gfx { | 10 namespace gfx { |
11 | 11 |
12 GLImageAndroidNativeBuffer::GLImageAndroidNativeBuffer(gfx::Size size) | 12 GLImageAndroidNativeBuffer::GLImageAndroidNativeBuffer(const gfx::Size& size) |
13 : GLImageEGL(size), | 13 : GLImageEGL(size), |
14 release_after_use_(false), | 14 release_after_use_(false), |
15 in_use_(false), | 15 in_use_(false), |
16 target_(0), | 16 target_(0), |
17 egl_image_for_unbind_(EGL_NO_IMAGE_KHR), | 17 egl_image_for_unbind_(EGL_NO_IMAGE_KHR), |
18 texture_id_for_unbind_(0) {} | 18 texture_id_for_unbind_(0) { |
| 19 } |
19 | 20 |
20 GLImageAndroidNativeBuffer::~GLImageAndroidNativeBuffer() { Destroy(); } | 21 GLImageAndroidNativeBuffer::~GLImageAndroidNativeBuffer() { Destroy(); } |
21 | 22 |
22 bool GLImageAndroidNativeBuffer::Initialize(gfx::GpuMemoryBufferHandle buffer) { | 23 bool GLImageAndroidNativeBuffer::Initialize(EGLClientBuffer native_buffer) { |
23 DCHECK(buffer.native_buffer); | |
24 | |
25 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; | 24 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; |
26 return GLImageEGL::Initialize( | 25 return GLImageEGL::Initialize( |
27 EGL_NATIVE_BUFFER_ANDROID, buffer.native_buffer, attrs); | 26 EGL_NATIVE_BUFFER_ANDROID, native_buffer, attrs); |
28 } | 27 } |
29 | 28 |
30 void GLImageAndroidNativeBuffer::Destroy() { | 29 void GLImageAndroidNativeBuffer::Destroy() { |
31 if (egl_image_for_unbind_ != EGL_NO_IMAGE_KHR) { | 30 if (egl_image_for_unbind_ != EGL_NO_IMAGE_KHR) { |
32 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), | 31 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), |
33 egl_image_for_unbind_); | 32 egl_image_for_unbind_); |
34 egl_image_for_unbind_ = EGL_NO_IMAGE_KHR; | 33 egl_image_for_unbind_ = EGL_NO_IMAGE_KHR; |
35 } | 34 } |
36 if (texture_id_for_unbind_) { | 35 if (texture_id_for_unbind_) { |
37 glDeleteTextures(1, &texture_id_for_unbind_); | 36 glDeleteTextures(1, &texture_id_for_unbind_); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 108 |
110 glEGLImageTargetTexture2DOES(target_, egl_image_for_unbind_); | 109 glEGLImageTargetTexture2DOES(target_, egl_image_for_unbind_); |
111 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 110 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
112 } | 111 } |
113 | 112 |
114 void GLImageAndroidNativeBuffer::SetReleaseAfterUse() { | 113 void GLImageAndroidNativeBuffer::SetReleaseAfterUse() { |
115 release_after_use_ = true; | 114 release_after_use_ = true; |
116 } | 115 } |
117 | 116 |
118 } // namespace gfx | 117 } // namespace gfx |
OLD | NEW |