Chromium Code Reviews| 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 bool ShouldPreferDiscreteGpu() const; | |
|
stuartmorgan
2011/10/12 07:13:24
Method-level comment?
Ken Russell (switch to Gerrit)
2011/10/12 22:39:42
Added.
| |
| 122 | |
| 120 private: | 123 private: |
| 121 void OnDestroy(); | 124 void OnDestroy(); |
| 122 | 125 |
| 123 bool OnControlMessageReceived(const IPC::Message& msg); | 126 bool OnControlMessageReceived(const IPC::Message& msg); |
| 124 | 127 |
| 125 void HandleMessage(); | 128 void HandleMessage(); |
| 126 | 129 |
| 127 // Message handlers. | 130 // Message handlers. |
| 128 void OnInitialize(base::ProcessHandle renderer_process); | 131 void OnInitialize(base::ProcessHandle renderer_process); |
| 129 void OnCreateOffscreenCommandBuffer( | 132 void OnCreateOffscreenCommandBuffer( |
| 130 const gfx::Size& size, | 133 const gfx::Size& size, |
| 131 const GPUCreateCommandBufferConfig& init_params, | 134 const GPUCreateCommandBufferConfig& init_params, |
| 132 IPC::Message* reply_message); | 135 IPC::Message* reply_message); |
| 133 void OnDestroyCommandBuffer(int32 route_id, IPC::Message* reply_message); | 136 void OnDestroyCommandBuffer(int32 route_id, IPC::Message* reply_message); |
| 134 | 137 |
| 135 void OnCreateTransportTexture(int32 context_route_id, int32 host_id); | 138 void OnCreateTransportTexture(int32 context_route_id, int32 host_id); |
| 136 | 139 |
| 137 void OnEcho(const IPC::Message& message); | 140 void OnEcho(const IPC::Message& message); |
| 138 | 141 |
| 142 void OnWillGpuSwitchOccur(bool is_creating_context, | |
| 143 gfx::GpuPreference gpu_preference, | |
| 144 IPC::Message* reply_message); | |
| 145 void OnCloseChannel(); | |
| 146 | |
| 147 void WillCreateCommandBuffer(gfx::GpuPreference gpu_preference); | |
| 148 void DidDestroyCommandBuffer(gfx::GpuPreference gpu_preference); | |
| 149 | |
| 139 // The lifetime of objects of this class is managed by a GpuChannelManager. | 150 // The lifetime of objects of this class is managed by a GpuChannelManager. |
| 140 // The GpuChannelManager destroy all the GpuChannels that they own when they | 151 // The GpuChannelManager destroy all the GpuChannels that they own when they |
| 141 // are destroyed. So a raw pointer is safe. | 152 // are destroyed. So a raw pointer is safe. |
| 142 GpuChannelManager* gpu_channel_manager_; | 153 GpuChannelManager* gpu_channel_manager_; |
| 143 | 154 |
| 144 scoped_ptr<IPC::SyncChannel> channel_; | 155 scoped_ptr<IPC::SyncChannel> channel_; |
| 145 | 156 |
| 146 std::deque<IPC::Message*> deferred_messages_; | 157 std::deque<IPC::Message*> deferred_messages_; |
| 147 | 158 |
| 148 // The id of the renderer who is on the other side of the channel. | 159 // The id of the renderer who is on the other side of the channel. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 168 | 179 |
| 169 // A collection of transport textures created. | 180 // A collection of transport textures created. |
| 170 typedef IDMap<TransportTexture, IDMapOwnPointer> TransportTextureMap; | 181 typedef IDMap<TransportTexture, IDMapOwnPointer> TransportTextureMap; |
| 171 TransportTextureMap transport_textures_; | 182 TransportTextureMap transport_textures_; |
| 172 | 183 |
| 173 bool log_messages_; // True if we should log sent and received messages. | 184 bool log_messages_; // True if we should log sent and received messages. |
| 174 gpu::gles2::DisallowedFeatures disallowed_features_; | 185 gpu::gles2::DisallowedFeatures disallowed_features_; |
| 175 GpuWatchdog* watchdog_; | 186 GpuWatchdog* watchdog_; |
| 176 bool software_; | 187 bool software_; |
| 177 bool handle_messages_scheduled_; | 188 bool handle_messages_scheduled_; |
| 189 int32 num_contexts_preferring_discrete_gpu_; | |
| 178 | 190 |
| 179 ScopedRunnableMethodFactory<GpuChannel> task_factory_; | 191 ScopedRunnableMethodFactory<GpuChannel> task_factory_; |
| 180 | 192 |
| 181 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 193 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
| 182 }; | 194 }; |
| 183 | 195 |
| 184 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 196 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| OLD | NEW |