Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: services/ui/ws/platform_display_default.h

Issue 2507943002: Move PlatformDisplayDefault into it's own file. (Closed)
Patch Set: Fixes. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/ws/platform_display.cc ('k') | services/ui/ws/platform_display_default.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 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 SERVICES_UI_WS_PLATFORM_DISPLAY_H_ 5 #ifndef SERVICES_UI_WS_PLATFORM_DISPLAY_DEFAULT_H_
6 #define SERVICES_UI_WS_PLATFORM_DISPLAY_H_ 6 #define SERVICES_UI_WS_PLATFORM_DISPLAY_DEFAULT_H_
7
8 #include <stdint.h>
9 7
10 #include <memory> 8 #include <memory>
11 9
12 #include "base/macros.h" 10 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/strings/string16.h"
15 #include "build/build_config.h"
16 #include "services/ui/display/viewport_metrics.h" 11 #include "services/ui/display/viewport_metrics.h"
17 #include "services/ui/public/interfaces/cursor.mojom.h"
18 #include "services/ui/public/interfaces/window_manager.mojom.h"
19 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
20 #include "services/ui/public/interfaces/window_tree.mojom.h"
21 #include "services/ui/ws/frame_generator.h" 12 #include "services/ui/ws/frame_generator.h"
22 #include "services/ui/ws/frame_generator_delegate.h" 13 #include "services/ui/ws/frame_generator_delegate.h"
14 #include "services/ui/ws/platform_display.h"
23 #include "services/ui/ws/platform_display_delegate.h" 15 #include "services/ui/ws/platform_display_delegate.h"
24 #include "ui/display/display.h"
25 #include "ui/platform_window/platform_window_delegate.h" 16 #include "ui/platform_window/platform_window_delegate.h"
26 17
27 namespace gfx {
28 class Rect;
29 }
30
31 namespace gpu {
32 class GpuChannelHost;
33 }
34
35 namespace ui { 18 namespace ui {
36 19
37 class CursorLoader; 20 class CursorLoader;
38 class PlatformWindow; 21 class PlatformWindow;
39 struct TextInputState;
40 22
41 namespace ws { 23 namespace ws {
42 24
43 class PlatformDisplayFactory; 25 // PlatformDisplay implementation that connects to a PlatformWindow and
44 struct PlatformDisplayInitParams; 26 // FrameGenerator for Chrome OS.
45 class ServerWindow; 27 class PlatformDisplayDefault : public PlatformDisplay,
46
47 // PlatformDisplay is used to connect the root ServerWindow to a display.
48 class PlatformDisplay {
49 public:
50 virtual ~PlatformDisplay() {}
51
52 static std::unique_ptr<PlatformDisplay> Create(
53 const PlatformDisplayInitParams& init_params);
54
55 virtual int64_t GetId() const = 0;
56
57 virtual void Init(PlatformDisplayDelegate* delegate) = 0;
58
59 virtual void SetViewportSize(const gfx::Size& size) = 0;
60
61 virtual void SetTitle(const base::string16& title) = 0;
62
63 virtual void SetCapture() = 0;
64
65 virtual void ReleaseCapture() = 0;
66
67 virtual void SetCursorById(mojom::Cursor cursor) = 0;
68
69 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0;
70 virtual void SetImeVisibility(bool visible) = 0;
71
72 virtual gfx::Rect GetBounds() const = 0;
73
74 // Updates the viewport metrics for the display, returning true if any
75 // metrics have changed.
76 virtual bool UpdateViewportMetrics(
77 const display::ViewportMetrics& metrics) = 0;
78
79 virtual const display::ViewportMetrics& GetViewportMetrics() const = 0;
80
81 virtual bool IsPrimaryDisplay() const = 0;
82
83 // Notifies the PlatformDisplay that a connection to the gpu has been
84 // established.
85 virtual void OnGpuChannelEstablished(
86 scoped_refptr<gpu::GpuChannelHost> gpu_channel) = 0;
87
88 // Overrides factory for testing. Default (NULL) value indicates regular
89 // (non-test) environment.
90 static void set_factory_for_testing(PlatformDisplayFactory* factory) {
91 PlatformDisplay::factory_ = factory;
92 }
93
94 private:
95 // Static factory instance (always NULL for non-test).
96 static PlatformDisplayFactory* factory_;
97 };
98
99 // PlatformDisplay implementation that connects to the services necessary to
100 // actually display.
101 class DefaultPlatformDisplay : public PlatformDisplay,
102 public ui::PlatformWindowDelegate, 28 public ui::PlatformWindowDelegate,
103 private FrameGeneratorDelegate { 29 private FrameGeneratorDelegate {
104 public: 30 public:
105 explicit DefaultPlatformDisplay(const PlatformDisplayInitParams& init_params); 31 explicit PlatformDisplayDefault(const PlatformDisplayInitParams& init_params);
106 ~DefaultPlatformDisplay() override; 32 ~PlatformDisplayDefault() override;
107 33
108 // PlatformDisplay: 34 // PlatformDisplay:
109 void Init(PlatformDisplayDelegate* delegate) override; 35 void Init(PlatformDisplayDelegate* delegate) override;
110 int64_t GetId() const override; 36 int64_t GetId() const override;
111 void SetViewportSize(const gfx::Size& size) override; 37 void SetViewportSize(const gfx::Size& size) override;
112 void SetTitle(const base::string16& title) override; 38 void SetTitle(const base::string16& title) override;
113 void SetCapture() override; 39 void SetCapture() override;
114 void ReleaseCapture() override; 40 void ReleaseCapture() override;
115 void SetCursorById(mojom::Cursor cursor) override; 41 void SetCursorById(mojom::Cursor cursor) override;
116 void UpdateTextInputState(const ui::TextInputState& state) override; 42 void UpdateTextInputState(const ui::TextInputState& state) override;
117 void SetImeVisibility(bool visible) override; 43 void SetImeVisibility(bool visible) override;
118 gfx::Rect GetBounds() const override; 44 gfx::Rect GetBounds() const override;
119 bool UpdateViewportMetrics(const display::ViewportMetrics& metrics) override; 45 bool UpdateViewportMetrics(const display::ViewportMetrics& metrics) override;
120 const display::ViewportMetrics& GetViewportMetrics() const override; 46 const display::ViewportMetrics& GetViewportMetrics() const override;
121 bool IsPrimaryDisplay() const override; 47 bool IsPrimaryDisplay() const override;
122 void OnGpuChannelEstablished( 48 void OnGpuChannelEstablished(
123 scoped_refptr<gpu::GpuChannelHost> gpu_channel) override; 49 scoped_refptr<gpu::GpuChannelHost> gpu_channel) override;
124 50
125 private: 51 private:
126 // Update the root_location of located events to be relative to the origin 52 // Update the root_location of located events to be relative to the origin
127 // of this display. For example, if the origin of this display is (1800, 0) 53 // of this display. For example, if the origin of this display is (1800, 0)
128 // and the location of the event is (100, 200) then the root_location will be 54 // and the location of the event is (100, 200) then the root_location will be
129 // updated to be (1900, 200). 55 // updated to be (1900, 200).
56 // TODO(riajiang): This is totally broken with HDPI.
130 void UpdateEventRootLocation(ui::LocatedEvent* event); 57 void UpdateEventRootLocation(ui::LocatedEvent* event);
131 58
132 // ui::PlatformWindowDelegate: 59 // ui::PlatformWindowDelegate:
133 void OnBoundsChanged(const gfx::Rect& new_bounds) override; 60 void OnBoundsChanged(const gfx::Rect& new_bounds) override;
134 void OnDamageRect(const gfx::Rect& damaged_region) override; 61 void OnDamageRect(const gfx::Rect& damaged_region) override;
135 void DispatchEvent(ui::Event* event) override; 62 void DispatchEvent(ui::Event* event) override;
136 void OnCloseRequest() override; 63 void OnCloseRequest() override;
137 void OnClosed() override; 64 void OnClosed() override;
138 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; 65 void OnWindowStateChanged(ui::PlatformWindowState new_state) override;
139 void OnLostCapture() override; 66 void OnLostCapture() override;
140 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, 67 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
141 float device_scale_factor) override; 68 float device_scale_factor) override;
142 void OnAcceleratedWidgetDestroyed() override; 69 void OnAcceleratedWidgetDestroyed() override;
143 void OnActivationChanged(bool active) override; 70 void OnActivationChanged(bool active) override;
144 71
145 // FrameGeneratorDelegate: 72 // FrameGeneratorDelegate:
146 bool IsInHighContrastMode() override; 73 bool IsInHighContrastMode() override;
147 74
148 int64_t id_; 75 int64_t display_id_;
149 76
150 #if !defined(OS_ANDROID) 77 #if !defined(OS_ANDROID)
151 std::unique_ptr<ui::CursorLoader> cursor_loader_; 78 std::unique_ptr<ui::CursorLoader> cursor_loader_;
152 #endif 79 #endif
153 80
154 PlatformDisplayDelegate* delegate_ = nullptr; 81 PlatformDisplayDelegate* delegate_ = nullptr;
155 std::unique_ptr<FrameGenerator> frame_generator_; 82 std::unique_ptr<FrameGenerator> frame_generator_;
156 83
157 display::ViewportMetrics metrics_; 84 display::ViewportMetrics metrics_;
158 std::unique_ptr<ui::PlatformWindow> platform_window_; 85 std::unique_ptr<ui::PlatformWindow> platform_window_;
159 86
160 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformDisplay); 87 DISALLOW_COPY_AND_ASSIGN(PlatformDisplayDefault);
161 }; 88 };
162 89
163 } // namespace ws 90 } // namespace ws
164
165 } // namespace ui 91 } // namespace ui
166 92
167 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_H_ 93 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_DEFAULT_H_
OLDNEW
« no previous file with comments | « services/ui/ws/platform_display.cc ('k') | services/ui/ws/platform_display_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698