| 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 #include "services/ui/ws/platform_display.h" | 5 #include "services/ui/ws/platform_display.h" |
| 6 | 6 |
| 7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "cc/ipc/quads.mojom.h" | 9 #include "cc/ipc/quads.mojom.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Don't notify the delegate from the destructor. | 96 // Don't notify the delegate from the destructor. |
| 97 delegate_ = nullptr; | 97 delegate_ = nullptr; |
| 98 | 98 |
| 99 frame_generator_.reset(); | 99 frame_generator_.reset(); |
| 100 // Destroy the PlatformWindow early on as it may call us back during | 100 // Destroy the PlatformWindow early on as it may call us back during |
| 101 // destruction and we want to be in a known state. But destroy the surface | 101 // destruction and we want to be in a known state. But destroy the surface |
| 102 // first because it can still be using the platform window. | 102 // first because it can still be using the platform window. |
| 103 platform_window_.reset(); | 103 platform_window_.reset(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void DefaultPlatformDisplay::SchedulePaint(const ServerWindow* window, | |
| 107 const gfx::Rect& bounds) { | |
| 108 DCHECK(window); | |
| 109 if (!window->IsDrawn()) | |
| 110 return; | |
| 111 const gfx::Rect root_relative_rect = | |
| 112 ConvertRectBetweenWindows(window, delegate_->GetRootWindow(), bounds); | |
| 113 if (root_relative_rect.IsEmpty()) | |
| 114 return; | |
| 115 frame_generator_->RequestRedraw(root_relative_rect); | |
| 116 } | |
| 117 | |
| 118 void DefaultPlatformDisplay::SetViewportSize(const gfx::Size& size) { | 106 void DefaultPlatformDisplay::SetViewportSize(const gfx::Size& size) { |
| 119 platform_window_->SetBounds(gfx::Rect(size)); | 107 platform_window_->SetBounds(gfx::Rect(size)); |
| 120 } | 108 } |
| 121 | 109 |
| 122 void DefaultPlatformDisplay::SetTitle(const base::string16& title) { | 110 void DefaultPlatformDisplay::SetTitle(const base::string16& title) { |
| 123 platform_window_->SetTitle(title); | 111 platform_window_->SetTitle(title); |
| 124 } | 112 } |
| 125 | 113 |
| 126 void DefaultPlatformDisplay::SetCapture() { | 114 void DefaultPlatformDisplay::SetCapture() { |
| 127 platform_window_->SetCapture(); | 115 platform_window_->SetCapture(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 150 if (ime) | 138 if (ime) |
| 151 ime->UpdateTextInputState(state); | 139 ime->UpdateTextInputState(state); |
| 152 } | 140 } |
| 153 | 141 |
| 154 void DefaultPlatformDisplay::SetImeVisibility(bool visible) { | 142 void DefaultPlatformDisplay::SetImeVisibility(bool visible) { |
| 155 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); | 143 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); |
| 156 if (ime) | 144 if (ime) |
| 157 ime->SetImeVisibility(visible); | 145 ime->SetImeVisibility(visible); |
| 158 } | 146 } |
| 159 | 147 |
| 160 bool DefaultPlatformDisplay::IsFramePending() const { | |
| 161 return frame_generator_->is_frame_pending(); | |
| 162 } | |
| 163 | |
| 164 gfx::Rect DefaultPlatformDisplay::GetBounds() const { | 148 gfx::Rect DefaultPlatformDisplay::GetBounds() const { |
| 165 return metrics_.bounds; | 149 return metrics_.bounds; |
| 166 } | 150 } |
| 167 | 151 |
| 168 bool DefaultPlatformDisplay::IsPrimaryDisplay() const { | 152 bool DefaultPlatformDisplay::IsPrimaryDisplay() const { |
| 169 return display::PlatformScreen::GetInstance()->GetPrimaryDisplayId() == id_; | 153 return display::PlatformScreen::GetInstance()->GetPrimaryDisplayId() == id_; |
| 170 } | 154 } |
| 171 | 155 |
| 172 void DefaultPlatformDisplay::OnGpuChannelEstablished( | 156 void DefaultPlatformDisplay::OnGpuChannelEstablished( |
| 173 scoped_refptr<gpu::GpuChannelHost> channel) { | 157 scoped_refptr<gpu::GpuChannelHost> channel) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 204 // We only care if the window size has changed. | 188 // We only care if the window size has changed. |
| 205 if (new_bounds.size() == metrics_.pixel_size) | 189 if (new_bounds.size() == metrics_.pixel_size) |
| 206 return; | 190 return; |
| 207 | 191 |
| 208 // TODO(kylechar): Maybe do something here. For CrOS we don't need to support | 192 // TODO(kylechar): Maybe do something here. For CrOS we don't need to support |
| 209 // PlatformWindow initiated resizes. For other platforms we need to do | 193 // PlatformWindow initiated resizes. For other platforms we need to do |
| 210 // something but that isn't fully flushed out. | 194 // something but that isn't fully flushed out. |
| 211 } | 195 } |
| 212 | 196 |
| 213 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) { | 197 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) { |
| 214 frame_generator_->RequestRedraw(damaged_region); | |
| 215 } | 198 } |
| 216 | 199 |
| 217 void DefaultPlatformDisplay::DispatchEvent(ui::Event* event) { | 200 void DefaultPlatformDisplay::DispatchEvent(ui::Event* event) { |
| 218 if (event->IsLocatedEvent()) | 201 if (event->IsLocatedEvent()) |
| 219 UpdateEventRootLocation(event->AsLocatedEvent()); | 202 UpdateEventRootLocation(event->AsLocatedEvent()); |
| 220 | 203 |
| 221 if (event->IsScrollEvent()) { | 204 if (event->IsScrollEvent()) { |
| 222 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as | 205 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as |
| 223 // they are once we have proper support for scroll events. | 206 // they are once we have proper support for scroll events. |
| 224 delegate_->OnEvent( | 207 delegate_->OnEvent( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 return delegate_->GetRootWindow(); | 270 return delegate_->GetRootWindow(); |
| 288 } | 271 } |
| 289 | 272 |
| 290 bool DefaultPlatformDisplay::IsInHighContrastMode() { | 273 bool DefaultPlatformDisplay::IsInHighContrastMode() { |
| 291 return delegate_ ? delegate_->IsInHighContrastMode() : false; | 274 return delegate_ ? delegate_->IsInHighContrastMode() : false; |
| 292 } | 275 } |
| 293 | 276 |
| 294 } // namespace ws | 277 } // namespace ws |
| 295 | 278 |
| 296 } // namespace ui | 279 } // namespace ui |
| OLD | NEW |