| 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 "components/mus/ws/platform_display.h" | 5 #include "components/mus/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/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 platform_window_ = | 193 platform_window_ = |
| 194 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); | 194 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); |
| 195 #else | 195 #else |
| 196 NOTREACHED() << "Unsupported platform"; | 196 NOTREACHED() << "Unsupported platform"; |
| 197 #endif | 197 #endif |
| 198 platform_window_->SetBounds(bounds); | 198 platform_window_->SetBounds(bounds); |
| 199 platform_window_->Show(); | 199 platform_window_->Show(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 DefaultPlatformDisplay::~DefaultPlatformDisplay() { | 202 DefaultPlatformDisplay::~DefaultPlatformDisplay() { |
| 203 delegate_->OnTopLevelSurfaceChanged(cc::SurfaceId()); | 203 // Don't notify the delegate from the destructor. |
| 204 delegate_ = nullptr; |
| 205 |
| 204 // Invalidate WeakPtrs now to avoid callbacks back into the | 206 // Invalidate WeakPtrs now to avoid callbacks back into the |
| 205 // DefaultPlatformDisplay during destruction of |top_level_display_client_|. | 207 // DefaultPlatformDisplay during destruction of |top_level_display_client_|. |
| 206 weak_factory_.InvalidateWeakPtrs(); | 208 weak_factory_.InvalidateWeakPtrs(); |
| 207 top_level_display_client_.reset(); | 209 top_level_display_client_.reset(); |
| 208 // Destroy the PlatformWindow early on as it may call us back during | 210 // Destroy the PlatformWindow early on as it may call us back during |
| 209 // destruction and we want to be in a known state. But destroy the surface | 211 // destruction and we want to be in a known state. But destroy the surface |
| 210 // first because it can still be using the platform window. | 212 // first because it can still be using the platform window. |
| 211 platform_window_.reset(); | 213 platform_window_.reset(); |
| 212 } | 214 } |
| 213 | 215 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 delegate_->OnEvent(char_event); | 394 delegate_->OnEvent(char_event); |
| 393 } | 395 } |
| 394 #endif | 396 #endif |
| 395 } | 397 } |
| 396 | 398 |
| 397 void DefaultPlatformDisplay::OnCloseRequest() { | 399 void DefaultPlatformDisplay::OnCloseRequest() { |
| 398 platform_window_->Close(); | 400 platform_window_->Close(); |
| 399 } | 401 } |
| 400 | 402 |
| 401 void DefaultPlatformDisplay::OnClosed() { | 403 void DefaultPlatformDisplay::OnClosed() { |
| 402 delegate_->OnDisplayClosed(); | 404 if (delegate_) |
| 405 delegate_->OnDisplayClosed(); |
| 403 } | 406 } |
| 404 | 407 |
| 405 void DefaultPlatformDisplay::OnWindowStateChanged( | 408 void DefaultPlatformDisplay::OnWindowStateChanged( |
| 406 ui::PlatformWindowState new_state) {} | 409 ui::PlatformWindowState new_state) {} |
| 407 | 410 |
| 408 void DefaultPlatformDisplay::OnLostCapture() { | 411 void DefaultPlatformDisplay::OnLostCapture() { |
| 409 delegate_->OnNativeCaptureLost(); | 412 delegate_->OnNativeCaptureLost(); |
| 410 } | 413 } |
| 411 | 414 |
| 412 void DefaultPlatformDisplay::OnAcceleratedWidgetAvailable( | 415 void DefaultPlatformDisplay::OnAcceleratedWidgetAvailable( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 429 | 432 |
| 430 void DefaultPlatformDisplay::RequestCopyOfOutput( | 433 void DefaultPlatformDisplay::RequestCopyOfOutput( |
| 431 scoped_ptr<cc::CopyOutputRequest> output_request) { | 434 scoped_ptr<cc::CopyOutputRequest> output_request) { |
| 432 if (top_level_display_client_) | 435 if (top_level_display_client_) |
| 433 top_level_display_client_->RequestCopyOfOutput(std::move(output_request)); | 436 top_level_display_client_->RequestCopyOfOutput(std::move(output_request)); |
| 434 } | 437 } |
| 435 | 438 |
| 436 } // namespace ws | 439 } // namespace ws |
| 437 | 440 |
| 438 } // namespace mus | 441 } // namespace mus |
| OLD | NEW |