Chromium Code Reviews| 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 | 7 |
| 8 #define FOURCC(a, b, c, d) \ | 8 #define FOURCC(a, b, c, d) \ |
| 9 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ | 9 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ |
| 10 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24)) | 10 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24)) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT | 130 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT |
| 131 // target, the EGL will take a reference to the dma_buf. | 131 // target, the EGL will take a reference to the dma_buf. |
| 132 std::vector<EGLint> attrs; | 132 std::vector<EGLint> attrs; |
| 133 attrs.push_back(EGL_WIDTH); | 133 attrs.push_back(EGL_WIDTH); |
| 134 attrs.push_back(size_.width()); | 134 attrs.push_back(size_.width()); |
| 135 attrs.push_back(EGL_HEIGHT); | 135 attrs.push_back(EGL_HEIGHT); |
| 136 attrs.push_back(size_.height()); | 136 attrs.push_back(size_.height()); |
| 137 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT); | 137 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT); |
| 138 attrs.push_back(FourCC(format)); | 138 attrs.push_back(FourCC(format)); |
| 139 | 139 |
| 140 const EGLint kLinuxDrmModifiers[] = {EGL_LINUX_DRM_PLANE0_MODIFIER0_EXT, | |
| 141 EGL_LINUX_DRM_PLANE1_MODIFIER0_EXT, | |
| 142 EGL_LINUX_DRM_PLANE2_MODIFIER0_EXT}; | |
| 143 | |
| 140 for (size_t plane = 0; | 144 for (size_t plane = 0; |
| 141 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); | 145 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); |
| 142 ++plane) { | 146 ++plane) { |
| 147 uint64_t modifier = pixmap->GetDmaBufModifier(plane); | |
| 143 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); | 148 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); |
| 144 attrs.push_back( | 149 attrs.push_back( |
| 145 pixmap->GetDmaBufFd(plane < pixmap->GetDmaBufFdCount() ? plane : 0)); | 150 pixmap->GetDmaBufFd(plane < pixmap->GetDmaBufFdCount() ? plane : 0)); |
| 146 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); | 151 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); |
| 147 attrs.push_back(pixmap->GetDmaBufOffset(plane)); | 152 attrs.push_back(pixmap->GetDmaBufOffset(plane)); |
| 148 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); | 153 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); |
| 149 attrs.push_back(pixmap->GetDmaBufPitch(plane)); | 154 attrs.push_back(pixmap->GetDmaBufPitch(plane)); |
| 155 attrs.push_back(kLinuxDrmModifiers[plane]); | |
|
rickyz (no longer on Chrome)
2016/06/28 06:53:13
Should we DCHECK that plane < arraysize(kLinuxDrmM
| |
| 156 attrs.push_back(modifier & 0xffffffff); | |
| 157 attrs.push_back(kLinuxDrmModifiers[plane] + 1); | |
| 158 attrs.push_back(static_cast<uint32_t>(modifier >> 32)); | |
| 150 } | 159 } |
| 151 attrs.push_back(EGL_NONE); | 160 attrs.push_back(EGL_NONE); |
| 152 | 161 |
| 153 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, | 162 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, |
| 154 static_cast<EGLClientBuffer>(nullptr), | 163 static_cast<EGLClientBuffer>(nullptr), |
| 155 &attrs[0])) { | 164 &attrs[0])) { |
| 156 return false; | 165 return false; |
| 157 } | 166 } |
| 158 } | 167 } |
| 159 | 168 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 case gfx::BufferFormat::UYVY_422: | 235 case gfx::BufferFormat::UYVY_422: |
| 227 NOTREACHED(); | 236 NOTREACHED(); |
| 228 return GL_NONE; | 237 return GL_NONE; |
| 229 } | 238 } |
| 230 | 239 |
| 231 NOTREACHED(); | 240 NOTREACHED(); |
| 232 return GL_NONE; | 241 return GL_NONE; |
| 233 } | 242 } |
| 234 | 243 |
| 235 } // namespace gl | 244 } // namespace gl |
| OLD | NEW |