| 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 COMPONENTS_MUS_WS_PLATFORM_DISPLAY_H_ | 5 #ifndef COMPONENTS_MUS_WS_PLATFORM_DISPLAY_H_ |
| 6 #define COMPONENTS_MUS_WS_PLATFORM_DISPLAY_H_ | 6 #define COMPONENTS_MUS_WS_PLATFORM_DISPLAY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 class GpuState; | 51 class GpuState; |
| 52 class SurfacesState; | 52 class SurfacesState; |
| 53 class DisplayCompositor; | 53 class DisplayCompositor; |
| 54 | 54 |
| 55 namespace ws { | 55 namespace ws { |
| 56 | 56 |
| 57 class EventDispatcher; | 57 class EventDispatcher; |
| 58 class PlatformDisplayFactory; | 58 class PlatformDisplayFactory; |
| 59 class ServerWindow; | 59 class ServerWindow; |
| 60 | 60 |
| 61 struct ViewportMetrics { |
| 62 gfx::Size size_in_pixels; |
| 63 float device_scale_factor = 0.f; |
| 64 }; |
| 65 |
| 61 // PlatformDisplay is used to connect the root ServerWindow to a display. | 66 // PlatformDisplay is used to connect the root ServerWindow to a display. |
| 62 class PlatformDisplay { | 67 class PlatformDisplay { |
| 63 public: | 68 public: |
| 64 virtual ~PlatformDisplay() {} | 69 virtual ~PlatformDisplay() {} |
| 65 | 70 |
| 66 static PlatformDisplay* Create(const PlatformDisplayInitParams& init_params); | 71 static PlatformDisplay* Create(const PlatformDisplayInitParams& init_params); |
| 67 | 72 |
| 68 virtual void Init(PlatformDisplayDelegate* delegate) = 0; | 73 virtual void Init(PlatformDisplayDelegate* delegate) = 0; |
| 69 | 74 |
| 70 // Schedules a paint for the specified region in the coordinates of |window|. | 75 // Schedules a paint for the specified region in the coordinates of |window|. |
| 71 virtual void SchedulePaint(const ServerWindow* window, | 76 virtual void SchedulePaint(const ServerWindow* window, |
| 72 const gfx::Rect& bounds) = 0; | 77 const gfx::Rect& bounds) = 0; |
| 73 | 78 |
| 74 virtual void SetViewportSize(const gfx::Size& size) = 0; | 79 virtual void SetViewportSize(const gfx::Size& size) = 0; |
| 75 | 80 |
| 76 virtual void SetTitle(const base::string16& title) = 0; | 81 virtual void SetTitle(const base::string16& title) = 0; |
| 77 | 82 |
| 78 virtual void SetCapture() = 0; | 83 virtual void SetCapture() = 0; |
| 79 | 84 |
| 80 virtual void ReleaseCapture() = 0; | 85 virtual void ReleaseCapture() = 0; |
| 81 | 86 |
| 82 virtual void SetCursorById(int32_t cursor) = 0; | 87 virtual void SetCursorById(int32_t cursor) = 0; |
| 83 | 88 |
| 84 virtual mojom::Rotation GetRotation() = 0; | 89 virtual mojom::Rotation GetRotation() = 0; |
| 85 | 90 |
| 86 virtual const mojom::ViewportMetrics& GetViewportMetrics() = 0; | 91 virtual float GetDeviceScaleFactor() = 0; |
| 87 | 92 |
| 88 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0; | 93 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0; |
| 89 virtual void SetImeVisibility(bool visible) = 0; | 94 virtual void SetImeVisibility(bool visible) = 0; |
| 90 | 95 |
| 91 // Returns true if a compositor frame has been submitted but not drawn yet. | 96 // Returns true if a compositor frame has been submitted but not drawn yet. |
| 92 virtual bool IsFramePending() const = 0; | 97 virtual bool IsFramePending() const = 0; |
| 93 | 98 |
| 94 virtual void RequestCopyOfOutput( | 99 virtual void RequestCopyOfOutput( |
| 95 std::unique_ptr<cc::CopyOutputRequest> output_request) = 0; | 100 std::unique_ptr<cc::CopyOutputRequest> output_request) = 0; |
| 96 | 101 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 115 | 120 |
| 116 // PlatformDisplay: | 121 // PlatformDisplay: |
| 117 void Init(PlatformDisplayDelegate* delegate) override; | 122 void Init(PlatformDisplayDelegate* delegate) override; |
| 118 void SchedulePaint(const ServerWindow* window, | 123 void SchedulePaint(const ServerWindow* window, |
| 119 const gfx::Rect& bounds) override; | 124 const gfx::Rect& bounds) override; |
| 120 void SetViewportSize(const gfx::Size& size) override; | 125 void SetViewportSize(const gfx::Size& size) override; |
| 121 void SetTitle(const base::string16& title) override; | 126 void SetTitle(const base::string16& title) override; |
| 122 void SetCapture() override; | 127 void SetCapture() override; |
| 123 void ReleaseCapture() override; | 128 void ReleaseCapture() override; |
| 124 void SetCursorById(int32_t cursor) override; | 129 void SetCursorById(int32_t cursor) override; |
| 125 const mojom::ViewportMetrics& GetViewportMetrics() override; | 130 float GetDeviceScaleFactor() override; |
| 126 mojom::Rotation GetRotation() override; | 131 mojom::Rotation GetRotation() override; |
| 127 void UpdateTextInputState(const ui::TextInputState& state) override; | 132 void UpdateTextInputState(const ui::TextInputState& state) override; |
| 128 void SetImeVisibility(bool visible) override; | 133 void SetImeVisibility(bool visible) override; |
| 129 bool IsFramePending() const override; | 134 bool IsFramePending() const override; |
| 130 void RequestCopyOfOutput( | 135 void RequestCopyOfOutput( |
| 131 std::unique_ptr<cc::CopyOutputRequest> output_request) override; | 136 std::unique_ptr<cc::CopyOutputRequest> output_request) override; |
| 132 | 137 |
| 133 private: | 138 private: |
| 134 void WantToDraw(); | 139 void WantToDraw(); |
| 135 | 140 |
| 136 // This method initiates a top level redraw of the display. | 141 // This method initiates a top level redraw of the display. |
| 137 // TODO(fsamuel): This should use vblank as a signal rather than a timer | 142 // TODO(fsamuel): This should use vblank as a signal rather than a timer |
| 138 // http://crbug.com/533042 | 143 // http://crbug.com/533042 |
| 139 void Draw(); | 144 void Draw(); |
| 140 | 145 |
| 141 // This is called after cc::Display has completed generating a new frame | 146 // This is called after cc::Display has completed generating a new frame |
| 142 // for the display. TODO(fsamuel): Idle time processing should happen here | 147 // for the display. TODO(fsamuel): Idle time processing should happen here |
| 143 // if there is budget for it. | 148 // if there is budget for it. |
| 144 void DidDraw(cc::SurfaceDrawStatus status); | 149 void DidDraw(cc::SurfaceDrawStatus status); |
| 145 void UpdateMetrics(const gfx::Size& size, float device_pixel_ratio); | 150 void UpdateMetrics(const gfx::Size& size, float device_scale_factor); |
| 146 std::unique_ptr<cc::CompositorFrame> GenerateCompositorFrame(); | 151 std::unique_ptr<cc::CompositorFrame> GenerateCompositorFrame(); |
| 147 | 152 |
| 148 // ui::PlatformWindowDelegate: | 153 // ui::PlatformWindowDelegate: |
| 149 void OnBoundsChanged(const gfx::Rect& new_bounds) override; | 154 void OnBoundsChanged(const gfx::Rect& new_bounds) override; |
| 150 void OnDamageRect(const gfx::Rect& damaged_region) override; | 155 void OnDamageRect(const gfx::Rect& damaged_region) override; |
| 151 void DispatchEvent(ui::Event* event) override; | 156 void DispatchEvent(ui::Event* event) override; |
| 152 void OnCloseRequest() override; | 157 void OnCloseRequest() override; |
| 153 void OnClosed() override; | 158 void OnClosed() override; |
| 154 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; | 159 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; |
| 155 void OnLostCapture() override; | 160 void OnLostCapture() override; |
| 156 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, | 161 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, |
| 157 float device_pixel_ratio) override; | 162 float device_scale_factor) override; |
| 158 void OnAcceleratedWidgetDestroyed() override; | 163 void OnAcceleratedWidgetDestroyed() override; |
| 159 void OnActivationChanged(bool active) override; | 164 void OnActivationChanged(bool active) override; |
| 160 | 165 |
| 161 scoped_refptr<GpuState> gpu_state_; | 166 scoped_refptr<GpuState> gpu_state_; |
| 162 scoped_refptr<SurfacesState> surfaces_state_; | 167 scoped_refptr<SurfacesState> surfaces_state_; |
| 163 PlatformDisplayDelegate* delegate_; | 168 PlatformDisplayDelegate* delegate_; |
| 164 | 169 |
| 165 mojom::ViewportMetrics metrics_; | 170 ViewportMetrics metrics_; |
| 166 gfx::Rect dirty_rect_; | 171 gfx::Rect dirty_rect_; |
| 167 base::Timer draw_timer_; | 172 base::Timer draw_timer_; |
| 168 bool frame_pending_; | 173 bool frame_pending_; |
| 169 | 174 |
| 170 std::unique_ptr<DisplayCompositor> display_compositor_; | 175 std::unique_ptr<DisplayCompositor> display_compositor_; |
| 171 std::unique_ptr<ui::PlatformWindow> platform_window_; | 176 std::unique_ptr<ui::PlatformWindow> platform_window_; |
| 172 | 177 |
| 173 #if !defined(OS_ANDROID) | 178 #if !defined(OS_ANDROID) |
| 174 std::unique_ptr<ui::CursorLoader> cursor_loader_; | 179 std::unique_ptr<ui::CursorLoader> cursor_loader_; |
| 175 #endif | 180 #endif |
| 176 | 181 |
| 177 base::WeakPtrFactory<DefaultPlatformDisplay> weak_factory_; | 182 base::WeakPtrFactory<DefaultPlatformDisplay> weak_factory_; |
| 178 | 183 |
| 179 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformDisplay); | 184 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformDisplay); |
| 180 }; | 185 }; |
| 181 | 186 |
| 182 } // namespace ws | 187 } // namespace ws |
| 183 | 188 |
| 184 } // namespace mus | 189 } // namespace mus |
| 185 | 190 |
| 186 #endif // COMPONENTS_MUS_WS_PLATFORM_DISPLAY_H_ | 191 #endif // COMPONENTS_MUS_WS_PLATFORM_DISPLAY_H_ |
| OLD | NEW |