Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: content/common/gpu/client/command_buffer_proxy_impl.h

Issue 10749019: VideoDecodeAccelerator now SupportsWeakPtr instead of being RefCountedThreadSafe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_
6 #define CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_
7 7
8 #if defined(ENABLE_GPU) 8 #if defined(ENABLE_GPU)
9 9
10 #include <map> 10 #include <map>
11 #include <queue> 11 #include <queue>
12 #include <string> 12 #include <string>
13 13
14 #include "gpu/ipc/command_buffer_proxy.h" 14 #include "gpu/ipc/command_buffer_proxy.h"
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/hash_tables.h" 18 #include "base/hash_tables.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "base/stl_util.h"
21 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" 22 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h"
22 #include "gpu/command_buffer/common/command_buffer.h" 23 #include "gpu/command_buffer/common/command_buffer.h"
23 #include "gpu/command_buffer/common/command_buffer_shared.h" 24 #include "gpu/command_buffer/common/command_buffer_shared.h"
24 #include "ipc/ipc_listener.h" 25 #include "ipc/ipc_listener.h"
25 26
26 class GpuChannelHost; 27 class GpuChannelHost;
27 struct GPUCommandBufferConsoleMessage; 28 struct GPUCommandBufferConsoleMessage;
28 struct GpuMemoryAllocationForRenderer; 29 struct GpuMemoryAllocationForRenderer;
29 30
30 namespace base { 31 namespace base {
(...skipping 12 matching lines...) Expand all
43 44
44 CommandBufferProxyImpl(GpuChannelHost* channel, int route_id); 45 CommandBufferProxyImpl(GpuChannelHost* channel, int route_id);
45 virtual ~CommandBufferProxyImpl(); 46 virtual ~CommandBufferProxyImpl();
46 47
47 // Sends an IPC message to create a GpuVideoDecodeAccelerator. Creates and 48 // Sends an IPC message to create a GpuVideoDecodeAccelerator. Creates and
48 // returns a pointer to a GpuVideoDecodeAcceleratorHost. 49 // returns a pointer to a GpuVideoDecodeAcceleratorHost.
49 // Returns NULL on failure to create the GpuVideoDecodeAcceleratorHost. 50 // Returns NULL on failure to create the GpuVideoDecodeAcceleratorHost.
50 // Note that the GpuVideoDecodeAccelerator may still fail to be created in 51 // Note that the GpuVideoDecodeAccelerator may still fail to be created in
51 // the GPU process, even if this returns non-NULL. In this case the client is 52 // the GPU process, even if this returns non-NULL. In this case the client is
52 // notified of an error later. 53 // notified of an error later.
53 scoped_refptr<GpuVideoDecodeAcceleratorHost> CreateVideoDecoder( 54 GpuVideoDecodeAcceleratorHost* CreateVideoDecoder(
54 media::VideoCodecProfile profile, 55 media::VideoCodecProfile profile,
55 media::VideoDecodeAccelerator::Client* client); 56 media::VideoDecodeAccelerator::Client* client);
56 57
57 // IPC::Listener implementation: 58 // IPC::Listener implementation:
58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
59 virtual void OnChannelError() OVERRIDE; 60 virtual void OnChannelError() OVERRIDE;
60 61
61 // CommandBufferProxy implementation: 62 // CommandBufferProxy implementation:
62 virtual int GetRouteID() const OVERRIDE; 63 virtual int GetRouteID() const OVERRIDE;
63 virtual bool Echo(const base::Closure& callback) OVERRIDE; 64 virtual bool Echo(const base::Closure& callback) OVERRIDE;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // TODO(apatrick): this is a temporary optimization while skia is calling 101 // TODO(apatrick): this is a temporary optimization while skia is calling
101 // ContentGLContext::MakeCurrent prior to every GL call. It saves returning 6 102 // ContentGLContext::MakeCurrent prior to every GL call. It saves returning 6
102 // ints redundantly when only the error is needed for the 103 // ints redundantly when only the error is needed for the
103 // CommandBufferProxyImpl implementation. 104 // CommandBufferProxyImpl implementation.
104 virtual gpu::error::Error GetLastError() OVERRIDE; 105 virtual gpu::error::Error GetLastError() OVERRIDE;
105 106
106 GpuChannelHost* channel() const { return channel_; } 107 GpuChannelHost* channel() const { return channel_; }
107 108
108 private: 109 private:
109 typedef std::map<int32, gpu::Buffer> TransferBufferMap; 110 typedef std::map<int32, gpu::Buffer> TransferBufferMap;
110 typedef std::map<int, scoped_refptr<GpuVideoDecodeAcceleratorHost> > Decoders; 111 typedef std::map<int, GpuVideoDecodeAcceleratorHost*> Decoders;
111 typedef base::hash_map<uint32, base::Closure> SignalTaskMap; 112 typedef base::hash_map<uint32, base::Closure> SignalTaskMap;
112 113
113 // Send an IPC message over the GPU channel. This is private to fully 114 // Send an IPC message over the GPU channel. This is private to fully
114 // encapsulate the channel; all callers of this function must explicitly 115 // encapsulate the channel; all callers of this function must explicitly
115 // verify that the context has not been lost. 116 // verify that the context has not been lost.
116 bool Send(IPC::Message* msg); 117 bool Send(IPC::Message* msg);
117 118
118 // Message handlers: 119 // Message handlers:
119 void OnUpdateState(const gpu::CommandBuffer::State& state); 120 void OnUpdateState(const gpu::CommandBuffer::State& state);
120 void OnNotifyRepaint(); 121 void OnNotifyRepaint();
121 void OnDestroyed(gpu::error::ContextLostReason reason); 122 void OnDestroyed(gpu::error::ContextLostReason reason);
122 void OnEchoAck(); 123 void OnEchoAck();
123 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); 124 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message);
124 void OnSetMemoryAllocation(const GpuMemoryAllocationForRenderer& allocation); 125 void OnSetMemoryAllocation(const GpuMemoryAllocationForRenderer& allocation);
125 void OnSignalSyncPointAck(uint32 id); 126 void OnSignalSyncPointAck(uint32 id);
126 127
127 // Try to read an updated copy of the state from shared memory. 128 // Try to read an updated copy of the state from shared memory.
128 void TryUpdateState(); 129 void TryUpdateState();
129 130
130 // Local cache of id to transfer buffer mapping. 131 // Local cache of id to transfer buffer mapping.
131 TransferBufferMap transfer_buffers_; 132 TransferBufferMap transfer_buffers_;
132 133
133 // Zero or more video decoder hosts owned by this proxy, keyed by their 134 // Zero or more video decoder hosts owned by this proxy, keyed by their
134 // decoder_route_id. 135 // decoder_route_id.
135 Decoders video_decoder_hosts_; 136 Decoders video_decoder_hosts_;
137 STLValueDeleter<Decoders> video_decoder_hosts_deleter_;
136 138
137 // The last cached state received from the service. 139 // The last cached state received from the service.
138 State last_state_; 140 State last_state_;
139 141
140 // The shared memory area used to update state. 142 // The shared memory area used to update state.
141 gpu::CommandBufferSharedState* shared_state_; 143 gpu::CommandBufferSharedState* shared_state_;
142 144
143 // |*this| is owned by |*channel_| and so is always outlived by it, so using a 145 // |*this| is owned by |*channel_| and so is always outlived by it, so using a
144 // raw pointer is ok. 146 // raw pointer is ok.
145 GpuChannelHost* channel_; 147 GpuChannelHost* channel_;
(...skipping 16 matching lines...) Expand all
162 // Tasks to be invoked in SignalSyncPoint responses. 164 // Tasks to be invoked in SignalSyncPoint responses.
163 uint32 next_signal_id_; 165 uint32 next_signal_id_;
164 SignalTaskMap signal_tasks_; 166 SignalTaskMap signal_tasks_;
165 167
166 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); 168 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl);
167 }; 169 };
168 170
169 #endif // ENABLE_GPU 171 #endif // ENABLE_GPU
170 172
171 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ 173 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698