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 | |
144 for (size_t plane = 0; | 140 for (size_t plane = 0; |
145 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); | 141 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); |
146 ++plane) { | 142 ++plane) { |
147 uint64_t modifier = pixmap->GetDmaBufModifier(plane); | |
148 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); | 143 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); |
149 attrs.push_back( | 144 attrs.push_back( |
150 pixmap->GetDmaBufFd(plane < pixmap->GetDmaBufFdCount() ? plane : 0)); | 145 pixmap->GetDmaBufFd(plane < pixmap->GetDmaBufFdCount() ? plane : 0)); |
151 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); | 146 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); |
152 attrs.push_back(pixmap->GetDmaBufOffset(plane)); | 147 attrs.push_back(pixmap->GetDmaBufOffset(plane)); |
153 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); | 148 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); |
154 attrs.push_back(pixmap->GetDmaBufPitch(plane)); | 149 attrs.push_back(pixmap->GetDmaBufPitch(plane)); |
155 DCHECK(plane < arraysize(kLinuxDrmModifiers)); | |
156 attrs.push_back(kLinuxDrmModifiers[plane]); | |
157 attrs.push_back(modifier & 0xffffffff); | |
158 attrs.push_back(kLinuxDrmModifiers[plane] + 1); | |
159 attrs.push_back(static_cast<uint32_t>(modifier >> 32)); | |
160 } | 150 } |
161 attrs.push_back(EGL_NONE); | 151 attrs.push_back(EGL_NONE); |
162 | 152 |
163 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, | 153 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, |
164 static_cast<EGLClientBuffer>(nullptr), | 154 static_cast<EGLClientBuffer>(nullptr), |
165 &attrs[0])) { | 155 &attrs[0])) { |
166 return false; | 156 return false; |
167 } | 157 } |
168 } | 158 } |
169 | 159 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 case gfx::BufferFormat::UYVY_422: | 226 case gfx::BufferFormat::UYVY_422: |
237 NOTREACHED(); | 227 NOTREACHED(); |
238 return GL_NONE; | 228 return GL_NONE; |
239 } | 229 } |
240 | 230 |
241 NOTREACHED(); | 231 NOTREACHED(); |
242 return GL_NONE; | 232 return GL_NONE; |
243 } | 233 } |
244 | 234 |
245 } // namespace gl | 235 } // namespace gl |
OLD | NEW |