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

Side by Side Diff: services/ui/gpu/gpu_service.cc

Issue 2801723002: GpuService: introduce GetGpuMemoryBufferAttribs as a mojo interface
Patch Set: GpuService: introduce GetGpuMemoryBufferAttribs as a mojo interface Created 3 years, 8 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
« no previous file with comments | « services/ui/gpu/gpu_service.h ('k') | services/ui/gpu/interfaces/gpu_service.mojom » ('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 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/gpu/gpu_service.h" 5 #include "services/ui/gpu/gpu_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const gpu::SyncToken& sync_token) { 234 const gpu::SyncToken& sync_token) {
235 if (io_runner_->BelongsToCurrentThread()) { 235 if (io_runner_->BelongsToCurrentThread()) {
236 main_runner_->PostTask( 236 main_runner_->PostTask(
237 FROM_HERE, base::Bind(&GpuService::DestroyGpuMemoryBuffer, weak_ptr_, 237 FROM_HERE, base::Bind(&GpuService::DestroyGpuMemoryBuffer, weak_ptr_,
238 id, client_id, sync_token)); 238 id, client_id, sync_token));
239 return; 239 return;
240 } 240 }
241 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token); 241 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
242 } 242 }
243 243
244 void GpuService::GetGpuMemoryBufferAttribs(
245 const GetGpuMemoryBufferAttribsCallback& callback) {
246 gfx::GpuMemoryBufferAttribVector supported_attribs;
247
248 for (int i = 0; i < static_cast<int>(gfx::BufferUsage::LAST); i++) {
249 gfx::GpuMemoryBufferAttribVector tmp =
250 gpu_memory_buffer_factory_->GetSupportedGpuMemoryBufferAttribsForUsage(
251 static_cast<gfx::BufferUsage>(i));
252 if (tmp.size() == 0)
253 continue;
254
255 gfx::GpuMemoryBufferAttribVector intersection;
256 std::sort(tmp.begin(), tmp.end());
257
258 if (supported_attribs.size() == 0)
259 supported_attribs = std::move(tmp);
260 else {
261 std::set_intersection(supported_attribs.begin(), supported_attribs.end(),
262 tmp.begin(), tmp.end(),
263 std::back_inserter(intersection));
264 supported_attribs = std::move(intersection);
265 }
266 }
267
268 callback.Run(supported_attribs);
sadrul 2017/04/19 21:40:23 Do we expect this list to change between requests?
varad 2017/04/21 13:01:32 Done.
269 }
270
244 void GpuService::GetVideoMemoryUsageStats( 271 void GpuService::GetVideoMemoryUsageStats(
245 const GetVideoMemoryUsageStatsCallback& callback) { 272 const GetVideoMemoryUsageStatsCallback& callback) {
246 if (io_runner_->BelongsToCurrentThread()) { 273 if (io_runner_->BelongsToCurrentThread()) {
247 auto wrap_callback = WrapCallback(io_runner_, callback); 274 auto wrap_callback = WrapCallback(io_runner_, callback);
248 main_runner_->PostTask( 275 main_runner_->PostTask(
249 FROM_HERE, base::Bind(&GpuService::GetVideoMemoryUsageStats, weak_ptr_, 276 FROM_HERE, base::Bind(&GpuService::GetVideoMemoryUsageStats, weak_ptr_,
250 wrap_callback)); 277 wrap_callback));
251 return; 278 return;
252 } 279 }
253 gpu::VideoMemoryUsageStats video_memory_usage_stats; 280 gpu::VideoMemoryUsageStats video_memory_usage_stats;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 525
499 void GpuService::Stop(const StopCallback& callback) { 526 void GpuService::Stop(const StopCallback& callback) {
500 DCHECK(io_runner_->BelongsToCurrentThread()); 527 DCHECK(io_runner_->BelongsToCurrentThread());
501 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] { 528 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] {
502 base::MessageLoop::current()->QuitWhenIdle(); 529 base::MessageLoop::current()->QuitWhenIdle();
503 }), 530 }),
504 callback); 531 callback);
505 } 532 }
506 533
507 } // namespace ui 534 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/gpu/gpu_service.h ('k') | services/ui/gpu/interfaces/gpu_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698