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

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

Issue 490233002: VaapiVideoAccelerator: make Vaapi accelerator work with ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on ToT Created 6 years 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/dri/gbm_buffer.h" 5 #include "ui/ozone/platform/dri/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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return NULL; 62 return NULL;
63 63
64 return buffer; 64 return buffer;
65 } 65 }
66 66
67 GbmPixmap::GbmPixmap(scoped_refptr<GbmBuffer> buffer) 67 GbmPixmap::GbmPixmap(scoped_refptr<GbmBuffer> buffer)
68 : buffer_(buffer), dma_buf_(-1) { 68 : buffer_(buffer), dma_buf_(-1) {
69 } 69 }
70 70
71 bool GbmPixmap::Initialize(DriWrapper* dri) { 71 bool GbmPixmap::Initialize(DriWrapper* dri) {
72 if (drmPrimeHandleToFD(dri->get_fd(), buffer_->GetHandle(), DRM_CLOEXEC, 72 // We want to use the GBM API because it's going to call into libdrm
73 &dma_buf_)) { 73 // which might do some optimizations on buffer allocation,
74 // especially when sharing buffers via DMABUF.
75 dma_buf_ = gbm_bo_get_fd(buffer_->bo());
76 if (dma_buf_ < 0) {
74 LOG(ERROR) << "Failed to export buffer to dma_buf"; 77 LOG(ERROR) << "Failed to export buffer to dma_buf";
75 return false; 78 return false;
76 } 79 }
77
78 return true; 80 return true;
79 } 81 }
80 82
81 GbmPixmap::~GbmPixmap() { 83 GbmPixmap::~GbmPixmap() {
82 if (dma_buf_ > 0) 84 if (dma_buf_ > 0)
83 close(dma_buf_); 85 close(dma_buf_);
84 } 86 }
85 87
86 void* GbmPixmap::GetEGLClientBuffer() { 88 void* GbmPixmap::GetEGLClientBuffer() {
87 // TODO(achaulk): change back to null when dma_buf bug is fixed. 89 // TODO(achaulk): change back to null when dma_buf bug is fixed.
88 return buffer_->bo(); 90 return buffer_->bo();
89 } 91 }
90 92
91 int GbmPixmap::GetDmaBufFd() { 93 int GbmPixmap::GetDmaBufFd() {
92 return dma_buf_; 94 return dma_buf_;
93 } 95 }
94 96
95 int GbmPixmap::GetDmaBufPitch() { 97 int GbmPixmap::GetDmaBufPitch() {
96 return gbm_bo_get_stride(buffer_->bo()); 98 return gbm_bo_get_stride(buffer_->bo());
97 } 99 }
98 100
99 } // namespace ui 101 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698