OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 SERVICES_UI_WS_PLATFORM_DISPLAY_H_ | 5 #ifndef SERVICES_UI_WS_PLATFORM_DISPLAY_H_ |
6 #define SERVICES_UI_WS_PLATFORM_DISPLAY_H_ | 6 #define SERVICES_UI_WS_PLATFORM_DISPLAY_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "services/ui/display/viewport_metrics.h" | 14 #include "services/ui/display/viewport_metrics.h" |
15 #include "services/ui/public/interfaces/cursor.mojom.h" | 15 #include "services/ui/public/interfaces/cursor.mojom.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 | 17 |
18 namespace gfx { | |
19 class Rect; | |
20 } | |
21 | |
22 namespace ui { | 18 namespace ui { |
23 | 19 |
24 struct TextInputState; | 20 struct TextInputState; |
25 | 21 |
26 namespace ws { | 22 namespace ws { |
27 | 23 |
28 class FrameGenerator; | 24 class FrameGenerator; |
29 class PlatformDisplayDelegate; | 25 class PlatformDisplayDelegate; |
30 class PlatformDisplayFactory; | 26 class PlatformDisplayFactory; |
31 struct PlatformDisplayInitParams; | 27 class ServerWindow; |
32 | 28 |
33 // PlatformDisplay is used to connect the root ServerWindow to a display. | 29 // PlatformDisplay is used to connect the root ServerWindow to a display. |
34 class PlatformDisplay { | 30 class PlatformDisplay { |
35 public: | 31 public: |
36 virtual ~PlatformDisplay() {} | 32 virtual ~PlatformDisplay() {} |
37 | 33 |
38 static std::unique_ptr<PlatformDisplay> Create( | 34 static std::unique_ptr<PlatformDisplay> Create( |
39 const PlatformDisplayInitParams& init_params); | 35 ServerWindow* root_window, |
40 | 36 const display::ViewportMetrics& metrics); |
41 virtual int64_t GetId() const = 0; | |
42 | 37 |
43 virtual void Init(PlatformDisplayDelegate* delegate) = 0; | 38 virtual void Init(PlatformDisplayDelegate* delegate) = 0; |
44 | 39 |
45 virtual void SetViewportSize(const gfx::Size& size) = 0; | 40 virtual void SetViewportSize(const gfx::Size& size) = 0; |
46 | 41 |
47 virtual void SetTitle(const base::string16& title) = 0; | 42 virtual void SetTitle(const base::string16& title) = 0; |
48 | 43 |
49 virtual void SetCapture() = 0; | 44 virtual void SetCapture() = 0; |
50 | 45 |
51 virtual void ReleaseCapture() = 0; | 46 virtual void ReleaseCapture() = 0; |
52 | 47 |
53 virtual void SetCursorById(mojom::Cursor cursor) = 0; | 48 virtual void SetCursorById(mojom::Cursor cursor) = 0; |
54 | 49 |
55 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0; | 50 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0; |
56 virtual void SetImeVisibility(bool visible) = 0; | 51 virtual void SetImeVisibility(bool visible) = 0; |
57 | 52 |
58 virtual gfx::Rect GetBounds() const = 0; | |
59 | |
60 // Updates the viewport metrics for the display, returning true if any | 53 // Updates the viewport metrics for the display, returning true if any |
61 // metrics have changed. | 54 // metrics have changed. |
62 virtual bool UpdateViewportMetrics( | 55 virtual bool UpdateViewportMetrics( |
63 const display::ViewportMetrics& metrics) = 0; | 56 const display::ViewportMetrics& metrics) = 0; |
64 | 57 |
65 virtual const display::ViewportMetrics& GetViewportMetrics() const = 0; | |
66 | |
67 // Returns the AcceleratedWidget associated with the Display. It can return | 58 // Returns the AcceleratedWidget associated with the Display. It can return |
68 // kNullAcceleratedWidget if the accelerated widget is not available yet. | 59 // kNullAcceleratedWidget if the accelerated widget is not available yet. |
69 virtual gfx::AcceleratedWidget GetAcceleratedWidget() const = 0; | 60 virtual gfx::AcceleratedWidget GetAcceleratedWidget() const = 0; |
70 | 61 |
71 virtual FrameGenerator* GetFrameGenerator() = 0; | 62 virtual FrameGenerator* GetFrameGenerator() = 0; |
72 | 63 |
73 // Overrides factory for testing. Default (NULL) value indicates regular | 64 // Overrides factory for testing. Default (NULL) value indicates regular |
74 // (non-test) environment. | 65 // (non-test) environment. |
75 static void set_factory_for_testing(PlatformDisplayFactory* factory) { | 66 static void set_factory_for_testing(PlatformDisplayFactory* factory) { |
76 PlatformDisplay::factory_ = factory; | 67 PlatformDisplay::factory_ = factory; |
77 } | 68 } |
78 | 69 |
79 private: | 70 private: |
80 // Static factory instance (always NULL for non-test). | 71 // Static factory instance (always NULL for non-test). |
81 static PlatformDisplayFactory* factory_; | 72 static PlatformDisplayFactory* factory_; |
82 }; | 73 }; |
83 | 74 |
84 | 75 |
85 } // namespace ws | 76 } // namespace ws |
86 } // namespace ui | 77 } // namespace ui |
87 | 78 |
88 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_H_ | 79 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_H_ |
OLD | NEW |