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

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

Powered by Google App Engine
This is Rietveld 408576698