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

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

Issue 1314553002: Move Format checks to HardwareDisplayPlane (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes Created 5 years, 3 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
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 { 14 namespace {
15 15
16 // Pixel configuration for the current buffer format. 16 // Pixel configuration for the current buffer format.
17 // TODO(dnicoara) These will need to change once we query the hardware for 17 // TODO(dnicoara) These will need to change once we query the hardware for
18 // supported configurations. 18 // supported configurations.
19 const uint8_t kColorDepth = 24; 19 const uint8_t kColorDepth = 24;
20 const uint8_t kPixelDepth = 32; 20 const uint8_t kPixelDepth = 32;
21 21
22 } // namespace 22 } // namespace
23 23
24 GbmBufferBase::GbmBufferBase(const scoped_refptr<DrmDevice>& drm, 24 GbmBufferBase::GbmBufferBase(const scoped_refptr<DrmDevice>& drm,
25 gbm_bo* bo, 25 gbm_bo* bo,
26 bool scanout) 26 bool scanout)
27 : drm_(drm), bo_(bo) { 27 : drm_(drm), bo_(bo) {
28 if (scanout && 28 if (scanout) {
29 !drm_->AddFramebuffer(gbm_bo_get_width(bo), gbm_bo_get_height(bo), 29 if (!drm_->AddFramebuffer(gbm_bo_get_width(bo), gbm_bo_get_height(bo),
30 kColorDepth, kPixelDepth, gbm_bo_get_stride(bo), 30 kColorDepth, kPixelDepth, gbm_bo_get_stride(bo),
31 gbm_bo_get_handle(bo).u32, &framebuffer_)) 31 gbm_bo_get_handle(bo).u32, &framebuffer_)) {
32 PLOG(ERROR) << "Failed to register buffer"; 32 PLOG(ERROR) << "Failed to register buffer";
33 return;
34 }
35
36 fb_pixel_format_ = gbm_bo_get_format(bo);
37 if (fb_pixel_format_ == GBM_FORMAT_ARGB8888)
38 fb_pixel_format_ = GBM_FORMAT_XRGB8888;
39
40 // For now, we always create a frame buffer of 24 bit color depth and
41 // support only XRGB format.
42 DCHECK(fb_pixel_format_ == GBM_FORMAT_XRGB8888);
43 }
33 } 44 }
34 45
35 GbmBufferBase::~GbmBufferBase() { 46 GbmBufferBase::~GbmBufferBase() {
36 if (framebuffer_) 47 if (framebuffer_)
37 drm_->RemoveFramebuffer(framebuffer_); 48 drm_->RemoveFramebuffer(framebuffer_);
38 } 49 }
39 50
40 uint32_t GbmBufferBase::GetFramebufferId() const { 51 uint32_t GbmBufferBase::GetFramebufferId() const {
41 return framebuffer_; 52 return framebuffer_;
42 } 53 }
43 54
44 uint32_t GbmBufferBase::GetHandle() const { 55 uint32_t GbmBufferBase::GetHandle() const {
45 return gbm_bo_get_handle(bo_).u32; 56 return gbm_bo_get_handle(bo_).u32;
46 } 57 }
47 58
48 gfx::Size GbmBufferBase::GetSize() const { 59 gfx::Size GbmBufferBase::GetSize() const {
49 return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_)); 60 return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_));
50 } 61 }
51 62
52 uint32_t GbmBufferBase::GetFormat() const { 63 uint32_t GbmBufferBase::GetFramebufferPixelFormat() const {
53 return gbm_bo_get_format(bo_); 64 return fb_pixel_format_;
54 } 65 }
55 66
56 } // namespace ui 67 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_buffer_base.h ('k') | ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698