OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/command_buffer/service/in_process_command_buffer.h" | 5 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/message_loop/message_loop_proxy.h" | |
18 #include "base/sequence_checker.h" | 17 #include "base/sequence_checker.h" |
19 #include "base/synchronization/condition_variable.h" | 18 #include "base/synchronization/condition_variable.h" |
20 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 20 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
22 #include "gpu/command_buffer/common/value_state.h" | 21 #include "gpu/command_buffer/common/value_state.h" |
23 #include "gpu/command_buffer/service/command_buffer_service.h" | 22 #include "gpu/command_buffer/service/command_buffer_service.h" |
24 #include "gpu/command_buffer/service/context_group.h" | 23 #include "gpu/command_buffer/service/context_group.h" |
25 #include "gpu/command_buffer/service/gl_context_virtual.h" | 24 #include "gpu/command_buffer/service/gl_context_virtual.h" |
26 #include "gpu/command_buffer/service/gpu_scheduler.h" | 25 #include "gpu/command_buffer/service/gpu_scheduler.h" |
27 #include "gpu/command_buffer/service/gpu_switches.h" | 26 #include "gpu/command_buffer/service/gpu_switches.h" |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 return last_state_.error; | 948 return last_state_.error; |
950 } | 949 } |
951 | 950 |
952 bool InProcessCommandBuffer::Initialize() { | 951 bool InProcessCommandBuffer::Initialize() { |
953 NOTREACHED(); | 952 NOTREACHED(); |
954 return false; | 953 return false; |
955 } | 954 } |
956 | 955 |
957 namespace { | 956 namespace { |
958 | 957 |
959 void PostCallback(const scoped_refptr<base::MessageLoopProxy>& loop, | 958 void PostCallback( |
960 const base::Closure& callback) { | 959 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
961 // The loop.get() check is to support using InProcessCommandBuffer on a thread | 960 const base::Closure& callback) { |
961 // The task_runner.get() check is to support using InProcessCommandBuffer on a | |
962 // thread | |
viettrungluu
2016/01/28 21:32:46
nit: Join this line with the next.
| |
962 // without a message loop. | 963 // without a message loop. |
963 if (loop.get() && !loop->BelongsToCurrentThread()) { | 964 if (task_runner.get() && !task_runner->BelongsToCurrentThread()) { |
964 loop->PostTask(FROM_HERE, callback); | 965 task_runner->PostTask(FROM_HERE, callback); |
965 } else { | 966 } else { |
966 callback.Run(); | 967 callback.Run(); |
967 } | 968 } |
968 } | 969 } |
969 | 970 |
970 void RunOnTargetThread(scoped_ptr<base::Closure> callback) { | 971 void RunOnTargetThread(scoped_ptr<base::Closure> callback) { |
971 DCHECK(callback.get()); | 972 DCHECK(callback.get()); |
972 callback->Run(); | 973 callback->Run(); |
973 } | 974 } |
974 | 975 |
975 } // anonymous namespace | 976 } // anonymous namespace |
976 | 977 |
977 base::Closure InProcessCommandBuffer::WrapCallback( | 978 base::Closure InProcessCommandBuffer::WrapCallback( |
978 const base::Closure& callback) { | 979 const base::Closure& callback) { |
979 // Make sure the callback gets deleted on the target thread by passing | 980 // Make sure the callback gets deleted on the target thread by passing |
980 // ownership. | 981 // ownership. |
981 scoped_ptr<base::Closure> scoped_callback(new base::Closure(callback)); | 982 scoped_ptr<base::Closure> scoped_callback(new base::Closure(callback)); |
982 base::Closure callback_on_client_thread = | 983 base::Closure callback_on_client_thread = |
983 base::Bind(&RunOnTargetThread, base::Passed(&scoped_callback)); | 984 base::Bind(&RunOnTargetThread, base::Passed(&scoped_callback)); |
984 base::Closure wrapped_callback = | 985 base::Closure wrapped_callback = |
985 base::Bind(&PostCallback, base::MessageLoopProxy::current(), | 986 base::Bind(&PostCallback, base::MessageLoop::current()->task_runner(), |
986 callback_on_client_thread); | 987 callback_on_client_thread); |
987 return wrapped_callback; | 988 return wrapped_callback; |
988 } | 989 } |
989 | 990 |
990 #if defined(OS_ANDROID) | 991 #if defined(OS_ANDROID) |
991 scoped_refptr<gfx::SurfaceTexture> | 992 scoped_refptr<gfx::SurfaceTexture> |
992 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 993 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { |
993 DCHECK(stream_texture_manager_); | 994 DCHECK(stream_texture_manager_); |
994 return stream_texture_manager_->GetSurfaceTexture(stream_id); | 995 return stream_texture_manager_->GetSurfaceTexture(stream_id); |
995 } | 996 } |
996 #endif | 997 #endif |
997 | 998 |
998 } // namespace gpu | 999 } // namespace gpu |
OLD | NEW |