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

Side by Side Diff: gpu/ipc/service/gpu_channel.cc

Issue 2372593003: Iterative cleanup for GL programs in GPU process (Closed)
Patch Set: fix build Created 4 years, 2 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 | « gpu/ipc/service/gpu_channel.h ('k') | gpu/ipc/service/gpu_channel_manager.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "gpu/ipc/service/gpu_channel.h" 5 #include "gpu/ipc/service/gpu_channel.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 16 matching lines...) Expand all
27 #include "base/threading/thread_task_runner_handle.h" 27 #include "base/threading/thread_task_runner_handle.h"
28 #include "base/timer/timer.h" 28 #include "base/timer/timer.h"
29 #include "base/trace_event/memory_dump_manager.h" 29 #include "base/trace_event/memory_dump_manager.h"
30 #include "base/trace_event/process_memory_dump.h" 30 #include "base/trace_event/process_memory_dump.h"
31 #include "base/trace_event/trace_event.h" 31 #include "base/trace_event/trace_event.h"
32 #include "build/build_config.h" 32 #include "build/build_config.h"
33 #include "gpu/command_buffer/common/mailbox.h" 33 #include "gpu/command_buffer/common/mailbox.h"
34 #include "gpu/command_buffer/service/command_executor.h" 34 #include "gpu/command_buffer/service/command_executor.h"
35 #include "gpu/command_buffer/service/image_factory.h" 35 #include "gpu/command_buffer/service/image_factory.h"
36 #include "gpu/command_buffer/service/mailbox_manager.h" 36 #include "gpu/command_buffer/service/mailbox_manager.h"
37 #include "gpu/command_buffer/service/program_manager.h"
37 #include "gpu/command_buffer/service/sync_point_manager.h" 38 #include "gpu/command_buffer/service/sync_point_manager.h"
38 #include "gpu/ipc/common/gpu_messages.h" 39 #include "gpu/ipc/common/gpu_messages.h"
39 #include "gpu/ipc/service/gpu_channel_manager.h" 40 #include "gpu/ipc/service/gpu_channel_manager.h"
40 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" 41 #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
41 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" 42 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
42 #include "ipc/ipc_channel.h" 43 #include "ipc/ipc_channel.h"
43 #include "ipc/message_filter.h" 44 #include "ipc/message_filter.h"
44 #include "ui/gl/gl_context.h" 45 #include "ui/gl/gl_context.h"
45 #include "ui/gl/gl_image_shared_memory.h" 46 #include "ui/gl/gl_image_shared_memory.h"
46 #include "ui/gl/gl_surface.h" 47 #include "ui/gl/gl_surface.h"
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 return nullptr; 1062 return nullptr;
1062 1063
1063 return manager->gpu_memory_buffer_factory() 1064 return manager->gpu_memory_buffer_factory()
1064 ->AsImageFactory() 1065 ->AsImageFactory()
1065 ->CreateImageForGpuMemoryBuffer(handle, size, format, internalformat, 1066 ->CreateImageForGpuMemoryBuffer(handle, size, format, internalformat,
1066 client_id_, surface_handle); 1067 client_id_, surface_handle);
1067 } 1068 }
1068 } 1069 }
1069 } 1070 }
1070 1071
1072 GpuChannelDeleter::GpuChannelDeleter(std::unique_ptr<GpuChannel> channel)
1073 : channel_(std::move(channel)) {
1074 for (const auto& stub : channel_->stubs_) {
1075 pending_stubs_.push(stub.second);
1076 }
1077 }
1078
1079 GpuChannelDeleter::~GpuChannelDeleter() = default;
1080
1081 bool GpuChannelDeleter::DeleteWithTimeout(const base::TimeTicks& timeout) {
1082 for (; pending_stubs_.size() > 0; pending_stubs_.pop()) {
1083 auto* decoder = pending_stubs_.front()->decoder();
1084 auto* surface = pending_stubs_.front()->surface();
1085
1086 if (!decoder) {
1087 continue;
1088 }
1089
1090 bool have_context = false;
1091 if (decoder->GetGLContext()) {
1092 // Try to make the context current regardless of whether it was lost, so
1093 // we don't leak resources.
1094 have_context = decoder->GetGLContext()->MakeCurrent(surface);
1095 }
1096
1097 auto* program_manager = decoder->GetContextGroup()->program_manager();
1098 if (!program_manager->PreDestroyWithTimeout(have_context, timeout)) {
1099 // If PreDestroyWithTimeout returns false, the timeout was reached
1100 // before deletion completed. We should also return false.
1101 return false;
1102 }
1103 }
1104
1105 return true;
1106 }
1107
1071 } // namespace gpu 1108 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/gpu_channel.h ('k') | gpu/ipc/service/gpu_channel_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698