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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return gpu_channel_manager_; | 55 return gpu_channel_manager_; |
56 } | 56 } |
57 | 57 |
58 // Returns the name of the associated IPC channel. | 58 // Returns the name of the associated IPC channel. |
59 std::string GetChannelName(); | 59 std::string GetChannelName(); |
60 | 60 |
61 #if defined(OS_POSIX) | 61 #if defined(OS_POSIX) |
62 int TakeRendererFileDescriptor(); | 62 int TakeRendererFileDescriptor(); |
63 #endif // defined(OS_POSIX) | 63 #endif // defined(OS_POSIX) |
64 | 64 |
65 base::ProcessId renderer_pid() const { return channel_->peer_pid(); } | 65 base::ProcessHandle renderer_process() const { |
| 66 return renderer_process_; |
| 67 } |
66 | 68 |
67 // IPC::Channel::Listener implementation: | 69 // IPC::Channel::Listener implementation: |
68 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 70 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
69 virtual void OnChannelError() OVERRIDE; | 71 virtual void OnChannelError() OVERRIDE; |
| 72 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
70 | 73 |
71 // IPC::Message::Sender implementation: | 74 // IPC::Message::Sender implementation: |
72 virtual bool Send(IPC::Message* msg) OVERRIDE; | 75 virtual bool Send(IPC::Message* msg) OVERRIDE; |
73 | 76 |
74 virtual void AppendAllCommandBufferStubs( | 77 virtual void AppendAllCommandBufferStubs( |
75 std::vector<GpuCommandBufferStubBase*>& stubs); | 78 std::vector<GpuCommandBufferStubBase*>& stubs); |
76 | 79 |
77 // This is called when a command buffer transitions from the unscheduled | 80 // This is called when a command buffer transitions from the unscheduled |
78 // state to the scheduled state, which potentially means the channel | 81 // state to the scheduled state, which potentially means the channel |
79 // transitions from the unscheduled to the scheduled state. When this occurs | 82 // transitions from the unscheduled to the scheduled state. When this occurs |
(...skipping 29 matching lines...) Expand all Loading... |
109 private: | 112 private: |
110 void OnDestroy(); | 113 void OnDestroy(); |
111 | 114 |
112 bool OnControlMessageReceived(const IPC::Message& msg); | 115 bool OnControlMessageReceived(const IPC::Message& msg); |
113 | 116 |
114 void HandleMessage(); | 117 void HandleMessage(); |
115 void PollWork(int route_id); | 118 void PollWork(int route_id); |
116 void ScheduleDelayedWork(GpuCommandBufferStub *stub, int64 delay); | 119 void ScheduleDelayedWork(GpuCommandBufferStub *stub, int64 delay); |
117 | 120 |
118 // Message handlers. | 121 // Message handlers. |
| 122 void OnInitialize(base::ProcessHandle renderer_process); |
119 void OnCreateOffscreenCommandBuffer( | 123 void OnCreateOffscreenCommandBuffer( |
120 const gfx::Size& size, | 124 const gfx::Size& size, |
121 const GPUCreateCommandBufferConfig& init_params, | 125 const GPUCreateCommandBufferConfig& init_params, |
122 IPC::Message* reply_message); | 126 IPC::Message* reply_message); |
123 void OnDestroyCommandBuffer(int32 route_id, IPC::Message* reply_message); | 127 void OnDestroyCommandBuffer(int32 route_id, IPC::Message* reply_message); |
124 | 128 |
125 void OnWillGpuSwitchOccur(bool is_creating_context, | 129 void OnWillGpuSwitchOccur(bool is_creating_context, |
126 gfx::GpuPreference gpu_preference, | 130 gfx::GpuPreference gpu_preference, |
127 IPC::Message* reply_message); | 131 IPC::Message* reply_message); |
128 void OnCloseChannel(); | 132 void OnCloseChannel(); |
129 | 133 |
130 void WillCreateCommandBuffer(gfx::GpuPreference gpu_preference); | 134 void WillCreateCommandBuffer(gfx::GpuPreference gpu_preference); |
131 void DidDestroyCommandBuffer(gfx::GpuPreference gpu_preference); | 135 void DidDestroyCommandBuffer(gfx::GpuPreference gpu_preference); |
132 | 136 |
133 // The lifetime of objects of this class is managed by a GpuChannelManager. | 137 // The lifetime of objects of this class is managed by a GpuChannelManager. |
134 // The GpuChannelManager destroy all the GpuChannels that they own when they | 138 // The GpuChannelManager destroy all the GpuChannels that they own when they |
135 // are destroyed. So a raw pointer is safe. | 139 // are destroyed. So a raw pointer is safe. |
136 GpuChannelManager* gpu_channel_manager_; | 140 GpuChannelManager* gpu_channel_manager_; |
137 | 141 |
138 scoped_ptr<IPC::SyncChannel> channel_; | 142 scoped_ptr<IPC::SyncChannel> channel_; |
139 | 143 |
140 std::deque<IPC::Message*> deferred_messages_; | 144 std::deque<IPC::Message*> deferred_messages_; |
141 | 145 |
142 // The id of the client who is on the other side of the channel. | 146 // The id of the client who is on the other side of the channel. |
143 int client_id_; | 147 int client_id_; |
144 | 148 |
145 // Uniquely identifies the channel within this GPU process. | 149 // Uniquely identifies the channel within this GPU process. |
146 std::string channel_id_; | 150 std::string channel_id_; |
147 | 151 |
| 152 // Handle to the renderer process that is on the other side of the channel. |
| 153 base::ProcessHandle renderer_process_; |
| 154 |
| 155 // The process id of the renderer process. |
| 156 base::ProcessId renderer_pid_; |
| 157 |
148 // Used to implement message routing functionality to CommandBuffer objects | 158 // Used to implement message routing functionality to CommandBuffer objects |
149 MessageRouter router_; | 159 MessageRouter router_; |
150 | 160 |
151 // The share group that all contexts associated with a particular renderer | 161 // The share group that all contexts associated with a particular renderer |
152 // process use. | 162 // process use. |
153 scoped_refptr<gfx::GLShareGroup> share_group_; | 163 scoped_refptr<gfx::GLShareGroup> share_group_; |
154 | 164 |
155 #if defined(ENABLE_GPU) | 165 #if defined(ENABLE_GPU) |
156 typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap; | 166 typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap; |
157 StubMap stubs_; | 167 StubMap stubs_; |
158 #endif // defined (ENABLE_GPU) | 168 #endif // defined (ENABLE_GPU) |
159 | 169 |
160 bool log_messages_; // True if we should log sent and received messages. | 170 bool log_messages_; // True if we should log sent and received messages. |
161 gpu::gles2::DisallowedFeatures disallowed_features_; | 171 gpu::gles2::DisallowedFeatures disallowed_features_; |
162 GpuWatchdog* watchdog_; | 172 GpuWatchdog* watchdog_; |
163 bool software_; | 173 bool software_; |
164 bool handle_messages_scheduled_; | 174 bool handle_messages_scheduled_; |
165 bool processed_get_state_fast_; | 175 bool processed_get_state_fast_; |
166 int32 num_contexts_preferring_discrete_gpu_; | 176 int32 num_contexts_preferring_discrete_gpu_; |
167 | 177 |
168 base::WeakPtrFactory<GpuChannel> weak_factory_; | 178 base::WeakPtrFactory<GpuChannel> weak_factory_; |
169 | 179 |
170 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 180 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
171 }; | 181 }; |
172 | 182 |
173 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 183 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
OLD | NEW |