Commit b0e22612 authored by Gil Dekel's avatar Gil Dekel Committed by Commit Bot

ozone/drm: Expose existence of the new privacy-screen property

Certain chromebooks now come with panels that have integrated privacy
screens on them. This CL exposes the existence of this property, or lack
thereof, by propagating this information from ozone/drm via
DisplaySnapshot.

Bug: b/147451539
Test: display_unittests
Change-Id: I8b531de0d1c8089a606913104d409a453a3034a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1994435
Commit-Queue: Gil Dekel <gildekel@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarStéphane Marchesin <marcheu@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731843}
parent 32b964ba
......@@ -161,7 +161,7 @@ std::unique_ptr<FakeDisplaySnapshot> Builder::Build() {
return std::make_unique<FakeDisplaySnapshot>(
id_, origin_, physical_size, type_, is_aspect_preserving_scaling_,
has_overscan_, has_color_correction_matrix_,
has_overscan_, has_privacy_screen_, has_color_correction_matrix_,
color_correction_in_linear_space_, name_, std::move(modes_),
current_mode_, native_mode_, product_code_, maximum_cursor_size_);
}
......@@ -291,6 +291,7 @@ FakeDisplaySnapshot::FakeDisplaySnapshot(int64_t display_id,
DisplayConnectionType type,
bool is_aspect_preserving_scaling,
bool has_overscan,
bool has_privacy_screen,
bool has_color_correction_matrix,
bool color_correction_in_linear_space,
std::string display_name,
......@@ -305,6 +306,7 @@ FakeDisplaySnapshot::FakeDisplaySnapshot(int64_t display_id,
type,
is_aspect_preserving_scaling,
has_overscan,
has_privacy_screen,
has_color_correction_matrix,
color_correction_in_linear_space,
gfx::ColorSpace(),
......
......@@ -84,6 +84,7 @@ class FAKE_DISPLAY_EXPORT FakeDisplaySnapshot : public DisplaySnapshot {
DisplayConnectionType type_ = DISPLAY_CONNECTION_TYPE_UNKNOWN;
bool is_aspect_preserving_scaling_ = false;
bool has_overscan_ = false;
bool has_privacy_screen_ = false;
bool has_color_correction_matrix_ = false;
bool color_correction_in_linear_space_ = false;
std::string name_;
......@@ -102,6 +103,7 @@ class FAKE_DISPLAY_EXPORT FakeDisplaySnapshot : public DisplaySnapshot {
DisplayConnectionType type,
bool is_aspect_preserving_scaling,
bool has_overscan,
bool has_privacy_screen,
bool has_color_correction_matrix,
bool color_correction_in_linear_space,
std::string display_name,
......
......@@ -172,7 +172,8 @@ TEST_P(DisplayChangeObserverTest, GetExternalManagedDisplayModeList) {
TEST_P(DisplayChangeObserverTest, GetEmptyExternalManagedDisplayModeList) {
FakeDisplaySnapshot display_snapshot(
123, gfx::Point(), gfx::Size(), DISPLAY_CONNECTION_TYPE_UNKNOWN, false,
false, false, false, std::string(), {}, nullptr, nullptr, 0, gfx::Size());
false, false, false, false, std::string(), {}, nullptr, nullptr, 0,
gfx::Size());
ManagedDisplayInfo::ManagedDisplayModeList display_modes =
DisplayChangeObserver::GetExternalManagedDisplayModeList(
......
......@@ -82,6 +82,7 @@ void CheckDisplaySnapShotMojoEqual(const DisplaySnapshot& input,
EXPECT_EQ(input.is_aspect_preserving_scaling(),
output.is_aspect_preserving_scaling());
EXPECT_EQ(input.has_overscan(), output.has_overscan());
EXPECT_EQ(input.has_privacy_screen(), output.has_privacy_screen());
EXPECT_EQ(input.has_color_correction_matrix(),
output.has_color_correction_matrix());
EXPECT_EQ(input.color_correction_in_linear_space(),
......@@ -255,6 +256,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) {
const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_DISPLAYPORT;
const bool is_aspect_preserving_scaling = true;
const bool has_overscan = true;
const bool has_privacy_screen = true;
const bool has_color_correction_matrix = true;
const bool color_correction_in_linear_space = true;
const gfx::ColorSpace display_color_space = gfx::ColorSpace::CreateREC709();
......@@ -275,7 +277,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) {
std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_color_correction_matrix,
has_overscan, has_privacy_screen, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), PanelOrientation::kNormal, edid,
current_mode, native_mode, product_code, year_of_manufacture,
......@@ -297,6 +299,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) {
const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_VGA;
const bool is_aspect_preserving_scaling = true;
const bool has_overscan = true;
const bool has_privacy_screen = true;
const bool has_color_correction_matrix = true;
const bool color_correction_in_linear_space = true;
const gfx::ColorSpace display_color_space = gfx::ColorSpace::CreateREC709();
......@@ -317,7 +320,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) {
std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_color_correction_matrix,
has_overscan, has_privacy_screen, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), PanelOrientation::kNormal, edid,
current_mode, native_mode, product_code, year_of_manufacture,
......@@ -339,6 +342,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotExternal) {
const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_HDMI;
const bool is_aspect_preserving_scaling = false;
const bool has_overscan = false;
const bool has_privacy_screen = false;
const bool has_color_correction_matrix = false;
const bool color_correction_in_linear_space = false;
const std::string display_name("HP Z24i");
......@@ -363,7 +367,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotExternal) {
std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_color_correction_matrix,
has_overscan, has_privacy_screen, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), PanelOrientation::kLeftUp, edid,
current_mode, native_mode, product_code, year_of_manufacture,
......@@ -384,6 +388,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotInternal) {
const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_INTERNAL;
const bool is_aspect_preserving_scaling = true;
const bool has_overscan = false;
const bool has_privacy_screen = false;
const bool has_color_correction_matrix = false;
const bool color_correction_in_linear_space = false;
const gfx::ColorSpace display_color_space =
......@@ -405,7 +410,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotInternal) {
std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_color_correction_matrix,
has_overscan, has_privacy_screen, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), PanelOrientation::kRightUp,
edid, current_mode, native_mode, product_code, year_of_manufacture,
......
......@@ -18,6 +18,7 @@ struct DisplaySnapshot {
display.mojom.DisplayConnectionType type;
bool is_aspect_preserving_scaling;
bool has_overscan;
bool has_privacy_screen;
bool has_color_correction_matrix;
bool color_correction_in_linear_space;
gfx.mojom.ColorSpace color_space;
......
......@@ -136,7 +136,7 @@ bool StructTraits<display::mojom::DisplaySnapshotDataView,
*out = std::make_unique<display::DisplaySnapshot>(
data.display_id(), origin, physical_size, type,
data.is_aspect_preserving_scaling(), data.has_overscan(),
data.has_color_correction_matrix(),
data.has_privacy_screen(), data.has_color_correction_matrix(),
data.color_correction_in_linear_space(), color_space,
data.bits_per_channel(), display_name, file_path, std::move(modes),
panel_orientation, std::move(edid), current_mode, native_mode,
......
......@@ -54,6 +54,11 @@ struct StructTraits<display::mojom::DisplaySnapshotDataView,
return snapshot->has_overscan();
}
static bool has_privacy_screen(
const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
return snapshot->has_privacy_screen();
}
static bool has_color_correction_matrix(
const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
return snapshot->has_color_correction_matrix();
......
......@@ -66,6 +66,7 @@ DisplaySnapshot::DisplaySnapshot(int64_t display_id,
DisplayConnectionType type,
bool is_aspect_preserving_scaling,
bool has_overscan,
bool has_privacy_screen,
bool has_color_correction_matrix,
bool color_correction_in_linear_space,
const gfx::ColorSpace& color_space,
......@@ -86,6 +87,7 @@ DisplaySnapshot::DisplaySnapshot(int64_t display_id,
type_(type),
is_aspect_preserving_scaling_(is_aspect_preserving_scaling),
has_overscan_(has_overscan),
has_privacy_screen_(has_privacy_screen),
has_color_correction_matrix_(has_color_correction_matrix),
color_correction_in_linear_space_(color_correction_in_linear_space),
color_space_(color_space),
......@@ -127,7 +129,7 @@ std::unique_ptr<DisplaySnapshot> DisplaySnapshot::Clone() {
return std::make_unique<DisplaySnapshot>(
display_id_, origin_, physical_size_, type_,
is_aspect_preserving_scaling_, has_overscan_,
is_aspect_preserving_scaling_, has_overscan_, has_privacy_screen_,
has_color_correction_matrix_, color_correction_in_linear_space_,
color_space_, bits_per_channel_, display_name_, sys_path_,
std::move(clone_modes), panel_orientation_, edid_, cloned_current_mode,
......
......@@ -35,6 +35,7 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot {
DisplayConnectionType type,
bool is_aspect_preserving_scaling,
bool has_overscan,
bool has_privacy_screen,
bool has_color_correction_matrix,
bool color_correction_in_linear_space,
const gfx::ColorSpace& color_space,
......@@ -60,6 +61,7 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot {
return is_aspect_preserving_scaling_;
}
bool has_overscan() const { return has_overscan_; }
bool has_privacy_screen() const { return has_privacy_screen_; }
bool has_color_correction_matrix() const {
return has_color_correction_matrix_;
}
......@@ -110,6 +112,8 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot {
const bool has_overscan_;
const bool has_privacy_screen_;
// Whether this display has advanced color correction available.
const bool has_color_correction_matrix_;
// Whether the color correction matrix will be applied in linear color space
......
......@@ -39,6 +39,7 @@ struct DisplaySnapshot_Params {
display::DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_NONE;
bool is_aspect_preserving_scaling = false;
bool has_overscan = false;
bool has_privacy_screen = false;
bool has_color_correction_matrix = false;
bool color_correction_in_linear_space = false;
gfx::ColorSpace color_space;
......
......@@ -53,6 +53,7 @@ IPC_STRUCT_TRAITS_BEGIN(ui::DisplaySnapshot_Params)
IPC_STRUCT_TRAITS_MEMBER(type)
IPC_STRUCT_TRAITS_MEMBER(is_aspect_preserving_scaling)
IPC_STRUCT_TRAITS_MEMBER(has_overscan)
IPC_STRUCT_TRAITS_MEMBER(has_privacy_screen)
IPC_STRUCT_TRAITS_MEMBER(has_color_correction_matrix)
IPC_STRUCT_TRAITS_MEMBER(color_correction_in_linear_space)
IPC_STRUCT_TRAITS_MEMBER(color_space)
......
......@@ -151,6 +151,11 @@ ScopedDrmPropertyBlobPtr GetDrmPropertyBlob(int fd,
return nullptr;
}
bool HasPrivacyScreen(int fd, drmModeConnector* connector) {
ScopedDrmPropertyPtr property;
return GetDrmProperty(fd, connector, "privacy-screen", &property) >= 0;
}
bool IsAspectPreserving(int fd, drmModeConnector* connector) {
ScopedDrmPropertyPtr property;
int index = GetDrmProperty(fd, connector, "scaling mode", &property);
......@@ -440,6 +445,7 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
IsAspectPreserving(fd, info->connector());
const display::PanelOrientation panel_orientation =
GetPanelOrientation(fd, info->connector());
const bool has_privacy_screen = HasPrivacyScreen(fd, info->connector());
const bool has_color_correction_matrix =
HasColorCorrectionMatrix(fd, info->crtc()) ||
HasPerPlaneColorCorrectionMatrix(fd, info->crtc());
......@@ -495,7 +501,7 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
return std::make_unique<display::DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_color_correction_matrix,
has_overscan, has_privacy_screen, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), panel_orientation, edid,
current_mode, native_mode, product_code, year_of_manufacture,
......@@ -515,6 +521,7 @@ std::vector<DisplaySnapshot_Params> CreateDisplaySnapshotParams(
p.type = d->type();
p.is_aspect_preserving_scaling = d->is_aspect_preserving_scaling();
p.has_overscan = d->has_overscan();
p.has_privacy_screen = d->has_privacy_screen();
p.has_color_correction_matrix = d->has_color_correction_matrix();
p.color_correction_in_linear_space = d->color_correction_in_linear_space();
p.color_space = d->color_space();
......@@ -563,7 +570,7 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
return std::make_unique<display::DisplaySnapshot>(
params.display_id, params.origin, params.physical_size, params.type,
params.is_aspect_preserving_scaling, params.has_overscan,
params.has_color_correction_matrix,
params.has_privacy_screen, params.has_color_correction_matrix,
params.color_correction_in_linear_space, params.color_space,
params.bits_per_channel, params.display_name, params.sys_path,
std::move(modes), params.panel_orientation, params.edid, current_mode,
......
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