| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_SCREEN_H_ | 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_SCREEN_H_ |
| 6 #define HEADLESS_LIB_BROWSER_HEADLESS_SCREEN_H_ | 6 #define HEADLESS_LIB_BROWSER_HEADLESS_SCREEN_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "ui/aura/window_observer.h" | 10 #include "ui/aura/window_observer.h" |
| 11 #include "ui/gfx/display.h" | 11 #include "ui/display/display.h" |
| 12 #include "ui/gfx/screen.h" | 12 #include "ui/display/screen.h" |
| 13 | 13 |
| 14 namespace gfx { | 14 namespace gfx { |
| 15 class Insets; | 15 class Insets; |
| 16 class Rect; | 16 class Rect; |
| 17 class Transform; | 17 class Transform; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace aura { | 20 namespace aura { |
| 21 class Window; | 21 class Window; |
| 22 class WindowTreeClient; | 22 class WindowTreeClient; |
| 23 class WindowTreeHost; | 23 class WindowTreeHost; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace headless { | 26 namespace headless { |
| 27 | 27 |
| 28 class HeadlessScreen : public gfx::Screen, public aura::WindowObserver { | 28 class HeadlessScreen : public display::Screen, public aura::WindowObserver { |
| 29 public: | 29 public: |
| 30 // Creates a gfx::Screen of the specified size. If no size is specified, then | 30 // Creates a display::Screen of the specified size. If no size is specified, |
| 31 // creates a 800x600 screen. |size| is in physical pixels. | 31 // then creates a 800x600 screen. |size| is in physical pixels. |
| 32 static HeadlessScreen* Create(const gfx::Size& size); | 32 static HeadlessScreen* Create(const gfx::Size& size); |
| 33 ~HeadlessScreen() override; | 33 ~HeadlessScreen() override; |
| 34 | 34 |
| 35 aura::WindowTreeHost* CreateHostForPrimaryDisplay(); | 35 aura::WindowTreeHost* CreateHostForPrimaryDisplay(); |
| 36 | 36 |
| 37 void SetDeviceScaleFactor(float device_scale_fator); | 37 void SetDeviceScaleFactor(float device_scale_fator); |
| 38 void SetDisplayRotation(gfx::Display::Rotation rotation); | 38 void SetDisplayRotation(display::Display::Rotation rotation); |
| 39 void SetUIScale(float ui_scale); | 39 void SetUIScale(float ui_scale); |
| 40 void SetWorkAreaInsets(const gfx::Insets& insets); | 40 void SetWorkAreaInsets(const gfx::Insets& insets); |
| 41 | 41 |
| 42 protected: | 42 protected: |
| 43 gfx::Transform GetRotationTransform() const; | 43 gfx::Transform GetRotationTransform() const; |
| 44 gfx::Transform GetUIScaleTransform() const; | 44 gfx::Transform GetUIScaleTransform() const; |
| 45 | 45 |
| 46 // WindowObserver overrides: | 46 // WindowObserver overrides: |
| 47 void OnWindowBoundsChanged(aura::Window* window, | 47 void OnWindowBoundsChanged(aura::Window* window, |
| 48 const gfx::Rect& old_bounds, | 48 const gfx::Rect& old_bounds, |
| 49 const gfx::Rect& new_bounds) override; | 49 const gfx::Rect& new_bounds) override; |
| 50 void OnWindowDestroying(aura::Window* window) override; | 50 void OnWindowDestroying(aura::Window* window) override; |
| 51 | 51 |
| 52 // gfx::Screen overrides: | 52 // display::Screen overrides: |
| 53 gfx::Point GetCursorScreenPoint() override; | 53 gfx::Point GetCursorScreenPoint() override; |
| 54 gfx::NativeWindow GetWindowUnderCursor() override; | 54 gfx::NativeWindow GetWindowUnderCursor() override; |
| 55 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; | 55 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; |
| 56 int GetNumDisplays() const override; | 56 int GetNumDisplays() const override; |
| 57 std::vector<gfx::Display> GetAllDisplays() const override; | 57 std::vector<display::Display> GetAllDisplays() const override; |
| 58 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override; | 58 display::Display GetDisplayNearestWindow(gfx::NativeView view) const override; |
| 59 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override; | 59 display::Display GetDisplayNearestPoint( |
| 60 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override; | 60 const gfx::Point& point) const override; |
| 61 gfx::Display GetPrimaryDisplay() const override; | 61 display::Display GetDisplayMatching( |
| 62 void AddObserver(gfx::DisplayObserver* observer) override; | 62 const gfx::Rect& match_rect) const override; |
| 63 void RemoveObserver(gfx::DisplayObserver* observer) override; | 63 display::Display GetPrimaryDisplay() const override; |
| 64 void AddObserver(display::DisplayObserver* observer) override; |
| 65 void RemoveObserver(display::DisplayObserver* observer) override; |
| 64 | 66 |
| 65 private: | 67 private: |
| 66 explicit HeadlessScreen(const gfx::Rect& screen_bounds); | 68 explicit HeadlessScreen(const gfx::Rect& screen_bounds); |
| 67 | 69 |
| 68 aura::WindowTreeHost* host_; | 70 aura::WindowTreeHost* host_; |
| 69 gfx::Display display_; | 71 display::Display display_; |
| 70 float ui_scale_; | 72 float ui_scale_; |
| 71 | 73 |
| 72 DISALLOW_COPY_AND_ASSIGN(HeadlessScreen); | 74 DISALLOW_COPY_AND_ASSIGN(HeadlessScreen); |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 } // namespace headless | 77 } // namespace headless |
| 76 | 78 |
| 77 #endif // HEADLESS_LIB_BROWSER_HEADLESS_SCREEN_H_ | 79 #endif // HEADLESS_LIB_BROWSER_HEADLESS_SCREEN_H_ |
| OLD | NEW |