Commit 857f47cd authored by kcwu@chromium.org's avatar kcwu@chromium.org

Fix HDCP in mirror mode.

BUG=chromium:371878
TEST=verified with pepper plugin manually

Review URL: https://codereview.chromium.org/284853002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271252 0039d316-1c4b-4281-b951-d872f2087c98
parent 6b6ff172
......@@ -936,6 +936,10 @@ void DisplayManager::SetSoftwareMirroring(bool enabled) {
return;
SetSecondDisplayMode(enabled ? MIRRORING : EXTENDED);
}
bool DisplayManager::SoftwareMirroringEnabled() const {
return software_mirroring_enabled();
}
#endif
void DisplayManager::SetSecondDisplayMode(SecondDisplayMode mode) {
......
......@@ -252,6 +252,7 @@ class ASH_EXPORT DisplayManager
// SoftwareMirroringController override:
#if defined(OS_CHROMEOS)
virtual void SetSoftwareMirroring(bool enabled) OVERRIDE;
virtual bool SoftwareMirroringEnabled() const OVERRIDE;
#endif
bool software_mirroring_enabled() const {
return second_display_mode_ == MIRRORING;
......
......@@ -215,15 +215,33 @@ void DisplayConfigurator::ForceInitialConfigure(
NotifyObservers(success, new_state);
}
bool DisplayConfigurator::IsMirroring() const {
return display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR ||
(mirroring_controller_ &&
mirroring_controller_->SoftwareMirroringEnabled());
}
bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) {
for (DisplayStateList::const_iterator it = cached_displays_.begin();
it != cached_displays_.end();
++it) {
uint32_t all_desired = 0;
ContentProtections::const_iterator request_it =
requests.find(it->display->display_id());
if (request_it != requests.end())
all_desired = request_it->second;
// In mirror mode, protection request of all displays need to be fulfilled.
// In non-mirror mode, only request of client's display needs to be
// fulfilled.
ContentProtections::const_iterator request_it;
if (IsMirroring()) {
for (request_it = requests.begin();
request_it != requests.end();
++request_it)
all_desired |= request_it->second;
} else {
request_it = requests.find(it->display->display_id());
if (request_it != requests.end())
all_desired = request_it->second;
}
switch (it->display->type()) {
case DISPLAY_CONNECTION_TYPE_UNKNOWN:
return false;
......@@ -294,8 +312,10 @@ bool DisplayConfigurator::QueryContentProtectionStatus(
for (DisplayStateList::const_iterator it = cached_displays_.begin();
it != cached_displays_.end();
++it) {
if (it->display->display_id() != display_id)
// Query display if it is in mirror mode or client on the same display.
if (!IsMirroring() && it->display->display_id() != display_id)
continue;
*link_mask |= it->display->type();
switch (it->display->type()) {
case DISPLAY_CONNECTION_TYPE_UNKNOWN:
......
......@@ -94,6 +94,7 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
// Called when the hardware mirroring failed.
virtual void SetSoftwareMirroring(bool enabled) = 0;
virtual bool SoftwareMirroringEnabled() const = 0;
};
class TouchscreenDelegate {
......@@ -321,6 +322,9 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
// (mirror_mode_width * mirrow_mode_height) / (native_width * native_height)
float GetMirroredDisplayAreaRatio(const DisplayState& display);
// Returns true if in either hardware or software mirroring mode.
bool IsMirroring() const;
// Applies display protections according to requests.
bool ApplyProtections(const ContentProtections& requests);
......
......@@ -350,7 +350,7 @@ class TestMirroringController
software_mirroring_enabled_ = enabled;
}
bool software_mirroring_enabled() const {
virtual bool SoftwareMirroringEnabled() const OVERRIDE {
return software_mirroring_enabled_;
}
......@@ -566,7 +566,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
kUngrab,
NULL),
log_->GetActionsAndClear());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
observer_.Reset();
......@@ -581,7 +581,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
kUngrab,
NULL),
log_->GetActionsAndClear());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Disconnect the second output.
......@@ -595,7 +595,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
kUngrab,
NULL),
log_->GetActionsAndClear());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Get rid of shared modes to force software mirroring.
......@@ -618,14 +618,14 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
kUngrab,
NULL),
log_->GetActionsAndClear());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
observer_.Reset();
EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR));
EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear());
EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
configurator_.display_state());
EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled());
EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure.
......@@ -633,7 +633,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
EXPECT_TRUE(
configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED));
EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Set back to software mirror mode.
......@@ -642,7 +642,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear());
EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
configurator_.display_state());
EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled());
EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Disconnect the second output.
......@@ -656,7 +656,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) {
kUngrab,
NULL),
log_->GetActionsAndClear());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
}
......@@ -676,7 +676,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
kUngrab,
NULL),
log_->GetActionsAndClear());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Turning off the internal display should switch the external display to
......@@ -714,7 +714,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
NULL),
log_->GetActionsAndClear());
EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Turn all displays on and check that mirroring is still used.
......@@ -733,7 +733,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
NULL),
log_->GetActionsAndClear());
EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Get rid of shared modes to force software mirroring.
......@@ -762,7 +762,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
log_->GetActionsAndClear());
EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
configurator_.display_state());
EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled());
EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Turning off the internal display should switch the external display to
......@@ -783,7 +783,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
NULL),
log_->GetActionsAndClear());
EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state());
EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled());
EXPECT_FALSE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// When all displays are turned off, the framebuffer should switch back
......@@ -809,7 +809,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
log_->GetActionsAndClear());
EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
configurator_.display_state());
EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled());
EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
// Turn all displays on and check that mirroring is still used.
......@@ -835,7 +835,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
log_->GetActionsAndClear());
EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
configurator_.display_state());
EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled());
EXPECT_TRUE(mirroring_controller_.SoftwareMirroringEnabled());
EXPECT_EQ(1, observer_.num_changes());
}
......
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