Commit b5488279 authored by Kristian H. Kristensen's avatar Kristian H. Kristensen Committed by Commit Bot

ozone/drm: Remove primary plane fb size restriction

Allow primary planes to not have to be the size of the mode. This lets
us configure a primary plane that's smaller than the current mode,
which will be useful for the underlay strategy.

This commit also adds a new option to ozone_demo to test the partial
primary plane functionality.

BUG=772239
TEST=ozone_demo --enable-drm-atomic --partial-primary-plane works on
    KBL or RK3399 boards showing red/blue pulsing square;
    ozone_demo --disable-drm-atomic --partial-primary-plane shows black
    screen but doesn't exit or crash.

Bug: 
Change-Id: Ie77b02848efca717dee465783c692333d2e6c988
Reviewed-on: https://chromium-review.googlesource.com/666000Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarDongseong Hwang <dongseong.hwang@intel.com>
Commit-Queue: Kristian H. Kristensen <hoegsberg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517429}
parent 0070b84a
......@@ -128,13 +128,18 @@ bool SurfacelessGlRenderer::Initialize() {
if (!GlRenderer::Initialize())
return false;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch("partial-primary-plane"))
primary_plane_rect_ = gfx::Rect(200, 200, 800, 800);
else
primary_plane_rect_ = gfx::Rect(size_);
for (size_t i = 0; i < arraysize(buffers_); ++i) {
buffers_[i].reset(new BufferWrapper());
if (!buffers_[i]->Initialize(widget_, size_))
if (!buffers_[i]->Initialize(widget_, primary_plane_rect_.size()))
return false;
}
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch("enable-overlay")) {
gfx::Size overlay_size = gfx::Size(size_.width() / 8, size_.height() / 8);
for (size_t i = 0; i < arraysize(overlay_buffer_); ++i) {
......@@ -200,7 +205,7 @@ void SurfacelessGlRenderer::RenderFrame() {
CHECK(overlay_list.front().overlay_handled);
surface_->ScheduleOverlayPlane(0, gfx::OVERLAY_TRANSFORM_NONE,
buffers_[back_buffer_]->image(),
gfx::Rect(size_), gfx::RectF(0, 0, 1, 1));
primary_plane_rect_, gfx::RectF(0, 0, 1, 1));
}
if (overlay_buffer_[0] && overlay_list.back().overlay_handled) {
......@@ -220,7 +225,7 @@ void SurfacelessGlRenderer::PostRenderFrameTask(gfx::SwapResult result) {
case gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS:
for (size_t i = 0; i < arraysize(buffers_); ++i) {
buffers_[i].reset(new BufferWrapper());
if (!buffers_[i]->Initialize(widget_, size_))
if (!buffers_[i]->Initialize(widget_, primary_plane_rect_.size()))
LOG(FATAL) << "Failed to recreate buffer";
}
// Fall through since we want to render a new frame anyways.
......
......@@ -58,6 +58,7 @@ class SurfacelessGlRenderer : public GlRenderer {
std::unique_ptr<BufferWrapper> overlay_buffer_[2];
bool disable_primary_plane_ = false;
gfx::Rect primary_plane_rect_;
std::unique_ptr<OverlayCandidatesOzone> overlay_checker_;
......
......@@ -80,20 +80,15 @@ bool CrtcController::SchedulePageFlip(
scoped_refptr<PageFlipRequest> page_flip_request) {
DCHECK(!page_flip_request_.get() || test_only);
DCHECK(!is_disabled_);
const OverlayPlane* primary = OverlayPlane::GetPrimaryPlane(overlays);
if (primary) {
DCHECK(primary->buffer.get());
// TODO(dcastagna): Get rid of this. Scaling on the primary plane is
// supported on all the devices.
if (primary->buffer->GetSize() !=
gfx::Size(mode_.hdisplay, mode_.vdisplay)) {
VLOG(2) << "Trying to pageflip a buffer with the wrong size. Expected "
<< mode_.hdisplay << "x" << mode_.vdisplay << " got "
<< primary->buffer->GetSize().ToString() << " for"
<< " crtc=" << crtc_ << " connector=" << connector_;
page_flip_request->Signal(gfx::SwapResult::SWAP_ACK);
return true;
}
if (primary && !drm_->plane_manager()->ValidatePrimarySize(*primary, mode_)) {
VLOG(2) << "Trying to pageflip a buffer with the wrong size. Expected "
<< mode_.hdisplay << "x" << mode_.vdisplay << " got "
<< primary->buffer->GetSize().ToString() << " for"
<< " crtc=" << crtc_ << " connector=" << connector_;
page_flip_request->Signal(gfx::SwapResult::SWAP_ACK);
return true;
}
if (!drm_->plane_manager()->AssignOverlayPlanes(plane_list, overlays, crtc_,
......
......@@ -93,6 +93,12 @@ class HardwareDisplayPlaneManager {
// plane_list->old_plane_list.
virtual bool DisableOverlayPlanes(HardwareDisplayPlaneList* plane_list) = 0;
// Check that the primary plane is valid for this
// PlaneManager. Specifically, legacy can't support primary planes
// that don't have the same size as the current mode of the crtc.
virtual bool ValidatePrimarySize(const OverlayPlane& primary,
const drmModeModeInfo& mode) = 0;
const std::vector<std::unique_ptr<HardwareDisplayPlane>>& planes() {
return planes_;
}
......
......@@ -116,6 +116,14 @@ bool HardwareDisplayPlaneManagerAtomic::DisableOverlayPlanes(
return ret;
}
bool HardwareDisplayPlaneManagerAtomic::ValidatePrimarySize(
const OverlayPlane& primary,
const drmModeModeInfo& mode) {
// Atomic KMS allows for primary planes that don't match the size of
// the current mode.
return true;
}
bool HardwareDisplayPlaneManagerAtomic::SetPlaneData(
HardwareDisplayPlaneList* plane_list,
HardwareDisplayPlane* hw_plane,
......
......@@ -22,6 +22,9 @@ class HardwareDisplayPlaneManagerAtomic : public HardwareDisplayPlaneManager {
bool test_only) override;
bool DisableOverlayPlanes(HardwareDisplayPlaneList* plane_list) override;
bool ValidatePrimarySize(const OverlayPlane& primary,
const drmModeModeInfo& mode) override;
private:
bool SetPlaneData(HardwareDisplayPlaneList* plane_list,
HardwareDisplayPlane* hw_plane,
......
......@@ -109,6 +109,14 @@ bool HardwareDisplayPlaneManagerLegacy::DisableOverlayPlanes(
return true;
}
bool HardwareDisplayPlaneManagerLegacy::ValidatePrimarySize(
const OverlayPlane& primary,
const drmModeModeInfo& mode) {
DCHECK(primary.buffer.get());
return primary.buffer->GetSize() == gfx::Size(mode.hdisplay, mode.vdisplay);
}
bool HardwareDisplayPlaneManagerLegacy::SetPlaneData(
HardwareDisplayPlaneList* plane_list,
HardwareDisplayPlane* hw_plane,
......
......@@ -22,6 +22,9 @@ class HardwareDisplayPlaneManagerLegacy : public HardwareDisplayPlaneManager {
bool test_only) override;
bool DisableOverlayPlanes(HardwareDisplayPlaneList* plane_list) override;
bool ValidatePrimarySize(const OverlayPlane& primary,
const drmModeModeInfo& mode) override;
protected:
bool SetPlaneData(HardwareDisplayPlaneList* plane_list,
HardwareDisplayPlane* hw_plane,
......
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