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

Side by Side Diff: ui/aura/local/window_port_local.cc

Issue 2868473002: Implement aura::Window::CreateCompositorFrameSink() (Closed)
Patch Set: Address review issues Created 3 years, 7 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 | « ui/aura/local/window_port_local.h ('k') | ui/aura/mus/window_port_mus.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 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 "ui/aura/window_port_local.h" 5 #include "ui/aura/local/window_port_local.h"
6 6
7 #include "cc/surfaces/surface_manager.h"
7 #include "ui/aura/client/cursor_client.h" 8 #include "ui/aura/client/cursor_client.h"
8 #include "ui/aura/env.h" 9 #include "ui/aura/env.h"
10 #include "ui/aura/local/compositor_frame_sink_local.h"
9 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
10 #include "ui/aura/window_delegate.h" 12 #include "ui/aura/window_delegate.h"
11 #include "ui/display/display.h" 13 #include "ui/display/display.h"
12 #include "ui/display/screen.h" 14 #include "ui/display/screen.h"
13 15
14 namespace aura { 16 namespace aura {
15 namespace { 17 namespace {
16 18
17 class ScopedCursorHider { 19 class ScopedCursorHider {
18 public: 20 public:
(...skipping 29 matching lines...) Expand all
48 50
49 private: 51 private:
50 Window* window_; 52 Window* window_;
51 bool hid_cursor_; 53 bool hid_cursor_;
52 54
53 DISALLOW_COPY_AND_ASSIGN(ScopedCursorHider); 55 DISALLOW_COPY_AND_ASSIGN(ScopedCursorHider);
54 }; 56 };
55 57
56 } // namespace 58 } // namespace
57 59
58 WindowPortLocal::WindowPortLocal(Window* window) : window_(window) {} 60 WindowPortLocal::WindowPortLocal(Window* window)
61 : window_(window), weak_factory_(this) {}
59 62
60 WindowPortLocal::~WindowPortLocal() {} 63 WindowPortLocal::~WindowPortLocal() {}
61 64
62 void WindowPortLocal::OnPreInit(Window* window) {} 65 void WindowPortLocal::OnPreInit(Window* window) {}
63 66
64 void WindowPortLocal::OnDeviceScaleFactorChanged(float device_scale_factor) { 67 void WindowPortLocal::OnDeviceScaleFactorChanged(float device_scale_factor) {
65 ScopedCursorHider hider(window_); 68 ScopedCursorHider hider(window_);
66 if (window_->delegate()) 69 if (window_->delegate())
67 window_->delegate()->OnDeviceScaleFactorChanged(device_scale_factor); 70 window_->delegate()->OnDeviceScaleFactorChanged(device_scale_factor);
68 } 71 }
(...skipping 13 matching lines...) Expand all
82 std::unique_ptr<ui::PropertyData> WindowPortLocal::OnWillChangeProperty( 85 std::unique_ptr<ui::PropertyData> WindowPortLocal::OnWillChangeProperty(
83 const void* key) { 86 const void* key) {
84 return nullptr; 87 return nullptr;
85 } 88 }
86 89
87 void WindowPortLocal::OnPropertyChanged( 90 void WindowPortLocal::OnPropertyChanged(
88 const void* key, 91 const void* key,
89 int64_t old_value, 92 int64_t old_value,
90 std::unique_ptr<ui::PropertyData> data) {} 93 std::unique_ptr<ui::PropertyData> data) {}
91 94
95 std::unique_ptr<cc::CompositorFrameSink>
96 WindowPortLocal::CreateCompositorFrameSink() {
97 DCHECK(!frame_sink_id_.is_valid());
98 auto* context_factory_private =
99 aura::Env::GetInstance()->context_factory_private();
100 frame_sink_id_ = context_factory_private->AllocateFrameSinkId();
101 auto frame_sink = base::MakeUnique<CompositorFrameSinkLocal>(
102 frame_sink_id_, context_factory_private->GetSurfaceManager());
103 frame_sink->SetSurfaceChangedCallback(base::Bind(
104 &WindowPortLocal::OnSurfaceChanged, weak_factory_.GetWeakPtr()));
105 return std::move(frame_sink);
106 }
107
108 cc::SurfaceId WindowPortLocal::GetSurfaceId() const {
109 return cc::SurfaceId(frame_sink_id_, local_surface_id_);
110 }
111
112 void WindowPortLocal::OnWindowAddedToRootWindow() {
113 if (frame_sink_id_.is_valid())
114 window_->layer()->GetCompositor()->AddFrameSink(frame_sink_id_);
115 }
116
117 void WindowPortLocal::OnWillRemoveWindowFromRootWindow() {
118 if (frame_sink_id_.is_valid())
119 window_->layer()->GetCompositor()->RemoveFrameSink(frame_sink_id_);
120 }
121
122 void WindowPortLocal::OnSurfaceChanged(const cc::SurfaceId& surface_id,
123 const gfx::Size& surface_size) {
124 DCHECK_EQ(surface_id.frame_sink_id(), frame_sink_id_);
125 local_surface_id_ = surface_id.local_surface_id();
126 // The bounds must be updated before switching to the new surface, because
127 // the layer may be mirrored, in which case a surface change causes the
128 // mirror layer to update its surface using the latest bounds.
129 window_->layer()->SetBounds(
130 gfx::Rect(window_->layer()->bounds().origin(), surface_size));
131 window_->layer()->SetShowPrimarySurface(
132 cc::SurfaceInfo(surface_id, 1.0f, surface_size),
133 aura::Env::GetInstance()
134 ->context_factory_private()
135 ->GetSurfaceManager()
136 ->reference_factory());
137 }
138
92 } // namespace aura 139 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/local/window_port_local.h ('k') | ui/aura/mus/window_port_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698