| 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_) |
| 216 return; |
| 217 |
| 218 EGLDisplay display = GLSurfaceEGL::GetHardwareDisplay(); |
| 219 const EGLAttrib attribs[] = { |
| 220 EGL_NONE, |
| 221 }; |
| 222 if (!eglImageFlushExternalEXT(display, egl_image_, attribs)) { |
| 223 LOG(ERROR) << "Failed to flush rendering"; |
| 224 return; |
| 225 } |
| 226 } |
| 227 |
| 211 void GLImageOzoneNativePixmap::OnMemoryDump( | 228 void GLImageOzoneNativePixmap::OnMemoryDump( |
| 212 base::trace_event::ProcessMemoryDump* pmd, | 229 base::trace_event::ProcessMemoryDump* pmd, |
| 213 uint64_t process_tracing_id, | 230 uint64_t process_tracing_id, |
| 214 const std::string& dump_name) { | 231 const std::string& dump_name) { |
| 215 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 | 232 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 |
| 216 } | 233 } |
| 217 | 234 |
| 218 // static | 235 // static |
| 219 unsigned GLImageOzoneNativePixmap::GetInternalFormatForTesting( | 236 unsigned GLImageOzoneNativePixmap::GetInternalFormatForTesting( |
| 220 gfx::BufferFormat format) { | 237 gfx::BufferFormat format) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 241 case gfx::BufferFormat::UYVY_422: | 258 case gfx::BufferFormat::UYVY_422: |
| 242 NOTREACHED(); | 259 NOTREACHED(); |
| 243 return GL_NONE; | 260 return GL_NONE; |
| 244 } | 261 } |
| 245 | 262 |
| 246 NOTREACHED(); | 263 NOTREACHED(); |
| 247 return GL_NONE; | 264 return GL_NONE; |
| 248 } | 265 } |
| 249 | 266 |
| 250 } // namespace gl | 267 } // namespace gl |
| OLD | NEW |