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

Side by Side Diff: ui/views/mus/surface_context_factory.cc

Issue 2563783002: ui + mus: Split ContextFactory into ContextFactory(Client) and ContextFactoryPrivate (Closed)
Patch Set: Restore mash Created 4 years 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/views/mus/surface_context_factory.h ('k') | ui/views/test/scoped_views_test_helper.cc » ('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 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.h" 11 #include "services/ui/public/cpp/gpu/gpu.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 19
21 class FakeReflector : public ui::Reflector { 20 SurfaceContextFactory::SurfaceContextFactory(ui::Gpu* gpu) : gpu_(gpu) {}
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
32 SurfaceContextFactory::SurfaceContextFactory(ui::Gpu* gpu)
33 : next_sink_id_(1u), gpu_(gpu) {}
34 21
35 SurfaceContextFactory::~SurfaceContextFactory() {} 22 SurfaceContextFactory::~SurfaceContextFactory() {}
36 23
37 void SurfaceContextFactory::CreateCompositorFrameSink( 24 void SurfaceContextFactory::CreateCompositorFrameSink(
38 base::WeakPtr<ui::Compositor> compositor) { 25 base::WeakPtr<ui::Compositor> compositor) {
39 ui::Window* window = compositor->window(); 26 ui::Window* window = compositor->window();
40 NativeWidgetMus* native_widget = NativeWidgetMus::GetForWindow(window); 27 NativeWidgetMus* native_widget = NativeWidgetMus::GetForWindow(window);
41 ui::mojom::CompositorFrameSinkType compositor_frame_sink_type = 28 ui::mojom::CompositorFrameSinkType compositor_frame_sink_type =
42 native_widget->compositor_frame_sink_type(); 29 native_widget->compositor_frame_sink_type();
43 auto compositor_frame_sink = window->RequestCompositorFrameSink( 30 auto compositor_frame_sink = window->RequestCompositorFrameSink(
44 compositor_frame_sink_type, make_scoped_refptr(new ui::ContextProvider( 31 compositor_frame_sink_type, make_scoped_refptr(new ui::ContextProvider(
45 gpu_->EstablishGpuChannelSync())), 32 gpu_->EstablishGpuChannelSync())),
46 gpu_->gpu_memory_buffer_manager()); 33 gpu_->gpu_memory_buffer_manager());
47 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); 34 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink));
48 } 35 }
49 36
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> 37 scoped_refptr<cc::ContextProvider>
62 SurfaceContextFactory::SharedMainThreadContextProvider() { 38 SurfaceContextFactory::SharedMainThreadContextProvider() {
63 // NOTIMPLEMENTED(); 39 // NOTIMPLEMENTED();
64 return nullptr; 40 return nullptr;
65 } 41 }
66 42
67 void SurfaceContextFactory::RemoveCompositor(ui::Compositor* compositor) { 43 void SurfaceContextFactory::RemoveCompositor(ui::Compositor* compositor) {
68 // NOTIMPLEMENTED(); 44 // NOTIMPLEMENTED();
69 } 45 }
70 46
71 bool SurfaceContextFactory::DoesCreateTestContexts() { 47 bool SurfaceContextFactory::DoesCreateTestContexts() {
72 return false; 48 return false;
73 } 49 }
74 50
75 uint32_t SurfaceContextFactory::GetImageTextureTarget(gfx::BufferFormat format, 51 uint32_t SurfaceContextFactory::GetImageTextureTarget(gfx::BufferFormat format,
76 gfx::BufferUsage usage) { 52 gfx::BufferUsage usage) {
77 // No GpuMemoryBuffer support, so just return GL_TEXTURE_2D. 53 // No GpuMemoryBuffer support, so just return GL_TEXTURE_2D.
78 return GL_TEXTURE_2D; 54 return GL_TEXTURE_2D;
79 } 55 }
80 56
81 gpu::GpuMemoryBufferManager* 57 gpu::GpuMemoryBufferManager*
82 SurfaceContextFactory::GetGpuMemoryBufferManager() { 58 SurfaceContextFactory::GetGpuMemoryBufferManager() {
83 return gpu_->gpu_memory_buffer_manager(); 59 return gpu_->gpu_memory_buffer_manager();
84 } 60 }
85 61
86 cc::TaskGraphRunner* SurfaceContextFactory::GetTaskGraphRunner() { 62 cc::TaskGraphRunner* SurfaceContextFactory::GetTaskGraphRunner() {
87 return raster_thread_helper_.task_graph_runner(); 63 return raster_thread_helper_.task_graph_runner();
88 } 64 }
89 65
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 66 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/surface_context_factory.h ('k') | ui/views/test/scoped_views_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698