Commit 4d26bef0 authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

ozone: drm: Remove framebuffer support from DrmBuffer

This is not used anywhere except in tests, so move it to the test code.
There's probably more to be done here; the test should probably mock GBM
instead of mocking dumb buffers, which have been completely removed
everywhere else.

Bug: 869206

Change-Id: I7900956d617d1341d222f0568516ae5027f6a9eb
Reviewed-on: https://chromium-review.googlesource.com/1155921
Commit-Queue: Michael Spang <spang@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579833}
parent 275d9f6a
......@@ -14,40 +14,6 @@ namespace ui {
namespace {
uint32_t GetFourCCCodeForSkColorType(SkColorType type) {
switch (type) {
case kUnknown_SkColorType:
case kAlpha_8_SkColorType:
return 0;
case kRGB_565_SkColorType:
return DRM_FORMAT_RGB565;
case kARGB_4444_SkColorType:
return DRM_FORMAT_ARGB4444;
case kN32_SkColorType:
return DRM_FORMAT_ARGB8888;
default:
NOTREACHED();
return 0;
}
}
scoped_refptr<DrmFramebuffer> AddFramebufferForDumbBuffer(
const scoped_refptr<DrmDevice>& drm,
uint32_t handle,
uint32_t stride,
const SkImageInfo& info) {
DrmFramebuffer::AddFramebufferParams params;
params.flags = 0;
params.format = GetFourCCCodeForSkColorType(info.colorType());
params.modifier = DRM_FORMAT_MOD_INVALID;
params.width = info.width();
params.height = info.height();
params.num_planes = 1;
params.handles[0] = handle;
params.strides[0] = stride;
return DrmFramebuffer::AddFramebuffer(drm, params);
}
} // namespace
DrmBuffer::DrmBuffer(const scoped_refptr<DrmDevice>& drm) : drm_(drm) {
......@@ -61,8 +27,7 @@ DrmBuffer::~DrmBuffer() {
PLOG(ERROR) << "DrmBuffer: DestroyDumbBuffer: handle " << handle_;
}
bool DrmBuffer::Initialize(const SkImageInfo& info,
bool should_register_framebuffer) {
bool DrmBuffer::Initialize(const SkImageInfo& info) {
if (!drm_->CreateDumbBuffer(info, &handle_, &stride_)) {
PLOG(ERROR) << "DrmBuffer: CreateDumbBuffer: width " << info.width()
<< " height " << info.height();
......@@ -75,12 +40,6 @@ bool DrmBuffer::Initialize(const SkImageInfo& info,
return false;
}
if (should_register_framebuffer) {
framebuffer_ = AddFramebufferForDumbBuffer(drm_, handle_, stride_, info);
if (!framebuffer_)
return false;
}
surface_ = SkSurface::MakeRasterDirect(info, mmap_base_, stride_);
if (!surface_) {
LOG(ERROR) << "DrmBuffer: Failed to create SkSurface: handle " << handle_;
......
......@@ -30,22 +30,16 @@ class DrmBuffer {
// Allocates the backing pixels and wraps them in |surface_|. |info| is used
// to describe the buffer characteristics (size, color format).
// |should_register_framebuffer| is used to distinguish the buffers that are
// used for modesetting.
bool Initialize(const SkImageInfo& info, bool should_register_framebuffer);
bool Initialize(const SkImageInfo& info);
SkCanvas* GetCanvas() const;
uint32_t GetHandle() const;
gfx::Size GetSize() const;
const scoped_refptr<DrmFramebuffer>& framebuffer() const {
return framebuffer_;
}
uint32_t stride() const { return stride_; }
protected:
const scoped_refptr<DrmDevice> drm_;
scoped_refptr<DrmFramebuffer> framebuffer_;
// Length of a row of pixels.
uint32_t stride_ = 0;
......
......@@ -363,8 +363,7 @@ void HardwareDisplayController::AllocateCursorBuffers() {
// Don't register a framebuffer for cursors since they are special (they
// aren't modesetting buffers and drivers may fail to register them due to
// their small sizes).
if (!cursor_buffers_[i]->Initialize(
info, false /* should_register_framebuffer */)) {
if (!cursor_buffers_[i]->Initialize(info)) {
LOG(FATAL) << "Failed to initialize cursor buffer";
return;
}
......
......@@ -6,9 +6,48 @@
#include "third_party/skia/include/core/SkImageInfo.h"
#include "ui/ozone/platform/drm/gpu/drm_buffer.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"
namespace ui {
namespace {
uint32_t GetFourCCCodeForSkColorType(SkColorType type) {
switch (type) {
case kUnknown_SkColorType:
case kAlpha_8_SkColorType:
return 0;
case kRGB_565_SkColorType:
return DRM_FORMAT_RGB565;
case kARGB_4444_SkColorType:
return DRM_FORMAT_ARGB4444;
case kN32_SkColorType:
return DRM_FORMAT_ARGB8888;
default:
NOTREACHED();
return 0;
}
}
scoped_refptr<DrmFramebuffer> AddFramebufferForDumbBuffer(
const scoped_refptr<DrmDevice>& drm,
uint32_t handle,
uint32_t stride,
const SkImageInfo& info) {
DrmFramebuffer::AddFramebufferParams params;
params.flags = 0;
params.format = GetFourCCCodeForSkColorType(info.colorType());
params.modifier = DRM_FORMAT_MOD_INVALID;
params.width = info.width();
params.height = info.height();
params.num_planes = 1;
params.handles[0] = handle;
params.strides[0] = stride;
return DrmFramebuffer::AddFramebuffer(drm, params);
}
} // namespace
MockDumbBufferGenerator::MockDumbBufferGenerator() {}
MockDumbBufferGenerator::~MockDumbBufferGenerator() {}
......@@ -20,10 +59,11 @@ scoped_refptr<DrmFramebuffer> MockDumbBufferGenerator::Create(
const gfx::Size& size) {
std::unique_ptr<DrmBuffer> buffer(new DrmBuffer(drm));
SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height());
if (!buffer->Initialize(info, true /* should_register_framebuffer */))
if (!buffer->Initialize(info))
return NULL;
return buffer->framebuffer();
return AddFramebufferForDumbBuffer(drm, buffer->GetHandle(), buffer->stride(),
info);
}
} // namespace ui
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment