Commit 646dd5bc authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Don't use IPC structs in DrmWindow::TestPageFlip

Instead of OverlayCheck_Params and OverlayCheckReturn_Params, use
OverlaySurfaceCandidate and OverlayStatus respectively. The IPC structs
are going away in the long term with the switch to mojo and they
prevent us from adding more fields that may not be serializable (e.g.
NativePixmap).

Bug: 756454
Change-Id: I8fc8c975cd1f67706329c8ea9a38503e196068a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850537
Commit-Queue: Saman Sami <samans@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706575}
parent 93b6e358
......@@ -9,6 +9,7 @@
#include <utility>
#include "base/files/platform_file.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/ozone/common/linux/drm_util_linux.h"
......@@ -57,15 +58,15 @@ DrmOverlayValidator::DrmOverlayValidator(DrmWindow* window) : window_(window) {}
DrmOverlayValidator::~DrmOverlayValidator() {}
std::vector<OverlayCheckReturn_Params> DrmOverlayValidator::TestPageFlip(
const std::vector<OverlayCheck_Params>& params,
OverlayStatusList DrmOverlayValidator::TestPageFlip(
const OverlaySurfaceCandidateList& params,
const DrmOverlayPlaneList& last_used_planes) {
std::vector<OverlayCheckReturn_Params> returns(params.size());
OverlayStatusList returns(params.size());
HardwareDisplayController* controller = window_->GetController();
if (!controller) {
// The controller is not yet installed.
for (auto& param : returns)
param.status = OVERLAY_STATUS_NOT;
param = OVERLAY_STATUS_NOT;
return returns;
}
......@@ -78,8 +79,8 @@ std::vector<OverlayCheckReturn_Params> DrmOverlayValidator::TestPageFlip(
reusable_buffers.push_back(plane.buffer);
for (size_t i = 0; i < params.size(); ++i) {
if (!params[i].is_overlay_candidate) {
returns[i].status = OVERLAY_STATUS_NOT;
if (!params[i].overlay_handled) {
returns[i] = OVERLAY_STATUS_NOT;
continue;
}
......@@ -88,12 +89,13 @@ std::vector<OverlayCheckReturn_Params> DrmOverlayValidator::TestPageFlip(
GetFourCCFormatFromBufferFormat(params[i].format), &reusable_buffers);
DrmOverlayPlane plane(buffer, params[i].plane_z_order, params[i].transform,
params[i].display_rect, params[i].crop_rect,
gfx::ToNearestRect(params[i].display_rect),
params[i].crop_rect,
/* enable_blend */ true, /* gpu_fence */ nullptr);
test_list.push_back(std::move(plane));
if (buffer && controller->TestPageFlip(test_list)) {
returns[i].status = OVERLAY_STATUS_ABLE;
returns[i] = OVERLAY_STATUS_ABLE;
} else {
// If test failed here, platform cannot support this configuration
// with current combination of layers. This is usually the case when this
......@@ -101,7 +103,7 @@ std::vector<OverlayCheckReturn_Params> DrmOverlayValidator::TestPageFlip(
// hardware resources and they might be already in use by other planes.
// For example this plane has requested scaling capabilities and all
// available scalars are already in use by other planes.
returns[i].status = OVERLAY_STATUS_NOT;
returns[i] = OVERLAY_STATUS_NOT;
test_list.pop_back();
}
}
......
......@@ -7,12 +7,11 @@
#include "base/containers/mru_cache.h"
#include "ui/ozone/platform/drm/gpu/drm_overlay_plane.h"
#include "ui/ozone/public/overlay_surface_candidate.h"
namespace ui {
class DrmWindow;
struct OverlayCheck_Params;
struct OverlayCheckReturn_Params;
class DrmOverlayValidator {
public:
......@@ -22,9 +21,8 @@ class DrmOverlayValidator {
// Tests if configurations |params| are compatible with |window_| and finds
// which of these configurations can be promoted to Overlay composition
// without failing the page flip. It expects |params| to be sorted by z_order.
std::vector<OverlayCheckReturn_Params> TestPageFlip(
const std::vector<OverlayCheck_Params>& params,
const DrmOverlayPlaneList& last_used_planes);
OverlayStatusList TestPageFlip(const OverlaySurfaceCandidateList& params,
const DrmOverlayPlaneList& last_used_planes);
private:
DrmWindow* const window_; // Not owned.
......
......@@ -12,6 +12,7 @@
#include "base/files/platform_file.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/common/linux/drm_util_linux.h"
......@@ -61,7 +62,7 @@ class DrmOverlayValidatorTest : public testing::Test {
return nullptr;
}
void AddPlane(const ui::OverlayCheck_Params& params);
void AddPlane(const ui::OverlaySurfaceCandidate& params);
scoped_refptr<ui::DrmFramebuffer> CreateBuffer() {
auto gbm_buffer = drm_->gbm_device()->CreateBuffer(
......@@ -95,7 +96,7 @@ class DrmOverlayValidatorTest : public testing::Test {
std::unique_ptr<ui::DrmDeviceManager> drm_device_manager_;
ui::DrmWindow* window_;
std::unique_ptr<ui::DrmOverlayValidator> overlay_validator_;
std::vector<ui::OverlayCheck_Params> overlay_params_;
std::vector<ui::OverlaySurfaceCandidate> overlay_params_;
ui::DrmOverlayPlaneList plane_list_;
int on_swap_buffers_count_;
......@@ -141,18 +142,20 @@ void DrmOverlayValidatorTest::SetUp() {
primary_rect_ = gfx::Rect(0, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay);
ui::OverlayCheck_Params primary_candidate;
ui::OverlaySurfaceCandidate primary_candidate;
primary_candidate.buffer_size = primary_rect_.size();
primary_candidate.display_rect = primary_rect_;
primary_candidate.display_rect = gfx::RectF(primary_rect_);
primary_candidate.format = gfx::BufferFormat::BGRX_8888;
primary_candidate.overlay_handled = true;
overlay_params_.push_back(primary_candidate);
AddPlane(primary_candidate);
ui::OverlayCheck_Params overlay_candidate;
ui::OverlaySurfaceCandidate overlay_candidate;
overlay_candidate.buffer_size = overlay_rect_.size();
overlay_candidate.display_rect = overlay_rect_;
overlay_candidate.display_rect = gfx::RectF(overlay_rect_);
overlay_candidate.plane_z_order = 1;
overlay_candidate.format = gfx::BufferFormat::BGRX_8888;
overlay_candidate.overlay_handled = true;
overlay_params_.push_back(overlay_candidate);
AddPlane(overlay_candidate);
}
......@@ -218,14 +221,16 @@ void DrmOverlayValidatorTest::InitializeDrmState(
/* use_atomic= */ true);
}
void DrmOverlayValidatorTest::AddPlane(const ui::OverlayCheck_Params& params) {
void DrmOverlayValidatorTest::AddPlane(
const ui::OverlaySurfaceCandidate& params) {
scoped_refptr<ui::DrmDevice> drm = window_->GetController()->GetDrmDevice();
scoped_refptr<ui::DrmFramebuffer> drm_framebuffer = CreateOverlayBuffer(
ui::GetFourCCFormatFromBufferFormat(params.format), params.buffer_size);
plane_list_.push_back(ui::DrmOverlayPlane(
std::move(drm_framebuffer), params.plane_z_order, params.transform,
params.display_rect, params.crop_rect, true, nullptr));
gfx::ToNearestRect(params.display_rect), params.crop_rect, true,
nullptr));
}
void DrmOverlayValidatorTest::TearDown() {
......@@ -239,42 +244,39 @@ TEST_F(DrmOverlayValidatorTest, WindowWithNoController) {
// present.
ui::HardwareDisplayController* controller = window_->GetController();
window_->SetController(nullptr);
std::vector<ui::OverlayCheckReturn_Params> returns =
overlay_validator_->TestPageFlip(overlay_params_,
ui::DrmOverlayPlaneList());
EXPECT_EQ(returns.front().status, ui::OVERLAY_STATUS_NOT);
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_NOT);
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
overlay_params_, ui::DrmOverlayPlaneList());
EXPECT_EQ(returns.front(), ui::OVERLAY_STATUS_NOT);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_NOT);
window_->SetController(controller);
}
TEST_F(DrmOverlayValidatorTest, DontPromoteMoreLayersThanAvailablePlanes) {
std::vector<ui::OverlayCheckReturn_Params> returns =
overlay_validator_->TestPageFlip(overlay_params_,
ui::DrmOverlayPlaneList());
EXPECT_EQ(returns.front().status, ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_NOT);
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
overlay_params_, ui::DrmOverlayPlaneList());
EXPECT_EQ(returns.front(), ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_NOT);
}
TEST_F(DrmOverlayValidatorTest, DontCollapseOverlayToPrimaryInFullScreen) {
// Overlay Validator should not collapse planes during validation.
overlay_params_.back().buffer_size = primary_rect_.size();
overlay_params_.back().display_rect = primary_rect_;
overlay_params_.back().display_rect = gfx::RectF(primary_rect_);
plane_list_.back().display_bounds = primary_rect_;
std::vector<ui::OverlayCheckReturn_Params> returns =
overlay_validator_->TestPageFlip(overlay_params_,
ui::DrmOverlayPlaneList());
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
overlay_params_, ui::DrmOverlayPlaneList());
// Second candidate should be marked as Invalid as we have only one plane
// per CRTC.
EXPECT_EQ(returns.front().status, ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_NOT);
EXPECT_EQ(returns.front(), ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_NOT);
}
TEST_F(DrmOverlayValidatorTest, OverlayFormat_XRGB) {
// This test checks for optimal format in case of non full screen video case.
// This should be XRGB when overlay doesn't support YUV.
overlay_params_.back().buffer_size = overlay_rect_.size();
overlay_params_.back().display_rect = overlay_rect_;
overlay_params_.back().display_rect = gfx::RectF(overlay_rect_);
plane_list_.back().display_bounds = overlay_rect_;
CrtcState state = {
......@@ -286,12 +288,11 @@ TEST_F(DrmOverlayValidatorTest, OverlayFormat_XRGB) {
};
InitializeDrmState(std::vector<CrtcState>(1, state));
std::vector<ui::OverlayCheckReturn_Params> returns =
overlay_validator_->TestPageFlip(overlay_params_,
ui::DrmOverlayPlaneList());
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
overlay_params_, ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
for (const auto& param : returns)
EXPECT_EQ(param.status, ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(param, ui::OVERLAY_STATUS_ABLE);
}
TEST_F(DrmOverlayValidatorTest, OverlayFormat_YUV) {
......@@ -300,7 +301,7 @@ TEST_F(DrmOverlayValidatorTest, OverlayFormat_YUV) {
// needed.
gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5);
overlay_params_.back().buffer_size = overlay_rect_.size();
overlay_params_.back().display_rect = overlay_rect_;
overlay_params_.back().display_rect = gfx::RectF(overlay_rect_);
overlay_params_.back().crop_rect = crop_rect;
overlay_params_.back().format = gfx::BufferFormat::YUV_420_BIPLANAR;
plane_list_.pop_back();
......@@ -315,19 +316,18 @@ TEST_F(DrmOverlayValidatorTest, OverlayFormat_YUV) {
};
InitializeDrmState(std::vector<CrtcState>(1, state));
std::vector<ui::OverlayCheckReturn_Params> returns =
overlay_validator_->TestPageFlip(overlay_params_,
ui::DrmOverlayPlaneList());
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
overlay_params_, ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
for (const auto& param : returns)
EXPECT_EQ(param.status, ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(param, ui::OVERLAY_STATUS_ABLE);
}
TEST_F(DrmOverlayValidatorTest, RejectYUVBuffersIfNotSupported) {
// Check case where buffer storage format is already UYVY but planes dont
// support it.
overlay_params_.back().buffer_size = overlay_rect_.size();
overlay_params_.back().display_rect = overlay_rect_;
overlay_params_.back().display_rect = gfx::RectF(overlay_rect_);
overlay_params_.back().format = gfx::BufferFormat::YUV_420_BIPLANAR;
plane_list_.pop_back();
AddPlane(overlay_params_.back());
......@@ -341,12 +341,11 @@ TEST_F(DrmOverlayValidatorTest, RejectYUVBuffersIfNotSupported) {
};
InitializeDrmState(std::vector<CrtcState>(1, state));
std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_;
std::vector<ui::OverlayCheckReturn_Params> returns =
overlay_validator_->TestPageFlip(validated_params,
ui::DrmOverlayPlaneList());
std::vector<ui::OverlaySurfaceCandidate> validated_params = overlay_params_;
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
validated_params, ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_NOT);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_NOT);
}
TEST_F(DrmOverlayValidatorTest,
......@@ -379,18 +378,17 @@ TEST_F(DrmOverlayValidatorTest,
gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5);
overlay_params_.back().buffer_size = overlay_rect_.size();
overlay_params_.back().display_rect = overlay_rect_;
overlay_params_.back().display_rect = gfx::RectF(overlay_rect_);
overlay_params_.back().crop_rect = crop_rect;
plane_list_.back().display_bounds = overlay_rect_;
plane_list_.back().crop_rect = crop_rect;
std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_;
std::vector<ui::OverlaySurfaceCandidate> validated_params = overlay_params_;
validated_params.back().format = gfx::BufferFormat::YUV_420_BIPLANAR;
std::vector<ui::OverlayCheckReturn_Params> returns =
overlay_validator_->TestPageFlip(validated_params,
ui::DrmOverlayPlaneList());
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
validated_params, ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_ABLE);
// This configuration should not be promoted to Overlay when either of the
// controllers dont support UYVY format.
......@@ -402,7 +400,7 @@ TEST_F(DrmOverlayValidatorTest,
returns = overlay_validator_->TestPageFlip(validated_params,
ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_NOT);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_NOT);
// Check case where we dont have support for packed formats in primary
// display.
......@@ -413,7 +411,7 @@ TEST_F(DrmOverlayValidatorTest,
returns = overlay_validator_->TestPageFlip(validated_params,
ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_NOT);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_NOT);
controller->RemoveCrtc(drm_, kCrtcIdBase + 1);
}
......@@ -444,14 +442,13 @@ TEST_F(DrmOverlayValidatorTest, OptimalFormatXRGB_MirroredControllers) {
EXPECT_TRUE(controller->Modeset(plane1, kDefaultMode));
overlay_params_.back().buffer_size = overlay_rect_.size();
overlay_params_.back().display_rect = overlay_rect_;
overlay_params_.back().display_rect = gfx::RectF(overlay_rect_);
plane_list_.back().display_bounds = overlay_rect_;
std::vector<ui::OverlayCheckReturn_Params> returns =
overlay_validator_->TestPageFlip(overlay_params_,
ui::DrmOverlayPlaneList());
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
overlay_params_, ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_ABLE);
// Check case where we dont have support for packed formats in Mirrored CRTC.
crtc_states[1].planes[1].formats = {DRM_FORMAT_XRGB8888};
......@@ -459,7 +456,7 @@ TEST_F(DrmOverlayValidatorTest, OptimalFormatXRGB_MirroredControllers) {
returns = overlay_validator_->TestPageFlip(overlay_params_,
ui::DrmOverlayPlaneList());
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_ABLE);
// Check case where we dont have support for packed formats in primary
// display.
......@@ -470,7 +467,7 @@ TEST_F(DrmOverlayValidatorTest, OptimalFormatXRGB_MirroredControllers) {
returns = overlay_validator_->TestPageFlip(overlay_params_,
ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
EXPECT_EQ(returns.back().status, ui::OVERLAY_STATUS_ABLE);
EXPECT_EQ(returns.back(), ui::OVERLAY_STATUS_ABLE);
controller->RemoveCrtc(drm_, kCrtcIdBase + 1);
}
......@@ -480,9 +477,31 @@ TEST_F(DrmOverlayValidatorTest, RejectBufferAllocationFail) {
// In that case we should reject the overlay candidate.
gbm_->set_allocation_failure(true);
std::vector<ui::OverlayCheckReturn_Params> returns =
overlay_validator_->TestPageFlip(overlay_params_,
ui::DrmOverlayPlaneList());
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
overlay_params_, ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
EXPECT_EQ(returns.front().status, ui::OVERLAY_STATUS_NOT);
EXPECT_EQ(returns.front(), ui::OVERLAY_STATUS_NOT);
}
// This test verifies that the Ozone/DRM implementation does not reject overlay
// candidates purely on the basis of having non-integer bounds. Instead, they
// should be rounded to the nearest integer.
TEST_F(DrmOverlayValidatorTest, NonIntegerDisplayRect) {
overlay_params_.back().display_rect.Inset(0.005f, 0.005f);
plane_list_.pop_back();
AddPlane(overlay_params_.back());
CrtcState state = {
/* .planes = */
{
{/* .formats = */ {DRM_FORMAT_XRGB8888}},
{/* .formats = */ {DRM_FORMAT_XRGB8888, DRM_FORMAT_NV12}},
},
};
InitializeDrmState(std::vector<CrtcState>(1, state));
std::vector<ui::OverlayStatus> returns = overlay_validator_->TestPageFlip(
overlay_params_, ui::DrmOverlayPlaneList());
EXPECT_EQ(2u, returns.size());
for (const auto& param : returns)
EXPECT_EQ(param, ui::OVERLAY_STATUS_ABLE);
}
......@@ -303,11 +303,9 @@ void DrmThread::CheckOverlayCapabilities(
const OverlayStatusList&)> callback) {
TRACE_EVENT0("drm,hwoverlays", "DrmThread::CheckOverlayCapabilities");
auto params = CreateParamsFromOverlaySurfaceCandidate(overlays);
std::move(callback).Run(
widget, overlays,
CreateOverlayStatusListFrom(
screen_manager_->GetWindow(widget)->TestPageFlip(params)));
screen_manager_->GetWindow(widget)->TestPageFlip(overlays));
}
void DrmThread::GetDeviceCursor(
......
......@@ -128,8 +128,8 @@ void DrmWindow::SchedulePageFlip(
std::move(presentation_callback));
}
std::vector<OverlayCheckReturn_Params> DrmWindow::TestPageFlip(
const std::vector<OverlayCheck_Params>& overlay_params) {
OverlayStatusList DrmWindow::TestPageFlip(
const OverlaySurfaceCandidateList& overlay_params) {
return overlay_validator_->TestPageFlip(overlay_params,
last_submitted_planes_);
}
......
......@@ -17,6 +17,7 @@
#include "ui/gfx/vsync_provider.h"
#include "ui/ozone/platform/drm/gpu/drm_overlay_plane.h"
#include "ui/ozone/platform/drm/gpu/page_flip_request.h"
#include "ui/ozone/public/overlay_surface_candidate.h"
#include "ui/ozone/public/swap_completion_callback.h"
class SkBitmap;
......@@ -31,8 +32,6 @@ namespace ui {
class DrmDeviceManager;
class DrmOverlayValidator;
class HardwareDisplayController;
struct OverlayCheck_Params;
struct OverlayCheckReturn_Params;
class ScreenManager;
// The GPU object representing a window.
......@@ -82,8 +81,8 @@ class DrmWindow {
void SchedulePageFlip(std::vector<DrmOverlayPlane> planes,
SwapCompletionOnceCallback submission_callback,
PresentationOnceCallback presentation_callback);
std::vector<OverlayCheckReturn_Params> TestPageFlip(
const std::vector<OverlayCheck_Params>& overlay_params);
OverlayStatusList TestPageFlip(
const OverlaySurfaceCandidateList& overlay_params);
// Returns the last buffer associated with this window.
const DrmOverlayPlane* GetLastModesetBuffer() const;
......
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