| Index: ui/ozone/platform/drm/gpu/drm_buffer.cc
|
| diff --git a/ui/ozone/platform/drm/gpu/drm_buffer.cc b/ui/ozone/platform/drm/gpu/drm_buffer.cc
|
| index 35e20976a25be5aae29206f5f5001bc3196e9d3a..ec3d99a545a5e3b2e124ef3d1cd9ad99ed93c57d 100644
|
| --- a/ui/ozone/platform/drm/gpu/drm_buffer.cc
|
| +++ b/ui/ozone/platform/drm/gpu/drm_buffer.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "ui/ozone/platform/drm/gpu/drm_buffer.h"
|
|
|
| +#include <drm_fourcc.h>
|
| +
|
| #include "base/logging.h"
|
| #include "ui/ozone/platform/drm/gpu/drm_device.h"
|
|
|
| @@ -32,6 +34,26 @@ uint8_t GetColorDepth(SkColorType type) {
|
| }
|
| }
|
|
|
| +// We always ignore Alpha.
|
| +uint32_t GetFourCCCodeForSkColorType(SkColorType type) {
|
| + switch (type) {
|
| + case kUnknown_SkColorType:
|
| + case kAlpha_8_SkColorType:
|
| + return 0;
|
| + case kIndex_8_SkColorType:
|
| + return DRM_FORMAT_C8;
|
| + case kRGB_565_SkColorType:
|
| + return DRM_FORMAT_RGB565;
|
| + case kARGB_4444_SkColorType:
|
| + return DRM_FORMAT_XRGB4444;
|
| + case kN32_SkColorType:
|
| + return DRM_FORMAT_XRGB8888;
|
| + default:
|
| + NOTREACHED();
|
| + return 0;
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| DrmBuffer::DrmBuffer(const scoped_refptr<DrmDevice>& drm) : drm_(drm) {
|
| @@ -64,12 +86,15 @@ bool DrmBuffer::Initialize(const SkImageInfo& info,
|
| return false;
|
| }
|
|
|
| - if (should_register_framebuffer &&
|
| - !drm_->AddFramebuffer(
|
| - info.width(), info.height(), GetColorDepth(info.colorType()),
|
| - info.bytesPerPixel() << 3, stride_, handle_, &framebuffer_)) {
|
| - PLOG(ERROR) << "DrmBuffer: AddFramebuffer: handle " << handle_;
|
| - return false;
|
| + if (should_register_framebuffer) {
|
| + if (!drm_->AddFramebuffer(
|
| + info.width(), info.height(), GetColorDepth(info.colorType()),
|
| + info.bytesPerPixel() << 3, stride_, handle_, &framebuffer_)) {
|
| + PLOG(ERROR) << "DrmBuffer: AddFramebuffer: handle " << handle_;
|
| + return false;
|
| + }
|
| +
|
| + fb_pixel_format_ = GetFourCCCodeForSkColorType(info.colorType());
|
| }
|
|
|
| surface_ =
|
| @@ -90,6 +115,10 @@ uint32_t DrmBuffer::GetFramebufferId() const {
|
| return framebuffer_;
|
| }
|
|
|
| +uint32_t DrmBuffer::GetFramebufferPixelFormat() const {
|
| + return fb_pixel_format_;
|
| +}
|
| +
|
| uint32_t DrmBuffer::GetHandle() const {
|
| return handle_;
|
| }
|
| @@ -98,10 +127,6 @@ gfx::Size DrmBuffer::GetSize() const {
|
| return gfx::Size(surface_->width(), surface_->height());
|
| }
|
|
|
| -uint32_t DrmBuffer::GetFormat() const {
|
| - return 0;
|
| -}
|
| -
|
| DrmBufferGenerator::DrmBufferGenerator() {
|
| }
|
|
|
|
|