OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gl/gl_image_linux_dma_buffer.h" | 5 #include "ui/gl/gl_image_linux_dma_buffer.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #define FOURCC(a, b, c, d) \ | 9 #define FOURCC(a, b, c, d) \ |
10 ((static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \ | 10 ((static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \ |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } // namespace | 90 } // namespace |
91 | 91 |
92 GLImageLinuxDMABuffer::GLImageLinuxDMABuffer(const gfx::Size& size, | 92 GLImageLinuxDMABuffer::GLImageLinuxDMABuffer(const gfx::Size& size, |
93 unsigned internalformat) | 93 unsigned internalformat) |
94 : GLImageEGL(size), internalformat_(internalformat) { | 94 : GLImageEGL(size), internalformat_(internalformat) { |
95 } | 95 } |
96 | 96 |
97 GLImageLinuxDMABuffer::~GLImageLinuxDMABuffer() { | 97 GLImageLinuxDMABuffer::~GLImageLinuxDMABuffer() { |
98 } | 98 } |
99 | 99 |
100 bool GLImageLinuxDMABuffer::Initialize(const base::FileDescriptor& handle, | 100 bool GLImageLinuxDMABuffer::Initialize( |
101 gfx::GpuMemoryBuffer::Format format, | 101 int num_buffers, |
102 int pitch) { | 102 const std::vector<base::FileDescriptor>& handles, |
| 103 const std::vector<gfx::GpuMemoryBuffer::Format>& formats, |
| 104 const std::vector<int>& pitches) { |
| 105 // TODO(emircan): See http://crbug.com/439520; support passing multiple |
| 106 // buffers when new multi-planar formats are added. |
| 107 if (num_buffers != 1) { |
| 108 NOTIMPLEMENTED(); |
| 109 return false; |
| 110 } |
| 111 const base::FileDescriptor& handle = handles[0]; |
| 112 const gfx::GpuMemoryBuffer::Format& format = formats[0]; |
| 113 int pitch = pitches[0]; |
| 114 |
103 if (!ValidFormat(internalformat_, format)) { | 115 if (!ValidFormat(internalformat_, format)) { |
104 LOG(ERROR) << "Invalid format: " << internalformat_; | 116 LOG(ERROR) << "Invalid format: " << internalformat_; |
105 return false; | 117 return false; |
106 } | 118 } |
107 | 119 |
108 if (!IsHandleValid(handle)) { | 120 if (!IsHandleValid(handle)) { |
109 LOG(ERROR) << "Invalid file descriptor: " << handle.fd; | 121 LOG(ERROR) << "Invalid file descriptor: " << handle.fd; |
110 return false; | 122 return false; |
111 } | 123 } |
112 | 124 |
(...skipping 10 matching lines...) Expand all Loading... |
123 EGL_DMA_BUF_PLANE0_OFFSET_EXT, | 135 EGL_DMA_BUF_PLANE0_OFFSET_EXT, |
124 0, | 136 0, |
125 EGL_DMA_BUF_PLANE0_PITCH_EXT, | 137 EGL_DMA_BUF_PLANE0_PITCH_EXT, |
126 pitch, | 138 pitch, |
127 EGL_NONE}; | 139 EGL_NONE}; |
128 return GLImageEGL::Initialize( | 140 return GLImageEGL::Initialize( |
129 EGL_LINUX_DMA_BUF_EXT, static_cast<EGLClientBuffer>(NULL), attrs); | 141 EGL_LINUX_DMA_BUF_EXT, static_cast<EGLClientBuffer>(NULL), attrs); |
130 } | 142 } |
131 | 143 |
132 } // namespace gfx | 144 } // namespace gfx |
OLD | NEW |