OLD | NEW |
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/views/mus/surface_context_factory.h" | 5 #include "ui/views/mus/surface_context_factory.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "cc/resources/shared_bitmap_manager.h" | 8 #include "cc/resources/shared_bitmap_manager.h" |
9 #include "cc/surfaces/surface_id_allocator.h" | 9 #include "cc/surfaces/surface_id_allocator.h" |
10 #include "services/ui/public/cpp/context_provider.h" | 10 #include "services/ui/public/cpp/context_provider.h" |
11 #include "services/ui/public/cpp/gpu/gpu_service.h" | 11 #include "services/ui/public/cpp/gpu/gpu_service.h" |
12 #include "services/ui/public/cpp/window.h" | 12 #include "services/ui/public/cpp/window.h" |
13 #include "services/ui/public/cpp/window_compositor_frame_sink.h" | 13 #include "services/ui/public/cpp/window_compositor_frame_sink.h" |
14 #include "ui/compositor/reflector.h" | 14 #include "ui/compositor/reflector.h" |
15 #include "ui/gl/gl_bindings.h" | 15 #include "ui/gl/gl_bindings.h" |
16 #include "ui/views/mus/native_widget_mus.h" | 16 #include "ui/views/mus/native_widget_mus.h" |
17 | 17 |
18 namespace views { | 18 namespace views { |
19 namespace { | |
20 | |
21 class FakeReflector : public ui::Reflector { | |
22 public: | |
23 FakeReflector() {} | |
24 ~FakeReflector() override {} | |
25 void OnMirroringCompositorResized() override {} | |
26 void AddMirroringLayer(ui::Layer* layer) override {} | |
27 void RemoveMirroringLayer(ui::Layer* layer) override {} | |
28 }; | |
29 | |
30 } // namespace | |
31 | 19 |
32 SurfaceContextFactory::SurfaceContextFactory(ui::GpuService* gpu_service) | 20 SurfaceContextFactory::SurfaceContextFactory(ui::GpuService* gpu_service) |
33 : next_sink_id_(1u), gpu_service_(gpu_service) {} | 21 : gpu_service_(gpu_service) {} |
34 | 22 |
35 SurfaceContextFactory::~SurfaceContextFactory() {} | 23 SurfaceContextFactory::~SurfaceContextFactory() {} |
36 | 24 |
37 void SurfaceContextFactory::CreateCompositorFrameSink( | 25 void SurfaceContextFactory::CreateCompositorFrameSink( |
38 base::WeakPtr<ui::Compositor> compositor) { | 26 base::WeakPtr<ui::Compositor> compositor) { |
39 ui::Window* window = compositor->window(); | 27 ui::Window* window = compositor->window(); |
40 NativeWidgetMus* native_widget = NativeWidgetMus::GetForWindow(window); | 28 NativeWidgetMus* native_widget = NativeWidgetMus::GetForWindow(window); |
41 ui::mojom::CompositorFrameSinkType compositor_frame_sink_type = | 29 ui::mojom::CompositorFrameSinkType compositor_frame_sink_type = |
42 native_widget->compositor_frame_sink_type(); | 30 native_widget->compositor_frame_sink_type(); |
43 auto compositor_frame_sink = window->RequestCompositorFrameSink( | 31 auto compositor_frame_sink = window->RequestCompositorFrameSink( |
44 compositor_frame_sink_type, make_scoped_refptr(new ui::ContextProvider( | 32 compositor_frame_sink_type, make_scoped_refptr(new ui::ContextProvider( |
45 gpu_service_->EstablishGpuChannelSync())), | 33 gpu_service_->EstablishGpuChannelSync())), |
46 gpu_service_->gpu_memory_buffer_manager()); | 34 gpu_service_->gpu_memory_buffer_manager()); |
47 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 35 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
48 } | 36 } |
49 | 37 |
50 std::unique_ptr<ui::Reflector> SurfaceContextFactory::CreateReflector( | |
51 ui::Compositor* mirroed_compositor, | |
52 ui::Layer* mirroring_layer) { | |
53 // NOTIMPLEMENTED(); | |
54 return base::WrapUnique(new FakeReflector); | |
55 } | |
56 | |
57 void SurfaceContextFactory::RemoveReflector(ui::Reflector* reflector) { | |
58 // NOTIMPLEMENTED(); | |
59 } | |
60 | |
61 scoped_refptr<cc::ContextProvider> | 38 scoped_refptr<cc::ContextProvider> |
62 SurfaceContextFactory::SharedMainThreadContextProvider() { | 39 SurfaceContextFactory::SharedMainThreadContextProvider() { |
63 // NOTIMPLEMENTED(); | 40 // NOTIMPLEMENTED(); |
64 return nullptr; | 41 return nullptr; |
65 } | 42 } |
66 | 43 |
67 void SurfaceContextFactory::RemoveCompositor(ui::Compositor* compositor) { | 44 void SurfaceContextFactory::RemoveCompositor(ui::Compositor* compositor) { |
68 // NOTIMPLEMENTED(); | 45 // NOTIMPLEMENTED(); |
69 } | 46 } |
70 | 47 |
71 bool SurfaceContextFactory::DoesCreateTestContexts() { | 48 bool SurfaceContextFactory::DoesCreateTestContexts() { |
72 return false; | 49 return false; |
73 } | 50 } |
74 | 51 |
75 uint32_t SurfaceContextFactory::GetImageTextureTarget(gfx::BufferFormat format, | 52 uint32_t SurfaceContextFactory::GetImageTextureTarget(gfx::BufferFormat format, |
76 gfx::BufferUsage usage) { | 53 gfx::BufferUsage usage) { |
77 // No GpuMemoryBuffer support, so just return GL_TEXTURE_2D. | 54 // No GpuMemoryBuffer support, so just return GL_TEXTURE_2D. |
78 return GL_TEXTURE_2D; | 55 return GL_TEXTURE_2D; |
79 } | 56 } |
80 | 57 |
81 gpu::GpuMemoryBufferManager* | 58 gpu::GpuMemoryBufferManager* |
82 SurfaceContextFactory::GetGpuMemoryBufferManager() { | 59 SurfaceContextFactory::GetGpuMemoryBufferManager() { |
83 return gpu_service_->gpu_memory_buffer_manager(); | 60 return gpu_service_->gpu_memory_buffer_manager(); |
84 } | 61 } |
85 | 62 |
86 cc::TaskGraphRunner* SurfaceContextFactory::GetTaskGraphRunner() { | 63 cc::TaskGraphRunner* SurfaceContextFactory::GetTaskGraphRunner() { |
87 return raster_thread_helper_.task_graph_runner(); | 64 return raster_thread_helper_.task_graph_runner(); |
88 } | 65 } |
89 | 66 |
90 cc::FrameSinkId SurfaceContextFactory::AllocateFrameSinkId() { | |
91 return cc::FrameSinkId(0, next_sink_id_++); | |
92 } | |
93 | |
94 cc::SurfaceManager* SurfaceContextFactory::GetSurfaceManager() { | |
95 return &surface_manager_; | |
96 } | |
97 | |
98 void SurfaceContextFactory::SetDisplayVisible(ui::Compositor* compositor, | |
99 bool visible) { | |
100 // TODO(fsamuel): display[compositor]->SetVisible(visible); | |
101 } | |
102 | |
103 void SurfaceContextFactory::ResizeDisplay(ui::Compositor* compositor, | |
104 const gfx::Size& size) { | |
105 // TODO(fsamuel): display[compositor]->Resize(size); | |
106 } | |
107 | |
108 } // namespace views | 67 } // namespace views |
OLD | NEW |