OLD | NEW |
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 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 21 matching lines...) Expand all Loading... |
32 class MessageLoopProxy; | 32 class MessageLoopProxy; |
33 class WaitableEvent; | 33 class WaitableEvent; |
34 } | 34 } |
35 | 35 |
36 namespace gpu { | 36 namespace gpu { |
37 struct RefCountedCounter; | 37 struct RefCountedCounter; |
38 } | 38 } |
39 | 39 |
40 // Encapsulates an IPC channel between the GPU process and one renderer | 40 // Encapsulates an IPC channel between the GPU process and one renderer |
41 // process. On the renderer side there's a corresponding GpuChannelHost. | 41 // process. On the renderer side there's a corresponding GpuChannelHost. |
42 class GpuChannel : public IPC::Channel::Listener, | 42 class GpuChannel : public IPC::Listener, |
43 public IPC::Message::Sender, | 43 public IPC::Sender, |
44 public base::RefCountedThreadSafe<GpuChannel> { | 44 public base::RefCountedThreadSafe<GpuChannel> { |
45 public: | 45 public: |
46 // Takes ownership of the renderer process handle. | 46 // Takes ownership of the renderer process handle. |
47 GpuChannel(GpuChannelManager* gpu_channel_manager, | 47 GpuChannel(GpuChannelManager* gpu_channel_manager, |
48 GpuWatchdog* watchdog, | 48 GpuWatchdog* watchdog, |
49 gfx::GLShareGroup* share_group, | 49 gfx::GLShareGroup* share_group, |
50 gpu::gles2::MailboxManager* mailbox_manager, | 50 gpu::gles2::MailboxManager* mailbox_manager, |
51 int client_id, | 51 int client_id, |
52 bool software); | 52 bool software); |
53 | 53 |
54 bool Init(base::MessageLoopProxy* io_message_loop, | 54 bool Init(base::MessageLoopProxy* io_message_loop, |
55 base::WaitableEvent* shutdown_event); | 55 base::WaitableEvent* shutdown_event); |
56 | 56 |
57 // Get the GpuChannelManager that owns this channel. | 57 // Get the GpuChannelManager that owns this channel. |
58 GpuChannelManager* gpu_channel_manager() const { | 58 GpuChannelManager* gpu_channel_manager() const { |
59 return gpu_channel_manager_; | 59 return gpu_channel_manager_; |
60 } | 60 } |
61 | 61 |
62 // Returns the name of the associated IPC channel. | 62 // Returns the name of the associated IPC channel. |
63 std::string GetChannelName(); | 63 std::string GetChannelName(); |
64 | 64 |
65 #if defined(OS_POSIX) | 65 #if defined(OS_POSIX) |
66 int TakeRendererFileDescriptor(); | 66 int TakeRendererFileDescriptor(); |
67 #endif // defined(OS_POSIX) | 67 #endif // defined(OS_POSIX) |
68 | 68 |
69 base::ProcessId renderer_pid() const { return channel_->peer_pid(); } | 69 base::ProcessId renderer_pid() const { return channel_->peer_pid(); } |
70 | 70 |
71 // IPC::Channel::Listener implementation: | 71 // IPC::Listener implementation: |
72 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 72 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
73 virtual void OnChannelError() OVERRIDE; | 73 virtual void OnChannelError() OVERRIDE; |
74 | 74 |
75 // IPC::Message::Sender implementation: | 75 // IPC::Sender implementation: |
76 virtual bool Send(IPC::Message* msg) OVERRIDE; | 76 virtual bool Send(IPC::Message* msg) OVERRIDE; |
77 | 77 |
78 virtual void AppendAllCommandBufferStubs( | 78 virtual void AppendAllCommandBufferStubs( |
79 std::vector<GpuCommandBufferStubBase*>& stubs); | 79 std::vector<GpuCommandBufferStubBase*>& stubs); |
80 | 80 |
81 // This is called when a command buffer transitions from the unscheduled | 81 // This is called when a command buffer transitions from the unscheduled |
82 // state to the scheduled state, which potentially means the channel | 82 // state to the scheduled state, which potentially means the channel |
83 // transitions from the unscheduled to the scheduled state. When this occurs | 83 // transitions from the unscheduled to the scheduled state. When this occurs |
84 // deferred IPC messaged are handled. | 84 // deferred IPC messaged are handled. |
85 void OnScheduled(); | 85 void OnScheduled(); |
(...skipping 10 matching lines...) Expand all Loading... |
96 | 96 |
97 void LoseAllContexts(); | 97 void LoseAllContexts(); |
98 | 98 |
99 // Destroy channel and all contained contexts. | 99 // Destroy channel and all contained contexts. |
100 void DestroySoon(); | 100 void DestroySoon(); |
101 | 101 |
102 // Generate a route ID guaranteed to be unique for this channel. | 102 // Generate a route ID guaranteed to be unique for this channel. |
103 int GenerateRouteID(); | 103 int GenerateRouteID(); |
104 | 104 |
105 // Called to add/remove a listener for a particular message routing ID. | 105 // Called to add/remove a listener for a particular message routing ID. |
106 void AddRoute(int32 route_id, IPC::Channel::Listener* listener); | 106 void AddRoute(int32 route_id, IPC::Listener* listener); |
107 void RemoveRoute(int32 route_id); | 107 void RemoveRoute(int32 route_id); |
108 | 108 |
109 gpu::RefCountedCounter* MessagesPendingCount() { | 109 gpu::RefCountedCounter* MessagesPendingCount() { |
110 return unprocessed_messages_.get(); | 110 return unprocessed_messages_.get(); |
111 } | 111 } |
112 | 112 |
113 // If preempt_by_counter->count is non-zero, any stub on this channel | 113 // If preempt_by_counter->count is non-zero, any stub on this channel |
114 // should stop issuing GL commands. Setting this to NULL stops deferral. | 114 // should stop issuing GL commands. Setting this to NULL stops deferral. |
115 void SetPreemptByCounter( | 115 void SetPreemptByCounter( |
116 scoped_refptr<gpu::RefCountedCounter> preempt_by_counter); | 116 scoped_refptr<gpu::RefCountedCounter> preempt_by_counter); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 bool software_; | 179 bool software_; |
180 bool handle_messages_scheduled_; | 180 bool handle_messages_scheduled_; |
181 bool processed_get_state_fast_; | 181 bool processed_get_state_fast_; |
182 | 182 |
183 base::WeakPtrFactory<GpuChannel> weak_factory_; | 183 base::WeakPtrFactory<GpuChannel> weak_factory_; |
184 | 184 |
185 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 185 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
186 }; | 186 }; |
187 | 187 |
188 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 188 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
OLD | NEW |