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

Side by Side Diff: ui/aura/mus/mus_context_factory.cc

Issue 2886873002: Only send the FrameSinkId to client when it is necessary (Closed)
Patch Set: WIP 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/mus/mus_context_factory.h" 5 #include "ui/aura/mus/mus_context_factory.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "services/ui/public/cpp/gpu/gpu.h" 8 #include "services/ui/public/cpp/gpu/gpu.h"
9 #include "ui/aura/mus/window_port_mus.h" 9 #include "ui/aura/mus/window_port_mus.h"
10 #include "ui/aura/window_tree_host.h" 10 #include "ui/aura/window_tree_host.h"
11 #include "ui/gl/gl_bindings.h" 11 #include "ui/gl/gl_bindings.h"
12 12
13 namespace aura { 13 namespace aura {
14 14
15 MusContextFactory::MusContextFactory(ui::Gpu* gpu) 15 MusContextFactory::MusContextFactory(ui::Gpu* gpu)
16 : gpu_(gpu), weak_ptr_factory_(this) {} 16 : gpu_(gpu), weak_ptr_factory_(this) {}
17 17
18 MusContextFactory::~MusContextFactory() {} 18 MusContextFactory::~MusContextFactory() {}
19 19
20 void MusContextFactory::OnEstablishedGpuChannel( 20 void MusContextFactory::OnEstablishedGpuChannel(
21 base::WeakPtr<ui::Compositor> compositor, 21 base::WeakPtr<ui::Compositor> compositor,
22 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { 22 scoped_refptr<gpu::GpuChannelHost> gpu_channel) {
23 if (!compositor) 23 if (!compositor)
24 return; 24 return;
25 WindowTreeHost* host = 25 WindowTreeHost* host =
26 WindowTreeHost::GetForAcceleratedWidget(compositor->widget()); 26 WindowTreeHost::GetForAcceleratedWidget(compositor->widget());
27 WindowPortMus* window_port = WindowPortMus::Get(host->window()); 27 WindowPortMus* window_port = WindowPortMus::Get(host->window());
28 DCHECK(window_port); 28 DCHECK(window_port);
29 window_port->RequestCompositorFrameSink( 29 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink =
30 gpu_->CreateContextProvider(std::move(gpu_channel)), 30 window_port->RequestCompositorFrameSink(
31 gpu_->gpu_memory_buffer_manager(), 31 gpu_->CreateContextProvider(std::move(gpu_channel)),
32 base::Bind(&MusContextFactory::OnCompositorFrameSinkAvailable, 32 gpu_->gpu_memory_buffer_manager());
33 weak_ptr_factory_.GetWeakPtr(), compositor));
34 }
35
36 void MusContextFactory::OnCompositorFrameSinkAvailable(
37 base::WeakPtr<ui::Compositor> compositor,
38 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink) {
39 if (!compositor)
40 return;
41 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); 33 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink));
42 } 34 }
43 35
44 void MusContextFactory::CreateCompositorFrameSink( 36 void MusContextFactory::CreateCompositorFrameSink(
45 base::WeakPtr<ui::Compositor> compositor) { 37 base::WeakPtr<ui::Compositor> compositor) {
46 gpu_->EstablishGpuChannel( 38 gpu_->EstablishGpuChannel(
47 base::Bind(&MusContextFactory::OnEstablishedGpuChannel, 39 base::Bind(&MusContextFactory::OnEstablishedGpuChannel,
48 weak_ptr_factory_.GetWeakPtr(), compositor)); 40 weak_ptr_factory_.GetWeakPtr(), compositor));
49 } 41 }
50 42
(...skipping 19 matching lines...) Expand all
70 62
71 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() { 63 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() {
72 return gpu_->gpu_memory_buffer_manager(); 64 return gpu_->gpu_memory_buffer_manager();
73 } 65 }
74 66
75 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() { 67 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() {
76 return raster_thread_helper_.task_graph_runner(); 68 return raster_thread_helper_.task_graph_runner();
77 } 69 }
78 70
79 } // namespace aura 71 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698