OLD | NEW |
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 "services/ui/ws/gpu_host.h" | 5 #include "services/ui/ws/gpu_host.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 class GpuClient : public mojom::Gpu { | 36 class GpuClient : public mojom::Gpu { |
37 public: | 37 public: |
38 GpuClient(int client_id, | 38 GpuClient(int client_id, |
39 gpu::GPUInfo* gpu_info, | 39 gpu::GPUInfo* gpu_info, |
40 ServerGpuMemoryBufferManager* gpu_memory_buffer_manager, | 40 ServerGpuMemoryBufferManager* gpu_memory_buffer_manager, |
41 mojom::GpuService* gpu_service) | 41 mojom::GpuService* gpu_service) |
42 : client_id_(client_id), | 42 : client_id_(client_id), |
43 gpu_info_(gpu_info), | 43 gpu_info_(gpu_info), |
44 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 44 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
45 gpu_service_(gpu_service) { | 45 gpu_service_(gpu_service) { |
| 46 LOG(ERROR) << "JR GpuClient device_id " << gpu_info->gpu.device_id << "\n"; |
46 DCHECK(gpu_memory_buffer_manager_); | 47 DCHECK(gpu_memory_buffer_manager_); |
47 DCHECK(gpu_service_); | 48 DCHECK(gpu_service_); |
48 } | 49 } |
49 ~GpuClient() override { | 50 ~GpuClient() override { |
| 51 LOG(ERROR) << "JR GpuClient death\n"; |
50 gpu_memory_buffer_manager_->DestroyAllGpuMemoryBufferForClient(client_id_); | 52 gpu_memory_buffer_manager_->DestroyAllGpuMemoryBufferForClient(client_id_); |
51 } | 53 } |
52 | 54 |
53 private: | 55 private: |
54 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, | 56 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, |
55 mojo::ScopedMessagePipeHandle channel_handle) { | 57 mojo::ScopedMessagePipeHandle channel_handle) { |
| 58 LOG(ERROR) << "JR OnGpuChannelEstablished device_id " |
| 59 << gpu_info_->gpu.device_id << "\n"; |
56 callback.Run(client_id_, std::move(channel_handle), *gpu_info_); | 60 callback.Run(client_id_, std::move(channel_handle), *gpu_info_); |
57 } | 61 } |
58 | 62 |
59 // mojom::Gpu overrides: | 63 // mojom::Gpu overrides: |
60 void EstablishGpuChannel( | 64 void EstablishGpuChannel( |
61 const EstablishGpuChannelCallback& callback) override { | 65 const EstablishGpuChannelCallback& callback) override { |
62 // TODO(sad): crbug.com/617415 figure out how to generate a meaningful | 66 // TODO(sad): crbug.com/617415 figure out how to generate a meaningful |
63 // tracing id. | 67 // tracing id. |
| 68 LOG(ERROR) << "JR GpuClient EstablishGpuChannel\n"; |
64 const uint64_t client_tracing_id = 0; | 69 const uint64_t client_tracing_id = 0; |
65 constexpr bool is_gpu_host = false; | 70 constexpr bool is_gpu_host = false; |
66 gpu_service_->EstablishGpuChannel( | 71 gpu_service_->EstablishGpuChannel( |
67 client_id_, client_tracing_id, is_gpu_host, | 72 client_id_, client_tracing_id, is_gpu_host, |
68 base::Bind(&GpuClient::OnGpuChannelEstablished, base::Unretained(this), | 73 base::Bind(&GpuClient::OnGpuChannelEstablished, base::Unretained(this), |
69 callback)); | 74 callback)); |
70 } | 75 } |
71 | 76 |
72 void CreateGpuMemoryBuffer( | 77 void CreateGpuMemoryBuffer( |
73 gfx::GpuMemoryBufferId id, | 78 gfx::GpuMemoryBufferId id, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // TODO(sad): Correctly initialize gpu::GpuPreferences (like it is initialized | 116 // TODO(sad): Correctly initialize gpu::GpuPreferences (like it is initialized |
112 // in GpuProcessHost::Init()). | 117 // in GpuProcessHost::Init()). |
113 gpu::GpuPreferences preferences; | 118 gpu::GpuPreferences preferences; |
114 gpu_main_->CreateGpuService(MakeRequest(&gpu_service_), | 119 gpu_main_->CreateGpuService(MakeRequest(&gpu_service_), |
115 gpu_host_binding_.CreateInterfacePtrAndBind(), | 120 gpu_host_binding_.CreateInterfacePtrAndBind(), |
116 preferences); | 121 preferences); |
117 gpu_memory_buffer_manager_ = base::MakeUnique<ServerGpuMemoryBufferManager>( | 122 gpu_memory_buffer_manager_ = base::MakeUnique<ServerGpuMemoryBufferManager>( |
118 gpu_service_.get(), next_client_id_++); | 123 gpu_service_.get(), next_client_id_++); |
119 } | 124 } |
120 | 125 |
121 GpuHost::~GpuHost() {} | 126 GpuHost::~GpuHost() { |
| 127 LOG(ERROR) << "JR GpuHost death\n"; |
| 128 } |
122 | 129 |
123 void GpuHost::Add(mojom::GpuRequest request) { | 130 mojom::Gpu* GpuHost::Add(mojom::GpuRequest request) { |
124 mojo::MakeStrongBinding( | 131 // gpu_bindings_.AddBinding( |
125 base::MakeUnique<GpuClient>(next_client_id_++, &gpu_info_, | 132 |
126 gpu_memory_buffer_manager_.get(), | 133 return mojo::MakeStrongBinding( |
127 gpu_service_.get()), | 134 base::MakeUnique<GpuClient>(next_client_id_++, &gpu_info_, |
128 std::move(request)); | 135 gpu_memory_buffer_manager_.get(), |
| 136 gpu_service_.get()), |
| 137 std::move(request)) |
| 138 ->impl(); |
129 } | 139 } |
130 | 140 |
131 void GpuHost::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) { | 141 void GpuHost::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) { |
132 #if defined(OS_WIN) | 142 #if defined(OS_WIN) |
133 gfx::RenderingWindowManager::GetInstance()->RegisterParent(widget); | 143 gfx::RenderingWindowManager::GetInstance()->RegisterParent(widget); |
134 #endif | 144 #endif |
135 } | 145 } |
136 | 146 |
137 void GpuHost::OnAcceleratedWidgetDestroyed(gfx::AcceleratedWidget widget) { | 147 void GpuHost::OnAcceleratedWidgetDestroyed(gfx::AcceleratedWidget widget) { |
138 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
139 gfx::RenderingWindowManager::GetInstance()->UnregisterParent(widget); | 149 gfx::RenderingWindowManager::GetInstance()->UnregisterParent(widget); |
140 #endif | 150 #endif |
141 } | 151 } |
142 | 152 |
143 void GpuHost::CreateDisplayCompositor( | 153 void GpuHost::CreateDisplayCompositor( |
144 cc::mojom::DisplayCompositorRequest request, | 154 cc::mojom::DisplayCompositorRequest request, |
145 cc::mojom::DisplayCompositorClientPtr client) { | 155 cc::mojom::DisplayCompositorClientPtr client) { |
146 gpu_main_->CreateDisplayCompositor(std::move(request), std::move(client)); | 156 gpu_main_->CreateDisplayCompositor(std::move(request), std::move(client)); |
147 } | 157 } |
148 | 158 |
149 void GpuHost::OnBadMessageFromGpu() { | 159 void GpuHost::OnBadMessageFromGpu() { |
150 // TODO(sad): Received some unexpected message from the gpu process. We | 160 // TODO(sad): Received some unexpected message from the gpu process. We |
151 // should kill the process and restart it. | 161 // should kill the process and restart it. |
152 NOTIMPLEMENTED(); | 162 NOTIMPLEMENTED(); |
153 } | 163 } |
154 | 164 |
155 void GpuHost::DidInitialize(const gpu::GPUInfo& gpu_info) { | 165 void GpuHost::DidInitialize(const gpu::GPUInfo& gpu_info) { |
| 166 LOG(ERROR) << "JR DidInitialize\n"; |
156 gpu_info_ = gpu_info; | 167 gpu_info_ = gpu_info; |
| 168 // CHECK(false); |
157 delegate_->OnGpuServiceInitialized(); | 169 delegate_->OnGpuServiceInitialized(); |
158 } | 170 } |
159 | 171 |
160 void GpuHost::DidCreateOffscreenContext(const GURL& url) {} | 172 void GpuHost::DidCreateOffscreenContext(const GURL& url) {} |
161 | 173 |
162 void GpuHost::DidDestroyOffscreenContext(const GURL& url) {} | 174 void GpuHost::DidDestroyOffscreenContext(const GURL& url) {} |
163 | 175 |
164 void GpuHost::DidDestroyChannel(int32_t client_id) {} | 176 void GpuHost::DidDestroyChannel(int32_t client_id) {} |
165 | 177 |
166 void GpuHost::DidLoseContext(bool offscreen, | 178 void GpuHost::DidLoseContext(bool offscreen, |
(...skipping 21 matching lines...) Expand all Loading... |
188 NOTREACHED(); | 200 NOTREACHED(); |
189 #endif | 201 #endif |
190 } | 202 } |
191 | 203 |
192 void GpuHost::StoreShaderToDisk(int32_t client_id, | 204 void GpuHost::StoreShaderToDisk(int32_t client_id, |
193 const std::string& key, | 205 const std::string& key, |
194 const std::string& shader) {} | 206 const std::string& shader) {} |
195 | 207 |
196 } // namespace ws | 208 } // namespace ws |
197 } // namespace ui | 209 } // namespace ui |
OLD | NEW |