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

Unified Diff: ui/ozone/platform/drm/gpu/drm_buffer.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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_buffer.h ('k') | ui/ozone/platform/drm/gpu/gbm_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
}
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_buffer.h ('k') | ui/ozone/platform/drm/gpu/gbm_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698