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

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

Issue 2189893004: Unify display ids between Display and PlatformDisplay. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Back to pure virtual. 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
« no previous file with comments | « services/ui/ws/platform_display.h ('k') | services/ui/ws/test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 PlatformDisplay* PlatformDisplay::Create( 47 PlatformDisplay* PlatformDisplay::Create(
48 const PlatformDisplayInitParams& init_params) { 48 const PlatformDisplayInitParams& init_params) {
49 if (factory_) 49 if (factory_)
50 return factory_->CreatePlatformDisplay(); 50 return factory_->CreatePlatformDisplay();
51 51
52 return new DefaultPlatformDisplay(init_params); 52 return new DefaultPlatformDisplay(init_params);
53 } 53 }
54 54
55 DefaultPlatformDisplay::DefaultPlatformDisplay( 55 DefaultPlatformDisplay::DefaultPlatformDisplay(
56 const PlatformDisplayInitParams& init_params) 56 const PlatformDisplayInitParams& init_params)
57 : display_id_(init_params.display_id), 57 : id_(init_params.display_id),
58 #if !defined(OS_ANDROID) 58 #if !defined(OS_ANDROID)
59 cursor_loader_(ui::CursorLoader::Create()), 59 cursor_loader_(ui::CursorLoader::Create()),
60 #endif 60 #endif
61 frame_generator_(new FrameGenerator(this, 61 frame_generator_(new FrameGenerator(this, init_params.surfaces_state)) {
62 init_params.surfaces_state)) {
63 metrics_.bounds = init_params.display_bounds; 62 metrics_.bounds = init_params.display_bounds;
64 // TODO(rjkroege): Preserve the display_id when Ozone platform can use it. 63 // TODO(rjkroege): Preserve the display_id when Ozone platform can use it.
65 } 64 }
66 65
67 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) { 66 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) {
68 delegate_ = delegate; 67 delegate_ = delegate;
69 68
70 #if defined(OS_WIN) 69 #if defined(OS_WIN)
71 platform_window_.reset(new ui::WinWindow(this, metrics_.bounds)); 70 platform_window_.reset(new ui::WinWindow(this, metrics_.bounds));
72 #elif defined(USE_X11) 71 #elif defined(USE_X11)
73 platform_window_.reset(new ui::X11Window(this)); 72 platform_window_.reset(new ui::X11Window(this));
74 #elif defined(OS_ANDROID) 73 #elif defined(OS_ANDROID)
75 platform_window_.reset(new ui::PlatformWindowAndroid(this)); 74 platform_window_.reset(new ui::PlatformWindowAndroid(this));
76 #elif defined(USE_OZONE) 75 #elif defined(USE_OZONE)
77 platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow( 76 platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
78 this, metrics_.bounds); 77 this, metrics_.bounds);
79 #else 78 #else
80 NOTREACHED() << "Unsupported platform"; 79 NOTREACHED() << "Unsupported platform";
81 #endif 80 #endif
82 platform_window_->SetBounds(metrics_.bounds); 81 platform_window_->SetBounds(metrics_.bounds);
83 platform_window_->Show(); 82 platform_window_->Show();
84 } 83 }
85 84
85 int64_t DefaultPlatformDisplay::GetId() const {
86 return id_;
87 }
88
86 DefaultPlatformDisplay::~DefaultPlatformDisplay() { 89 DefaultPlatformDisplay::~DefaultPlatformDisplay() {
87 // Don't notify the delegate from the destructor. 90 // Don't notify the delegate from the destructor.
88 delegate_ = nullptr; 91 delegate_ = nullptr;
89 92
90 frame_generator_.reset(); 93 frame_generator_.reset();
91 // Destroy the PlatformWindow early on as it may call us back during 94 // Destroy the PlatformWindow early on as it may call us back during
92 // destruction and we want to be in a known state. But destroy the surface 95 // destruction and we want to be in a known state. But destroy the surface
93 // first because it can still be using the platform window. 96 // first because it can still be using the platform window.
94 platform_window_.reset(); 97 platform_window_.reset();
95 } 98 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void DefaultPlatformDisplay::SetImeVisibility(bool visible) { 157 void DefaultPlatformDisplay::SetImeVisibility(bool visible) {
155 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); 158 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController();
156 if (ime) 159 if (ime)
157 ime->SetImeVisibility(visible); 160 ime->SetImeVisibility(visible);
158 } 161 }
159 162
160 bool DefaultPlatformDisplay::IsFramePending() const { 163 bool DefaultPlatformDisplay::IsFramePending() const {
161 return frame_generator_->is_frame_pending(); 164 return frame_generator_->is_frame_pending();
162 } 165 }
163 166
164 int64_t DefaultPlatformDisplay::GetDisplayId() const {
165 return display_id_;
166 }
167
168 gfx::Rect DefaultPlatformDisplay::GetBounds() const { 167 gfx::Rect DefaultPlatformDisplay::GetBounds() const {
169 return metrics_.bounds; 168 return metrics_.bounds;
170 } 169 }
171 170
172 void DefaultPlatformDisplay::UpdateMetrics(const gfx::Rect& bounds, 171 void DefaultPlatformDisplay::UpdateMetrics(const gfx::Rect& bounds,
173 float device_scale_factor) { 172 float device_scale_factor) {
174 if (display::Display::HasForceDeviceScaleFactor()) 173 if (display::Display::HasForceDeviceScaleFactor())
175 device_scale_factor = display::Display::GetForcedDeviceScaleFactor(); 174 device_scale_factor = display::Display::GetForcedDeviceScaleFactor();
176 if (metrics_.bounds == bounds && 175 if (metrics_.bounds == bounds &&
177 metrics_.device_scale_factor == device_scale_factor) 176 metrics_.device_scale_factor == device_scale_factor)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return delegate_ ? delegate_->IsInHighContrastMode() : false; 277 return delegate_ ? delegate_->IsInHighContrastMode() : false;
279 } 278 }
280 279
281 const ViewportMetrics& DefaultPlatformDisplay::GetViewportMetrics() { 280 const ViewportMetrics& DefaultPlatformDisplay::GetViewportMetrics() {
282 return metrics_; 281 return metrics_;
283 } 282 }
284 283
285 } // namespace ws 284 } // namespace ws
286 285
287 } // namespace ui 286 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/platform_display.h ('k') | services/ui/ws/test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698