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

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

Issue 1422563002: [Ozone] Enables overlay render format setting path and by default use UYVY (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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_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/gpu/drm_device.h" 10 #include "ui/ozone/platform/drm/gpu/drm_device.h"
11 11
12 namespace ui { 12 namespace ui {
13 13
14 namespace {
15
16 // Pixel configuration for the current buffer format.
17 // TODO(dnicoara) These will need to change once we query the hardware for
18 // supported configurations.
19 const uint8_t kColorDepth = 24;
20 const uint8_t kPixelDepth = 32;
21
22 } // namespace
23
24 GbmBufferBase::GbmBufferBase(const scoped_refptr<DrmDevice>& drm, 14 GbmBufferBase::GbmBufferBase(const scoped_refptr<DrmDevice>& drm,
25 gbm_bo* bo, 15 gbm_bo* bo,
26 bool scanout) 16 bool scanout)
27 : drm_(drm), bo_(bo) { 17 : drm_(drm), bo_(bo) {
28 if (scanout) { 18 if (scanout) {
29 if (!drm_->AddFramebuffer(gbm_bo_get_width(bo), gbm_bo_get_height(bo),
30 kColorDepth, kPixelDepth, gbm_bo_get_stride(bo),
31 gbm_bo_get_handle(bo).u32, &framebuffer_)) {
32 PLOG(ERROR) << "Failed to register buffer";
33 return;
34 }
35
36 fb_pixel_format_ = gbm_bo_get_format(bo); 19 fb_pixel_format_ = gbm_bo_get_format(bo);
37 if (fb_pixel_format_ == GBM_FORMAT_ARGB8888) 20 if (fb_pixel_format_ == GBM_FORMAT_ARGB8888)
38 fb_pixel_format_ = GBM_FORMAT_XRGB8888; 21 fb_pixel_format_ = GBM_FORMAT_XRGB8888;
39 22
40 // For now, we always create a frame buffer of 24 bit color depth and 23 // For now, we only support XRGB and UYVY format.
41 // support only XRGB format. 24 DCHECK(fb_pixel_format_ == GBM_FORMAT_XRGB8888 ||
42 DCHECK(fb_pixel_format_ == GBM_FORMAT_XRGB8888); 25 fb_pixel_format_ == GBM_FORMAT_UYVY);
26
27 uint32_t handles[4] = {0};
28 handles[0] = gbm_bo_get_handle(bo).u32;
29 uint32_t strides[4] = {0};
30 strides[0] = gbm_bo_get_stride(bo);
31 uint32_t offsets[4] = {0};
32
33 if (!drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo),
34 fb_pixel_format_, handles, strides, offsets,
35 &framebuffer_, 0)) {
36 PLOG(ERROR) << "Failed to register buffer";
37 return;
38 }
43 } 39 }
44 } 40 }
45 41
46 GbmBufferBase::~GbmBufferBase() { 42 GbmBufferBase::~GbmBufferBase() {
47 if (framebuffer_) 43 if (framebuffer_)
48 drm_->RemoveFramebuffer(framebuffer_); 44 drm_->RemoveFramebuffer(framebuffer_);
49 } 45 }
50 46
51 uint32_t GbmBufferBase::GetFramebufferId() const { 47 uint32_t GbmBufferBase::GetFramebufferId() const {
52 return framebuffer_; 48 return framebuffer_;
53 } 49 }
54 50
55 uint32_t GbmBufferBase::GetHandle() const { 51 uint32_t GbmBufferBase::GetHandle() const {
56 return gbm_bo_get_handle(bo_).u32; 52 return gbm_bo_get_handle(bo_).u32;
57 } 53 }
58 54
59 gfx::Size GbmBufferBase::GetSize() const { 55 gfx::Size GbmBufferBase::GetSize() const {
60 return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_)); 56 return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_));
61 } 57 }
62 58
63 uint32_t GbmBufferBase::GetFramebufferPixelFormat() const { 59 uint32_t GbmBufferBase::GetFramebufferPixelFormat() const {
64 return fb_pixel_format_; 60 return fb_pixel_format_;
65 } 61 }
66 62
67 bool GbmBufferBase::RequiresGlFinish() const { 63 bool GbmBufferBase::RequiresGlFinish() const {
68 return !drm_->is_primary_device(); 64 return !drm_->is_primary_device();
69 } 65 }
70 66
71 } // namespace ui 67 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698