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

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: 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>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 void GbmPixmap::SetScalingCallback(const ScalingCallback& scaling_callback) { 89 void GbmPixmap::SetScalingCallback(const ScalingCallback& scaling_callback) {
90 scaling_callback_ = scaling_callback; 90 scaling_callback_ = scaling_callback;
91 } 91 }
92 92
93 scoped_refptr<NativePixmap> GbmPixmap::GetScaledPixmap(gfx::Size new_size) { 93 scoped_refptr<NativePixmap> GbmPixmap::GetScaledPixmap(gfx::Size new_size) {
94 return scaling_callback_.Run(new_size); 94 return scaling_callback_.Run(new_size);
95 } 95 }
96 96
97 bool GbmPixmap::ExportHandle(gfx::NativePixmapHandle* handle) {
98 int dmabuf_fd = dup(dma_buf_);
99 if (dmabuf_fd < 0) {
100 PLOG(ERROR) << "dup";
101 return false;
102 }
103
104 handle->fd = base::FileDescriptor(base::ScopedFD(dmabuf_fd));
105 handle->stride = gbm_bo_get_stride(buffer_->bo());
106 return true;
107 }
108
97 GbmPixmap::~GbmPixmap() { 109 GbmPixmap::~GbmPixmap() {
98 if (dma_buf_ > 0) 110 if (dma_buf_ > 0)
99 close(dma_buf_); 111 close(dma_buf_);
100 } 112 }
101 113
102 void* GbmPixmap::GetEGLClientBuffer() { 114 void* GbmPixmap::GetEGLClientBuffer() {
103 return nullptr; 115 return nullptr;
104 } 116 }
105 117
106 int GbmPixmap::GetDmaBufFd() { 118 int GbmPixmap::GetDmaBufFd() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 155
144 gfx::Size pixmap_size = buffer_->GetSize(); 156 gfx::Size pixmap_size = buffer_->GetSize();
145 // If the required size is not integer-sized, round it to the next integer. 157 // If the required size is not integer-sized, round it to the next integer.
146 *required_size = gfx::ToCeiledSize( 158 *required_size = gfx::ToCeiledSize(
147 gfx::SizeF(display_bounds.width() / crop_rect.width(), 159 gfx::SizeF(display_bounds.width() / crop_rect.width(),
148 display_bounds.height() / crop_rect.height())); 160 display_bounds.height() / crop_rect.height()));
149 return pixmap_size != *required_size; 161 return pixmap_size != *required_size;
150 } 162 }
151 163
152 } // namespace ui 164 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698