| 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 <map> | 10 #include <map> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 virtual ~PlatformDisplay() {} | 55 virtual ~PlatformDisplay() {} |
| 56 | 56 |
| 57 static PlatformDisplay* Create(const PlatformDisplayInitParams& init_params); | 57 static PlatformDisplay* Create(const PlatformDisplayInitParams& init_params); |
| 58 | 58 |
| 59 virtual int64_t GetId() const = 0; |
| 60 |
| 59 virtual void Init(PlatformDisplayDelegate* delegate) = 0; | 61 virtual void Init(PlatformDisplayDelegate* delegate) = 0; |
| 60 | 62 |
| 61 // Schedules a paint for the specified region in the coordinates of |window|. | 63 // Schedules a paint for the specified region in the coordinates of |window|. |
| 62 virtual void SchedulePaint(const ServerWindow* window, | 64 virtual void SchedulePaint(const ServerWindow* window, |
| 63 const gfx::Rect& bounds) = 0; | 65 const gfx::Rect& bounds) = 0; |
| 64 | 66 |
| 65 virtual void SetViewportSize(const gfx::Size& size) = 0; | 67 virtual void SetViewportSize(const gfx::Size& size) = 0; |
| 66 | 68 |
| 67 virtual void SetTitle(const base::string16& title) = 0; | 69 virtual void SetTitle(const base::string16& title) = 0; |
| 68 | 70 |
| 69 virtual void SetCapture() = 0; | 71 virtual void SetCapture() = 0; |
| 70 | 72 |
| 71 virtual void ReleaseCapture() = 0; | 73 virtual void ReleaseCapture() = 0; |
| 72 | 74 |
| 73 virtual void SetCursorById(int32_t cursor) = 0; | 75 virtual void SetCursorById(int32_t cursor) = 0; |
| 74 | 76 |
| 75 virtual ::display::Display::Rotation GetRotation() = 0; | 77 virtual ::display::Display::Rotation GetRotation() = 0; |
| 76 | 78 |
| 77 virtual float GetDeviceScaleFactor() = 0; | 79 virtual float GetDeviceScaleFactor() = 0; |
| 78 | 80 |
| 79 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0; | 81 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0; |
| 80 virtual void SetImeVisibility(bool visible) = 0; | 82 virtual void SetImeVisibility(bool visible) = 0; |
| 81 | 83 |
| 82 // Returns true if a compositor frame has been submitted but not drawn yet. | 84 // Returns true if a compositor frame has been submitted but not drawn yet. |
| 83 virtual bool IsFramePending() const = 0; | 85 virtual bool IsFramePending() const = 0; |
| 84 | 86 |
| 85 virtual void RequestCopyOfOutput( | 87 virtual void RequestCopyOfOutput( |
| 86 std::unique_ptr<cc::CopyOutputRequest> output_request) = 0; | 88 std::unique_ptr<cc::CopyOutputRequest> output_request) = 0; |
| 87 | 89 |
| 88 virtual int64_t GetDisplayId() const = 0; | |
| 89 | |
| 90 virtual gfx::Rect GetBounds() const = 0; | 90 virtual gfx::Rect GetBounds() const = 0; |
| 91 | 91 |
| 92 // Overrides factory for testing. Default (NULL) value indicates regular | 92 // Overrides factory for testing. Default (NULL) value indicates regular |
| 93 // (non-test) environment. | 93 // (non-test) environment. |
| 94 static void set_factory_for_testing(PlatformDisplayFactory* factory) { | 94 static void set_factory_for_testing(PlatformDisplayFactory* factory) { |
| 95 PlatformDisplay::factory_ = factory; | 95 PlatformDisplay::factory_ = factory; |
| 96 } | 96 } |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 // Static factory instance (always NULL for non-test). | 99 // Static factory instance (always NULL for non-test). |
| 100 static PlatformDisplayFactory* factory_; | 100 static PlatformDisplayFactory* factory_; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 // PlatformDisplay implementation that connects to the services necessary to | 103 // PlatformDisplay implementation that connects to the services necessary to |
| 104 // actually display. | 104 // actually display. |
| 105 class DefaultPlatformDisplay : public PlatformDisplay, | 105 class DefaultPlatformDisplay : public PlatformDisplay, |
| 106 public ui::PlatformWindowDelegate, | 106 public ui::PlatformWindowDelegate, |
| 107 private FrameGeneratorDelegate { | 107 private FrameGeneratorDelegate { |
| 108 public: | 108 public: |
| 109 explicit DefaultPlatformDisplay(const PlatformDisplayInitParams& init_params); | 109 explicit DefaultPlatformDisplay(const PlatformDisplayInitParams& init_params); |
| 110 ~DefaultPlatformDisplay() override; | 110 ~DefaultPlatformDisplay() override; |
| 111 | 111 |
| 112 // PlatformDisplay: | 112 // PlatformDisplay: |
| 113 void Init(PlatformDisplayDelegate* delegate) override; | 113 void Init(PlatformDisplayDelegate* delegate) override; |
| 114 int64_t GetId() const override; |
| 114 void SchedulePaint(const ServerWindow* window, | 115 void SchedulePaint(const ServerWindow* window, |
| 115 const gfx::Rect& bounds) override; | 116 const gfx::Rect& bounds) override; |
| 116 void SetViewportSize(const gfx::Size& size) override; | 117 void SetViewportSize(const gfx::Size& size) override; |
| 117 void SetTitle(const base::string16& title) override; | 118 void SetTitle(const base::string16& title) override; |
| 118 void SetCapture() override; | 119 void SetCapture() override; |
| 119 void ReleaseCapture() override; | 120 void ReleaseCapture() override; |
| 120 void SetCursorById(int32_t cursor) override; | 121 void SetCursorById(int32_t cursor) override; |
| 121 float GetDeviceScaleFactor() override; | 122 float GetDeviceScaleFactor() override; |
| 122 ::display::Display::Rotation GetRotation() override; | 123 ::display::Display::Rotation GetRotation() override; |
| 123 void UpdateTextInputState(const ui::TextInputState& state) override; | 124 void UpdateTextInputState(const ui::TextInputState& state) override; |
| 124 void SetImeVisibility(bool visible) override; | 125 void SetImeVisibility(bool visible) override; |
| 125 bool IsFramePending() const override; | 126 bool IsFramePending() const override; |
| 126 void RequestCopyOfOutput( | 127 void RequestCopyOfOutput( |
| 127 std::unique_ptr<cc::CopyOutputRequest> output_request) override; | 128 std::unique_ptr<cc::CopyOutputRequest> output_request) override; |
| 128 int64_t GetDisplayId() const override; | |
| 129 gfx::Rect GetBounds() const override; | 129 gfx::Rect GetBounds() const override; |
| 130 | 130 |
| 131 private: | 131 private: |
| 132 void UpdateMetrics(const gfx::Rect& bounds, float device_scale_factor); | 132 void UpdateMetrics(const gfx::Rect& bounds, float device_scale_factor); |
| 133 | 133 |
| 134 // ui::PlatformWindowDelegate: | 134 // ui::PlatformWindowDelegate: |
| 135 void OnBoundsChanged(const gfx::Rect& new_bounds) override; | 135 void OnBoundsChanged(const gfx::Rect& new_bounds) override; |
| 136 void OnDamageRect(const gfx::Rect& damaged_region) override; | 136 void OnDamageRect(const gfx::Rect& damaged_region) override; |
| 137 void DispatchEvent(ui::Event* event) override; | 137 void DispatchEvent(ui::Event* event) override; |
| 138 void OnCloseRequest() override; | 138 void OnCloseRequest() override; |
| 139 void OnClosed() override; | 139 void OnClosed() override; |
| 140 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; | 140 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; |
| 141 void OnLostCapture() override; | 141 void OnLostCapture() override; |
| 142 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, | 142 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, |
| 143 float device_scale_factor) override; | 143 float device_scale_factor) override; |
| 144 void OnAcceleratedWidgetDestroyed() override; | 144 void OnAcceleratedWidgetDestroyed() override; |
| 145 void OnActivationChanged(bool active) override; | 145 void OnActivationChanged(bool active) override; |
| 146 | 146 |
| 147 // FrameGeneratorDelegate: | 147 // FrameGeneratorDelegate: |
| 148 ServerWindow* GetRootWindow() override; | 148 ServerWindow* GetRootWindow() override; |
| 149 void OnCompositorFrameDrawn() override; | 149 void OnCompositorFrameDrawn() override; |
| 150 bool IsInHighContrastMode() override; | 150 bool IsInHighContrastMode() override; |
| 151 const ViewportMetrics& GetViewportMetrics() override; | 151 const ViewportMetrics& GetViewportMetrics() override; |
| 152 | 152 |
| 153 int64_t display_id_; | 153 int64_t id_; |
| 154 | 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_ |
| OLD | NEW |