| 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/ozone/platform/drm/gpu/gbm_buffer.h" | 5 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" |
| 6 | 6 |
| 7 #include <drm.h> | 7 #include <drm.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <gbm.h> | 9 #include <gbm.h> |
| 10 #include <xf86drm.h> | 10 #include <xf86drm.h> |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 void GbmPixmap::SetProcessingCallback( | 157 void GbmPixmap::SetProcessingCallback( |
| 158 const ProcessingCallback& processing_callback) { | 158 const ProcessingCallback& processing_callback) { |
| 159 DCHECK(processing_callback_.is_null()); | 159 DCHECK(processing_callback_.is_null()); |
| 160 processing_callback_ = processing_callback; | 160 processing_callback_ = processing_callback; |
| 161 } | 161 } |
| 162 | 162 |
| 163 gfx::NativePixmapHandle GbmPixmap::ExportHandle() { | 163 gfx::NativePixmapHandle GbmPixmap::ExportHandle() { |
| 164 gfx::NativePixmapHandle handle; | 164 gfx::NativePixmapHandle handle; |
| 165 for (size_t i = 0; | 165 for (size_t i = 0; |
| 166 i < gfx::NumberOfPlanesForBufferFormat(buffer_->GetFormat()); ++i) { | 166 i < gfx::NumberOfPlanesForBufferFormat(buffer_->GetFormat()); ++i) { |
| 167 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(buffer_->GetFd(i)))); | 167 // Some formats (e.g: YVU_420) might have less than one fd per plane. |
| 168 if (!scoped_fd.is_valid()) { | 168 if (i < buffer_->GetFdCount()) { |
| 169 PLOG(ERROR) << "dup"; | 169 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(buffer_->GetFd(i)))); |
| 170 return gfx::NativePixmapHandle(); | 170 if (!scoped_fd.is_valid()) { |
| 171 PLOG(ERROR) << "dup"; |
| 172 return gfx::NativePixmapHandle(); |
| 173 } |
| 174 handle.fds.emplace_back( |
| 175 base::FileDescriptor(scoped_fd.release(), true /* auto_close */)); |
| 171 } | 176 } |
| 172 handle.fds.emplace_back( | |
| 173 base::FileDescriptor(scoped_fd.release(), true /* auto_close */)); | |
| 174 handle.strides_and_offsets.emplace_back(buffer_->GetStride(i), | 177 handle.strides_and_offsets.emplace_back(buffer_->GetStride(i), |
| 175 buffer_->GetOffset(i)); | 178 buffer_->GetOffset(i)); |
| 176 } | 179 } |
| 177 return handle; | 180 return handle; |
| 178 } | 181 } |
| 179 | 182 |
| 180 GbmPixmap::~GbmPixmap() { | 183 GbmPixmap::~GbmPixmap() { |
| 181 } | 184 } |
| 182 | 185 |
| 183 void* GbmPixmap::GetEGLClientBuffer() const { | 186 void* GbmPixmap::GetEGLClientBuffer() const { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 DCHECK(!processing_callback_.is_null()); | 257 DCHECK(!processing_callback_.is_null()); |
| 255 if (!processing_callback_.Run(this, processed_pixmap_)) { | 258 if (!processing_callback_.Run(this, processed_pixmap_)) { |
| 256 LOG(ERROR) << "Failed processing NativePixmap"; | 259 LOG(ERROR) << "Failed processing NativePixmap"; |
| 257 return nullptr; | 260 return nullptr; |
| 258 } | 261 } |
| 259 | 262 |
| 260 return processed_pixmap_->buffer(); | 263 return processed_pixmap_->buffer(); |
| 261 } | 264 } |
| 262 | 265 |
| 263 } // namespace ui | 266 } // namespace ui |
| OLD | NEW |