0

Rename gfx::Display to display::Display

* renamed dispay_util.h to display_test_util.h
* move PrintTo for Display to display_test_util.h
* removed unused flag decl.
* removed ui:: namespace from display switches. This is what gfx/switches.h does, and makes more sense as command line flag is global (has to be unique).

This CL depends on https://codereview.chromium.org/1964153002/.

BUG=597761
TBR=sky@chromium.org, jam@chromium.org, benwells@chromium.org,

Review-Url: https://codereview.chromium.org/1965073002
Cr-Commit-Position: refs/heads/master@{#392835}
This commit is contained in:
oshima
2016-05-10 19:40:10 -07:00
committed by Commit bot
parent 8d6f29a404
commit 06b3960db2
66 changed files with 275 additions and 432 deletions
ash
chrome/browser
components/test_runner
content
extensions/browser
api
guest_view
mash/wm
media/capture/video/linux
ui

@@ -326,6 +326,7 @@ static_library("ash_shell_lib_with_content") {
"//ui/aura",
"//ui/base",
"//ui/compositor",
"//ui/display",
"//ui/events/devices",
"//ui/message_center",
"//ui/views:test_support",

@@ -18,13 +18,12 @@ namespace aura {
class Window;
}
namespace gfx {
class Point;
namespace display {
class Display;
}
namespace display {
using Display = gfx::Display;
namespace gfx {
class Point;
}
namespace ash {

@@ -28,12 +28,8 @@ class ScreenPositionClient;
}
}
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
}
namespace ui {

@@ -11,14 +11,13 @@ namespace aura {
class Window;
}
namespace gfx {
namespace display {
class Display;
class Rect;
class Transform;
}
namespace display {
using Display = gfx::Display;
namespace gfx {
class Rect;
class Transform;
}
namespace ash {

@@ -12,14 +12,13 @@ namespace aura {
class Window;
}
namespace gfx {
namespace display {
class Display;
class Rect;
class Point;
}
namespace display {
using Display = gfx::Display;
namespace gfx {
class Rect;
class Point;
}
namespace ash {

@@ -222,7 +222,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
// |wm::GetActiveWindow()->GetRootWindow()|.
static aura::Window* GetTargetRootWindow();
// Returns the id of the gfx::Display corresponding to the window returned
// Returns the id of the display::Display corresponding to the window returned
// by |GetTargetRootWindow()|
static int64_t GetTargetDisplayId();

@@ -9,13 +9,12 @@
#include "base/macros.h"
#include "ui/base/ui_base_types.h"
namespace gfx {
namespace display {
class Display;
class Rect;
}
namespace display {
using Display = gfx::Display;
namespace gfx {
class Rect;
}
namespace ash {

@@ -14,17 +14,16 @@
#include "ui/wm/core/window_animations.h"
#include "ui/wm/public/window_types.h"
namespace gfx {
namespace display {
class Display;
}
namespace gfx {
class Point;
class Rect;
class Size;
}
namespace display {
using Display = gfx::Display;
}
namespace ui {
class Layer;
}

@@ -841,7 +841,7 @@ const FeatureEntry kFeatureEntries[] = {
IDS_FLAGS_DISPLAY_COLOR_CALIBRATION_NAME,
IDS_FLAGS_DISPLAY_COLOR_CALIBRATION_DESCRIPTION, kOsCrOS,
SINGLE_DISABLE_VALUE_TYPE(
ui::switches::kDisableDisplayColorCalibration),
::switches::kDisableDisplayColorCalibration),
},
{
"disable-quirks-client", IDS_FLAGS_DISABLE_QUIRKS_CLIENT_NAME,

@@ -67,9 +67,9 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_observer.h"
#include "ui/display/display_switches.h"
#include "ui/events/event_switches.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/gfx/switches.h"
#include "ui/gl/gl_switches.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"

@@ -45,6 +45,7 @@
#include "ui/app_list/app_list_switches.h"
#include "ui/base/ui_base_switches.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/display/display_switches.h"
#include "ui/events/event_switches.h"
#include "ui/gfx/switches.h"
#include "ui/gl/gl_switches.h"

@@ -33,10 +33,10 @@
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/window_open_disposition.h"
#include "ui/display/display_switches.h"
#include "ui/display/screen.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/switches.h"
namespace {

@@ -16,13 +16,12 @@
@class AppListAnimationController;
namespace gfx {
namespace display {
class Display;
class Point;
}
namespace display {
using Display = gfx::Display;
namespace gfx {
class Point;
}
// AppListServiceMac manages global resources needed for the app list to

@@ -8,14 +8,13 @@
#include "base/macros.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
namespace display {
class Display;
class Point;
class Rect;
}
namespace display {
using Display = gfx::Display;
namespace gfx {
class Point;
class Rect;
}
namespace autofill {

@@ -11,16 +11,15 @@ namespace app_list {
class AppListView;
}
namespace gfx {
namespace display {
class Display;
}
namespace gfx {
class Point;
class Size;
} // namespace gfx
namespace display {
using Display = gfx::Display;
}
// Responsible for positioning an AppListView on Linux.
// TODO(tapted): Shouldn't be a class - move the static member functions out.
class AppListLinux {

@@ -9,17 +9,16 @@ namespace app_list {
class AppListView;
}
namespace gfx {
namespace display {
class Display;
}
namespace gfx {
class Point;
class Rect;
class Size;
}
namespace display {
using Display = gfx::Display;
}
// Responsible for positioning an AppListView on Windows.
// TODO(tapted): Shouldn't be a class - move the static member functions out.
class AppListWin {

@@ -13,12 +13,8 @@
class Browser;
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
class Screen;
}

@@ -115,6 +115,7 @@ component("test_runner") {
"//net",
"//skia",
"//third_party/WebKit/public:blink",
"//ui/display",
"//ui/events:dom_keycode_converter",
"//ui/events:events_base",
"//ui/gfx",

@@ -8,6 +8,7 @@ include_rules = [
"+third_party/skia",
"+third_party/WebKit/public/platform",
"+third_party/WebKit/public/web",
"+ui/display",
"+ui/events",
"+ui/gfx",
"+v8/include",

@@ -62,11 +62,11 @@
#include "third_party/WebKit/public/web/WebView.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/display/display_switches.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/switches.h"
#if defined(__linux__) || defined(ANDROID)
#include "third_party/WebKit/public/web/linux/WebFontRendering.h"

@@ -28,6 +28,7 @@
'../../net/net.gyp:net',
'../../skia/skia.gyp:skia',
'../../third_party/WebKit/public/blink.gyp:blink',
'../../ui/display/display.gyp:display',
'../../ui/events/events.gyp:dom_keycode_converter',
'../../ui/events/events.gyp:events_base',
'../../ui/gfx/gfx.gyp:gfx',

@@ -17,9 +17,9 @@
#include "content/shell/browser/shell.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/display/display_switches.h"
#include "ui/events/event_utils.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/switches.h"
#include "ui/touch_selection/touch_selection_controller_test_api.h"
namespace content {

@@ -7,8 +7,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/display/display.h"
#include "ui/display/display_switches.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/switches.h"
#if defined(OS_WIN)
#include "base/win/windows_version.h"

@@ -176,6 +176,7 @@
#include "storage/browser/fileapi/sandbox_file_system_backend.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/ui_base_switches.h"
#include "ui/display/display_switches.h"
#include "ui/events/event_switches.h"
#include "ui/gfx/switches.h"
#include "ui/gl/gl_switches.h"

@@ -37,8 +37,8 @@
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/base/layout.h"
#include "ui/base/ui_base_switches.h"
#include "ui/display/display_switches.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/switches.h"
#include "ui/gl/gl_switches.h"
#if defined(OS_WIN)

@@ -57,10 +57,10 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebSandboxFlags.h"
#include "ui/display/display_switches.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/switches.h"
#if defined(USE_AURA)
#include "content/browser/renderer_host/render_widget_host_view_aura.h"

@@ -25,6 +25,7 @@
#include "content/public/common/result_codes.h"
#include "sandbox/linux/services/namespace_sandbox.h"
#include "sandbox/linux/suid/client/setuid_sandbox_host.h"
#include "ui/display/display_switches.h"
#include "ui/gfx/switches.h"
namespace content {

@@ -39,8 +39,8 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
#include "ui/display/display_switches.h"
#include "ui/events/event_switches.h"
#include "ui/gfx/switches.h"
#include "ui/gl/gl_switches.h"
#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.

@@ -12,12 +12,8 @@
#include "base/macros.h"
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
}
namespace extensions {

@@ -37,7 +37,7 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "ui/gfx/switches.h"
#include "ui/display/display_switches.h"
using guest_view::GuestViewManager;
using guest_view::TestGuestViewManager;

@@ -11,7 +11,7 @@
#include "mash/wm/bridge/wm_globals_mus.h"
#include "mash/wm/bridge/wm_window_mus.h"
#include "mash/wm/root_window_controller.h"
#include "ui/gfx/display.h"
#include "ui/display/display.h"
#include "ui/views/mus/native_widget_mus.h"
#include "ui/views/widget/widget.h"
@@ -64,7 +64,7 @@ gfx::Point WmRootWindowControllerMus::ConvertPointFromScreen(
return target->GetRootWindow()->ConvertPointToTarget(target, result);
}
const gfx::Display& WmRootWindowControllerMus::GetDisplay() const {
const display::Display& WmRootWindowControllerMus::GetDisplay() const {
return root_window_controller_->display();
}

@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "base/observer_list.h"
namespace gfx {
namespace display {
class Display;
}
@@ -47,7 +47,7 @@ class WmRootWindowControllerMus : public ash::wm::WmRootWindowController {
gfx::Point ConvertPointFromScreen(const WmWindowMus* target,
const gfx::Point& point) const;
const gfx::Display& GetDisplay() const;
const display::Display& GetDisplay() const;
// WmRootWindowController:
bool HasShelf() override;

@@ -18,7 +18,7 @@
#include "mash/wm/property_util.h"
#include "ui/aura/mus/mus_util.h"
#include "ui/base/hit_test.h"
#include "ui/gfx/display.h"
#include "ui/display/display.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"

@@ -47,7 +47,7 @@ RootWindowController* RootWindowController::CreateFromDisplay(
mus::mojom::DisplayPtr display,
mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) {
RootWindowController* controller = new RootWindowController(app);
controller->display_ = display.To<gfx::Display>();
controller->display_ = display.To<display::Display>();
mus::WindowTreeConnection::CreateForWindowManager(
controller, std::move(client_request),
mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED,

@@ -13,7 +13,7 @@
#include "components/mus/public/interfaces/window_tree_host.mojom.h"
#include "mash/wm/public/interfaces/container.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "ui/gfx/display.h"
#include "ui/display/display.h"
namespace mus {
class WindowManagerClient;
@@ -68,7 +68,7 @@ class RootWindowController : public mus::WindowObserver,
void OnAccelerator(uint32_t id, const ui::Event& event);
const gfx::Display& display() const { return display_; }
const display::Display& display() const { return display_; }
ShelfLayoutManager* GetShelfLayoutManager();
StatusLayoutManager* GetStatusLayoutManager();
@@ -102,7 +102,7 @@ class RootWindowController : public mus::WindowObserver,
std::unique_ptr<ShadowController> shadow_controller_;
gfx::Display display_;
display::Display display_;
DISALLOW_COPY_AND_ASSIGN(RootWindowController);
};

@@ -8,12 +8,8 @@
#include "base/macros.h"
#include "media/capture/video/linux/video_capture_device_linux.h"
namespace gfx {
class Display;
} // namespace gfx
namespace display {
using Display = gfx::Display;
class Display;
} // namespace display
namespace media {

@@ -10,12 +10,8 @@
#include "ui/base/cursor/cursor.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
}
namespace ui {

@@ -37,7 +37,7 @@ class TestScreen : public display::Screen, public WindowObserver {
void SetUIScale(float ui_scale);
void SetWorkAreaInsets(const gfx::Insets& insets);
// gfx::Screen overrides:
// display::Screen overrides:
display::Display GetPrimaryDisplay() const override;
protected:

@@ -30,12 +30,8 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/wm/public/window_types.h"
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
}
namespace gfx {

@@ -33,6 +33,7 @@ component("display") {
"chromeos/x11/native_display_delegate_x11.h",
"chromeos/x11/native_display_event_dispatcher_x11.cc",
"chromeos/x11/native_display_event_dispatcher_x11.h",
"display.cc",
"display.h",
"display_change_notifier.cc",
"display_change_notifier.h",
@@ -142,6 +143,7 @@ source_set("test_support") {
"chromeos/test/test_display_layout_manager.h",
"chromeos/test/test_native_display_delegate.cc",
"chromeos/test/test_native_display_delegate.h",
"test/display_test_util.h",
"test/test_screen.cc",
"test/test_screen.h",
]

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/gfx/display.h"
#include "ui/display/display.h"
#include <algorithm>
@@ -11,13 +11,13 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "ui/display/display_switches.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/switches.h"
namespace gfx {
namespace display {
namespace {
// This variable tracks whether the forced device scale factor switch needs to
@@ -77,8 +77,7 @@ Display::Display()
: id_(kInvalidDisplayID),
device_scale_factor_(GetForcedDeviceScaleFactor()),
rotation_(ROTATE_0),
touch_support_(TOUCH_SUPPORT_UNKNOWN) {
}
touch_support_(TOUCH_SUPPORT_UNKNOWN) {}
Display::Display(const Display& other) = default;
@@ -100,8 +99,7 @@ Display::Display(int64_t id, const gfx::Rect& bounds)
#endif
}
Display::~Display() {
}
Display::~Display() {}
int Display::RotationAsDegree() const {
switch (rotation_) {
@@ -114,7 +112,6 @@ int Display::RotationAsDegree() const {
case ROTATE_270:
return 270;
}
NOTREACHED();
return 0;
}
@@ -139,17 +136,15 @@ void Display::SetRotationAsDegree(int rotation) {
}
}
Insets Display::GetWorkAreaInsets() const {
return gfx::Insets(work_area_.y() - bounds_.y(),
work_area_.x() - bounds_.x(),
gfx::Insets Display::GetWorkAreaInsets() const {
return gfx::Insets(work_area_.y() - bounds_.y(), work_area_.x() - bounds_.x(),
bounds_.bottom() - work_area_.bottom(),
bounds_.right() - work_area_.right());
}
void Display::SetScaleAndBounds(
float device_scale_factor,
const gfx::Rect& bounds_in_pixel) {
Insets insets = bounds_.InsetsFrom(work_area_);
void Display::SetScaleAndBounds(float device_scale_factor,
const gfx::Rect& bounds_in_pixel) {
gfx::Insets insets = bounds_.InsetsFrom(work_area_);
if (!HasForceDeviceScaleFactor()) {
#if defined(OS_MACOSX)
// Unless an explicit scale factor was provided for testing, ensure the
@@ -186,10 +181,8 @@ gfx::Size Display::GetSizeInPixel() const {
std::string Display::ToString() const {
return base::StringPrintf(
"Display[%lld] bounds=%s, workarea=%s, scale=%f, %s",
static_cast<long long int>(id_),
bounds_.ToString().c_str(),
work_area_.ToString().c_str(),
device_scale_factor_,
static_cast<long long int>(id_), bounds_.ToString().c_str(),
work_area_.ToString().c_str(), device_scale_factor_,
IsInternal() ? "internal" : "external");
}
@@ -219,4 +212,4 @@ bool Display::HasInternalDisplay() {
return internal_display_id_ != kInvalidDisplayID;
}
} // namespace gfx
} // namespace display

@@ -72,6 +72,7 @@
'chromeos/x11/native_display_delegate_x11.h',
'chromeos/x11/native_display_event_dispatcher_x11.cc',
'chromeos/x11/native_display_event_dispatcher_x11.h',
'display.cc',
'display.h',
'display_change_notifier.cc',
'display_change_notifier.h',
@@ -208,6 +209,7 @@
'chromeos/test/test_display_layout_manager.h',
'chromeos/test/test_native_display_delegate.cc',
'chromeos/test/test_native_display_delegate.h',
'test/display_test_util.h',
'test/test_screen.cc',
'test/test_screen.h',
],

@@ -1,17 +1,169 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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 UI_DISPLAY_DISPLAY_H_
#define UI_DISPLAY_DISPLAY_H_
#include "ui/gfx/display.h"
#include <stdint.h>
#include "base/compiler_specific.h"
#include "ui/display/display_export.h"
#include "ui/gfx/geometry/rect.h"
namespace display {
// TODO(oshima): move the gfx::Display to display::Display.
using Display = gfx::Display;
// This class typically, but does not always, correspond to a physical display
// connected to the system. A fake Display may exist on a headless system, or a
// Display may correspond to a remote, virtual display.
//
// Note: The screen and display currently uses pixel coordinate
// system. For platforms that support DIP (density independent pixel),
// |bounds()| and |work_area| will return values in DIP coordinate
// system, not in backing pixels.
class DISPLAY_EXPORT Display final {
public:
// Screen Rotation in clock-wise degrees.
// This enum corresponds to DisplayRotationDefaultProto::Rotation in
// chrome/browser/chromeos/policy/proto/chrome_device_policy.proto.
enum Rotation {
ROTATE_0 = 0,
ROTATE_90,
ROTATE_180,
ROTATE_270,
};
} // display
// The display rotation can have multiple causes for change. A user can set a
// preference. On devices with accelerometers, they can change the rotation.
// RotationSource allows for the tracking of a Rotation per source of the
// change. ROTATION_SOURCE_ACTIVE is the current rotation of the display.
// Rotation changes not due to an accelerometer, nor the user, are to use this
// source directly. ROTATION_SOURCE_UNKNOWN is when no rotation source has
// been provided.
enum RotationSource {
ROTATION_SOURCE_ACCELEROMETER = 0,
ROTATION_SOURCE_ACTIVE,
ROTATION_SOURCE_USER,
ROTATION_SOURCE_UNKNOWN,
};
// Touch support for the display.
enum TouchSupport {
TOUCH_SUPPORT_UNKNOWN,
TOUCH_SUPPORT_AVAILABLE,
TOUCH_SUPPORT_UNAVAILABLE,
};
enum : int64_t { kInvalidDisplayID = -1 };
// Creates a display with kInvalidDisplayID as default.
Display();
explicit Display(int64_t id);
Display(int64_t id, const gfx::Rect& bounds);
Display(const Display& other);
~Display();
// Returns the forced device scale factor, which is given by
// "--force-device-scale-factor".
static float GetForcedDeviceScaleFactor();
// Indicates if a device scale factor is being explicitly enforced from the
// command line via "--force-device-scale-factor".
static bool HasForceDeviceScaleFactor();
// Resets the caches used to determine if a device scale factor is being
// forced from the command line via "--force-device-scale-factor", and thus
// ensures that the command line is reevaluated.
static void ResetForceDeviceScaleFactorForTesting();
// Sets/Gets unique identifier associated with the display.
// -1 means invalid display and it doesn't not exit.
int64_t id() const { return id_; }
void set_id(int64_t id) { id_ = id; }
// Gets/Sets the display's bounds in display::Screen's coordinates.
const gfx::Rect& bounds() const { return bounds_; }
void set_bounds(const gfx::Rect& bounds) { bounds_ = bounds; }
// Gets/Sets the display's work area in display::Screen's coordinates.
const gfx::Rect& work_area() const { return work_area_; }
void set_work_area(const gfx::Rect& work_area) { work_area_ = work_area; }
// Output device's pixel scale factor. This specifies how much the
// UI should be scaled when the actual output has more pixels than
// standard displays (which is around 100~120dpi.) The potential return
// values depend on each platforms.
float device_scale_factor() const { return device_scale_factor_; }
void set_device_scale_factor(float scale) { device_scale_factor_ = scale; }
Rotation rotation() const { return rotation_; }
void set_rotation(Rotation rotation) { rotation_ = rotation; }
int RotationAsDegree() const;
void SetRotationAsDegree(int rotation);
TouchSupport touch_support() const { return touch_support_; }
void set_touch_support(TouchSupport support) { touch_support_ = support; }
// Utility functions that just return the size of display and
// work area.
const gfx::Size& size() const { return bounds_.size(); }
const gfx::Size& work_area_size() const { return work_area_.size(); }
// Returns the work area insets.
gfx::Insets GetWorkAreaInsets() const;
// Sets the device scale factor and display bounds in pixel. This
// updates the work are using the same insets between old bounds and
// work area.
void SetScaleAndBounds(float device_scale_factor,
const gfx::Rect& bounds_in_pixel);
// Sets the display's size. This updates the work area using the same insets
// between old bounds and work area.
void SetSize(const gfx::Size& size_in_pixel);
// Computes and updates the display's work are using
// |work_area_insets| and the bounds.
void UpdateWorkAreaFromInsets(const gfx::Insets& work_area_insets);
// Returns the display's size in pixel coordinates.
gfx::Size GetSizeInPixel() const;
// Returns a string representation of the display;
std::string ToString() const;
// True if the display contains valid display id.
bool is_valid() const { return id_ != kInvalidDisplayID; }
// True if the display corresponds to internal panel.
bool IsInternal() const;
// Gets/Sets an id of display corresponding to internal panel.
static int64_t InternalDisplayId();
static void SetInternalDisplayId(int64_t internal_display_id);
// Test if the |id| is for the internal display if any.
static bool IsInternalDisplayId(int64_t id);
// True if there is an internal display.
static bool HasInternalDisplay();
// Maximum cursor size in native pixels.
const gfx::Size& maximum_cursor_size() const { return maximum_cursor_size_; }
void set_maximum_cursor_size(const gfx::Size& size) {
maximum_cursor_size_ = size;
}
private:
int64_t id_;
gfx::Rect bounds_;
gfx::Rect work_area_;
float device_scale_factor_;
Rotation rotation_;
TouchSupport touch_support_;
gfx::Size maximum_cursor_size_;
};
} // namespace display
#endif // UI_DISPLAY_DISPLAY_H_

@@ -11,12 +11,8 @@
#include "base/observer_list.h"
#include "ui/display/display_export.h"
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
class DisplayObserver;
// DisplayChangeNotifier is a class implementing the handling of DisplayObserver

@@ -10,13 +10,12 @@
#include "ui/display/display_export.h"
namespace gfx {
class Display;
class Point;
class Rect;
}
namespace display {
using Display = gfx::Display;
class Display;
// Returns the display in |displays| closest to |point|.
DISPLAY_EXPORT const Display* FindDisplayNearestPoint(

@@ -9,12 +9,8 @@
#include "ui/display/display_export.h"
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
// Observers for display configuration changes.
// TODO(oshima): consolidate |WorkAreaWatcherObserver| and

@@ -5,13 +5,14 @@
#include "build/build_config.h"
#include "ui/display/display_switches.h"
namespace ui {
namespace switches {
// Overrides the device scale factor for the browser UI and the contents.
const char kForceDeviceScaleFactor[] = "force-device-scale-factor";
#if defined(OS_CHROMEOS)
const char kDisableDisplayColorCalibration[] =
"disable-display-color-calibration";
#endif
} // namespace switches
} // namespace ui

@@ -9,14 +9,14 @@
#include "build/build_config.h"
#include "ui/display/display_export.h"
namespace ui {
namespace switches {
DISPLAY_EXPORT extern const char kForceDeviceScaleFactor[];
#if defined(OS_CHROMEOS)
DISPLAY_EXPORT extern const char kDisableDisplayColorCalibration[];
#endif
} // namespace switches
} // namespace ui
#endif // UI_BASE_UI_BASE_SWITCHES_H_
#endif // UI_DISPLAY_DISPLAY_SWITCHES_H_

@@ -6,10 +6,10 @@
#include "base/command_line.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display_switches.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/switches.h"
namespace display {

@@ -20,12 +20,8 @@ class Value;
template <typename T> class JSONValueConverter;
}
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
// An identifier used to manage display layout in DisplayManager /
// DisplayLayoutStore.

@@ -13,13 +13,12 @@
#include "ui/gfx/native_widget_types.h"
namespace gfx {
class Display;
class Point;
class Rect;
}
namespace display {
using Display = gfx::Display;
class Display;
class DisplayObserver;
// A utility class for getting various info about screen size, displays,

@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_GFX_TEST_DISPLAY_UTIL_H_
#define UI_GFX_TEST_DISPLAY_UTIL_H_
#ifndef UI_DISPLAY_TEST_DISPLAY_TEST_UTIL_H_
#define UI_DISPLAY_TEST_DISPLAY_TEST_UTIL_H_
#include "ui/gfx/display.h"
#include "ui/display/display.h"
namespace gfx {
namespace display {
inline bool operator==(const Display& lhs, const Display& rhs) {
return lhs.id() == rhs.id() &&
@@ -18,6 +18,10 @@ inline bool operator==(const Display& lhs, const Display& rhs) {
lhs.touch_support() == rhs.touch_support();
}
} // namespace gfx
void PrintTo(const Display& display, ::std::ostream* os) {
*os << display.ToString();
}
#endif // UI_GFX_TEST_DISPLAY_UTIL_H_
} // namespace display
#endif // UI_DISPLAY_TEST_DISPLAY_TEST_UTIL_H_

@@ -18,13 +18,13 @@
#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display.h"
#include "ui/display/display_switches.h"
#include "ui/display/screen.h"
#include "ui/display/test/display_test_util.h"
#include "ui/display/win/display_info.h"
#include "ui/display/win/dpi.h"
#include "ui/display/win/screen_win_display.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/switches.h"
#include "ui/gfx/test/display_util.h"
namespace display {
namespace win {

@@ -68,8 +68,6 @@ component("gfx") {
"color_profile_win.cc",
"color_utils.cc",
"color_utils.h",
"display.cc",
"display.h",
"favicon_size.cc",
"favicon_size.h",
"font.cc",
@@ -640,7 +638,6 @@ source_set("test_support") {
"image/image_unittest_util.h",
"image/image_unittest_util_ios.mm",
"image/image_unittest_util_mac.mm",
"test/display_util.h",
"test/fontconfig_util_linux.cc",
"test/fontconfig_util_linux.h",
"test/gfx_util.cc",

@@ -1,174 +0,0 @@
// Copyright (c) 2012 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 UI_GFX_DISPLAY_H_
#define UI_GFX_DISPLAY_H_
#include <stdint.h>
#include "base/compiler_specific.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/gfx_export.h"
namespace gfx {
// This class typically, but does not always, correspond to a physical display
// connected to the system. A fake Display may exist on a headless system, or a
// Display may correspond to a remote, virtual display.
//
// Note: The screen and display currently uses pixel coordinate
// system. For platforms that support DIP (density independent pixel),
// |bounds()| and |work_area| will return values in DIP coordinate
// system, not in backing pixels.
class GFX_EXPORT Display final {
public:
// Screen Rotation in clock-wise degrees.
// This enum corresponds to DisplayRotationDefaultProto::Rotation in
// chrome/browser/chromeos/policy/proto/chrome_device_policy.proto.
enum Rotation {
ROTATE_0 = 0,
ROTATE_90,
ROTATE_180,
ROTATE_270,
};
// The display rotation can have multiple causes for change. A user can set a
// preference. On devices with accelerometers, they can change the rotation.
// RotationSource allows for the tracking of a Rotation per source of the
// change. ROTATION_SOURCE_ACTIVE is the current rotation of the display.
// Rotation changes not due to an accelerometer, nor the user, are to use this
// source directly. ROTATION_SOURCE_UNKNOWN is when no rotation source has
// been provided.
enum RotationSource {
ROTATION_SOURCE_ACCELEROMETER = 0,
ROTATION_SOURCE_ACTIVE,
ROTATION_SOURCE_USER,
ROTATION_SOURCE_UNKNOWN,
};
// Touch support for the display.
enum TouchSupport {
TOUCH_SUPPORT_UNKNOWN,
TOUCH_SUPPORT_AVAILABLE,
TOUCH_SUPPORT_UNAVAILABLE,
};
enum : int64_t { kInvalidDisplayID = -1 };
// Creates a display with kInvalidDisplayID as default.
Display();
explicit Display(int64_t id);
Display(int64_t id, const Rect& bounds);
Display(const Display& other);
~Display();
// Returns the forced device scale factor, which is given by
// "--force-device-scale-factor".
static float GetForcedDeviceScaleFactor();
// Indicates if a device scale factor is being explicitly enforced from the
// command line via "--force-device-scale-factor".
static bool HasForceDeviceScaleFactor();
// Resets the caches used to determine if a device scale factor is being
// forced from the command line via "--force-device-scale-factor", and thus
// ensures that the command line is reevaluated.
static void ResetForceDeviceScaleFactorForTesting();
// Sets/Gets unique identifier associated with the display.
// -1 means invalid display and it doesn't not exit.
int64_t id() const { return id_; }
void set_id(int64_t id) { id_ = id; }
// Gets/Sets the display's bounds in gfx::Screen's coordinates.
const Rect& bounds() const { return bounds_; }
void set_bounds(const Rect& bounds) { bounds_ = bounds; }
// Gets/Sets the display's work area in gfx::Screen's coordinates.
const Rect& work_area() const { return work_area_; }
void set_work_area(const Rect& work_area) { work_area_ = work_area; }
// Output device's pixel scale factor. This specifies how much the
// UI should be scaled when the actual output has more pixels than
// standard displays (which is around 100~120dpi.) The potential return
// values depend on each platforms.
float device_scale_factor() const { return device_scale_factor_; }
void set_device_scale_factor(float scale) { device_scale_factor_ = scale; }
Rotation rotation() const { return rotation_; }
void set_rotation(Rotation rotation) { rotation_ = rotation; }
int RotationAsDegree() const;
void SetRotationAsDegree(int rotation);
TouchSupport touch_support() const { return touch_support_; }
void set_touch_support(TouchSupport support) { touch_support_ = support; }
// Utility functions that just return the size of display and
// work area.
const Size& size() const { return bounds_.size(); }
const Size& work_area_size() const { return work_area_.size(); }
// Returns the work area insets.
Insets GetWorkAreaInsets() const;
// Sets the device scale factor and display bounds in pixel. This
// updates the work are using the same insets between old bounds and
// work area.
void SetScaleAndBounds(float device_scale_factor,
const gfx::Rect& bounds_in_pixel);
// Sets the display's size. This updates the work area using the same insets
// between old bounds and work area.
void SetSize(const gfx::Size& size_in_pixel);
// Computes and updates the display's work are using
// |work_area_insets| and the bounds.
void UpdateWorkAreaFromInsets(const gfx::Insets& work_area_insets);
// Returns the display's size in pixel coordinates.
gfx::Size GetSizeInPixel() const;
// Returns a string representation of the display;
std::string ToString() const;
// True if the display contains valid display id.
bool is_valid() const { return id_ != kInvalidDisplayID; }
// True if the display corresponds to internal panel.
bool IsInternal() const;
// Gets/Sets an id of display corresponding to internal panel.
static int64_t InternalDisplayId();
static void SetInternalDisplayId(int64_t internal_display_id);
// Test if the |id| is for the internal display if any.
static bool IsInternalDisplayId(int64_t id);
// True if there is an internal display.
static bool HasInternalDisplay();
// Maximum cursor size in native pixels.
const Size& maximum_cursor_size() const { return maximum_cursor_size_; }
void set_maximum_cursor_size(const Size& size) {
maximum_cursor_size_ = size;
}
private:
int64_t id_;
Rect bounds_;
Rect work_area_;
float device_scale_factor_;
Rotation rotation_;
TouchSupport touch_support_;
Size maximum_cursor_size_;
};
// This is declared here for use in gtest-based unit tests but is defined in
// the gfx_test_support target. Depend on that to use this in your unit test.
// This should not be used in production code - call ToString() instead.
void PrintTo(const Display& display, ::std::ostream* os);
} // namespace gfx
#endif // UI_GFX_DISPLAY_H_

@@ -1,67 +0,0 @@
// Copyright (c) 2012 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 "ui/gfx/display.h"
#include "base/command_line.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/switches.h"
namespace gfx {
namespace {
TEST(DisplayTest, WorkArea) {
Display display(0, Rect(0, 0, 100, 100));
EXPECT_EQ("0,0 100x100", display.bounds().ToString());
EXPECT_EQ("0,0 100x100", display.work_area().ToString());
display.set_work_area(Rect(3, 4, 90, 80));
EXPECT_EQ("0,0 100x100", display.bounds().ToString());
EXPECT_EQ("3,4 90x80", display.work_area().ToString());
display.SetScaleAndBounds(1.0f, Rect(10, 20, 50, 50));
EXPECT_EQ("10,20 50x50", display.bounds().ToString());
EXPECT_EQ("13,24 40x30", display.work_area().ToString());
display.SetSize(Size(200, 200));
EXPECT_EQ("13,24 190x180", display.work_area().ToString());
display.UpdateWorkAreaFromInsets(Insets(3, 4, 5, 6));
EXPECT_EQ("14,23 190x192", display.work_area().ToString());
}
TEST(DisplayTest, Scale) {
Display display(0, Rect(0, 0, 100, 100));
display.set_work_area(Rect(10, 10, 80, 80));
EXPECT_EQ("0,0 100x100", display.bounds().ToString());
EXPECT_EQ("10,10 80x80", display.work_area().ToString());
// Scale it back to 2x
display.SetScaleAndBounds(2.0f, Rect(0, 0, 140, 140));
EXPECT_EQ("0,0 70x70", display.bounds().ToString());
EXPECT_EQ("10,10 50x50", display.work_area().ToString());
// Scale it back to 1x
display.SetScaleAndBounds(1.0f, Rect(0, 0, 100, 100));
EXPECT_EQ("0,0 100x100", display.bounds().ToString());
EXPECT_EQ("10,10 80x80", display.work_area().ToString());
}
// https://crbug.com/517944
TEST(DisplayTest, ForcedDeviceScaleFactorByCommandLine) {
Display::ResetForceDeviceScaleFactorForTesting();
// Look ma, no value!
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kForceDeviceScaleFactor);
EXPECT_EQ(1, Display::GetForcedDeviceScaleFactor());
Display::ResetForceDeviceScaleFactorForTesting();
}
} // namespace
} // namespace gfx

@@ -180,8 +180,6 @@
'color_profile_win.cc',
'color_utils.cc',
'color_utils.h',
'display.cc',
'display.h',
'favicon_size.cc',
'favicon_size.h',
'font.cc',
@@ -533,7 +531,6 @@
'image/image_unittest_util.h',
'image/image_unittest_util_ios.mm',
'image/image_unittest_util_mac.mm',
'test/display_util.h',
'test/fontconfig_util_linux.cc',
'test/fontconfig_util_linux.h',
'test/gfx_util.cc',

@@ -7,9 +7,6 @@
namespace switches {
// Overrides the device scale factor for the browser UI and the contents.
const char kForceDeviceScaleFactor[] = "force-device-scale-factor";
#if defined(OS_WIN)
// Disables DirectWrite font rendering for general UI elements.
const char kDisableDirectWriteForUI[] = "disable-directwrite-for-ui";

@@ -10,9 +10,6 @@
namespace switches {
GFX_EXPORT extern const char kAllowArbitraryScaleFactorInImageSkia[];
GFX_EXPORT extern const char kForceDeviceScaleFactor[];
#if defined(OS_WIN)
GFX_EXPORT extern const char kDisableDirectWriteForUI[];
#endif

@@ -8,7 +8,6 @@
#include <sstream>
#include <string>
#include "ui/gfx/display.h"
#include "ui/gfx/geometry/box_f.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point3_f.h"
@@ -96,10 +95,6 @@ void PrintTo(const BoxF& box, ::std::ostream* os) {
*os << box.ToString();
}
void PrintTo(const Display& display, ::std::ostream* os) {
*os << display.ToString();
}
void PrintTo(const Point& point, ::std::ostream* os) {
*os << point.ToString();
}

@@ -26,16 +26,12 @@ namespace base {
class RunLoop;
}
namespace views {
class Widget;
}
namespace gfx {
namespace display {
class Display;
}
namespace display {
using Display = gfx::Display;
namespace views {
class Widget;
}
namespace message_center {

@@ -8,13 +8,12 @@
#include "ui/message_center/message_center_export.h"
namespace gfx {
class Display;
class Point;
class Rect;
}
namespace display {
using Display = gfx::Display;
class Display;
}
namespace message_center {

@@ -5,8 +5,8 @@
#include "ui/views/mus/screen_mus.h"
#include "base/command_line.h"
#include "ui/display/display_switches.h"
#include "ui/display/screen.h"
#include "ui/gfx/switches.h"
#include "ui/views/mus/window_manager_connection.h"
#include "ui/views/test/scoped_views_test_helper.h"
#include "ui/views/test/views_test_base.h"

@@ -13,12 +13,8 @@ namespace aura {
class RootWindow;
}
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
}
namespace ui {

@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <X11/Xlib.h>
#include <X11/extensions/shape.h>
#include <stddef.h>
#include <X11/extensions/shape.h>
#include <X11/Xlib.h>
#include <memory>
#include <vector>
@@ -23,13 +23,13 @@
#include "ui/aura/window_tree_host.h"
#include "ui/base/hit_test.h"
#include "ui/base/x/x11_util.h"
#include "ui/display/display_switches.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
#include "ui/events/platform/x11/x11_event_source_glib.h"
#include "ui/events/test/platform_event_source_test_api.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/path.h"
#include "ui/gfx/switches.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/test/x11_property_change_waiter.h"

@@ -10,12 +10,8 @@
#include "ui/wm/core/native_cursor_manager_delegate.h"
#include "ui/wm/wm_export.h"
namespace gfx {
class Display;
}
namespace display {
using Display = gfx::Display;
class Display;
}
namespace wm {