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

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

Issue 1483633002: ozone: support gfx::BufferFormat::RGBX_8888 as a native pixmap format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gl_image_ozone_native_pixmap also, which gl_unittests check Created 5 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
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_buffer_base.h ('k') | no next file » | 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/drm/gpu/gbm_buffer_base.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_buffer_base.h"
6 6
7 #include <gbm.h> 7 #include <gbm.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/ozone/platform/drm/common/drm_util.h"
10 #include "ui/ozone/platform/drm/gpu/drm_device.h" 11 #include "ui/ozone/platform/drm/gpu/drm_device.h"
11 12
12 namespace ui { 13 namespace ui {
13 14
14 GbmBufferBase::GbmBufferBase(const scoped_refptr<DrmDevice>& drm, 15 GbmBufferBase::GbmBufferBase(const scoped_refptr<DrmDevice>& drm,
15 gbm_bo* bo, 16 gbm_bo* bo,
16 bool scanout) 17 gfx::BufferFormat format,
18 gfx::BufferUsage usage)
17 : drm_(drm), bo_(bo) { 19 : drm_(drm), bo_(bo) {
18 if (scanout) { 20 if (usage == gfx::BufferUsage::SCANOUT) {
19 fb_pixel_format_ = gbm_bo_get_format(bo); 21 framebuffer_pixel_format_ = GetFourCCFormatForFramebuffer(format);
20 if (fb_pixel_format_ == GBM_FORMAT_ARGB8888)
21 fb_pixel_format_ = GBM_FORMAT_XRGB8888;
22
23 // For now, we only support XRGB and UYVY format.
24 DCHECK(fb_pixel_format_ == GBM_FORMAT_XRGB8888 ||
25 fb_pixel_format_ == GBM_FORMAT_UYVY);
26 22
27 uint32_t handles[4] = {0}; 23 uint32_t handles[4] = {0};
28 handles[0] = gbm_bo_get_handle(bo).u32; 24 handles[0] = gbm_bo_get_handle(bo).u32;
29 uint32_t strides[4] = {0}; 25 uint32_t strides[4] = {0};
30 strides[0] = gbm_bo_get_stride(bo); 26 strides[0] = gbm_bo_get_stride(bo);
31 uint32_t offsets[4] = {0}; 27 uint32_t offsets[4] = {0};
32 28
33 if (!drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo), 29 if (!drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo),
34 fb_pixel_format_, handles, strides, offsets, 30 framebuffer_pixel_format_, handles, strides,
35 &framebuffer_, 0)) { 31 offsets, &framebuffer_, 0)) {
36 PLOG(ERROR) << "Failed to register buffer"; 32 PLOG(ERROR) << "Failed to register buffer";
37 return; 33 return;
38 } 34 }
39 } 35 }
40 } 36 }
41 37
42 GbmBufferBase::~GbmBufferBase() { 38 GbmBufferBase::~GbmBufferBase() {
43 if (framebuffer_) 39 if (framebuffer_)
44 drm_->RemoveFramebuffer(framebuffer_); 40 drm_->RemoveFramebuffer(framebuffer_);
45 } 41 }
46 42
47 uint32_t GbmBufferBase::GetFramebufferId() const { 43 uint32_t GbmBufferBase::GetFramebufferId() const {
48 return framebuffer_; 44 return framebuffer_;
49 } 45 }
50 46
51 uint32_t GbmBufferBase::GetHandle() const { 47 uint32_t GbmBufferBase::GetHandle() const {
52 return gbm_bo_get_handle(bo_).u32; 48 return gbm_bo_get_handle(bo_).u32;
53 } 49 }
54 50
55 gfx::Size GbmBufferBase::GetSize() const { 51 gfx::Size GbmBufferBase::GetSize() const {
56 return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_)); 52 return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_));
57 } 53 }
58 54
59 uint32_t GbmBufferBase::GetFramebufferPixelFormat() const { 55 uint32_t GbmBufferBase::GetFramebufferPixelFormat() const {
60 return fb_pixel_format_; 56 DCHECK(framebuffer_);
57 return framebuffer_pixel_format_;
61 } 58 }
62 59
63 bool GbmBufferBase::RequiresGlFinish() const { 60 bool GbmBufferBase::RequiresGlFinish() const {
64 return !drm_->is_primary_device(); 61 return !drm_->is_primary_device();
65 } 62 }
66 63
67 } // namespace ui 64 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_buffer_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698