| 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 | 8 |
| 8 #define FOURCC(a, b, c, d) \ | 9 #define FOURCC(a, b, c, d) \ |
| 9 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ | 10 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ |
| 10 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24)) | 11 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24)) |
| 11 | 12 |
| 12 #define DRM_FORMAT_R8 FOURCC('R', '8', ' ', ' ') | 13 #define DRM_FORMAT_R8 FOURCC('R', '8', ' ', ' ') |
| 13 #define DRM_FORMAT_RGB565 FOURCC('R', 'G', '1', '6') | 14 #define DRM_FORMAT_RGB565 FOURCC('R', 'G', '1', '6') |
| 14 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4') | 15 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4') |
| 15 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4') | 16 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4') |
| 16 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4') | 17 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4') |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT | 131 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT |
| 131 // target, the EGL will take a reference to the dma_buf. | 132 // target, the EGL will take a reference to the dma_buf. |
| 132 std::vector<EGLint> attrs; | 133 std::vector<EGLint> attrs; |
| 133 attrs.push_back(EGL_WIDTH); | 134 attrs.push_back(EGL_WIDTH); |
| 134 attrs.push_back(size_.width()); | 135 attrs.push_back(size_.width()); |
| 135 attrs.push_back(EGL_HEIGHT); | 136 attrs.push_back(EGL_HEIGHT); |
| 136 attrs.push_back(size_.height()); | 137 attrs.push_back(size_.height()); |
| 137 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT); | 138 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT); |
| 138 attrs.push_back(FourCC(format)); | 139 attrs.push_back(FourCC(format)); |
| 139 | 140 |
| 141 const EGLint kLinuxDrmModifiers[] = {EGL_LINUX_DRM_PLANE0_MODIFIER0_EXT, |
| 142 EGL_LINUX_DRM_PLANE1_MODIFIER0_EXT, |
| 143 EGL_LINUX_DRM_PLANE2_MODIFIER0_EXT}; |
| 144 bool has_dma_buf_import_modifier = |
| 145 GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_dma_buf_import_modifiers"); |
| 146 |
| 140 for (size_t plane = 0; | 147 for (size_t plane = 0; |
| 141 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); | 148 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); |
| 142 ++plane) { | 149 ++plane) { |
| 143 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); | 150 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); |
| 144 attrs.push_back( | 151 attrs.push_back( |
| 145 pixmap->GetDmaBufFd(plane < pixmap->GetDmaBufFdCount() ? plane : 0)); | 152 pixmap->GetDmaBufFd(plane < pixmap->GetDmaBufFdCount() ? plane : 0)); |
| 146 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); | 153 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); |
| 147 attrs.push_back(pixmap->GetDmaBufOffset(plane)); | 154 attrs.push_back(pixmap->GetDmaBufOffset(plane)); |
| 148 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); | 155 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); |
| 149 attrs.push_back(pixmap->GetDmaBufPitch(plane)); | 156 attrs.push_back(pixmap->GetDmaBufPitch(plane)); |
| 157 if (has_dma_buf_import_modifier) { |
| 158 uint64_t modifier = pixmap->GetDmaBufModifier(plane); |
| 159 DCHECK(plane < arraysize(kLinuxDrmModifiers)); |
| 160 attrs.push_back(kLinuxDrmModifiers[plane]); |
| 161 attrs.push_back(modifier & 0xffffffff); |
| 162 attrs.push_back(kLinuxDrmModifiers[plane] + 1); |
| 163 attrs.push_back(static_cast<uint32_t>(modifier >> 32)); |
| 164 } |
| 150 } | 165 } |
| 151 attrs.push_back(EGL_NONE); | 166 attrs.push_back(EGL_NONE); |
| 152 | 167 |
| 153 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, | 168 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, |
| 154 static_cast<EGLClientBuffer>(nullptr), | 169 static_cast<EGLClientBuffer>(nullptr), |
| 155 &attrs[0])) { | 170 &attrs[0])) { |
| 156 return false; | 171 return false; |
| 157 } | 172 } |
| 158 } | 173 } |
| 159 | 174 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 case gfx::BufferFormat::UYVY_422: | 241 case gfx::BufferFormat::UYVY_422: |
| 227 NOTREACHED(); | 242 NOTREACHED(); |
| 228 return GL_NONE; | 243 return GL_NONE; |
| 229 } | 244 } |
| 230 | 245 |
| 231 NOTREACHED(); | 246 NOTREACHED(); |
| 232 return GL_NONE; | 247 return GL_NONE; |
| 233 } | 248 } |
| 234 | 249 |
| 235 } // namespace gl | 250 } // namespace gl |
| OLD | NEW |