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..413a1c2d4f2d05714f0e9f2e43dd283717bdbb3a 100644 |
--- a/ui/ozone/platform/drm/gpu/gbm_buffer.cc |
+++ b/ui/ozone/platform/drm/gpu/gbm_buffer.cc |
@@ -22,6 +22,9 @@ |
namespace ui { |
+// Optimal format for renderring on overlay. |
+const gfx::BufferFormat kOverlayRenderFormat = gfx::BufferFormat::UYVY_422; |
kalyank
2015/10/30 22:19:32
nit: Rendering
william.xie1
2015/11/02 02:09:25
Done.
|
+ |
GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm, |
gbm_bo* bo, |
gfx::BufferUsage usage) |
@@ -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) { |
kalyank
2015/10/30 22:19:32
I like the way it is currently, any reason for thi
william.xie1
2015/11/02 02:09:25
processing=scaling+csc
|
+ 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:Figure out the optimal render foramt for overlay |
kalyank
2015/10/30 22:19:32
Nit: format
william.xie1
2015/11/02 02:09:25
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 |