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_COMMAND_BUFFER_PROXY_H_ | 5 #ifndef CONTENT_RENDERER_GPU_COMMAND_BUFFER_PROXY_H_ |
6 #define CONTENT_RENDERER_GPU_COMMAND_BUFFER_PROXY_H_ | 6 #define CONTENT_RENDERER_GPU_COMMAND_BUFFER_PROXY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #if defined(ENABLE_GPU) | 9 #if defined(ENABLE_GPU) |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <queue> | 12 #include <queue> |
13 | 13 |
14 #include "base/callback_old.h" | 14 #include "base/callback_old.h" |
15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "content/renderer/gpu/gpu_video_decode_accelerator_host.h" | 17 #include "content/renderer/gpu/gpu_video_decode_accelerator_host.h" |
18 #include "gpu/command_buffer/common/command_buffer.h" | 18 #include "gpu/command_buffer/common/command_buffer.h" |
19 #include "ipc/ipc_channel.h" | 19 #include "ipc/ipc_channel.h" |
20 #include "ipc/ipc_message.h" | 20 #include "ipc/ipc_message.h" |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class SharedMemory; | 23 class SharedMemory; |
24 } | 24 } |
25 | 25 |
26 namespace gfx { | 26 namespace gfx { |
27 class Size; | 27 class Size; |
28 } | 28 } |
29 | 29 |
| 30 class GpuChannelHost; |
30 class PluginChannelHost; | 31 class PluginChannelHost; |
31 class Task; | 32 class Task; |
32 | 33 |
33 // Client side proxy that forwards messages synchronously to a | 34 // Client side proxy that forwards messages synchronously to a |
34 // CommandBufferStub. | 35 // CommandBufferStub. |
35 class CommandBufferProxy : public gpu::CommandBuffer, | 36 class CommandBufferProxy : public gpu::CommandBuffer, |
36 public IPC::Channel::Listener { | 37 public IPC::Channel::Listener { |
37 public: | 38 public: |
38 CommandBufferProxy(IPC::Channel::Sender* channel, int route_id); | 39 CommandBufferProxy(GpuChannelHost* channel, int route_id); |
39 virtual ~CommandBufferProxy(); | 40 virtual ~CommandBufferProxy(); |
40 | 41 |
41 // IPC::Channel::Listener implementation: | 42 // IPC::Channel::Listener implementation: |
42 virtual bool OnMessageReceived(const IPC::Message& message); | 43 virtual bool OnMessageReceived(const IPC::Message& message); |
43 virtual void OnChannelError(); | 44 virtual void OnChannelError(); |
44 | 45 |
45 int route_id() const { return route_id_; } | 46 int route_id() const { return route_id_; } |
46 | 47 |
47 // CommandBuffer implementation: | 48 // CommandBuffer implementation: |
48 virtual bool Initialize(int32 size); | 49 virtual bool Initialize(int32 size); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 void OnDestroyed(gpu::error::ContextLostReason reason); | 111 void OnDestroyed(gpu::error::ContextLostReason reason); |
111 | 112 |
112 // As with the service, the client takes ownership of the ring buffer. | 113 // As with the service, the client takes ownership of the ring buffer. |
113 int32 num_entries_; | 114 int32 num_entries_; |
114 scoped_ptr<base::SharedMemory> ring_buffer_; | 115 scoped_ptr<base::SharedMemory> ring_buffer_; |
115 | 116 |
116 // Local cache of id to transfer buffer mapping. | 117 // Local cache of id to transfer buffer mapping. |
117 typedef std::map<int32, gpu::Buffer> TransferBufferMap; | 118 typedef std::map<int32, gpu::Buffer> TransferBufferMap; |
118 TransferBufferMap transfer_buffers_; | 119 TransferBufferMap transfer_buffers_; |
119 | 120 |
120 // The video decoder host corresponding to the stub's video decoder in the GPU | 121 // Zero or more video decoder hosts owned by this proxy, keyed by their |
121 // process, if one exists. | 122 // decoder_route_id. |
122 scoped_refptr<GpuVideoDecodeAcceleratorHost> video_decoder_host_; | 123 typedef std::map<int, scoped_refptr<GpuVideoDecodeAcceleratorHost> > Decoders; |
| 124 Decoders video_decoder_hosts_; |
123 | 125 |
124 // The last cached state received from the service. | 126 // The last cached state received from the service. |
125 State last_state_; | 127 State last_state_; |
126 | 128 |
127 IPC::Channel::Sender* channel_; | 129 // |*this| is owned by |*channel_| and so is always outlived by it, so using a |
| 130 // raw pointer is ok. |
| 131 GpuChannelHost* channel_; |
128 int route_id_; | 132 int route_id_; |
129 unsigned int flush_count_; | 133 unsigned int flush_count_; |
130 | 134 |
131 scoped_ptr<Task> notify_repaint_task_; | 135 scoped_ptr<Task> notify_repaint_task_; |
132 | 136 |
133 scoped_ptr<Callback0::Type> swap_buffers_callback_; | 137 scoped_ptr<Callback0::Type> swap_buffers_callback_; |
134 scoped_ptr<Callback0::Type> channel_error_callback_; | 138 scoped_ptr<Callback0::Type> channel_error_callback_; |
135 | 139 |
136 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxy); | 140 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxy); |
137 }; | 141 }; |
138 | 142 |
139 #endif // ENABLE_GPU | 143 #endif // ENABLE_GPU |
140 | 144 |
141 #endif // CONTENT_RENDERER_GPU_COMMAND_BUFFER_PROXY_H_ | 145 #endif // CONTENT_RENDERER_GPU_COMMAND_BUFFER_PROXY_H_ |
OLD | NEW |