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

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

Issue 2189893004: Unify display ids between Display and PlatformDisplay. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move id into PlatformDisplay and fix tests. Created 4 years, 4 months 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
OLDNEW
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 <map> 10 #include <map>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 namespace ws { 45 namespace ws {
46 46
47 class EventDispatcher; 47 class EventDispatcher;
48 class PlatformDisplayFactory; 48 class PlatformDisplayFactory;
49 struct PlatformDisplayInitParams; 49 struct PlatformDisplayInitParams;
50 class ServerWindow; 50 class ServerWindow;
51 51
52 // PlatformDisplay is used to connect the root ServerWindow to a display. 52 // PlatformDisplay is used to connect the root ServerWindow to a display.
53 class PlatformDisplay { 53 class PlatformDisplay {
54 public: 54 public:
55 PlatformDisplay(int64_t id);
msw 2016/07/28 19:01:02 Oh dang; I saw |set_factory_for_testing| and thoug
kylechar 2016/07/28 19:20:16 I think sky is OOO but I'll talk with sadrul or rj
55 virtual ~PlatformDisplay() {} 56 virtual ~PlatformDisplay() {}
56 57
57 static PlatformDisplay* Create(const PlatformDisplayInitParams& init_params); 58 static PlatformDisplay* Create(const PlatformDisplayInitParams& init_params);
58 59
60 int64_t id() const { return id_; }
61
59 virtual void Init(PlatformDisplayDelegate* delegate) = 0; 62 virtual void Init(PlatformDisplayDelegate* delegate) = 0;
60 63
61 // Schedules a paint for the specified region in the coordinates of |window|. 64 // Schedules a paint for the specified region in the coordinates of |window|.
62 virtual void SchedulePaint(const ServerWindow* window, 65 virtual void SchedulePaint(const ServerWindow* window,
63 const gfx::Rect& bounds) = 0; 66 const gfx::Rect& bounds) = 0;
64 67
65 virtual void SetViewportSize(const gfx::Size& size) = 0; 68 virtual void SetViewportSize(const gfx::Size& size) = 0;
66 69
67 virtual void SetTitle(const base::string16& title) = 0; 70 virtual void SetTitle(const base::string16& title) = 0;
68 71
69 virtual void SetCapture() = 0; 72 virtual void SetCapture() = 0;
70 73
71 virtual void ReleaseCapture() = 0; 74 virtual void ReleaseCapture() = 0;
72 75
73 virtual void SetCursorById(int32_t cursor) = 0; 76 virtual void SetCursorById(int32_t cursor) = 0;
74 77
75 virtual ::display::Display::Rotation GetRotation() = 0; 78 virtual ::display::Display::Rotation GetRotation() = 0;
76 79
77 virtual float GetDeviceScaleFactor() = 0; 80 virtual float GetDeviceScaleFactor() = 0;
78 81
79 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0; 82 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0;
80 virtual void SetImeVisibility(bool visible) = 0; 83 virtual void SetImeVisibility(bool visible) = 0;
81 84
82 // Returns true if a compositor frame has been submitted but not drawn yet. 85 // Returns true if a compositor frame has been submitted but not drawn yet.
83 virtual bool IsFramePending() const = 0; 86 virtual bool IsFramePending() const = 0;
84 87
85 virtual void RequestCopyOfOutput( 88 virtual void RequestCopyOfOutput(
86 std::unique_ptr<cc::CopyOutputRequest> output_request) = 0; 89 std::unique_ptr<cc::CopyOutputRequest> output_request) = 0;
87 90
88 virtual int64_t GetDisplayId() const = 0;
89
90 virtual gfx::Rect GetBounds() const = 0; 91 virtual gfx::Rect GetBounds() const = 0;
91 92
92 // Overrides factory for testing. Default (NULL) value indicates regular 93 // Overrides factory for testing. Default (NULL) value indicates regular
93 // (non-test) environment. 94 // (non-test) environment.
94 static void set_factory_for_testing(PlatformDisplayFactory* factory) { 95 static void set_factory_for_testing(PlatformDisplayFactory* factory) {
95 PlatformDisplay::factory_ = factory; 96 PlatformDisplay::factory_ = factory;
96 } 97 }
97 98
98 private: 99 private:
100 int64_t id_;
101
99 // Static factory instance (always NULL for non-test). 102 // Static factory instance (always NULL for non-test).
100 static PlatformDisplayFactory* factory_; 103 static PlatformDisplayFactory* factory_;
101 }; 104 };
msw 2016/07/28 19:01:02 nit: DISALLOW_COPY_AND_ASSIGN(PlatformDisplay); if
kylechar 2016/07/28 19:20:16 Done.
102 105
103 // PlatformDisplay implementation that connects to the services necessary to 106 // PlatformDisplay implementation that connects to the services necessary to
104 // actually display. 107 // actually display.
105 class DefaultPlatformDisplay : public PlatformDisplay, 108 class DefaultPlatformDisplay : public PlatformDisplay,
106 public ui::PlatformWindowDelegate, 109 public ui::PlatformWindowDelegate,
107 private FrameGeneratorDelegate { 110 private FrameGeneratorDelegate {
108 public: 111 public:
109 explicit DefaultPlatformDisplay(const PlatformDisplayInitParams& init_params); 112 explicit DefaultPlatformDisplay(const PlatformDisplayInitParams& init_params);
110 ~DefaultPlatformDisplay() override; 113 ~DefaultPlatformDisplay() override;
111 114
112 // PlatformDisplay: 115 // PlatformDisplay:
113 void Init(PlatformDisplayDelegate* delegate) override; 116 void Init(PlatformDisplayDelegate* delegate) override;
114 void SchedulePaint(const ServerWindow* window, 117 void SchedulePaint(const ServerWindow* window,
115 const gfx::Rect& bounds) override; 118 const gfx::Rect& bounds) override;
116 void SetViewportSize(const gfx::Size& size) override; 119 void SetViewportSize(const gfx::Size& size) override;
117 void SetTitle(const base::string16& title) override; 120 void SetTitle(const base::string16& title) override;
118 void SetCapture() override; 121 void SetCapture() override;
119 void ReleaseCapture() override; 122 void ReleaseCapture() override;
120 void SetCursorById(int32_t cursor) override; 123 void SetCursorById(int32_t cursor) override;
121 float GetDeviceScaleFactor() override; 124 float GetDeviceScaleFactor() override;
122 ::display::Display::Rotation GetRotation() override; 125 ::display::Display::Rotation GetRotation() override;
123 void UpdateTextInputState(const ui::TextInputState& state) override; 126 void UpdateTextInputState(const ui::TextInputState& state) override;
124 void SetImeVisibility(bool visible) override; 127 void SetImeVisibility(bool visible) override;
125 bool IsFramePending() const override; 128 bool IsFramePending() const override;
126 void RequestCopyOfOutput( 129 void RequestCopyOfOutput(
127 std::unique_ptr<cc::CopyOutputRequest> output_request) override; 130 std::unique_ptr<cc::CopyOutputRequest> output_request) override;
128 int64_t GetDisplayId() const override;
129 gfx::Rect GetBounds() const override; 131 gfx::Rect GetBounds() const override;
130 132
131 private: 133 private:
132 void UpdateMetrics(const gfx::Rect& bounds, float device_scale_factor); 134 void UpdateMetrics(const gfx::Rect& bounds, float device_scale_factor);
133 135
134 // ui::PlatformWindowDelegate: 136 // ui::PlatformWindowDelegate:
135 void OnBoundsChanged(const gfx::Rect& new_bounds) override; 137 void OnBoundsChanged(const gfx::Rect& new_bounds) override;
136 void OnDamageRect(const gfx::Rect& damaged_region) override; 138 void OnDamageRect(const gfx::Rect& damaged_region) override;
137 void DispatchEvent(ui::Event* event) override; 139 void DispatchEvent(ui::Event* event) override;
138 void OnCloseRequest() override; 140 void OnCloseRequest() override;
139 void OnClosed() override; 141 void OnClosed() override;
140 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; 142 void OnWindowStateChanged(ui::PlatformWindowState new_state) override;
141 void OnLostCapture() override; 143 void OnLostCapture() override;
142 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, 144 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
143 float device_scale_factor) override; 145 float device_scale_factor) override;
144 void OnAcceleratedWidgetDestroyed() override; 146 void OnAcceleratedWidgetDestroyed() override;
145 void OnActivationChanged(bool active) override; 147 void OnActivationChanged(bool active) override;
146 148
147 // FrameGeneratorDelegate: 149 // FrameGeneratorDelegate:
148 ServerWindow* GetRootWindow() override; 150 ServerWindow* GetRootWindow() override;
149 void OnCompositorFrameDrawn() override; 151 void OnCompositorFrameDrawn() override;
150 bool IsInHighContrastMode() override; 152 bool IsInHighContrastMode() override;
151 const ViewportMetrics& GetViewportMetrics() override; 153 const ViewportMetrics& GetViewportMetrics() override;
152 154
153 int64_t display_id_;
154
155 #if !defined(OS_ANDROID) 155 #if !defined(OS_ANDROID)
156 std::unique_ptr<ui::CursorLoader> cursor_loader_; 156 std::unique_ptr<ui::CursorLoader> cursor_loader_;
157 #endif 157 #endif
158 158
159 PlatformDisplayDelegate* delegate_ = nullptr; 159 PlatformDisplayDelegate* delegate_ = nullptr;
160 std::unique_ptr<FrameGenerator> frame_generator_; 160 std::unique_ptr<FrameGenerator> frame_generator_;
161 161
162 ViewportMetrics metrics_; 162 ViewportMetrics metrics_;
163 std::unique_ptr<ui::PlatformWindow> platform_window_; 163 std::unique_ptr<ui::PlatformWindow> platform_window_;
164 164
165 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformDisplay); 165 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformDisplay);
166 }; 166 };
167 167
168 } // namespace ws 168 } // namespace ws
169 169
170 } // namespace ui 170 } // namespace ui
171 171
172 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_H_ 172 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698