OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/id_map.h" | 14 #include "base/id_map.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/process.h" | 17 #include "base/process.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "content/common/gpu/gpu_command_buffer_stub.h" | 19 #include "content/common/gpu/gpu_command_buffer_stub.h" |
20 #include "content/common/message_router.h" | 20 #include "content/common/message_router.h" |
21 #include "ipc/ipc_sync_channel.h" | 21 #include "ipc/ipc_sync_channel.h" |
22 #include "ui/gfx/gl/gl_share_group.h" | 22 #include "ui/gfx/gl/gl_share_group.h" |
| 23 #include "ui/gfx/gl/gpu_preference.h" |
23 #include "ui/gfx/native_widget_types.h" | 24 #include "ui/gfx/native_widget_types.h" |
24 #include "ui/gfx/size.h" | 25 #include "ui/gfx/size.h" |
25 | 26 |
26 class GpuChannelManager; | 27 class GpuChannelManager; |
27 struct GPUCreateCommandBufferConfig; | 28 struct GPUCreateCommandBufferConfig; |
28 class GpuWatchdog; | 29 class GpuWatchdog; |
29 class TransportTexture; | 30 class TransportTexture; |
30 | 31 |
31 namespace base { | 32 namespace base { |
32 class MessageLoopProxy; | 33 class MessageLoopProxy; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // TransportTexture to delete and detach itself. | 111 // TransportTexture to delete and detach itself. |
111 void DestroyTransportTexture(int32 route_id); | 112 void DestroyTransportTexture(int32 route_id); |
112 | 113 |
113 // Generate a route ID guaranteed to be unique for this channel. | 114 // Generate a route ID guaranteed to be unique for this channel. |
114 int GenerateRouteID(); | 115 int GenerateRouteID(); |
115 | 116 |
116 // Called to add/remove a listener for a particular message routing ID. | 117 // Called to add/remove a listener for a particular message routing ID. |
117 void AddRoute(int32 route_id, IPC::Channel::Listener* listener); | 118 void AddRoute(int32 route_id, IPC::Channel::Listener* listener); |
118 void RemoveRoute(int32 route_id); | 119 void RemoveRoute(int32 route_id); |
119 | 120 |
| 121 // Indicates whether newly created contexts should prefer the |
| 122 // discrete GPU even if they would otherwise use the integrated GPU. |
| 123 bool ShouldPreferDiscreteGpu() const; |
| 124 |
120 private: | 125 private: |
121 void OnDestroy(); | 126 void OnDestroy(); |
122 | 127 |
123 bool OnControlMessageReceived(const IPC::Message& msg); | 128 bool OnControlMessageReceived(const IPC::Message& msg); |
124 | 129 |
125 void HandleMessage(); | 130 void HandleMessage(); |
126 | 131 |
127 // Message handlers. | 132 // Message handlers. |
128 void OnInitialize(base::ProcessHandle renderer_process); | 133 void OnInitialize(base::ProcessHandle renderer_process); |
129 void OnCreateOffscreenCommandBuffer( | 134 void OnCreateOffscreenCommandBuffer( |
130 const gfx::Size& size, | 135 const gfx::Size& size, |
131 const GPUCreateCommandBufferConfig& init_params, | 136 const GPUCreateCommandBufferConfig& init_params, |
132 IPC::Message* reply_message); | 137 IPC::Message* reply_message); |
133 void OnDestroyCommandBuffer(int32 route_id, IPC::Message* reply_message); | 138 void OnDestroyCommandBuffer(int32 route_id, IPC::Message* reply_message); |
134 | 139 |
135 void OnCreateTransportTexture(int32 context_route_id, int32 host_id); | 140 void OnCreateTransportTexture(int32 context_route_id, int32 host_id); |
136 | 141 |
137 void OnEcho(const IPC::Message& message); | 142 void OnEcho(const IPC::Message& message); |
138 | 143 |
| 144 void OnWillGpuSwitchOccur(bool is_creating_context, |
| 145 gfx::GpuPreference gpu_preference, |
| 146 IPC::Message* reply_message); |
| 147 void OnCloseChannel(); |
| 148 |
| 149 void WillCreateCommandBuffer(gfx::GpuPreference gpu_preference); |
| 150 void DidDestroyCommandBuffer(gfx::GpuPreference gpu_preference); |
| 151 |
139 // The lifetime of objects of this class is managed by a GpuChannelManager. | 152 // The lifetime of objects of this class is managed by a GpuChannelManager. |
140 // The GpuChannelManager destroy all the GpuChannels that they own when they | 153 // The GpuChannelManager destroy all the GpuChannels that they own when they |
141 // are destroyed. So a raw pointer is safe. | 154 // are destroyed. So a raw pointer is safe. |
142 GpuChannelManager* gpu_channel_manager_; | 155 GpuChannelManager* gpu_channel_manager_; |
143 | 156 |
144 scoped_ptr<IPC::SyncChannel> channel_; | 157 scoped_ptr<IPC::SyncChannel> channel_; |
145 | 158 |
146 std::deque<IPC::Message*> deferred_messages_; | 159 std::deque<IPC::Message*> deferred_messages_; |
147 | 160 |
148 // The id of the renderer who is on the other side of the channel. | 161 // The id of the renderer who is on the other side of the channel. |
(...skipping 19 matching lines...) Expand all Loading... |
168 | 181 |
169 // A collection of transport textures created. | 182 // A collection of transport textures created. |
170 typedef IDMap<TransportTexture, IDMapOwnPointer> TransportTextureMap; | 183 typedef IDMap<TransportTexture, IDMapOwnPointer> TransportTextureMap; |
171 TransportTextureMap transport_textures_; | 184 TransportTextureMap transport_textures_; |
172 | 185 |
173 bool log_messages_; // True if we should log sent and received messages. | 186 bool log_messages_; // True if we should log sent and received messages. |
174 gpu::gles2::DisallowedFeatures disallowed_features_; | 187 gpu::gles2::DisallowedFeatures disallowed_features_; |
175 GpuWatchdog* watchdog_; | 188 GpuWatchdog* watchdog_; |
176 bool software_; | 189 bool software_; |
177 bool handle_messages_scheduled_; | 190 bool handle_messages_scheduled_; |
| 191 int32 num_contexts_preferring_discrete_gpu_; |
178 | 192 |
179 ScopedRunnableMethodFactory<GpuChannel> task_factory_; | 193 ScopedRunnableMethodFactory<GpuChannel> task_factory_; |
180 | 194 |
181 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 195 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
182 }; | 196 }; |
183 | 197 |
184 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 198 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
OLD | NEW |