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_RENDERER_GPU_GPU_CHANNEL_HOST_H_ | 5 #ifndef CONTENT_RENDERER_GPU_GPU_CHANNEL_HOST_H_ |
6 #define CONTENT_RENDERER_GPU_GPU_CHANNEL_HOST_H_ | 6 #define CONTENT_RENDERER_GPU_GPU_CHANNEL_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/process_util.h" | 16 #include "base/process_util.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "content/common/gpu/gpu_info.h" | 18 #include "content/common/gpu/gpu_info.h" |
19 #include "content/common/message_router.h" | 19 #include "content/common/message_router.h" |
20 #include "content/renderer/gpu/gpu_video_decode_accelerator_host.h" | 20 #include "content/renderer/gpu/gpu_video_decode_accelerator_host.h" |
21 #include "ipc/ipc_channel_handle.h" | 21 #include "ipc/ipc_channel_handle.h" |
22 #include "ipc/ipc_channel_proxy.h" | 22 #include "ipc/ipc_channel_proxy.h" |
23 #include "ipc/ipc_sync_channel.h" | 23 #include "ipc/ipc_sync_channel.h" |
| 24 #include "ui/gfx/gl/gpu_preference.h" |
24 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
25 #include "ui/gfx/size.h" | 26 #include "ui/gfx/size.h" |
26 | 27 |
27 class CommandBufferProxy; | 28 class CommandBufferProxy; |
28 class GpuSurfaceProxy; | 29 class GpuSurfaceProxy; |
29 class GURL; | 30 class GURL; |
30 class TransportTextureService; | 31 class TransportTextureService; |
31 | 32 |
32 namespace base { | 33 namespace base { |
33 class MessageLoopProxy; | 34 class MessageLoopProxy; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 74 |
74 // IPC::Message::Sender implementation: | 75 // IPC::Message::Sender implementation: |
75 virtual bool Send(IPC::Message* msg); | 76 virtual bool Send(IPC::Message* msg); |
76 | 77 |
77 // Create and connect to a command buffer in the GPU process. | 78 // Create and connect to a command buffer in the GPU process. |
78 CommandBufferProxy* CreateViewCommandBuffer( | 79 CommandBufferProxy* CreateViewCommandBuffer( |
79 int render_view_id, | 80 int render_view_id, |
80 CommandBufferProxy* share_group, | 81 CommandBufferProxy* share_group, |
81 const std::string& allowed_extensions, | 82 const std::string& allowed_extensions, |
82 const std::vector<int32>& attribs, | 83 const std::vector<int32>& attribs, |
83 const GURL& active_url); | 84 const GURL& active_url, |
| 85 gfx::GpuPreference gpu_preference); |
84 | 86 |
85 // Create and connect to a command buffer in the GPU process. | 87 // Create and connect to a command buffer in the GPU process. |
86 CommandBufferProxy* CreateOffscreenCommandBuffer( | 88 CommandBufferProxy* CreateOffscreenCommandBuffer( |
87 const gfx::Size& size, | 89 const gfx::Size& size, |
88 CommandBufferProxy* share_group, | 90 CommandBufferProxy* share_group, |
89 const std::string& allowed_extensions, | 91 const std::string& allowed_extensions, |
90 const std::vector<int32>& attribs, | 92 const std::vector<int32>& attribs, |
91 const GURL& active_url); | 93 const GURL& active_url, |
| 94 gfx::GpuPreference gpu_preference); |
92 | 95 |
93 // Creates a video decoder in the GPU process. | 96 // Creates a video decoder in the GPU process. |
94 // Returned pointer is owned by the CommandBufferProxy for |route_id|. | 97 // Returned pointer is owned by the CommandBufferProxy for |route_id|. |
95 GpuVideoDecodeAcceleratorHost* CreateVideoDecoder( | 98 GpuVideoDecodeAcceleratorHost* CreateVideoDecoder( |
96 int command_buffer_route_id, | 99 int command_buffer_route_id, |
97 media::VideoDecodeAccelerator::Profile profile, | 100 media::VideoDecodeAccelerator::Profile profile, |
98 media::VideoDecodeAccelerator::Client* client); | 101 media::VideoDecodeAccelerator::Client* client); |
99 | 102 |
100 // Destroy a command buffer created by this channel. | 103 // Destroy a command buffer created by this channel. |
101 void DestroyCommandBuffer(CommandBufferProxy* command_buffer); | 104 void DestroyCommandBuffer(CommandBufferProxy* command_buffer); |
102 | 105 |
103 TransportTextureService* transport_texture_service() { | 106 TransportTextureService* transport_texture_service() { |
104 return transport_texture_service_.get(); | 107 return transport_texture_service_.get(); |
105 } | 108 } |
106 | 109 |
107 // Add a route for the current message loop. | 110 // Add a route for the current message loop. |
108 void AddRoute(int route_id, base::WeakPtr<IPC::Channel::Listener> listener); | 111 void AddRoute(int route_id, base::WeakPtr<IPC::Channel::Listener> listener); |
109 void RemoveRoute(int route_id); | 112 void RemoveRoute(int route_id); |
110 | 113 |
| 114 // Asks the GPU process whether the creation or destruction of the |
| 115 // given command buffer on the given GPU will provoke a switch of |
| 116 // the GPU from integrated to discrete or vice versa. This requires |
| 117 // all of the GL contexts in the same share group in the GPU process |
| 118 // to be dropped. |
| 119 bool WillGpuSwitchOccur(bool is_creating_context, |
| 120 gfx::GpuPreference gpu_preference); |
| 121 |
| 122 // Forcibly close the channel on the GPU process side. This will |
| 123 // cause all command buffers on this side to soon afterward start |
| 124 // registering lost contexts. It also has the side effect of setting |
| 125 // the state on this side to lost. |
| 126 void ForciblyCloseChannel(); |
| 127 |
111 private: | 128 private: |
112 // An shim class for working with listeners between threads. | 129 // An shim class for working with listeners between threads. |
113 // It is used to post a task to the thread that owns the listener, | 130 // It is used to post a task to the thread that owns the listener, |
114 // and where it's safe to dereference the weak pointer. | 131 // and where it's safe to dereference the weak pointer. |
115 class Listener : | 132 class Listener : |
116 public base::RefCountedThreadSafe<Listener> { | 133 public base::RefCountedThreadSafe<Listener> { |
117 public: | 134 public: |
118 Listener(base::WeakPtr<IPC::Channel::Listener> listener, | 135 Listener(base::WeakPtr<IPC::Channel::Listener> listener, |
119 scoped_refptr<base::MessageLoopProxy> loop); | 136 scoped_refptr<base::MessageLoopProxy> loop); |
120 virtual ~Listener(); | 137 virtual ~Listener(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // textures. These messages are routed to TransportTextureHost. | 189 // textures. These messages are routed to TransportTextureHost. |
173 scoped_refptr<TransportTextureService> transport_texture_service_; | 190 scoped_refptr<TransportTextureService> transport_texture_service_; |
174 | 191 |
175 // A filter for sending messages from thread other than the main thread. | 192 // A filter for sending messages from thread other than the main thread. |
176 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; | 193 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; |
177 | 194 |
178 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 195 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
179 }; | 196 }; |
180 | 197 |
181 #endif // CONTENT_RENDERER_GPU_GPU_CHANNEL_HOST_H_ | 198 #endif // CONTENT_RENDERER_GPU_GPU_CHANNEL_HOST_H_ |
OLD | NEW |