Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: ui/ozone/platform/drm/gpu/gbm_buffer.cc

Issue 1263323004: Add NativePixmapHandle type & interface for exporting them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unnecesary #include and DCHECK msgs Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
14 #include "ui/gfx/geometry/size_conversions.h" 14 #include "ui/gfx/geometry/size_conversions.h"
15 #include "ui/gfx/native_pixmap_handle_ozone.h"
15 #include "ui/ozone/platform/drm/gpu/drm_window.h" 16 #include "ui/ozone/platform/drm/gpu/drm_window.h"
16 #include "ui/ozone/platform/drm/gpu/gbm_device.h" 17 #include "ui/ozone/platform/drm/gpu/gbm_device.h"
17 18
18 namespace ui { 19 namespace ui {
19 20
20 namespace { 21 namespace {
21 22
22 int GetGbmFormatFromBufferFormat(gfx::BufferFormat fmt) { 23 int GetGbmFormatFromBufferFormat(gfx::BufferFormat fmt) {
23 switch (fmt) { 24 switch (fmt) {
24 case gfx::BufferFormat::BGRA_8888: 25 case gfx::BufferFormat::BGRA_8888:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 88 }
88 89
89 void GbmPixmap::SetScalingCallback(const ScalingCallback& scaling_callback) { 90 void GbmPixmap::SetScalingCallback(const ScalingCallback& scaling_callback) {
90 scaling_callback_ = scaling_callback; 91 scaling_callback_ = scaling_callback;
91 } 92 }
92 93
93 scoped_refptr<NativePixmap> GbmPixmap::GetScaledPixmap(gfx::Size new_size) { 94 scoped_refptr<NativePixmap> GbmPixmap::GetScaledPixmap(gfx::Size new_size) {
94 return scaling_callback_.Run(new_size); 95 return scaling_callback_.Run(new_size);
95 } 96 }
96 97
98 gfx::NativePixmapHandle GbmPixmap::ExportHandle() {
99 gfx::NativePixmapHandle handle;
100
101 int dmabuf_fd = dup(dma_buf_);
dshwang 2015/08/06 08:14:48 other code uses HANDLE_EINTR with dup() int dmabuf
spang 2015/08/06 20:53:29 Done.
102 if (dmabuf_fd < 0) {
103 PLOG(ERROR) << "dup";
104 return handle;
105 }
106
107 handle.fd = base::FileDescriptor(base::ScopedFD(dmabuf_fd));
108 handle.stride = gbm_bo_get_stride(buffer_->bo());
109 return handle;
110 }
111
97 GbmPixmap::~GbmPixmap() { 112 GbmPixmap::~GbmPixmap() {
98 if (dma_buf_ > 0) 113 if (dma_buf_ > 0)
99 close(dma_buf_); 114 close(dma_buf_);
100 } 115 }
101 116
102 void* GbmPixmap::GetEGLClientBuffer() { 117 void* GbmPixmap::GetEGLClientBuffer() {
103 return nullptr; 118 return nullptr;
104 } 119 }
105 120
106 int GbmPixmap::GetDmaBufFd() { 121 int GbmPixmap::GetDmaBufFd() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 158
144 gfx::Size pixmap_size = buffer_->GetSize(); 159 gfx::Size pixmap_size = buffer_->GetSize();
145 // If the required size is not integer-sized, round it to the next integer. 160 // If the required size is not integer-sized, round it to the next integer.
146 *required_size = gfx::ToCeiledSize( 161 *required_size = gfx::ToCeiledSize(
147 gfx::SizeF(display_bounds.width() / crop_rect.width(), 162 gfx::SizeF(display_bounds.width() / crop_rect.width(),
148 display_bounds.height() / crop_rect.height())); 163 display_bounds.height() / crop_rect.height()));
149 return pixmap_size != *required_size; 164 return pixmap_size != *required_size;
150 } 165 }
151 166
152 } // namespace ui 167 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698