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

Side by Side Diff: ui/ozone/platform/drm/gpu/gbm_buffer.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: keep hardware overlay creating 24 bits plane 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
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.h" 5 #include "ui/ozone/platform/drm/gpu/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 13 matching lines...) Expand all
24 24
25 namespace { 25 namespace {
26 // Optimal format for rendering on overlay. 26 // Optimal format for rendering on overlay.
27 const gfx::BufferFormat kOverlayRenderFormat = gfx::BufferFormat::UYVY_422; 27 const gfx::BufferFormat kOverlayRenderFormat = gfx::BufferFormat::UYVY_422;
28 } // namespace 28 } // namespace
29 29
30 namespace ui { 30 namespace ui {
31 31
32 GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm, 32 GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm,
33 gbm_bo* bo, 33 gbm_bo* bo,
34 gfx::BufferFormat format,
34 gfx::BufferUsage usage) 35 gfx::BufferUsage usage)
35 : GbmBufferBase(gbm, bo, usage == gfx::BufferUsage::SCANOUT), 36 : GbmBufferBase(gbm, bo, usage == gfx::BufferUsage::SCANOUT),
37 format_(format),
36 usage_(usage) {} 38 usage_(usage) {}
37 39
38 GbmBuffer::~GbmBuffer() { 40 GbmBuffer::~GbmBuffer() {
39 if (bo()) 41 if (bo())
40 gbm_bo_destroy(bo()); 42 gbm_bo_destroy(bo());
41 } 43 }
42 44
43 // static 45 // static
44 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( 46 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(
45 const scoped_refptr<GbmDevice>& gbm, 47 const scoped_refptr<GbmDevice>& gbm,
46 gfx::BufferFormat format, 48 gfx::BufferFormat format,
47 const gfx::Size& size, 49 const gfx::Size& size,
48 gfx::BufferUsage usage) { 50 gfx::BufferUsage usage) {
49 TRACE_EVENT2("drm", "GbmBuffer::CreateBuffer", "device", 51 TRACE_EVENT2("drm", "GbmBuffer::CreateBuffer", "device",
50 gbm->device_path().value(), "size", size.ToString()); 52 gbm->device_path().value(), "size", size.ToString());
51 bool use_scanout = (usage == gfx::BufferUsage::SCANOUT); 53 bool use_scanout = (usage == gfx::BufferUsage::SCANOUT);
52 unsigned flags = 0; 54 unsigned flags = 0;
53 // GBM_BO_USE_SCANOUT is the hint of x-tiling. 55 // GBM_BO_USE_SCANOUT is the hint of x-tiling.
54 if (use_scanout) 56 if (use_scanout)
55 flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; 57 flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
56 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), 58 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(),
57 GetFourCCFormatFromBufferFormat(format), flags); 59 GetFourCCFormatFromBufferFormat(format), flags);
58 if (!bo) 60 if (!bo)
59 return nullptr; 61 return nullptr;
60 62
61 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, usage)); 63 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, format, usage));
62 if (use_scanout && !buffer->GetFramebufferId()) 64 if (use_scanout && !buffer->GetFramebufferId())
63 return nullptr; 65 return nullptr;
64 66
65 return buffer; 67 return buffer;
66 } 68 }
67 69
68 GbmPixmap::GbmPixmap(GbmSurfaceFactory* surface_manager) 70 GbmPixmap::GbmPixmap(GbmSurfaceFactory* surface_manager)
69 : surface_manager_(surface_manager) {} 71 : surface_manager_(surface_manager) {}
70 72
71 void GbmPixmap::Initialize(base::ScopedFD dma_buf, int dma_buf_pitch) { 73 void GbmPixmap::Initialize(base::ScopedFD dma_buf, int dma_buf_pitch) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 137
136 int GbmPixmap::GetDmaBufFd() const { 138 int GbmPixmap::GetDmaBufFd() const {
137 return dma_buf_.get(); 139 return dma_buf_.get();
138 } 140 }
139 141
140 int GbmPixmap::GetDmaBufPitch() const { 142 int GbmPixmap::GetDmaBufPitch() const {
141 return dma_buf_pitch_; 143 return dma_buf_pitch_;
142 } 144 }
143 145
144 gfx::BufferFormat GbmPixmap::GetBufferFormat() const { 146 gfx::BufferFormat GbmPixmap::GetBufferFormat() const {
145 return GetBufferFormatFromFourCCFormat(buffer_->GetFramebufferPixelFormat()); 147 return buffer_->GetFormat();
146 } 148 }
147 149
148 gfx::Size GbmPixmap::GetBufferSize() const { 150 gfx::Size GbmPixmap::GetBufferSize() const {
149 return buffer_->GetSize(); 151 return buffer_->GetSize();
150 } 152 }
151 153
152 bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 154 bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
153 int plane_z_order, 155 int plane_z_order,
154 gfx::OverlayTransform plane_transform, 156 gfx::OverlayTransform plane_transform,
155 const gfx::Rect& display_bounds, 157 const gfx::Rect& display_bounds,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 gfx::Size pixmap_size = buffer_->GetSize(); 202 gfx::Size pixmap_size = buffer_->GetSize();
201 // If the required size is not integer-sized, round it to the next integer. 203 // If the required size is not integer-sized, round it to the next integer.
202 *target_size = gfx::ToCeiledSize( 204 *target_size = gfx::ToCeiledSize(
203 gfx::SizeF(display_bounds.width() / crop_rect.width(), 205 gfx::SizeF(display_bounds.width() / crop_rect.width(),
204 display_bounds.height() / crop_rect.height())); 206 display_bounds.height() / crop_rect.height()));
205 207
206 return pixmap_size != *target_size || GetBufferFormat() != *target_format; 208 return pixmap_size != *target_size || GetBufferFormat() != *target_format;
207 } 209 }
208 210
209 } // namespace ui 211 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698