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

Unified Diff: ui/ozone/platform/drm/gpu/gbm_buffer.cc

Issue 1422563002: [Ozone] Enables overlay render format setting path and by default use UYVY (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
Index: ui/ozone/platform/drm/gpu/gbm_buffer.cc
diff --git a/ui/ozone/platform/drm/gpu/gbm_buffer.cc b/ui/ozone/platform/drm/gpu/gbm_buffer.cc
index b94164d3acc44e1422bb81dec961ace7ef62ce22..efb4fae1029ce17e0a78cc1310876746f872a79e 100644
--- a/ui/ozone/platform/drm/gpu/gbm_buffer.cc
+++ b/ui/ozone/platform/drm/gpu/gbm_buffer.cc
@@ -20,6 +20,9 @@
#include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
#include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h"
+// Optimal format for rendering on overlay.
+const gfx::BufferFormat kOverlayRenderFormat = gfx::BufferFormat::UYVY_422;
+
namespace ui {
GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm,
@@ -85,12 +88,15 @@ bool GbmPixmap::InitializeFromBuffer(const scoped_refptr<GbmBuffer>& buffer) {
return true;
}
-void GbmPixmap::SetScalingCallback(const ScalingCallback& scaling_callback) {
- scaling_callback_ = scaling_callback;
+void GbmPixmap::SetProcessingCallback(
+ const ProcessingCallback& processing_callback) {
+ processing_callback_ = processing_callback;
}
-scoped_refptr<NativePixmap> GbmPixmap::GetScaledPixmap(gfx::Size new_size) {
- return scaling_callback_.Run(new_size);
+scoped_refptr<NativePixmap> GbmPixmap::GetProcessedPixmap(
+ gfx::Size target_size,
+ gfx::BufferFormat target_format) {
+ return processing_callback_.Run(target_size, target_format);
}
gfx::NativePixmapHandle GbmPixmap::ExportHandle() {
@@ -122,17 +128,23 @@ int GbmPixmap::GetDmaBufPitch() {
return dma_buf_pitch_;
}
+gfx::BufferFormat GbmPixmap::GetBufferFormat() {
+ return GetBufferFormatFromFourCCFormat(buffer_->GetFramebufferPixelFormat());
+}
+
bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
int plane_z_order,
gfx::OverlayTransform plane_transform,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect) {
- gfx::Size required_size;
- if (plane_z_order &&
- ShouldApplyScaling(display_bounds, crop_rect, &required_size)) {
- scoped_refptr<NativePixmap> scaled_pixmap = GetScaledPixmap(required_size);
- if (scaled_pixmap) {
- return scaled_pixmap->ScheduleOverlayPlane(
+ gfx::Size target_size;
+ gfx::BufferFormat target_format;
+ if (plane_z_order && ShouldApplyProcessing(display_bounds, crop_rect,
+ &target_size, &target_format)) {
+ scoped_refptr<NativePixmap> processed_pixmap =
+ GetProcessedPixmap(target_size, target_format);
+ if (processed_pixmap) {
+ return processed_pixmap->ScheduleOverlayPlane(
widget, plane_z_order, plane_transform, display_bounds, crop_rect);
} else {
return false;
@@ -152,25 +164,29 @@ bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
return true;
}
-bool GbmPixmap::ShouldApplyScaling(const gfx::Rect& display_bounds,
- const gfx::RectF& crop_rect,
- gfx::Size* required_size) {
+bool GbmPixmap::ShouldApplyProcessing(const gfx::Rect& display_bounds,
+ const gfx::RectF& crop_rect,
+ gfx::Size* target_size,
+ gfx::BufferFormat* target_format) {
if (crop_rect.width() == 0 || crop_rect.height() == 0) {
- PLOG(ERROR) << "ShouldApplyScaling passed zero scaling target.";
+ PLOG(ERROR) << "ShouldApplyProcessing passed zero processing target.";
return false;
}
if (!buffer_) {
- PLOG(ERROR) << "ShouldApplyScaling requires a buffer.";
+ PLOG(ERROR) << "ShouldApplyProcessing requires a buffer.";
return false;
}
+ // TODO(william.xie): Figure out the optimal render foramt for overlay.
kalyank 2015/11/06 17:30:26 nit: format
william.xie1 2015/11/06 18:24:02 Done.
+ *target_format = kOverlayRenderFormat;
gfx::Size pixmap_size = buffer_->GetSize();
// If the required size is not integer-sized, round it to the next integer.
- *required_size = gfx::ToCeiledSize(
+ *target_size = gfx::ToCeiledSize(
gfx::SizeF(display_bounds.width() / crop_rect.width(),
display_bounds.height() / crop_rect.height()));
- return pixmap_size != *required_size;
+
+ return pixmap_size != *target_size || GetBufferFormat() != *target_format;
}
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698