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

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

Issue 2763143002: Remove FrameGenerator::root_window_ (Closed)
Patch Set: Addressed nits Created 3 years, 9 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_default.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_default.h" 5 #include "services/ui/ws/platform_display_default.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "gpu/ipc/client/gpu_channel_host.h" 8 #include "gpu/ipc/client/gpu_channel_host.h"
9 #include "services/ui/display/screen_manager.h" 9 #include "services/ui/display/screen_manager.h"
10 #include "services/ui/ws/display_client_compositor_frame_sink.h" 10 #include "services/ui/ws/display_client_compositor_frame_sink.h"
(...skipping 19 matching lines...) Expand all
30 namespace ws { 30 namespace ws {
31 31
32 PlatformDisplayDefault::PlatformDisplayDefault( 32 PlatformDisplayDefault::PlatformDisplayDefault(
33 ServerWindow* root_window, 33 ServerWindow* root_window,
34 const display::ViewportMetrics& metrics) 34 const display::ViewportMetrics& metrics)
35 : root_window_(root_window), 35 : root_window_(root_window),
36 #if !defined(OS_ANDROID) 36 #if !defined(OS_ANDROID)
37 image_cursors_(new ImageCursors), 37 image_cursors_(new ImageCursors),
38 #endif 38 #endif
39 metrics_(metrics), 39 metrics_(metrics),
40 widget_(gfx::kNullAcceleratedWidget), 40 widget_(gfx::kNullAcceleratedWidget) {
41 init_device_scale_factor_(metrics.device_scale_factor) { 41 root_window_->AddObserver(this);
42 } 42 }
43 43
44 PlatformDisplayDefault::~PlatformDisplayDefault() { 44 PlatformDisplayDefault::~PlatformDisplayDefault() {
45 root_window_->RemoveObserver(this);
45 // Don't notify the delegate from the destructor. 46 // Don't notify the delegate from the destructor.
46 delegate_ = nullptr; 47 delegate_ = nullptr;
47 48
48 frame_generator_.reset(); 49 frame_generator_.reset();
49 // Destroy the PlatformWindow early on as it may call us back during 50 // Destroy the PlatformWindow early on as it may call us back during
50 // destruction and we want to be in a known state. But destroy the surface 51 // destruction and we want to be in a known state. But destroy the surface
51 // first because it can still be using the platform window. 52 // first because it can still be using the platform window.
52 platform_window_.reset(); 53 platform_window_.reset();
53 } 54 }
54 55
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 widget_, mojo::MakeRequest(&compositor_frame_sink), 251 widget_, mojo::MakeRequest(&compositor_frame_sink),
251 std::move(compositor_frame_sink_client), 252 std::move(compositor_frame_sink_client),
252 mojo::MakeRequest(&display_private)); 253 mojo::MakeRequest(&display_private));
253 254
254 auto display_client_compositor_frame_sink = 255 auto display_client_compositor_frame_sink =
255 base::MakeUnique<DisplayClientCompositorFrameSink>( 256 base::MakeUnique<DisplayClientCompositorFrameSink>(
256 root_window_->frame_sink_id(), std::move(compositor_frame_sink), 257 root_window_->frame_sink_id(), std::move(compositor_frame_sink),
257 std::move(display_private), 258 std::move(display_private),
258 std::move(compositor_frame_sink_client_request)); 259 std::move(compositor_frame_sink_client_request));
259 frame_generator_ = base::MakeUnique<FrameGenerator>( 260 frame_generator_ = base::MakeUnique<FrameGenerator>(
260 root_window_, std::move(display_client_compositor_frame_sink)); 261 std::move(display_client_compositor_frame_sink));
261 frame_generator_->SetDeviceScaleFactor(init_device_scale_factor_); 262 frame_generator_->OnWindowVisibilityChanged(root_window_->visible());
263 frame_generator_->OnWindowBoundsChanged(root_window_->bounds());
264 frame_generator_->SetDeviceScaleFactor(metrics_.device_scale_factor);
262 } 265 }
263 266
264 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { 267 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() {
265 NOTREACHED(); 268 NOTREACHED();
266 } 269 }
267 270
268 void PlatformDisplayDefault::OnActivationChanged(bool active) {} 271 void PlatformDisplayDefault::OnActivationChanged(bool active) {}
269 272
273 void PlatformDisplayDefault::OnWindowBoundsChanged(
msw 2017/03/22 19:36:52 Why not make FrameGenerator observe the ServerWind
Alex Z. 2017/03/22 20:51:10 We wanted to make FrameGenerator as simple as poss
274 ServerWindow* window,
275 const gfx::Rect& old_bounds,
276 const gfx::Rect& new_bounds) {
277 if (frame_generator_)
278 frame_generator_->OnWindowBoundsChanged(new_bounds);
279 }
280
281 void PlatformDisplayDefault::OnWindowVisibilityChanged(ServerWindow* window) {
282 if (frame_generator_)
283 frame_generator_->OnWindowVisibilityChanged(window->visible());
284 }
285
270 } // namespace ws 286 } // namespace ws
271 } // namespace ui 287 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/platform_display_default.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698