Chromium Code Reviews| 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 if (i < buffer_->GetFdCount()) { |
|
dnicoara
2016/06/13 13:41:17
nit: Would you mind adding a comment explaining wh
Daniele Castagna
2016/06/13 17:07:58
Done.
| |
| 168 if (!scoped_fd.is_valid()) { | 168 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(buffer_->GetFd(i)))); |
| 169 PLOG(ERROR) << "dup"; | 169 if (!scoped_fd.is_valid()) { |
| 170 return gfx::NativePixmapHandle(); | 170 PLOG(ERROR) << "dup"; |
| 171 return gfx::NativePixmapHandle(); | |
| 172 } | |
| 173 handle.fds.emplace_back( | |
| 174 base::FileDescriptor(scoped_fd.release(), true /* auto_close */)); | |
| 171 } | 175 } |
| 172 handle.fds.emplace_back( | |
| 173 base::FileDescriptor(scoped_fd.release(), true /* auto_close */)); | |
| 174 handle.strides_and_offsets.emplace_back(buffer_->GetStride(i), | 176 handle.strides_and_offsets.emplace_back(buffer_->GetStride(i), |
| 175 buffer_->GetOffset(i)); | 177 buffer_->GetOffset(i)); |
| 176 } | 178 } |
| 177 return handle; | 179 return handle; |
| 178 } | 180 } |
| 179 | 181 |
| 180 GbmPixmap::~GbmPixmap() { | 182 GbmPixmap::~GbmPixmap() { |
| 181 } | 183 } |
| 182 | 184 |
| 183 void* GbmPixmap::GetEGLClientBuffer() const { | 185 void* GbmPixmap::GetEGLClientBuffer() const { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 DCHECK(!processing_callback_.is_null()); | 256 DCHECK(!processing_callback_.is_null()); |
| 255 if (!processing_callback_.Run(this, processed_pixmap_)) { | 257 if (!processing_callback_.Run(this, processed_pixmap_)) { |
| 256 LOG(ERROR) << "Failed processing NativePixmap"; | 258 LOG(ERROR) << "Failed processing NativePixmap"; |
| 257 return nullptr; | 259 return nullptr; |
| 258 } | 260 } |
| 259 | 261 |
| 260 return processed_pixmap_->buffer(); | 262 return processed_pixmap_->buffer(); |
| 261 } | 263 } |
| 262 | 264 |
| 263 } // namespace ui | 265 } // namespace ui |
| OLD | NEW |