OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/gfx/buffer_format_util.h" | 5 #include "ui/gfx/buffer_format_util.h" |
6 #include "ui/gl/gl_image_ozone_native_pixmap.h" | 6 #include "ui/gl/gl_image_ozone_native_pixmap.h" |
7 #include "ui/gl/gl_surface_egl.h" | 7 #include "ui/gl/gl_surface_egl.h" |
8 | 8 |
9 #define FOURCC(a, b, c, d) \ | 9 #define FOURCC(a, b, c, d) \ |
10 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ | 10 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 } | 94 } |
95 | 95 |
96 NOTREACHED(); | 96 NOTREACHED(); |
97 return 0; | 97 return 0; |
98 } | 98 } |
99 | 99 |
100 } // namespace | 100 } // namespace |
101 | 101 |
102 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size, | 102 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size, |
103 unsigned internalformat) | 103 unsigned internalformat) |
104 : GLImageEGL(size), internalformat_(internalformat) {} | 104 : GLImageEGL(size), |
105 internalformat_(internalformat), | |
106 has_image_flush_external_( | |
107 GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_flush_external")) {} | |
105 | 108 |
106 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() { | 109 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() { |
107 } | 110 } |
108 | 111 |
109 bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap, | 112 bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap, |
110 gfx::BufferFormat format) { | 113 gfx::BufferFormat format) { |
111 DCHECK(!pixmap_); | 114 DCHECK(!pixmap_); |
112 if (pixmap->GetEGLClientBuffer()) { | 115 if (pixmap->GetEGLClientBuffer()) { |
113 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; | 116 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; |
114 if (!GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR, | 117 if (!GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 gfx::AcceleratedWidget widget, | 204 gfx::AcceleratedWidget widget, |
202 int z_order, | 205 int z_order, |
203 gfx::OverlayTransform transform, | 206 gfx::OverlayTransform transform, |
204 const gfx::Rect& bounds_rect, | 207 const gfx::Rect& bounds_rect, |
205 const gfx::RectF& crop_rect) { | 208 const gfx::RectF& crop_rect) { |
206 DCHECK(pixmap_); | 209 DCHECK(pixmap_); |
207 return pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect, | 210 return pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect, |
208 crop_rect); | 211 crop_rect); |
209 } | 212 } |
210 | 213 |
214 void GLImageOzoneNativePixmap::Flush() { | |
215 if (has_image_flush_external_) { | |
liberato (no reviews please)
2016/07/14 14:38:35
random nit: can early out and avoid the indent.
| |
216 EGLDisplay display = GLSurfaceEGL::GetHardwareDisplay(); | |
217 const EGLAttrib attribs[] = { | |
218 EGL_NONE, | |
219 }; | |
220 if (!eglImageFlushExternalEXT(display, egl_image_, attribs)) { | |
221 LOG(ERROR) << "Failed to flush rendering"; | |
222 return; | |
223 } | |
224 } | |
225 } | |
226 | |
211 void GLImageOzoneNativePixmap::OnMemoryDump( | 227 void GLImageOzoneNativePixmap::OnMemoryDump( |
212 base::trace_event::ProcessMemoryDump* pmd, | 228 base::trace_event::ProcessMemoryDump* pmd, |
213 uint64_t process_tracing_id, | 229 uint64_t process_tracing_id, |
214 const std::string& dump_name) { | 230 const std::string& dump_name) { |
215 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 | 231 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 |
216 } | 232 } |
217 | 233 |
218 // static | 234 // static |
219 unsigned GLImageOzoneNativePixmap::GetInternalFormatForTesting( | 235 unsigned GLImageOzoneNativePixmap::GetInternalFormatForTesting( |
220 gfx::BufferFormat format) { | 236 gfx::BufferFormat format) { |
(...skipping 20 matching lines...) Expand all Loading... | |
241 case gfx::BufferFormat::UYVY_422: | 257 case gfx::BufferFormat::UYVY_422: |
242 NOTREACHED(); | 258 NOTREACHED(); |
243 return GL_NONE; | 259 return GL_NONE; |
244 } | 260 } |
245 | 261 |
246 NOTREACHED(); | 262 NOTREACHED(); |
247 return GL_NONE; | 263 return GL_NONE; |
248 } | 264 } |
249 | 265 |
250 } // namespace gl | 266 } // namespace gl |
OLD | NEW |