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

ozone/drm: Plumb privacy-screen property to return state

Currently, DisplaySnapshot provides an API that says whether or not
privacy-screen is supported by the display.

This CL modifies this API so that querying the prop will return the
state; whether it exists or not, and enabled/disabled if does.

Bug: b/147451539
Test: display_unittests
Change-Id: Idf4b111f0325550907eebe676f51e705eb8dad2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2007871
Commit-Queue: Gil Dekel <gildekel@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#734249}
parent 836b2d8a
...@@ -161,7 +161,7 @@ std::unique_ptr<FakeDisplaySnapshot> Builder::Build() { ...@@ -161,7 +161,7 @@ std::unique_ptr<FakeDisplaySnapshot> Builder::Build() {
return std::make_unique<FakeDisplaySnapshot>( return std::make_unique<FakeDisplaySnapshot>(
id_, origin_, physical_size, type_, is_aspect_preserving_scaling_, id_, origin_, physical_size, type_, is_aspect_preserving_scaling_,
has_overscan_, has_privacy_screen_, has_color_correction_matrix_, has_overscan_, privacy_screen_state_, has_color_correction_matrix_,
color_correction_in_linear_space_, name_, std::move(modes_), color_correction_in_linear_space_, name_, std::move(modes_),
current_mode_, native_mode_, product_code_, maximum_cursor_size_); current_mode_, native_mode_, product_code_, maximum_cursor_size_);
} }
...@@ -285,28 +285,29 @@ const DisplayMode* Builder::AddOrFindDisplayMode( ...@@ -285,28 +285,29 @@ const DisplayMode* Builder::AddOrFindDisplayMode(
return modes_.back().get(); return modes_.back().get();
} }
FakeDisplaySnapshot::FakeDisplaySnapshot(int64_t display_id, FakeDisplaySnapshot::FakeDisplaySnapshot(
const gfx::Point& origin, int64_t display_id,
const gfx::Size& physical_size, const gfx::Point& origin,
DisplayConnectionType type, const gfx::Size& physical_size,
bool is_aspect_preserving_scaling, DisplayConnectionType type,
bool has_overscan, bool is_aspect_preserving_scaling,
bool has_privacy_screen, bool has_overscan,
bool has_color_correction_matrix, PrivacyScreenState privacy_screen_state,
bool color_correction_in_linear_space, bool has_color_correction_matrix,
std::string display_name, bool color_correction_in_linear_space,
DisplayModeList modes, std::string display_name,
const DisplayMode* current_mode, DisplayModeList modes,
const DisplayMode* native_mode, const DisplayMode* current_mode,
int64_t product_code, const DisplayMode* native_mode,
const gfx::Size& maximum_cursor_size) int64_t product_code,
const gfx::Size& maximum_cursor_size)
: DisplaySnapshot(display_id, : DisplaySnapshot(display_id,
origin, origin,
physical_size, physical_size,
type, type,
is_aspect_preserving_scaling, is_aspect_preserving_scaling,
has_overscan, has_overscan,
has_privacy_screen, privacy_screen_state,
has_color_correction_matrix, has_color_correction_matrix,
color_correction_in_linear_space, color_correction_in_linear_space,
gfx::ColorSpace(), gfx::ColorSpace(),
......
...@@ -84,7 +84,7 @@ class FAKE_DISPLAY_EXPORT FakeDisplaySnapshot : public DisplaySnapshot { ...@@ -84,7 +84,7 @@ class FAKE_DISPLAY_EXPORT FakeDisplaySnapshot : public DisplaySnapshot {
DisplayConnectionType type_ = DISPLAY_CONNECTION_TYPE_UNKNOWN; DisplayConnectionType type_ = DISPLAY_CONNECTION_TYPE_UNKNOWN;
bool is_aspect_preserving_scaling_ = false; bool is_aspect_preserving_scaling_ = false;
bool has_overscan_ = false; bool has_overscan_ = false;
bool has_privacy_screen_ = false; PrivacyScreenState privacy_screen_state_ = kNotSupported;
bool has_color_correction_matrix_ = false; bool has_color_correction_matrix_ = false;
bool color_correction_in_linear_space_ = false; bool color_correction_in_linear_space_ = false;
std::string name_; std::string name_;
...@@ -103,7 +103,7 @@ class FAKE_DISPLAY_EXPORT FakeDisplaySnapshot : public DisplaySnapshot { ...@@ -103,7 +103,7 @@ class FAKE_DISPLAY_EXPORT FakeDisplaySnapshot : public DisplaySnapshot {
DisplayConnectionType type, DisplayConnectionType type,
bool is_aspect_preserving_scaling, bool is_aspect_preserving_scaling,
bool has_overscan, bool has_overscan,
bool has_privacy_screen, PrivacyScreenState privacy_screen_state,
bool has_color_correction_matrix, bool has_color_correction_matrix,
bool color_correction_in_linear_space, bool color_correction_in_linear_space,
std::string display_name, std::string display_name,
......
...@@ -172,8 +172,8 @@ TEST_P(DisplayChangeObserverTest, GetExternalManagedDisplayModeList) { ...@@ -172,8 +172,8 @@ TEST_P(DisplayChangeObserverTest, GetExternalManagedDisplayModeList) {
TEST_P(DisplayChangeObserverTest, GetEmptyExternalManagedDisplayModeList) { TEST_P(DisplayChangeObserverTest, GetEmptyExternalManagedDisplayModeList) {
FakeDisplaySnapshot display_snapshot( FakeDisplaySnapshot display_snapshot(
123, gfx::Point(), gfx::Size(), DISPLAY_CONNECTION_TYPE_UNKNOWN, false, 123, gfx::Point(), gfx::Size(), DISPLAY_CONNECTION_TYPE_UNKNOWN, false,
false, false, false, false, std::string(), {}, nullptr, nullptr, 0, false, PrivacyScreenState::kNotSupported, false, false, std::string(), {},
gfx::Size()); nullptr, nullptr, 0, gfx::Size());
ManagedDisplayInfo::ManagedDisplayModeList display_modes = ManagedDisplayInfo::ManagedDisplayModeList display_modes =
DisplayChangeObserver::GetExternalManagedDisplayModeList( DisplayChangeObserver::GetExternalManagedDisplayModeList(
......
...@@ -31,3 +31,9 @@ enum PanelOrientation { ...@@ -31,3 +31,9 @@ enum PanelOrientation {
RIGHT_UP = 3 RIGHT_UP = 3
}; };
// Corresponds to display::PrivacyScreenState
enum PrivacyScreenState {
DISABLED = 0,
ENABLED = 1,
NOT_SUPPORTED = 2
};
...@@ -14,4 +14,5 @@ public_deps = [ ...@@ -14,4 +14,5 @@ public_deps = [
type_mappings = [ type_mappings = [
"display.mojom.DisplayConnectionType=::display::DisplayConnectionType", "display.mojom.DisplayConnectionType=::display::DisplayConnectionType",
"display.mojom.HDCPState=::display::HDCPState", "display.mojom.HDCPState=::display::HDCPState",
"display.mojom.PrivacyScreenState=::display::PrivacyScreenState",
] ]
...@@ -147,4 +147,39 @@ bool EnumTraits<display::mojom::PanelOrientation, display::PanelOrientation>:: ...@@ -147,4 +147,39 @@ bool EnumTraits<display::mojom::PanelOrientation, display::PanelOrientation>::
return false; return false;
} }
// static
display::mojom::PrivacyScreenState EnumTraits<
display::mojom::PrivacyScreenState,
display::PrivacyScreenState>::ToMojom(display::PrivacyScreenState state) {
switch (state) {
case display::PrivacyScreenState::kDisabled:
return display::mojom::PrivacyScreenState::DISABLED;
case display::PrivacyScreenState::kEnabled:
return display::mojom::PrivacyScreenState::ENABLED;
case display::PrivacyScreenState::kNotSupported:
return display::mojom::PrivacyScreenState::NOT_SUPPORTED;
}
NOTREACHED();
return display::mojom::PrivacyScreenState::NOT_SUPPORTED;
}
// static
bool EnumTraits<display::mojom::PrivacyScreenState,
display::PrivacyScreenState>::
FromMojom(display::mojom::PrivacyScreenState state,
display::PrivacyScreenState* out) {
switch (state) {
case display::mojom::PrivacyScreenState::DISABLED:
*out = display::PrivacyScreenState::kDisabled;
return true;
case display::mojom::PrivacyScreenState::ENABLED:
*out = display::PrivacyScreenState::kEnabled;
return true;
case display::mojom::PrivacyScreenState::NOT_SUPPORTED:
*out = display::PrivacyScreenState::kNotSupported;
return true;
}
return false;
}
} // namespace mojo } // namespace mojo
...@@ -34,6 +34,15 @@ struct EnumTraits<display::mojom::PanelOrientation, display::PanelOrientation> { ...@@ -34,6 +34,15 @@ struct EnumTraits<display::mojom::PanelOrientation, display::PanelOrientation> {
display::PanelOrientation* out); display::PanelOrientation* out);
}; };
template <>
struct EnumTraits<display::mojom::PrivacyScreenState,
display::PrivacyScreenState> {
static display::mojom::PrivacyScreenState ToMojom(
display::PrivacyScreenState type);
static bool FromMojom(display::mojom::PrivacyScreenState type,
display::PrivacyScreenState* out);
};
} // namespace mojo } // namespace mojo
#endif // UI_DISPLAY_MOJOM_DISPLAY_CONSTANTS_MOJOM_TRAITS_H_ #endif // UI_DISPLAY_MOJOM_DISPLAY_CONSTANTS_MOJOM_TRAITS_H_
...@@ -82,7 +82,7 @@ void CheckDisplaySnapShotMojoEqual(const DisplaySnapshot& input, ...@@ -82,7 +82,7 @@ void CheckDisplaySnapShotMojoEqual(const DisplaySnapshot& input,
EXPECT_EQ(input.is_aspect_preserving_scaling(), EXPECT_EQ(input.is_aspect_preserving_scaling(),
output.is_aspect_preserving_scaling()); output.is_aspect_preserving_scaling());
EXPECT_EQ(input.has_overscan(), output.has_overscan()); EXPECT_EQ(input.has_overscan(), output.has_overscan());
EXPECT_EQ(input.has_privacy_screen(), output.has_privacy_screen()); EXPECT_EQ(input.privacy_screen_state(), output.privacy_screen_state());
EXPECT_EQ(input.has_color_correction_matrix(), EXPECT_EQ(input.has_color_correction_matrix(),
output.has_color_correction_matrix()); output.has_color_correction_matrix());
EXPECT_EQ(input.color_correction_in_linear_space(), EXPECT_EQ(input.color_correction_in_linear_space(),
...@@ -256,7 +256,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) { ...@@ -256,7 +256,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) {
const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_DISPLAYPORT; const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_DISPLAYPORT;
const bool is_aspect_preserving_scaling = true; const bool is_aspect_preserving_scaling = true;
const bool has_overscan = true; const bool has_overscan = true;
const bool has_privacy_screen = true; const PrivacyScreenState privacy_screen_state = kEnabled;
const bool has_color_correction_matrix = true; const bool has_color_correction_matrix = true;
const bool color_correction_in_linear_space = true; const bool color_correction_in_linear_space = true;
const gfx::ColorSpace display_color_space = gfx::ColorSpace::CreateREC709(); const gfx::ColorSpace display_color_space = gfx::ColorSpace::CreateREC709();
...@@ -277,7 +277,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) { ...@@ -277,7 +277,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentAndNativeModesNull) {
std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>( std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling, display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_privacy_screen, has_color_correction_matrix, has_overscan, privacy_screen_state, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel, color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), PanelOrientation::kNormal, edid, display_name, sys_path, std::move(modes), PanelOrientation::kNormal, edid,
current_mode, native_mode, product_code, year_of_manufacture, current_mode, native_mode, product_code, year_of_manufacture,
...@@ -299,7 +299,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) { ...@@ -299,7 +299,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) {
const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_VGA; const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_VGA;
const bool is_aspect_preserving_scaling = true; const bool is_aspect_preserving_scaling = true;
const bool has_overscan = true; const bool has_overscan = true;
const bool has_privacy_screen = true; const PrivacyScreenState privacy_screen_state = kEnabled;
const bool has_color_correction_matrix = true; const bool has_color_correction_matrix = true;
const bool color_correction_in_linear_space = true; const bool color_correction_in_linear_space = true;
const gfx::ColorSpace display_color_space = gfx::ColorSpace::CreateREC709(); const gfx::ColorSpace display_color_space = gfx::ColorSpace::CreateREC709();
...@@ -320,7 +320,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) { ...@@ -320,7 +320,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotCurrentModeNull) {
std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>( std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling, display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_privacy_screen, has_color_correction_matrix, has_overscan, privacy_screen_state, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel, color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), PanelOrientation::kNormal, edid, display_name, sys_path, std::move(modes), PanelOrientation::kNormal, edid,
current_mode, native_mode, product_code, year_of_manufacture, current_mode, native_mode, product_code, year_of_manufacture,
...@@ -342,7 +342,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotExternal) { ...@@ -342,7 +342,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotExternal) {
const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_HDMI; const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_HDMI;
const bool is_aspect_preserving_scaling = false; const bool is_aspect_preserving_scaling = false;
const bool has_overscan = false; const bool has_overscan = false;
const bool has_privacy_screen = false; const PrivacyScreenState privacy_screen_state = kDisabled;
const bool has_color_correction_matrix = false; const bool has_color_correction_matrix = false;
const bool color_correction_in_linear_space = false; const bool color_correction_in_linear_space = false;
const std::string display_name("HP Z24i"); const std::string display_name("HP Z24i");
...@@ -367,7 +367,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotExternal) { ...@@ -367,7 +367,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotExternal) {
std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>( std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling, display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_privacy_screen, has_color_correction_matrix, has_overscan, privacy_screen_state, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel, color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), PanelOrientation::kLeftUp, edid, display_name, sys_path, std::move(modes), PanelOrientation::kLeftUp, edid,
current_mode, native_mode, product_code, year_of_manufacture, current_mode, native_mode, product_code, year_of_manufacture,
...@@ -388,7 +388,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotInternal) { ...@@ -388,7 +388,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotInternal) {
const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_INTERNAL; const DisplayConnectionType type = DISPLAY_CONNECTION_TYPE_INTERNAL;
const bool is_aspect_preserving_scaling = true; const bool is_aspect_preserving_scaling = true;
const bool has_overscan = false; const bool has_overscan = false;
const bool has_privacy_screen = false; const PrivacyScreenState privacy_screen_state = kNotSupported;
const bool has_color_correction_matrix = false; const bool has_color_correction_matrix = false;
const bool color_correction_in_linear_space = false; const bool color_correction_in_linear_space = false;
const gfx::ColorSpace display_color_space = const gfx::ColorSpace display_color_space =
...@@ -410,7 +410,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotInternal) { ...@@ -410,7 +410,7 @@ TEST(DisplayStructTraitsTest, DisplaySnapshotInternal) {
std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>( std::unique_ptr<DisplaySnapshot> input = std::make_unique<DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling, display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_privacy_screen, has_color_correction_matrix, has_overscan, privacy_screen_state, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel, color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), PanelOrientation::kRightUp, display_name, sys_path, std::move(modes), PanelOrientation::kRightUp,
edid, current_mode, native_mode, product_code, year_of_manufacture, edid, current_mode, native_mode, product_code, year_of_manufacture,
......
...@@ -18,7 +18,7 @@ struct DisplaySnapshot { ...@@ -18,7 +18,7 @@ struct DisplaySnapshot {
display.mojom.DisplayConnectionType type; display.mojom.DisplayConnectionType type;
bool is_aspect_preserving_scaling; bool is_aspect_preserving_scaling;
bool has_overscan; bool has_overscan;
bool has_privacy_screen; display.mojom.PrivacyScreenState privacy_screen_state;
bool has_color_correction_matrix; bool has_color_correction_matrix;
bool color_correction_in_linear_space; bool color_correction_in_linear_space;
gfx.mojom.ColorSpace color_space; gfx.mojom.ColorSpace color_space;
......
...@@ -81,6 +81,10 @@ bool StructTraits<display::mojom::DisplaySnapshotDataView, ...@@ -81,6 +81,10 @@ bool StructTraits<display::mojom::DisplaySnapshotDataView,
if (!data.ReadType(&type)) if (!data.ReadType(&type))
return false; return false;
display::PrivacyScreenState privacy_screen_state;
if (!data.ReadPrivacyScreenState(&privacy_screen_state))
return false;
display::PanelOrientation panel_orientation; display::PanelOrientation panel_orientation;
if (!data.ReadPanelOrientation(&panel_orientation)) if (!data.ReadPanelOrientation(&panel_orientation))
return false; return false;
...@@ -136,7 +140,7 @@ bool StructTraits<display::mojom::DisplaySnapshotDataView, ...@@ -136,7 +140,7 @@ bool StructTraits<display::mojom::DisplaySnapshotDataView,
*out = std::make_unique<display::DisplaySnapshot>( *out = std::make_unique<display::DisplaySnapshot>(
data.display_id(), origin, physical_size, type, data.display_id(), origin, physical_size, type,
data.is_aspect_preserving_scaling(), data.has_overscan(), data.is_aspect_preserving_scaling(), data.has_overscan(),
data.has_privacy_screen(), data.has_color_correction_matrix(), privacy_screen_state, data.has_color_correction_matrix(),
data.color_correction_in_linear_space(), color_space, data.color_correction_in_linear_space(), color_space,
data.bits_per_channel(), display_name, file_path, std::move(modes), data.bits_per_channel(), display_name, file_path, std::move(modes),
panel_orientation, std::move(edid), current_mode, native_mode, panel_orientation, std::move(edid), current_mode, native_mode,
......
...@@ -54,9 +54,9 @@ struct StructTraits<display::mojom::DisplaySnapshotDataView, ...@@ -54,9 +54,9 @@ struct StructTraits<display::mojom::DisplaySnapshotDataView,
return snapshot->has_overscan(); return snapshot->has_overscan();
} }
static bool has_privacy_screen( static display::PrivacyScreenState privacy_screen_state(
const std::unique_ptr<display::DisplaySnapshot>& snapshot) { const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
return snapshot->has_privacy_screen(); return snapshot->privacy_screen_state();
} }
static bool has_color_correction_matrix( static bool has_color_correction_matrix(
......
...@@ -72,6 +72,14 @@ enum PanelOrientation { ...@@ -72,6 +72,14 @@ enum PanelOrientation {
kLast = kRightUp kLast = kRightUp
}; };
// The existence, or lack thereof, and state of an ePrivacy screen.
enum PrivacyScreenState {
kDisabled = 0,
kEnabled = 1,
kNotSupported = 2,
kPrivacyScreenStateLast = kNotSupported,
};
// Defines the float values closest to repeating decimal scale factors. // Defines the float values closest to repeating decimal scale factors.
constexpr float kDsf_1_777 = 1.77777779102325439453125f; constexpr float kDsf_1_777 = 1.77777779102325439453125f;
constexpr float kDsf_2_252 = 2.2522523403167724609375f; constexpr float kDsf_2_252 = 2.2522523403167724609375f;
......
...@@ -66,7 +66,7 @@ DisplaySnapshot::DisplaySnapshot(int64_t display_id, ...@@ -66,7 +66,7 @@ DisplaySnapshot::DisplaySnapshot(int64_t display_id,
DisplayConnectionType type, DisplayConnectionType type,
bool is_aspect_preserving_scaling, bool is_aspect_preserving_scaling,
bool has_overscan, bool has_overscan,
bool has_privacy_screen, PrivacyScreenState privacy_screen_state,
bool has_color_correction_matrix, bool has_color_correction_matrix,
bool color_correction_in_linear_space, bool color_correction_in_linear_space,
const gfx::ColorSpace& color_space, const gfx::ColorSpace& color_space,
...@@ -87,7 +87,7 @@ DisplaySnapshot::DisplaySnapshot(int64_t display_id, ...@@ -87,7 +87,7 @@ DisplaySnapshot::DisplaySnapshot(int64_t display_id,
type_(type), type_(type),
is_aspect_preserving_scaling_(is_aspect_preserving_scaling), is_aspect_preserving_scaling_(is_aspect_preserving_scaling),
has_overscan_(has_overscan), has_overscan_(has_overscan),
has_privacy_screen_(has_privacy_screen), privacy_screen_state_(privacy_screen_state),
has_color_correction_matrix_(has_color_correction_matrix), has_color_correction_matrix_(has_color_correction_matrix),
color_correction_in_linear_space_(color_correction_in_linear_space), color_correction_in_linear_space_(color_correction_in_linear_space),
color_space_(color_space), color_space_(color_space),
...@@ -129,7 +129,7 @@ std::unique_ptr<DisplaySnapshot> DisplaySnapshot::Clone() { ...@@ -129,7 +129,7 @@ std::unique_ptr<DisplaySnapshot> DisplaySnapshot::Clone() {
return std::make_unique<DisplaySnapshot>( return std::make_unique<DisplaySnapshot>(
display_id_, origin_, physical_size_, type_, display_id_, origin_, physical_size_, type_,
is_aspect_preserving_scaling_, has_overscan_, has_privacy_screen_, is_aspect_preserving_scaling_, has_overscan_, privacy_screen_state_,
has_color_correction_matrix_, color_correction_in_linear_space_, has_color_correction_matrix_, color_correction_in_linear_space_,
color_space_, bits_per_channel_, display_name_, sys_path_, color_space_, bits_per_channel_, display_name_, sys_path_,
std::move(clone_modes), panel_orientation_, edid_, cloned_current_mode, std::move(clone_modes), panel_orientation_, edid_, cloned_current_mode,
......
...@@ -35,7 +35,7 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot { ...@@ -35,7 +35,7 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot {
DisplayConnectionType type, DisplayConnectionType type,
bool is_aspect_preserving_scaling, bool is_aspect_preserving_scaling,
bool has_overscan, bool has_overscan,
bool has_privacy_screen, PrivacyScreenState privacy_screen_state,
bool has_color_correction_matrix, bool has_color_correction_matrix,
bool color_correction_in_linear_space, bool color_correction_in_linear_space,
const gfx::ColorSpace& color_space, const gfx::ColorSpace& color_space,
...@@ -61,7 +61,9 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot { ...@@ -61,7 +61,9 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot {
return is_aspect_preserving_scaling_; return is_aspect_preserving_scaling_;
} }
bool has_overscan() const { return has_overscan_; } bool has_overscan() const { return has_overscan_; }
bool has_privacy_screen() const { return has_privacy_screen_; } PrivacyScreenState privacy_screen_state() const {
return privacy_screen_state_;
}
bool has_color_correction_matrix() const { bool has_color_correction_matrix() const {
return has_color_correction_matrix_; return has_color_correction_matrix_;
} }
...@@ -112,7 +114,7 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot { ...@@ -112,7 +114,7 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot {
const bool has_overscan_; const bool has_overscan_;
const bool has_privacy_screen_; const PrivacyScreenState privacy_screen_state_;
// Whether this display has advanced color correction available. // Whether this display has advanced color correction available.
const bool has_color_correction_matrix_; const bool has_color_correction_matrix_;
......
...@@ -39,7 +39,8 @@ struct DisplaySnapshot_Params { ...@@ -39,7 +39,8 @@ struct DisplaySnapshot_Params {
display::DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_NONE; display::DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_NONE;
bool is_aspect_preserving_scaling = false; bool is_aspect_preserving_scaling = false;
bool has_overscan = false; bool has_overscan = false;
bool has_privacy_screen = false; display::PrivacyScreenState privacy_screen_state =
display::PrivacyScreenState::kNotSupported;
bool has_color_correction_matrix = false; bool has_color_correction_matrix = false;
bool color_correction_in_linear_space = false; bool color_correction_in_linear_space = false;
gfx::ColorSpace color_space; gfx::ColorSpace color_space;
......
...@@ -39,6 +39,9 @@ IPC_ENUM_TRAITS_MAX_VALUE(display::HDCPState, display::HDCP_STATE_LAST) ...@@ -39,6 +39,9 @@ IPC_ENUM_TRAITS_MAX_VALUE(display::HDCPState, display::HDCP_STATE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(display::PanelOrientation, IPC_ENUM_TRAITS_MAX_VALUE(display::PanelOrientation,
display::PanelOrientation::kLast) display::PanelOrientation::kLast)
IPC_ENUM_TRAITS_MAX_VALUE(display::PrivacyScreenState,
display::PrivacyScreenState::kPrivacyScreenStateLast)
// clang-format off // clang-format off
IPC_STRUCT_TRAITS_BEGIN(ui::DisplayMode_Params) IPC_STRUCT_TRAITS_BEGIN(ui::DisplayMode_Params)
IPC_STRUCT_TRAITS_MEMBER(size) IPC_STRUCT_TRAITS_MEMBER(size)
...@@ -53,7 +56,7 @@ IPC_STRUCT_TRAITS_BEGIN(ui::DisplaySnapshot_Params) ...@@ -53,7 +56,7 @@ IPC_STRUCT_TRAITS_BEGIN(ui::DisplaySnapshot_Params)
IPC_STRUCT_TRAITS_MEMBER(type) IPC_STRUCT_TRAITS_MEMBER(type)
IPC_STRUCT_TRAITS_MEMBER(is_aspect_preserving_scaling) IPC_STRUCT_TRAITS_MEMBER(is_aspect_preserving_scaling)
IPC_STRUCT_TRAITS_MEMBER(has_overscan) IPC_STRUCT_TRAITS_MEMBER(has_overscan)
IPC_STRUCT_TRAITS_MEMBER(has_privacy_screen) IPC_STRUCT_TRAITS_MEMBER(privacy_screen_state)
IPC_STRUCT_TRAITS_MEMBER(has_color_correction_matrix) IPC_STRUCT_TRAITS_MEMBER(has_color_correction_matrix)
IPC_STRUCT_TRAITS_MEMBER(color_correction_in_linear_space) IPC_STRUCT_TRAITS_MEMBER(color_correction_in_linear_space)
IPC_STRUCT_TRAITS_MEMBER(color_space) IPC_STRUCT_TRAITS_MEMBER(color_space)
......
...@@ -151,9 +151,24 @@ ScopedDrmPropertyBlobPtr GetDrmPropertyBlob(int fd, ...@@ -151,9 +151,24 @@ ScopedDrmPropertyBlobPtr GetDrmPropertyBlob(int fd,
return nullptr; return nullptr;
} }
bool HasPrivacyScreen(int fd, drmModeConnector* connector) { display::PrivacyScreenState GetPrivacyScreenState(int fd,
drmModeConnector* connector) {
ScopedDrmPropertyPtr property; ScopedDrmPropertyPtr property;
return GetDrmProperty(fd, connector, "privacy-screen", &property) >= 0; int index = GetDrmProperty(fd, connector, "privacy-screen", &property);
if (index < 0)
return display::PrivacyScreenState::kNotSupported;
DCHECK_LT(connector->prop_values[index],
display::PrivacyScreenState::kPrivacyScreenStateLast);
if (connector->prop_values[index] >=
display::PrivacyScreenState::kPrivacyScreenStateLast) {
LOG(ERROR) << "Invalid privacy-screen property value: Expected < "
<< display::PrivacyScreenState::kPrivacyScreenStateLast
<< ", but got: " << connector->prop_values[index];
}
return static_cast<display::PrivacyScreenState>(
connector->prop_values[index]);
} }
bool IsAspectPreserving(int fd, drmModeConnector* connector) { bool IsAspectPreserving(int fd, drmModeConnector* connector) {
...@@ -445,7 +460,8 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot( ...@@ -445,7 +460,8 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
IsAspectPreserving(fd, info->connector()); IsAspectPreserving(fd, info->connector());
const display::PanelOrientation panel_orientation = const display::PanelOrientation panel_orientation =
GetPanelOrientation(fd, info->connector()); GetPanelOrientation(fd, info->connector());
const bool has_privacy_screen = HasPrivacyScreen(fd, info->connector()); const display::PrivacyScreenState privacy_screen_state =
GetPrivacyScreenState(fd, info->connector());
const bool has_color_correction_matrix = const bool has_color_correction_matrix =
HasColorCorrectionMatrix(fd, info->crtc()) || HasColorCorrectionMatrix(fd, info->crtc()) ||
HasPerPlaneColorCorrectionMatrix(fd, info->crtc()); HasPerPlaneColorCorrectionMatrix(fd, info->crtc());
...@@ -501,7 +517,7 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot( ...@@ -501,7 +517,7 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
return std::make_unique<display::DisplaySnapshot>( return std::make_unique<display::DisplaySnapshot>(
display_id, origin, physical_size, type, is_aspect_preserving_scaling, display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_privacy_screen, has_color_correction_matrix, has_overscan, privacy_screen_state, has_color_correction_matrix,
color_correction_in_linear_space, display_color_space, bits_per_channel, color_correction_in_linear_space, display_color_space, bits_per_channel,
display_name, sys_path, std::move(modes), panel_orientation, edid, display_name, sys_path, std::move(modes), panel_orientation, edid,
current_mode, native_mode, product_code, year_of_manufacture, current_mode, native_mode, product_code, year_of_manufacture,
...@@ -521,7 +537,7 @@ std::vector<DisplaySnapshot_Params> CreateDisplaySnapshotParams( ...@@ -521,7 +537,7 @@ std::vector<DisplaySnapshot_Params> CreateDisplaySnapshotParams(
p.type = d->type(); p.type = d->type();
p.is_aspect_preserving_scaling = d->is_aspect_preserving_scaling(); p.is_aspect_preserving_scaling = d->is_aspect_preserving_scaling();
p.has_overscan = d->has_overscan(); p.has_overscan = d->has_overscan();
p.has_privacy_screen = d->has_privacy_screen(); p.privacy_screen_state = d->privacy_screen_state();
p.has_color_correction_matrix = d->has_color_correction_matrix(); p.has_color_correction_matrix = d->has_color_correction_matrix();
p.color_correction_in_linear_space = d->color_correction_in_linear_space(); p.color_correction_in_linear_space = d->color_correction_in_linear_space();
p.color_space = d->color_space(); p.color_space = d->color_space();
...@@ -570,7 +586,7 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot( ...@@ -570,7 +586,7 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
return std::make_unique<display::DisplaySnapshot>( return std::make_unique<display::DisplaySnapshot>(
params.display_id, params.origin, params.physical_size, params.type, params.display_id, params.origin, params.physical_size, params.type,
params.is_aspect_preserving_scaling, params.has_overscan, params.is_aspect_preserving_scaling, params.has_overscan,
params.has_privacy_screen, params.has_color_correction_matrix, params.privacy_screen_state, params.has_color_correction_matrix,
params.color_correction_in_linear_space, params.color_space, params.color_correction_in_linear_space, params.color_space,
params.bits_per_channel, params.display_name, params.sys_path, params.bits_per_channel, params.display_name, params.sys_path,
std::move(modes), params.panel_orientation, params.edid, current_mode, 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