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

Side by Side Diff: ui/ozone/platform/dri/gbm_buffer.cc

Issue 667293002: [Ozone-GBM] Use dma_buf with surfaceless (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « ui/ozone/platform/dri/gbm_buffer.h ('k') | ui/ozone/platform/dri/gbm_surface_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dri/gbm_buffer.h" 5 #include "ui/ozone/platform/dri/gbm_buffer.h"
6 6
7 #include <drm.h>
8 #include <fcntl.h>
7 #include <gbm.h> 9 #include <gbm.h>
10 #include <xf86drm.h>
8 11
9 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "ui/ozone/platform/dri/dri_wrapper.h"
10 14
11 namespace ui { 15 namespace ui {
12 16
13 namespace { 17 namespace {
14 18
15 int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) { 19 int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) {
16 switch (fmt) { 20 switch (fmt) {
17 case SurfaceFactoryOzone::RGBA_8888: 21 case SurfaceFactoryOzone::RGBA_8888:
18 return GBM_BO_FORMAT_ARGB8888; 22 return GBM_BO_FORMAT_ARGB8888;
19 case SurfaceFactoryOzone::RGBX_8888: 23 case SurfaceFactoryOzone::RGBX_8888:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 if (!bo) 57 if (!bo)
54 return NULL; 58 return NULL;
55 59
56 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(dri, bo, scanout)); 60 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(dri, bo, scanout));
57 if (scanout && !buffer->GetFramebufferId()) 61 if (scanout && !buffer->GetFramebufferId())
58 return NULL; 62 return NULL;
59 63
60 return buffer; 64 return buffer;
61 } 65 }
62 66
63 GbmPixmap::GbmPixmap(scoped_refptr<GbmBuffer> buffer) : buffer_(buffer) { 67 GbmPixmap::GbmPixmap(scoped_refptr<GbmBuffer> buffer)
68 : buffer_(buffer), dma_buf_(-1) {
69 }
70
71 bool GbmPixmap::Initialize(DriWrapper* dri) {
72 if (drmPrimeHandleToFD(dri->get_fd(),
73 buffer_->GetHandle(),
74 DRM_CLOEXEC,
75 &dma_buf_)) {
76 LOG(ERROR) << "Failed to export buffer to dma_buf";
77 return false;
78 }
79
80 return true;
64 } 81 }
65 82
66 GbmPixmap::~GbmPixmap() { 83 GbmPixmap::~GbmPixmap() {
84 if (dma_buf_ > 0)
85 close(dma_buf_);
67 } 86 }
68 87
69 void* GbmPixmap::GetEGLClientBuffer() { 88 void* GbmPixmap::GetEGLClientBuffer() {
70 return buffer_->bo(); 89 return NULL;
71 } 90 }
72 91
73 int GbmPixmap::GetDmaBufFd() { 92 int GbmPixmap::GetDmaBufFd() {
74 return -1; 93 return dma_buf_;
75 } 94 }
76 95
77 int GbmPixmap::GetDmaBufPitch() { 96 int GbmPixmap::GetDmaBufPitch() {
78 return -1; 97 return gbm_bo_get_stride(buffer_->bo());
79 } 98 }
80 99
81 } // namespace ui 100 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/gbm_buffer.h ('k') | ui/ozone/platform/dri/gbm_surface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698