Commit bed23cbb authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: cleans up display related mojoms

This removes the mojom interfaces DevDisplayController and DisplayController which
are unused. OutputProtection is still necessary. As OutputProtection is now provided
by ash, OutputProtection has been moved to ash. Additionally, OutputProtection has
been renamed to DisplayOutputProtection. OutputProtection was previously in the
display namespace, so that renaming to DisplayOutputProtection makes it more
obvious what the class is for.

BUG=842365
TEST=none


Change-Id: I1f469032fc991139964b04b9740da64abafa89e0
Reviewed-on: https://chromium-review.googlesource.com/1183892Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585215}
parent 13de6cf8
...@@ -790,6 +790,8 @@ component("ash") { ...@@ -790,6 +790,8 @@ component("ash") {
"display/display_configuration_observer.cc", "display/display_configuration_observer.cc",
"display/display_error_observer.cc", "display/display_error_observer.cc",
"display/display_move_window_util.cc", "display/display_move_window_util.cc",
"display/display_output_protection.cc",
"display/display_output_protection.h",
"display/display_prefs.cc", "display/display_prefs.cc",
"display/display_shutdown_observer.cc", "display/display_shutdown_observer.cc",
"display/display_util.cc", "display/display_util.cc",
...@@ -1323,7 +1325,6 @@ component("ash") { ...@@ -1323,7 +1325,6 @@ component("ash") {
"//services/ui/public/cpp", "//services/ui/public/cpp",
"//services/ui/public/cpp/input_devices", "//services/ui/public/cpp/input_devices",
"//services/ui/public/interfaces", "//services/ui/public/interfaces",
"//services/ui/public/interfaces/display",
"//services/ui/ws2:host", "//services/ui/ws2:host",
"//services/ui/ws2:lib", "//services/ui/ws2:lib",
"//skia", "//skia",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/display/display_output_protection.h"
#include <utility>
#include "ui/display/manager/display_configurator.h"
using display::DisplayConfigurator;
namespace ash {
// A BindingContext is created for each bind request. BindingContext contains
// the state unique to each connection.
class DisplayOutputProtection::BindingContext {
public:
explicit BindingContext(DisplayConfigurator* display_configurator)
: display_configurator_(display_configurator),
client_id_(display_configurator_->RegisterContentProtectionClient()) {}
~BindingContext() {
display_configurator_->UnregisterContentProtectionClient(client_id_);
}
uint64_t client_id() const { return client_id_; }
private:
display::DisplayConfigurator* const display_configurator_;
const uint64_t client_id_;
DISALLOW_COPY_AND_ASSIGN(BindingContext);
};
DisplayOutputProtection::DisplayOutputProtection(
DisplayConfigurator* display_configurator)
: display_configurator_(display_configurator) {}
DisplayOutputProtection::~DisplayOutputProtection() = default;
void DisplayOutputProtection::BindRequest(
mojom::DisplayOutputProtectionRequest request) {
std::unique_ptr<BindingContext> context =
std::make_unique<BindingContext>(display_configurator_);
bindings_.AddBinding(this, std::move(request), std::move(context));
}
void DisplayOutputProtection::QueryContentProtectionStatus(
int64_t display_id,
QueryContentProtectionStatusCallback callback) {
display_configurator_->QueryContentProtectionStatus(
bindings_.dispatch_context()->client_id(), display_id,
std::move(callback));
}
void DisplayOutputProtection::SetContentProtection(
int64_t display_id,
uint32_t desired_method_mask,
SetContentProtectionCallback callback) {
display_configurator_->SetContentProtection(
bindings_.dispatch_context()->client_id(), display_id,
desired_method_mask, std::move(callback));
}
} // namespace ash
...@@ -2,26 +2,34 @@ ...@@ -2,26 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef SERVICES_UI_DISPLAY_OUTPUT_PROTECTION_H_ #ifndef ASH_DISPLAY_DISPLAY_OUTPUT_PROTECTION_H_
#define SERVICES_UI_DISPLAY_OUTPUT_PROTECTION_H_ #define ASH_DISPLAY_DISPLAY_OUTPUT_PROTECTION_H_
#include <stdint.h> #include <stdint.h>
#include <memory>
#include "ash/public/interfaces/display_output_protection.mojom.h"
#include "base/macros.h" #include "base/macros.h"
#include "services/ui/public/interfaces/display/output_protection.mojom.h" #include "mojo/public/cpp/bindings/binding_set.h"
namespace display { namespace display {
class DisplayConfigurator; class DisplayConfigurator;
}
namespace ash {
// OutputProtection provides the necessary functionality to configure output // DisplayOutputProtection provides the necessary functionality to configure
// protection. // output protection.
class OutputProtection : public mojom::OutputProtection { class DisplayOutputProtection : public mojom::DisplayOutputProtection {
public: public:
explicit OutputProtection(DisplayConfigurator* display_configurator); explicit DisplayOutputProtection(
~OutputProtection() override; display::DisplayConfigurator* display_configurator);
~DisplayOutputProtection() override;
// mojom::OutputProtection: void BindRequest(mojom::DisplayOutputProtectionRequest request);
// mojom::DisplayOutputProtection:
void QueryContentProtectionStatus( void QueryContentProtectionStatus(
int64_t display_id, int64_t display_id,
QueryContentProtectionStatusCallback callback) override; QueryContentProtectionStatusCallback callback) override;
...@@ -30,12 +38,18 @@ class OutputProtection : public mojom::OutputProtection { ...@@ -30,12 +38,18 @@ class OutputProtection : public mojom::OutputProtection {
SetContentProtectionCallback callback) override; SetContentProtectionCallback callback) override;
private: private:
DisplayConfigurator* const display_configurator_; class BindingContext;
const uint64_t client_id_;
display::DisplayConfigurator* const display_configurator_;
mojo::BindingSetBase<mojom::DisplayOutputProtection,
mojo::Binding<mojom::DisplayOutputProtection>,
std::unique_ptr<BindingContext>>
bindings_;
DISALLOW_COPY_AND_ASSIGN(OutputProtection); DISALLOW_COPY_AND_ASSIGN(DisplayOutputProtection);
}; };
} // namespace display } // namespace ash
#endif // SERVICES_UI_DISPLAY_OUTPUT_PROTECTION_H_ #endif // ASH_DISPLAY_DISPLAY_OUTPUT_PROTECTION_H_
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
], ],
// Only chrome is allowed to use this (required as dbus runs in Chrome). // Only chrome is allowed to use this (required as dbus runs in Chrome).
"display": [ "display": [
"ash.mojom.AshDisplayController" "ash.mojom.AshDisplayController",
"ash.mojom.DisplayOutputProtection"
], ],
"mus:window_manager": [ "ui.mojom.AcceleratorRegistrar" ], "mus:window_manager": [ "ui.mojom.AcceleratorRegistrar" ],
"service_manager:service_factory": [ "service_manager:service_factory": [
...@@ -73,7 +74,6 @@ ...@@ -73,7 +74,6 @@
"quick_launch_app": [ "mash:launchable" ], "quick_launch_app": [ "mash:launchable" ],
"service_manager": [ "service_manager:singleton" ], "service_manager": [ "service_manager:singleton" ],
"ui": [ "ui": [
"display_dev",
"ozone", "ozone",
"window_manager" "window_manager"
], ],
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ash/client_image_registry.h" #include "ash/client_image_registry.h"
#include "ash/display/ash_display_controller.h" #include "ash/display/ash_display_controller.h"
#include "ash/display/cros_display_config.h" #include "ash/display/cros_display_config.h"
#include "ash/display/display_output_protection.h"
#include "ash/events/event_rewriter_controller.h" #include "ash/events/event_rewriter_controller.h"
#include "ash/first_run/first_run_helper.h" #include "ash/first_run/first_run_helper.h"
#include "ash/highlighter/highlighter_controller.h" #include "ash/highlighter/highlighter_controller.h"
...@@ -109,6 +110,11 @@ void BindClientImageRegistryRequestOnMainThread( ...@@ -109,6 +110,11 @@ void BindClientImageRegistryRequestOnMainThread(
Shell::Get()->client_image_registry()->BindRequest(std::move(request)); Shell::Get()->client_image_registry()->BindRequest(std::move(request));
} }
void BindDisplayOutputProtectionRequestOnMainThread(
mojom::DisplayOutputProtectionRequest request) {
Shell::Get()->display_output_protection()->BindRequest(std::move(request));
}
void BindDockedMagnifierControllerRequestOnMainThread( void BindDockedMagnifierControllerRequestOnMainThread(
mojom::DockedMagnifierControllerRequest request) { mojom::DockedMagnifierControllerRequest request) {
Shell::Get()->docked_magnifier_controller()->BindRequest(std::move(request)); Shell::Get()->docked_magnifier_controller()->BindRequest(std::move(request));
...@@ -254,6 +260,9 @@ void RegisterInterfaces( ...@@ -254,6 +260,9 @@ void RegisterInterfaces(
registry->AddInterface( registry->AddInterface(
base::BindRepeating(&BindClientImageRegistryRequestOnMainThread), base::BindRepeating(&BindClientImageRegistryRequestOnMainThread),
main_thread_task_runner); main_thread_task_runner);
registry->AddInterface(
base::BindRepeating(&BindDisplayOutputProtectionRequestOnMainThread),
main_thread_task_runner);
if (features::IsDockedMagnifierEnabled()) { if (features::IsDockedMagnifierEnabled()) {
registry->AddInterface( registry->AddInterface(
base::BindRepeating(&BindDockedMagnifierControllerRequestOnMainThread), base::BindRepeating(&BindDockedMagnifierControllerRequestOnMainThread),
......
...@@ -26,6 +26,7 @@ mojom("interfaces_internal") { ...@@ -26,6 +26,7 @@ mojom("interfaces_internal") {
"client_image_registry.mojom", "client_image_registry.mojom",
"constants.mojom", "constants.mojom",
"cros_display_config.mojom", "cros_display_config.mojom",
"display_output_protection.mojom",
"docked_magnifier_controller.mojom", "docked_magnifier_controller.mojom",
"event_properties.mojom", "event_properties.mojom",
"event_rewriter_controller.mojom", "event_rewriter_controller.mojom",
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
module display.mojom; module ash.mojom;
// An interface for clients that are allowed to control the display output // An interface for clients that are allowed to control the display output
// content protection. Multiple clients can request content protection at // content protection. Multiple clients can request content protection at
// the same time, and the display will be protected until all clients are // the same time, and the display will be protected until all clients are
// closed or set |desired_method_mask| to 0 with |SetContentProtection|. // closed or set |desired_method_mask| to 0 with |SetContentProtection|.
interface OutputProtection { interface DisplayOutputProtection {
// Queries link status and protection status. // Queries link status and protection status.
// |link_mask| is the type of connected display links, which is a bitmask of // |link_mask| is the type of connected display links, which is a bitmask of
// DisplayConnectionType values. // DisplayConnectionType values.
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "ash/display/display_configuration_controller.h" #include "ash/display/display_configuration_controller.h"
#include "ash/display/display_configuration_observer.h" #include "ash/display/display_configuration_observer.h"
#include "ash/display/display_error_observer.h" #include "ash/display/display_error_observer.h"
#include "ash/display/display_output_protection.h"
#include "ash/display/display_prefs.h" #include "ash/display/display_prefs.h"
#include "ash/display/display_shutdown_observer.h" #include "ash/display/display_shutdown_observer.h"
#include "ash/display/event_transformation_handler.h" #include "ash/display/event_transformation_handler.h"
...@@ -194,7 +195,6 @@ ...@@ -194,7 +195,6 @@
#include "ui/display/manager/display_configurator.h" #include "ui/display/manager/display_configurator.h"
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
#include "ui/display/manager/touch_transform_setter.h" #include "ui/display/manager/touch_transform_setter.h"
#include "ui/display/mojo/dev_display_controller.mojom.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/display/types/native_display_delegate.h" #include "ui/display/types/native_display_delegate.h"
#include "ui/events/event_target_iterator.h" #include "ui/events/event_target_iterator.h"
...@@ -724,7 +724,9 @@ Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate, ...@@ -724,7 +724,9 @@ Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate,
window_cycle_controller_(std::make_unique<WindowCycleController>()), window_cycle_controller_(std::make_unique<WindowCycleController>()),
window_selector_controller_(std::make_unique<WindowSelectorController>()), window_selector_controller_(std::make_unique<WindowSelectorController>()),
tray_bluetooth_helper_(std::make_unique<TrayBluetoothHelper>()), tray_bluetooth_helper_(std::make_unique<TrayBluetoothHelper>()),
display_configurator_(new display::DisplayConfigurator()), display_configurator_(std::make_unique<display::DisplayConfigurator>()),
display_output_protection_(std::make_unique<DisplayOutputProtection>(
display_configurator_.get())),
native_cursor_manager_(nullptr), native_cursor_manager_(nullptr),
weak_factory_(this) { weak_factory_(this) {
display_manager_.reset(ScreenAsh::CreateDisplayManager()); display_manager_.reset(ScreenAsh::CreateDisplayManager());
......
...@@ -108,6 +108,7 @@ class BluetoothPowerController; ...@@ -108,6 +108,7 @@ class BluetoothPowerController;
class BrightnessControlDelegate; class BrightnessControlDelegate;
class CastConfigController; class CastConfigController;
class ClientImageRegistry; class ClientImageRegistry;
class DisplayOutputProtection;
class CrosDisplayConfig; class CrosDisplayConfig;
class DetachableBaseHandler; class DetachableBaseHandler;
class DetachableBaseNotificationController; class DetachableBaseNotificationController;
...@@ -395,6 +396,9 @@ class ASH_EXPORT Shell : public SessionObserver, ...@@ -395,6 +396,9 @@ class ASH_EXPORT Shell : public SessionObserver,
DisplayErrorObserver* display_error_observer() { DisplayErrorObserver* display_error_observer() {
return display_error_observer_.get(); return display_error_observer_.get();
} }
DisplayOutputProtection* display_output_protection() {
return display_output_protection_.get();
}
DockedMagnifierController* docked_magnifier_controller(); DockedMagnifierController* docked_magnifier_controller();
aura::Env* aura_env() { return aura_env_; } aura::Env* aura_env() { return aura_env_; }
...@@ -847,6 +851,7 @@ class ASH_EXPORT Shell : public SessionObserver, ...@@ -847,6 +851,7 @@ class ASH_EXPORT Shell : public SessionObserver,
std::unique_ptr<VirtualKeyboardController> virtual_keyboard_controller_; std::unique_ptr<VirtualKeyboardController> virtual_keyboard_controller_;
// Controls video output device state. // Controls video output device state.
std::unique_ptr<display::DisplayConfigurator> display_configurator_; std::unique_ptr<display::DisplayConfigurator> display_configurator_;
std::unique_ptr<DisplayOutputProtection> display_output_protection_;
std::unique_ptr<DisplayColorManager> display_color_manager_; std::unique_ptr<DisplayColorManager> display_color_manager_;
std::unique_ptr<DisplayErrorObserver> display_error_observer_; std::unique_ptr<DisplayErrorObserver> display_error_observer_;
std::unique_ptr<ProjectingObserver> projecting_observer_; std::unique_ptr<ProjectingObserver> projecting_observer_;
......
...@@ -65,7 +65,6 @@ ...@@ -65,7 +65,6 @@
"secure_channel": [ "secure_channel" ], "secure_channel": [ "secure_channel" ],
"shortcut_viewer_app": [ "shortcut_viewer" ], "shortcut_viewer_app": [ "shortcut_viewer" ],
"ui": [ "ui": [
"display_dev",
"ime_registrar", "ime_registrar",
"input_device_controller", "input_device_controller",
"window_manager" "window_manager"
......
...@@ -190,7 +190,6 @@ source_set("chromeos") { ...@@ -190,7 +190,6 @@ source_set("chromeos") {
"//services/preferences/public/mojom", "//services/preferences/public/mojom",
"//services/service_manager/public/cpp", "//services/service_manager/public/cpp",
"//services/service_manager/runner/common", "//services/service_manager/runner/common",
"//services/ui/public/interfaces/display",
# TODO: care about enable_basic_printing and enable_print_preview. # TODO: care about enable_basic_printing and enable_print_preview.
"//components/sync", "//components/sync",
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/display/output_protection_controller_mus.h" #include "chrome/browser/chromeos/display/output_protection_controller_mus.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "content/public/common/service_manager_connection.h" #include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
...@@ -12,7 +13,7 @@ namespace chromeos { ...@@ -12,7 +13,7 @@ namespace chromeos {
OutputProtectionControllerMus::OutputProtectionControllerMus() { OutputProtectionControllerMus::OutputProtectionControllerMus() {
content::ServiceManagerConnection::GetForProcess() content::ServiceManagerConnection::GetForProcess()
->GetConnector() ->GetConnector()
->BindInterface("ui", &output_protection_); ->BindInterface(ash::mojom::kServiceName, &display_output_protection_);
} }
OutputProtectionControllerMus::~OutputProtectionControllerMus() { OutputProtectionControllerMus::~OutputProtectionControllerMus() {
...@@ -23,7 +24,8 @@ void OutputProtectionControllerMus::QueryStatus( ...@@ -23,7 +24,8 @@ void OutputProtectionControllerMus::QueryStatus(
int64_t display_id, int64_t display_id,
const OutputProtectionDelegate::QueryStatusCallback& callback) { const OutputProtectionDelegate::QueryStatusCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
output_protection_->QueryContentProtectionStatus(display_id, callback); display_output_protection_->QueryContentProtectionStatus(display_id,
callback);
} }
void OutputProtectionControllerMus::SetProtection( void OutputProtectionControllerMus::SetProtection(
...@@ -31,8 +33,8 @@ void OutputProtectionControllerMus::SetProtection( ...@@ -31,8 +33,8 @@ void OutputProtectionControllerMus::SetProtection(
uint32_t desired_method_mask, uint32_t desired_method_mask,
const OutputProtectionDelegate::SetProtectionCallback& callback) { const OutputProtectionDelegate::SetProtectionCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
output_protection_->SetContentProtection(display_id, desired_method_mask, display_output_protection_->SetContentProtection(
callback); display_id, desired_method_mask, callback);
} }
} // namespace chromeos } // namespace chromeos
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
#ifndef CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_CONTROLLER_MUS_H_ #ifndef CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_CONTROLLER_MUS_H_
#define CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_CONTROLLER_MUS_H_ #define CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_CONTROLLER_MUS_H_
#include "ash/public/interfaces/display_output_protection.mojom.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "chrome/browser/chromeos/display/output_protection_delegate.h" #include "chrome/browser/chromeos/display/output_protection_delegate.h"
#include "services/ui/public/interfaces/display/output_protection.mojom.h"
namespace chromeos { namespace chromeos {
...@@ -29,7 +29,7 @@ class OutputProtectionControllerMus ...@@ -29,7 +29,7 @@ class OutputProtectionControllerMus
const OutputProtectionDelegate::SetProtectionCallback& callback) override; const OutputProtectionDelegate::SetProtectionCallback& callback) override;
private: private:
display::mojom::OutputProtectionPtr output_protection_; ash::mojom::DisplayOutputProtectionPtr display_output_protection_;
base::ThreadChecker thread_checker_; base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(OutputProtectionControllerMus); DISALLOW_COPY_AND_ASSIGN(OutputProtectionControllerMus);
......
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
"tracing": [ "tracing": [
"tracing" "tracing"
], ],
"ui": [ "arc_manager", "display_output_protection" ], "ui": [ "arc_manager" ],
"unzip_service": [ "unzip_file" ], "unzip_service": [ "unzip_file" ],
"video_capture": [ "capture", "tests" ] "video_capture": [ "capture", "tests" ]
} }
......
...@@ -78,10 +78,6 @@ service_test("services_unittests") { ...@@ -78,10 +78,6 @@ service_test("services_unittests") {
deps += [ "//services/video_capture:tests" ] deps += [ "//services/video_capture:tests" ]
} }
if (is_chromeos) {
deps += [ "//services/ui/display:tests" ]
}
test_runner = "//services/test:run_all_service_tests" test_runner = "//services/test:run_all_service_tests"
catalog = ":services_unittests_catalog" catalog = ":services_unittests_catalog"
......
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/ui.gni")
import("//testing/test.gni")
source_set("display") {
sources = [
"screen_manager.cc",
"screen_manager.h",
"screen_manager_delegate.h",
"viewport_metrics.cc",
"viewport_metrics.h",
]
deps = [
"//base",
"//services/service_manager/public/cpp",
"//ui/display",
"//ui/gfx",
]
if (use_ozone) {
if (is_chromeos) {
sources += [
"output_protection.cc",
"output_protection.h",
"screen_manager_forwarding.cc",
"screen_manager_forwarding.h",
"screen_manager_ozone_internal.cc",
"screen_manager_ozone_internal.h",
]
deps += [
"//chromeos",
"//services/ui/public/interfaces/display",
"//ui/display/manager",
"//ui/display/mojo:interfaces",
"//ui/ozone",
]
} else {
sources += [
"screen_manager_ozone_external.cc",
"screen_manager_ozone_external.h",
]
}
} else {
sources += [
"screen_manager_stub_internal.cc",
"screen_manager_stub_internal.h",
]
}
}
if (is_chromeos) {
source_set("tests") {
testonly = true
sources = [
"screen_manager_ozone_internal_unittests.cc",
]
deps = [
":display",
"//base",
"//base/test:test_support",
"//services/ui/common:task_runner_test_base",
"//testing/gmock",
"//testing/gtest",
"//ui/base",
"//ui/display/manager",
"//ui/events/devices",
"//ui/gfx",
"//ui/gfx:test_support",
"//ui/ozone",
]
data_deps = [
"//ui/resources:ui_test_pak_data",
]
}
}
kylechar@chromium.org
rjkroege@chromium.org
# COMPONENT: Internals>Services>WindowService
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ui/display/output_protection.h"
#include "ui/display/manager/display_configurator.h"
namespace display {
OutputProtection::OutputProtection(DisplayConfigurator* display_configurator)
: display_configurator_(display_configurator),
client_id_(display_configurator_->RegisterContentProtectionClient()) {}
OutputProtection::~OutputProtection() {
display_configurator_->UnregisterContentProtectionClient(client_id_);
}
void OutputProtection::QueryContentProtectionStatus(
int64_t display_id,
QueryContentProtectionStatusCallback callback) {
display_configurator_->QueryContentProtectionStatus(client_id_, display_id,
std::move(callback));
}
void OutputProtection::SetContentProtection(
int64_t display_id,
uint32_t desired_method_mask,
SetContentProtectionCallback callback) {
display_configurator_->SetContentProtection(
client_id_, display_id, desired_method_mask, std::move(callback));
}
} // namespace display
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ui/display/screen_manager.h"
#include "base/logging.h"
namespace display {
// static
ScreenManager* ScreenManager::instance_ = nullptr;
ScreenManager::ScreenManager() {
DCHECK(!instance_);
instance_ = this;
}
ScreenManager::~ScreenManager() {
DCHECK_EQ(instance_, this);
instance_ = nullptr;
}
// static
ScreenManager* ScreenManager::GetInstance() {
DCHECK(instance_);
return instance_;
}
} // namespace display
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_DISPLAY_SCREEN_MANAGER_H_
#define SERVICES_UI_DISPLAY_SCREEN_MANAGER_H_
#include <memory>
#include "base/macros.h"
#include "services/service_manager/public/cpp/bind_source_info.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/ui/display/screen_manager_delegate.h"
namespace display {
class ScreenBase;
// ScreenManager provides the necessary functionality to configure all
// attached physical displays.
class ScreenManager {
public:
ScreenManager();
virtual ~ScreenManager();
// Creates a singleton ScreenManager instance.
static std::unique_ptr<ScreenManager> Create();
static ScreenManager* GetInstance();
// Registers Mojo interfaces provided.
virtual void AddInterfaces(
service_manager::BinderRegistryWithArgs<
const service_manager::BindSourceInfo&>* registry) = 0;
// Triggers initial display configuration to start. On device this will
// configuration the connected displays. Off device this will create one or
// more fake displays and pretend to configure them. A non-null |delegate|
// must be provided that will receive notifications when displays are added,
// removed or modified.
virtual void Init(ScreenManagerDelegate* delegate) = 0;
// Handle requests from the platform to close a display.
virtual void RequestCloseDisplay(int64_t display_id) = 0;
virtual display::ScreenBase* GetScreen() = 0;
private:
static ScreenManager* instance_; // Instance is not owned.
DISALLOW_COPY_AND_ASSIGN(ScreenManager);
};
} // namespace display
#endif // SERVICES_UI_DISPLAY_SCREEN_MANAGER_H_
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_DISPLAY_SCREEN_MANAGER_DELEGATE_H_
#define SERVICES_UI_DISPLAY_SCREEN_MANAGER_DELEGATE_H_
#include <stdint.h>
namespace display {
class Display;
struct ViewportMetrics;
// The ScreenManagerDelegate will be informed of changes to the display or
// screen state by ScreenManager.
class ScreenManagerDelegate {
public:
// Called when a display is added.
virtual void OnDisplayAdded(const display::Display& display,
const ViewportMetrics& metrics) = 0;
// Called when a display is modified.
virtual void OnDisplayModified(const display::Display& display,
const ViewportMetrics& metrics) = 0;
// Called when a display is removed.
virtual void OnDisplayRemoved(int64_t display_id) = 0;
// Called when the primary display is changed.
virtual void OnPrimaryDisplayChanged(int64_t primary_display_id) = 0;
protected:
virtual ~ScreenManagerDelegate() {}
};
} // namespace display
#endif // SERVICES_UI_DISPLAY_SCREEN_MANAGER_DELEGATE_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ui/display/screen_manager_forwarding.h"
#include <utility>
#include "base/bind.h"
#include "chromeos/system/devicemode.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "ui/display/screen_base.h"
#include "ui/display/types/display_constants.h"
#include "ui/display/types/display_snapshot.h"
#include "ui/display/types/fake_display_controller.h"
#include "ui/display/types/native_display_delegate.h"
#include "ui/ozone/public/ozone_platform.h"
namespace display {
namespace {
// Finds the display mode in |snapshot| that corresponds to |mode_to_find|.
const DisplayMode* GetCorrespondingMode(const DisplaySnapshot& snapshot,
const DisplayMode* mode_to_find) {
if (!mode_to_find)
return nullptr;
for (auto& mode : snapshot.modes()) {
if (mode->size() == mode_to_find->size() &&
mode->is_interlaced() == mode_to_find->is_interlaced() &&
mode->refresh_rate() == mode_to_find->refresh_rate()) {
return mode.get();
}
}
NOTREACHED();
return nullptr;
}
} // namespace
ScreenManagerForwarding::ScreenManagerForwarding(Mode mode)
: is_in_process_(mode == Mode::IN_WM_PROCESS),
screen_(std::make_unique<display::ScreenBase>()),
binding_(this),
dev_controller_binding_(this) {
if (!is_in_process_)
Screen::SetScreenInstance(screen_.get());
}
ScreenManagerForwarding::~ScreenManagerForwarding() {
if (native_display_delegate_)
native_display_delegate_->RemoveObserver(this);
if (!is_in_process_)
Screen::SetScreenInstance(nullptr);
}
void ScreenManagerForwarding::AddInterfaces(
service_manager::BinderRegistryWithArgs<
const service_manager::BindSourceInfo&>* registry) {
registry->AddInterface<mojom::NativeDisplayDelegate>(
base::Bind(&ScreenManagerForwarding::BindNativeDisplayDelegateRequest,
base::Unretained(this)));
registry->AddInterface<mojom::DevDisplayController>(
base::Bind(&ScreenManagerForwarding::BindDevDisplayControllerRequest,
base::Unretained(this)));
}
void ScreenManagerForwarding::Init(ScreenManagerDelegate* delegate) {
// Done in NativeDisplayDelegate::Initialize() instead.
}
void ScreenManagerForwarding::RequestCloseDisplay(int64_t display_id) {
if (!fake_display_controller_)
return;
// Tell NativeDisplayDelegate to remove the display. This triggers an
// OnConfigurationChanged() and the corresponding display snapshot will be
// gone.
fake_display_controller_->RemoveDisplay(display_id);
}
display::ScreenBase* ScreenManagerForwarding::GetScreen() {
return screen_.get();
}
void ScreenManagerForwarding::OnConfigurationChanged() {
if (observer_.is_bound())
observer_->OnConfigurationChanged();
}
void ScreenManagerForwarding::OnDisplaySnapshotsInvalidated() {
snapshot_map_.clear();
}
void ScreenManagerForwarding::Initialize(
mojom::NativeDisplayObserverPtr observer,
InitializeCallback callback) {
DCHECK(!native_display_delegate_);
observer_ = std::move(observer);
native_display_delegate_ =
ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate();
native_display_delegate_->AddObserver(this);
native_display_delegate_->Initialize();
// FakeDisplayController is only applicable when not running on a CrOS device.
if (!chromeos::IsRunningAsSystemCompositor()) {
fake_display_controller_ =
native_display_delegate_->GetFakeDisplayController();
}
// Provide the list of display snapshots initially. ForwardingDisplayDelegate
// will wait synchronously for this.
native_display_delegate_->GetDisplays(
base::BindOnce(&ScreenManagerForwarding::ForwardGetDisplays,
base::Unretained(this), std::move(callback)));
// When ForwardingDisplayDelegate receives this it will start asynchronous
// operation and redo any configuration that was skipped.
observer_->OnConfigurationChanged();
}
void ScreenManagerForwarding::TakeDisplayControl(
TakeDisplayControlCallback callback) {
DCHECK(native_display_delegate_);
native_display_delegate_->TakeDisplayControl(std::move(callback));
}
void ScreenManagerForwarding::RelinquishDisplayControl(
RelinquishDisplayControlCallback callback) {
DCHECK(native_display_delegate_);
native_display_delegate_->RelinquishDisplayControl(std::move(callback));
}
void ScreenManagerForwarding::GetDisplays(GetDisplaysCallback callback) {
DCHECK(native_display_delegate_);
native_display_delegate_->GetDisplays(
base::BindOnce(&ScreenManagerForwarding::ForwardGetDisplays,
base::Unretained(this), std::move(callback)));
}
void ScreenManagerForwarding::Configure(
int64_t display_id,
base::Optional<std::unique_ptr<display::DisplayMode>> mode,
const gfx::Point& origin,
ConfigureCallback callback) {
DCHECK(native_display_delegate_);
DisplaySnapshot* snapshot = snapshot_map_[display_id];
if (!snapshot) {
std::move(callback).Run(false);
return;
}
// We need a pointer to the mode in |snapshot|, not the equivalent mode we
// received over Mojo.
const DisplayMode* snapshot_mode =
mode ? GetCorrespondingMode(*snapshot, mode->get()) : nullptr;
native_display_delegate_->Configure(
*snapshot, snapshot_mode, origin,
base::BindOnce(&ScreenManagerForwarding::ForwardConfigure,
base::Unretained(this), snapshot, snapshot_mode, origin,
std::move(callback)));
}
void ScreenManagerForwarding::GetHDCPState(int64_t display_id,
GetHDCPStateCallback callback) {
DCHECK(native_display_delegate_);
const DisplaySnapshot* snapshot = snapshot_map_[display_id];
if (!snapshot) {
std::move(callback).Run(false, HDCP_STATE_UNDESIRED);
return;
}
native_display_delegate_->GetHDCPState(*snapshot, std::move(callback));
}
void ScreenManagerForwarding::SetHDCPState(int64_t display_id,
display::HDCPState state,
SetHDCPStateCallback callback) {
DCHECK(native_display_delegate_);
const DisplaySnapshot* snapshot = snapshot_map_[display_id];
if (!snapshot) {
std::move(callback).Run(false);
return;
}
native_display_delegate_->SetHDCPState(*snapshot, state, std::move(callback));
}
void ScreenManagerForwarding::SetColorMatrix(
int64_t display_id,
const std::vector<float>& color_matrix) {
DCHECK(native_display_delegate_);
DCHECK(snapshot_map_.count(display_id));
native_display_delegate_->SetColorMatrix(display_id, color_matrix);
}
void ScreenManagerForwarding::SetGammaCorrection(
int64_t display_id,
const std::vector<display::GammaRampRGBEntry>& degamma_lut,
const std::vector<display::GammaRampRGBEntry>& gamma_lut) {
DCHECK(native_display_delegate_);
DCHECK(snapshot_map_.count(display_id));
native_display_delegate_->SetGammaCorrection(display_id, degamma_lut,
gamma_lut);
}
void ScreenManagerForwarding::ToggleAddRemoveDisplay() {
if (!fake_display_controller_)
return;
int num_displays = screen_->GetNumDisplays();
if (num_displays == 1) {
// If we have one display, add a second display with the same size.
Display primary_display = screen_->GetPrimaryDisplay();
fake_display_controller_->AddDisplay(primary_display.GetSizeInPixel());
} else if (num_displays > 1) {
// If we have more than one display, remove the first display we find that
// isn't the primary display.
Display primary_display = screen_->GetPrimaryDisplay();
for (auto& display : screen_->display_list().displays()) {
if (display.id() != primary_display.id()) {
fake_display_controller_->RemoveDisplay(display.id());
break;
}
}
} else {
// If we have no displays, add one with a default size.
fake_display_controller_->AddDisplay(gfx::Size(1024, 768));
}
}
void ScreenManagerForwarding::BindNativeDisplayDelegateRequest(
mojom::NativeDisplayDelegateRequest request,
const service_manager::BindSourceInfo& source_info) {
DCHECK(!binding_.is_bound());
binding_.Bind(std::move(request));
}
void ScreenManagerForwarding::BindDevDisplayControllerRequest(
mojom::DevDisplayControllerRequest request,
const service_manager::BindSourceInfo& source_info) {
DCHECK(!dev_controller_binding_.is_bound());
dev_controller_binding_.Bind(std::move(request));
}
void ScreenManagerForwarding::ForwardGetDisplays(
GetDisplaysCallback callback,
const std::vector<DisplaySnapshot*>& snapshots) {
snapshot_map_.clear();
std::vector<std::unique_ptr<DisplaySnapshot>> snapshot_clones;
for (auto* snapshot : snapshots) {
snapshot_map_[snapshot->display_id()] = snapshot;
// Clone display snapshots to send over IPC.
snapshot_clones.push_back(snapshot->Clone());
}
std::move(callback).Run(std::move(snapshot_clones));
}
void ScreenManagerForwarding::ForwardConfigure(
DisplaySnapshot* snapshot,
const DisplayMode* mode,
const gfx::Point& origin,
mojom::NativeDisplayDelegate::ConfigureCallback callback,
bool status) {
if (status) {
// Modify display snapshot similar to how ConfigureDisplaysTask would. Ozone
// DRM needs these to be changed and ConfigureDisplaysTasks can't do it.
snapshot->set_current_mode(mode);
snapshot->set_origin(origin);
}
std::move(callback).Run(status);
}
} // namespace display
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_DISPLAY_SCREEN_MANAGER_FORWARDING_H_
#define SERVICES_UI_DISPLAY_SCREEN_MANAGER_FORWARDING_H_
#include <memory>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/ui/display/screen_manager.h"
#include "ui/display/mojo/dev_display_controller.mojom.h"
#include "ui/display/mojo/native_display_delegate.mojom.h"
#include "ui/display/types/native_display_observer.h"
namespace display {
class FakeDisplayController;
class NativeDisplayDelegate;
// ScreenManager implementation that implements mojom::NativeDisplayDelegate.
// This will own a real NativeDisplayDelegate and forwards calls to and
// responses from it over Mojo.
class ScreenManagerForwarding : public ScreenManager,
public mojom::DevDisplayController,
public NativeDisplayObserver,
public mojom::NativeDisplayDelegate {
public:
enum class Mode {
IN_WM_PROCESS,
OWN_PROCESS,
};
// |in_process| is true if the UI Service runs inside WM's process, false if
// it runs inside its own process.
explicit ScreenManagerForwarding(Mode mode);
~ScreenManagerForwarding() override;
// ScreenManager:
void AddInterfaces(
service_manager::BinderRegistryWithArgs<
const service_manager::BindSourceInfo&>* registry) override;
void Init(ScreenManagerDelegate* delegate) override;
void RequestCloseDisplay(int64_t display_id) override;
display::ScreenBase* GetScreen() override;
// NativeDisplayObserver:
void OnConfigurationChanged() override;
void OnDisplaySnapshotsInvalidated() override;
// mojom::NativeDisplayDelegate:
void Initialize(mojom::NativeDisplayObserverPtr observer,
InitializeCallback callback) override;
void TakeDisplayControl(TakeDisplayControlCallback callback) override;
void RelinquishDisplayControl(
RelinquishDisplayControlCallback callback) override;
void GetDisplays(GetDisplaysCallback callback) override;
void Configure(int64_t display_id,
base::Optional<std::unique_ptr<display::DisplayMode>> mode,
const gfx::Point& origin,
ConfigureCallback callback) override;
void GetHDCPState(int64_t display_id, GetHDCPStateCallback callback) override;
void SetHDCPState(int64_t display_id,
display::HDCPState state,
SetHDCPStateCallback callback) override;
void SetColorMatrix(int64_t display_id,
const std::vector<float>& color_matrix) override;
void SetGammaCorrection(
int64_t display_id,
const std::vector<display::GammaRampRGBEntry>& degamma_lut,
const std::vector<display::GammaRampRGBEntry>& gamma_lut) override;
// mojom::DevDisplayController:
void ToggleAddRemoveDisplay() override;
private:
void BindNativeDisplayDelegateRequest(
mojom::NativeDisplayDelegateRequest request,
const service_manager::BindSourceInfo& source_info);
void BindDevDisplayControllerRequest(
mojom::DevDisplayControllerRequest request,
const service_manager::BindSourceInfo& source_info);
// Forwards results from GetDisplays() back with |callback|.
void ForwardGetDisplays(GetDisplaysCallback callback,
const std::vector<DisplaySnapshot*>& displays);
// Forwards results from call to Configure() back with |callback|.
void ForwardConfigure(
DisplaySnapshot* snapshot,
const DisplayMode* mode,
const gfx::Point& origin,
mojom::NativeDisplayDelegate::ConfigureCallback callback,
bool status);
// True if the UI Service runs inside WM's process, false if it runs inside
// its own process.
const bool is_in_process_;
std::unique_ptr<display::ScreenBase> screen_;
mojo::Binding<mojom::NativeDisplayDelegate> binding_;
mojom::NativeDisplayObserverPtr observer_;
mojo::Binding<mojom::DevDisplayController> dev_controller_binding_;
std::unique_ptr<display::NativeDisplayDelegate> native_display_delegate_;
// Cached pointers to snapshots owned by the |native_display_delegate_|.
base::flat_map<int64_t, DisplaySnapshot*> snapshot_map_;
// If not null it provides a way to modify the display state when running off
// device (eg. running mustash on Linux).
FakeDisplayController* fake_display_controller_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ScreenManagerForwarding);
};
} // namespace display
#endif // SERVICES_UI_DISPLAY_SCREEN_MANAGER_FORWARDING_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ui/display/screen_manager_ozone_external.h"
#include <memory>
#include "services/service_manager/public/cpp/binder_registry.h"
#include "ui/display/screen_base.h"
#include "ui/display/types/display_constants.h"
namespace display {
// static
std::unique_ptr<ScreenManager> ScreenManager::Create() {
return std::make_unique<ScreenManagerOzoneExternal>();
}
ScreenManagerOzoneExternal::ScreenManagerOzoneExternal()
: screen_(std::make_unique<display::ScreenBase>()) {}
ScreenManagerOzoneExternal::~ScreenManagerOzoneExternal() {}
void ScreenManagerOzoneExternal::AddInterfaces(
service_manager::BinderRegistryWithArgs<
const service_manager::BindSourceInfo&>* registry) {}
void ScreenManagerOzoneExternal::Init(ScreenManagerDelegate* delegate) {}
void ScreenManagerOzoneExternal::RequestCloseDisplay(int64_t display_id) {}
display::ScreenBase* ScreenManagerOzoneExternal::GetScreen() {
return screen_.get();
}
} // namespace display
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_EXTERNAL_H_
#define SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_EXTERNAL_H_
#include "services/ui/display/screen_manager.h"
namespace display {
// In external window mode, the purpose of having a ScreenManager
// does not apply: there is not a ScreenManagerDelegate manager
// responsible for creating Display instances.
// Basically, in this mode WindowTreeHost creates the display instance.
//
// ScreenManagerOzoneExternal provides the stub out implementation
// of ScreenManager for Ozone non-chromeos platforms.
class ScreenManagerOzoneExternal : public ScreenManager {
public:
ScreenManagerOzoneExternal();
~ScreenManagerOzoneExternal() override;
private:
// ScreenManager.
void AddInterfaces(
service_manager::BinderRegistryWithArgs<
const service_manager::BindSourceInfo&>* registry) override;
void Init(ScreenManagerDelegate* delegate) override;
void RequestCloseDisplay(int64_t display_id) override;
display::ScreenBase* GetScreen() override;
std::unique_ptr<display::ScreenBase> screen_;
DISALLOW_COPY_AND_ASSIGN(ScreenManagerOzoneExternal);
};
} // namespace display
#endif // SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_EXTERNAL_H_
This diff is collapsed.
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_INTERNAL_H_
#define SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_INTERNAL_H_
#include <stdint.h>
#include <memory>
#include "base/macros.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "services/ui/display/screen_manager.h"
#include "services/ui/display/viewport_metrics.h"
#include "services/ui/public/interfaces/display/display_controller.mojom.h"
#include "services/ui/public/interfaces/display/output_protection.mojom.h"
#include "ui/display/display.h"
#include "ui/display/display_observer.h"
#include "ui/display/manager/display_configurator.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/mojo/dev_display_controller.mojom.h"
#include "ui/display/types/display_constants.h"
namespace display {
class DisplayChangeObserver;
class FakeDisplayController;
class ScreenBase;
class TouchTransformController;
// ScreenManagerOzoneInternal provides the necessary functionality to configure
// all attached physical displays on the the ozone platform when operating in
// internal window mode.
class ScreenManagerOzoneInternal : public ScreenManager,
public mojom::DevDisplayController,
public mojom::DisplayController,
public DisplayObserver,
public DisplayManager::Delegate {
public:
ScreenManagerOzoneInternal();
~ScreenManagerOzoneInternal() override;
void SetPrimaryDisplayId(int64_t display_id);
// ScreenManager:
void AddInterfaces(
service_manager::BinderRegistryWithArgs<
const service_manager::BindSourceInfo&>* registry) override;
void Init(ScreenManagerDelegate* delegate) override;
void RequestCloseDisplay(int64_t display_id) override;
display::ScreenBase* GetScreen() override;
// mojom::DevDisplayController:
void ToggleAddRemoveDisplay() override;
// mojom::DisplayController:
void IncreaseInternalDisplayZoom() override;
void DecreaseInternalDisplayZoom() override;
void ResetInternalDisplayZoom() override;
void RotateCurrentDisplayCW() override;
void SwapPrimaryDisplay() override;
void ToggleMirrorMode() override;
void SetDisplayWorkArea(int64_t display_id,
const gfx::Size& size,
const gfx::Insets& insets) override;
void TakeDisplayControl(TakeDisplayControlCallback callback) override;
void RelinquishDisplayControl(
RelinquishDisplayControlCallback callback) override;
private:
friend class ScreenManagerOzoneInternalTest;
ViewportMetrics GetViewportMetricsForDisplay(const Display& display);
// DisplayObserver:
void OnDisplayAdded(const Display& new_display) override;
void OnDisplayRemoved(const Display& old_display) override;
void OnDisplayMetricsChanged(const Display& display,
uint32_t changed_metrics) override;
// DisplayManager::Delegate:
void CreateOrUpdateMirroringDisplay(
const DisplayInfoList& display_info_list) override;
void CloseMirroringDisplayIfNotNecessary() override;
void PreDisplayConfigurationChange(bool clear_focus) override;
void PostDisplayConfigurationChange() override;
DisplayConfigurator* display_configurator() override;
void BindDisplayControllerRequest(
mojom::DisplayControllerRequest request,
const service_manager::BindSourceInfo& source_info);
void BindOutputProtectionRequest(
mojom::OutputProtectionRequest request,
const service_manager::BindSourceInfo& source_info);
void BindDevDisplayControllerRequest(
mojom::DevDisplayControllerRequest request,
const service_manager::BindSourceInfo& source_info);
DisplayConfigurator display_configurator_;
std::unique_ptr<DisplayManager> display_manager_;
std::unique_ptr<DisplayChangeObserver> display_change_observer_;
std::unique_ptr<TouchTransformController> touch_transform_controller_;
// A Screen instance is created in the constructor because it might be
// accessed early. The ownership of this object will be transfered to
// |display_manager_| when that gets initialized.
std::unique_ptr<ScreenBase> screen_owned_;
// Used to add/remove/modify displays.
ScreenBase* screen_;
ScreenManagerDelegate* delegate_ = nullptr;
std::unique_ptr<NativeDisplayDelegate> native_display_delegate_;
// If not null it provides a way to modify the display state when running off
// device (eg. running mustash on Linux).
FakeDisplayController* fake_display_controller_ = nullptr;
int64_t primary_display_id_ = kInvalidDisplayId;
mojo::BindingSet<mojom::DisplayController> controller_bindings_;
mojo::BindingSet<mojom::DevDisplayController> test_bindings_;
DISALLOW_COPY_AND_ASSIGN(ScreenManagerOzoneInternal);
};
} // namespace display
#endif // SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_INTERNAL_H_
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ui/display/screen_manager_stub_internal.h"
#include <memory>
#include "base/bind.h"
#include "base/location.h"
#include "base/threading/thread_task_runner_handle.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/ui/display/viewport_metrics.h"
#include "ui/display/screen_base.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
namespace display {
namespace {
constexpr gfx::Size kDisplayPixelSize(1024, 768);
// Build a 1024x768 pixel display.
Display DefaultDisplay() {
float device_scale_factor = 1.f;
if (Display::HasForceDeviceScaleFactor())
device_scale_factor = Display::GetForcedDeviceScaleFactor();
gfx::Size scaled_size =
gfx::ConvertSizeToDIP(device_scale_factor, kDisplayPixelSize);
Display display(1);
display.set_bounds(gfx::Rect(scaled_size));
display.set_work_area(display.bounds());
display.set_device_scale_factor(device_scale_factor);
return display;
}
} // namespace
// static
std::unique_ptr<ScreenManager> ScreenManager::Create() {
return std::make_unique<ScreenManagerStubInternal>();
}
ScreenManagerStubInternal::ScreenManagerStubInternal()
: screen_(std::make_unique<display::ScreenBase>()),
weak_ptr_factory_(this) {}
ScreenManagerStubInternal::~ScreenManagerStubInternal() {}
void ScreenManagerStubInternal::FixedSizeScreenConfiguration() {
ViewportMetrics metrics;
metrics.bounds_in_pixels = gfx::Rect(kDisplayPixelSize);
metrics.device_scale_factor = display_.device_scale_factor();
metrics.ui_scale_factor = 1.f;
delegate_->OnDisplayAdded(display_, metrics);
}
void ScreenManagerStubInternal::AddInterfaces(
service_manager::BinderRegistryWithArgs<
const service_manager::BindSourceInfo&>* registry) {}
void ScreenManagerStubInternal::Init(ScreenManagerDelegate* delegate) {
DCHECK(delegate);
delegate_ = delegate;
display_ = DefaultDisplay();
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&ScreenManagerStubInternal::FixedSizeScreenConfiguration,
weak_ptr_factory_.GetWeakPtr()));
}
void ScreenManagerStubInternal::RequestCloseDisplay(int64_t display_id) {
if (display_id == display_.id()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&ScreenManagerDelegate::OnDisplayRemoved,
base::Unretained(delegate_), display_id));
}
}
display::ScreenBase* ScreenManagerStubInternal::GetScreen() {
return screen_.get();
}
} // namespace display
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_DISPLAY_SCREEN_MANAGER_STUB_INTERNAL_H_
#define SERVICES_UI_DISPLAY_SCREEN_MANAGER_STUB_INTERNAL_H_
#include <stdint.h>
#include "base/memory/weak_ptr.h"
#include "services/ui/display/screen_manager.h"
#include "ui/display/display.h"
namespace display {
class ScreenBase;
// ScreenManagerStubInternal provides the necessary functionality to configure a
// fixed 1024x768 display for non-ozone platforms.
class ScreenManagerStubInternal : public ScreenManager {
public:
ScreenManagerStubInternal();
~ScreenManagerStubInternal() override;
private:
// Fake creation of a single 1024x768 display.
void FixedSizeScreenConfiguration();
// ScreenManager.
void AddInterfaces(
service_manager::BinderRegistryWithArgs<
const service_manager::BindSourceInfo&>* registry) override;
void Init(ScreenManagerDelegate* delegate) override;
void RequestCloseDisplay(int64_t display_id) override;
display::ScreenBase* GetScreen() override;
// Sample display information.
Display display_;
ScreenManagerDelegate* delegate_ = nullptr;
std::unique_ptr<ScreenBase> screen_;
base::WeakPtrFactory<ScreenManagerStubInternal> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ScreenManagerStubInternal);
};
} // namespace display
#endif // SERVICES_UI_DISPLAY_SCREEN_MANAGER_STUB_INTERNAL_H_
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ui/display/viewport_metrics.h"
#include "base/strings/stringprintf.h"
namespace display {
std::string ViewportMetrics::ToString() const {
return base::StringPrintf(
"ViewportMetrics(bounds_in_pixels=%s, device_scale_factor=%g)",
bounds_in_pixels.ToString().c_str(), device_scale_factor);
}
} // namespace display
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_DISPLAY_VIEWPORT_METRICS_H_
#define SERVICES_UI_DISPLAY_VIEWPORT_METRICS_H_
#include <string>
#include "ui/gfx/geometry/rect.h"
namespace display {
struct ViewportMetrics {
std::string ToString() const;
gfx::Rect bounds_in_pixels;
float device_scale_factor = 0.0f;
};
inline bool operator==(const ViewportMetrics& lhs, const ViewportMetrics& rhs) {
return lhs.bounds_in_pixels == rhs.bounds_in_pixels &&
lhs.device_scale_factor == rhs.device_scale_factor;
}
inline bool operator!=(const ViewportMetrics& lhs, const ViewportMetrics& rhs) {
return !(lhs == rhs);
}
} // namespace display
#endif // SERVICES_UI_DISPLAY_VIEWPORT_METRICS_H_
...@@ -32,15 +32,6 @@ ...@@ -32,15 +32,6 @@
"discardable_memory": [ "discardable_memory": [
"discardable_memory.mojom.DiscardableSharedMemoryManager" "discardable_memory.mojom.DiscardableSharedMemoryManager"
], ],
"display_controller": [
"display.mojom.DisplayController"
],
"display_output_protection": [
"display.mojom.OutputProtection"
],
"display_dev": [
"display.mojom.DevDisplayController"
],
"gpu_client": [ "gpu_client": [
"ui.mojom.Gpu" "ui.mojom.Gpu"
], ],
...@@ -58,7 +49,6 @@ ...@@ -58,7 +49,6 @@
// TODO(sky): update this to reflect what is really possible. // TODO(sky): update this to reflect what is really possible.
"window_manager": [ "window_manager": [
"discardable_memory.mojom.DiscardableSharedMemoryManager", "discardable_memory.mojom.DiscardableSharedMemoryManager",
"display.mojom.DisplayController",
"display.mojom.NativeDisplayDelegate", "display.mojom.NativeDisplayDelegate",
"ui.mojom.AccessibilityManager", "ui.mojom.AccessibilityManager",
"ui.mojom.EventInjector", "ui.mojom.EventInjector",
......
...@@ -31,7 +31,6 @@ mojom("interfaces") { ...@@ -31,7 +31,6 @@ mojom("interfaces") {
"//media/mojo/interfaces", "//media/mojo/interfaces",
"//mojo/public/mojom/base", "//mojo/public/mojom/base",
"//services/ui/public/interfaces/cursor", "//services/ui/public/interfaces/cursor",
"//services/ui/public/interfaces/display",
"//services/ui/public/interfaces/ime", "//services/ui/public/interfaces/ime",
"//services/viz/public/interfaces", "//services/viz/public/interfaces",
"//skia/public/interfaces", "//skia/public/interfaces",
......
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//mojo/public/tools/bindings/mojom.gni")
mojom("display") {
sources = [
"display_controller.mojom",
"output_protection.mojom",
]
public_deps = [
"//ui/gfx/geometry/mojo",
]
}
per-file *_struct_traits*.*=set noparent
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module display.mojom;
import "ui/gfx/geometry/mojo/geometry.mojom";
// An interface for clients that are allowed to make changes to the display
// state.
interface DisplayController {
// =========================== Keyboard Shortcuts ===========================
// Increase zoom on internal display.
IncreaseInternalDisplayZoom();
// Decrease zoom on internal display.
DecreaseInternalDisplayZoom();
// Reset zoom on internal display to default level.
ResetInternalDisplayZoom();
// Rotate the current display by 90° CW. The current display is the display
// closest to the mouse cursor.
RotateCurrentDisplayCW();
// Swap the primary display and the next display.
SwapPrimaryDisplay();
// Toggles between mirroring and extended mode.
ToggleMirrorMode();
// ============================ Virtual Terminal ============================
// Take control of all display output. This is called when switching from the
// virtual terminal back to Chrome in response to a dbus message.
TakeDisplayControl() => (bool status);
// Relinquish control of all display output. This is called when switching
// from Chrome to the virtual terminal in response to a dbus message.
RelinquishDisplayControl() => (bool status);
// ========================= Configuration Changes ==========================
// Sets the display work area with the provided insets. The display size is
// included to ensure that the insets are for the current display size.
SetDisplayWorkArea(int64 display_id,
gfx.mojom.Size size,
gfx.mojom.Insets insets);
// TODO(kylechar): This interface will need to be expanded to provide
// additional functionality for the display settings page and other ash
// keyboard accelerators.
};
...@@ -340,11 +340,6 @@ DisplayManager::~DisplayManager() { ...@@ -340,11 +340,6 @@ DisplayManager::~DisplayManager() {
#endif #endif
} }
void DisplayManager::SetDevDisplayController(
mojom::DevDisplayControllerPtr controller) {
dev_display_controller_ = std::move(controller);
}
bool DisplayManager::InitFromCommandLine() { bool DisplayManager::InitFromCommandLine() {
DisplayInfoList info_list; DisplayInfoList info_list;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
...@@ -1349,13 +1344,6 @@ void DisplayManager::SetMirrorMode( ...@@ -1349,13 +1344,6 @@ void DisplayManager::SetMirrorMode(
void DisplayManager::AddRemoveDisplay() { void DisplayManager::AddRemoveDisplay() {
DCHECK(!active_display_list_.empty()); DCHECK(!active_display_list_.empty());
// DevDisplayController will have NativeDisplayDelegate add/remove a display
// so that the full display configuration code runs.
if (dev_display_controller_.is_bound()) {
dev_display_controller_->ToggleAddRemoveDisplay();
return;
}
DisplayInfoList new_display_info_list; DisplayInfoList new_display_info_list;
const ManagedDisplayInfo& first_display = const ManagedDisplayInfo& first_display =
IsInUnifiedMode() IsInUnifiedMode()
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "ui/display/manager/display_manager_export.h" #include "ui/display/manager/display_manager_export.h"
#include "ui/display/manager/display_manager_utilities.h" #include "ui/display/manager/display_manager_utilities.h"
#include "ui/display/manager/managed_display_info.h" #include "ui/display/manager/managed_display_info.h"
#include "ui/display/mojo/dev_display_controller.mojom.h"
#include "ui/display/types/display_constants.h" #include "ui/display/types/display_constants.h"
#include "ui/display/unified_desktop_utils.h" #include "ui/display/unified_desktop_utils.h"
...@@ -148,11 +147,6 @@ class DISPLAY_MANAGER_EXPORT DisplayManager ...@@ -148,11 +147,6 @@ class DISPLAY_MANAGER_EXPORT DisplayManager
return current_unified_desktop_matrix_; return current_unified_desktop_matrix_;
} }
// Sets controller used to add/remove fake displays. If this is set then
// AddRemoveDisplay() will delegate out to |dev_display_controller_| instead
// of adding/removing a ManagedDisplayInfo.
void SetDevDisplayController(mojom::DevDisplayControllerPtr controller);
// Initializes displays using command line flag. Returns false if no command // Initializes displays using command line flag. Returns false if no command
// line flag was provided. // line flag was provided.
bool InitFromCommandLine(); bool InitFromCommandLine();
...@@ -663,8 +657,6 @@ class DISPLAY_MANAGER_EXPORT DisplayManager ...@@ -663,8 +657,6 @@ class DISPLAY_MANAGER_EXPORT DisplayManager
base::ObserverList<DisplayObserver>::Unchecked observers_; base::ObserverList<DisplayObserver>::Unchecked observers_;
display::mojom::DevDisplayControllerPtr dev_display_controller_;
// Not empty if mixed mirror mode should be turned on (the specified source // Not empty if mixed mirror mode should be turned on (the specified source
// display is mirrored to the specified destination displays). Empty if mixed // display is mirrored to the specified destination displays). Empty if mixed
// mirror mode is disabled. // mirror mode is disabled.
......
...@@ -6,7 +6,6 @@ import("//mojo/public/tools/bindings/mojom.gni") ...@@ -6,7 +6,6 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") { mojom("interfaces") {
sources = [ sources = [
"dev_display_controller.mojom",
"display.mojom", "display.mojom",
"display_constants.mojom", "display_constants.mojom",
"display_layout.mojom", "display_layout.mojom",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module display.mojom;
// Provides a way to modify the display state at runtime. Will only work when
// running off device with fake displays for development.
interface DevDisplayController {
// Toggles adding or removing a fake display. If there is only one display
// a second display is added. If there is more than one display then the last
// display is removed.
ToggleAddRemoveDisplay();
};
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