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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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_buffer_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/dri/gbm_buffer.h"
6
7 #include <gbm.h>
8
9 #include "base/logging.h"
10
11 namespace ui {
12
13 namespace {
14
15 int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) {
16 switch (fmt) {
17 case SurfaceFactoryOzone::RGBA_8888:
18 return GBM_BO_FORMAT_ARGB8888;
19 case SurfaceFactoryOzone::RGBX_8888:
20 return GBM_BO_FORMAT_XRGB8888;
21 default:
22 NOTREACHED();
23 return 0;
24 }
25 }
26
27 } // namespace
28
29 GbmBuffer::GbmBuffer(DriWrapper* dri, gbm_bo* bo, bool scanout)
30 : GbmBufferBase(dri, bo, scanout) {
31 }
32
33 GbmBuffer::~GbmBuffer() {
34 if (bo())
35 gbm_bo_destroy(bo());
36 }
37
38 // static
39 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(
40 DriWrapper* dri,
41 gbm_device* device,
42 SurfaceFactoryOzone::BufferFormat format,
43 const gfx::Size& size,
44 bool scanout) {
45 unsigned flags = GBM_BO_USE_RENDERING;
46 if (scanout)
47 flags |= GBM_BO_USE_SCANOUT;
48 gbm_bo* bo = gbm_bo_create(device,
49 size.width(),
50 size.height(),
51 GetGbmFormatFromBufferFormat(format),
52 flags);
53 if (!bo)
54 return NULL;
55
56 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(dri, bo, scanout));
57 if (scanout && !buffer->GetFramebufferId())
58 return NULL;
59
60 return buffer;
61 }
62
63 GbmPixmap::GbmPixmap(scoped_refptr<GbmBuffer> buffer) : buffer_(buffer) {
64 }
65
66 GbmPixmap::~GbmPixmap() {
67 }
68
69 void* GbmPixmap::GetEGLClientBuffer() {
70 return buffer_->bo();
71 }
72
73 int GbmPixmap::GetDmaBufFd() {
74 return -1;
75 }
76
77 int GbmPixmap::GetDmaBufPitch() {
78 return -1;
79 }
80
81 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/gbm_buffer.h ('k') | ui/ozone/platform/dri/gbm_buffer_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698