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

Side by Side Diff: content/renderer/gpu/command_buffer_proxy.h

Issue 9340012: Move gpu client files to content_common, in content/common/gpu/client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unneeded enums Created 8 years, 10 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
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/gpu/command_buffer_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_GPU_COMMAND_BUFFER_PROXY_H_
6 #define CONTENT_RENDERER_GPU_COMMAND_BUFFER_PROXY_H_
7 #pragma once
8
9 #if defined(ENABLE_GPU)
10
11 #include <map>
12 #include <queue>
13
14 #include "base/callback.h"
15 #include "base/memory/linked_ptr.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h"
18 #include "content/renderer/gpu/gpu_video_decode_accelerator_host.h"
19 #include "gpu/command_buffer/common/command_buffer.h"
20 #include "ipc/ipc_channel.h"
21 #include "ipc/ipc_message.h"
22
23 class GpuChannelHost;
24 struct GPUCommandBufferConsoleMessage;
25
26 namespace base {
27 class SharedMemory;
28 }
29
30 // Client side proxy that forwards messages synchronously to a
31 // CommandBufferStub.
32 class CommandBufferProxy : public gpu::CommandBuffer,
33 public IPC::Channel::Listener,
34 public base::SupportsWeakPtr<CommandBufferProxy> {
35 public:
36 CommandBufferProxy(GpuChannelHost* channel, int route_id);
37 virtual ~CommandBufferProxy();
38
39 // IPC::Channel::Listener implementation:
40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
41 virtual void OnChannelError() OVERRIDE;
42
43 int route_id() const { return route_id_; }
44
45 // CommandBuffer implementation:
46 virtual bool Initialize() OVERRIDE;
47 virtual State GetState() OVERRIDE;
48 virtual State GetLastState() OVERRIDE;
49 virtual void Flush(int32 put_offset) OVERRIDE;
50 virtual State FlushSync(int32 put_offset, int32 last_known_get) OVERRIDE;
51 virtual void SetGetBuffer(int32 shm_id) OVERRIDE;
52 virtual void SetGetOffset(int32 get_offset) OVERRIDE;
53 virtual int32 CreateTransferBuffer(size_t size, int32 id_request) OVERRIDE;
54 virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory,
55 size_t size,
56 int32 id_request) OVERRIDE;
57 virtual void DestroyTransferBuffer(int32 id) OVERRIDE;
58 virtual gpu::Buffer GetTransferBuffer(int32 handle) OVERRIDE;
59 virtual void SetToken(int32 token) OVERRIDE;
60 virtual void SetParseError(gpu::error::Error error) OVERRIDE;
61 virtual void SetContextLostReason(
62 gpu::error::ContextLostReason reason) OVERRIDE;
63
64 // Invoke the task when the channel has been flushed. Takes care of deleting
65 // the task whether the echo succeeds or not.
66 bool Echo(const base::Closure& callback);
67
68 // Sends an IPC message with the new state of surface visibility
69 bool SetSurfaceVisible(bool visible);
70
71 // Reparent a command buffer. TODO(apatrick): going forward, the notion of
72 // the parent / child relationship between command buffers is going away in
73 // favor of the notion of surfaces that can be drawn to in one command buffer
74 // and bound as a texture in any other.
75 virtual bool SetParent(CommandBufferProxy* parent_command_buffer,
76 uint32 parent_texture_id);
77
78 void SetChannelErrorCallback(const base::Closure& callback);
79
80 // Set a task that will be invoked the next time the window becomes invalid
81 // and needs to be repainted. Takes ownership of task.
82 void SetNotifyRepaintTask(const base::Closure& callback);
83
84 // Sends an IPC message to create a GpuVideoDecodeAccelerator. Creates and
85 // returns a pointer to a GpuVideoDecodeAcceleratorHost.
86 // Returns NULL on failure to create the GpuVideoDecodeAcceleratorHost.
87 // Note that the GpuVideoDecodeAccelerator may still fail to be created in
88 // the GPU process, even if this returns non-NULL. In this case the client is
89 // notified of an error later.
90 scoped_refptr<GpuVideoDecodeAcceleratorHost> CreateVideoDecoder(
91 media::VideoDecodeAccelerator::Profile profile,
92 media::VideoDecodeAccelerator::Client* client);
93
94 // TODO(apatrick): this is a temporary optimization while skia is calling
95 // RendererGLContext::MakeCurrent prior to every GL call. It saves returning 6
96 // ints redundantly when only the error is needed for the CommandBufferProxy
97 // implementation.
98 virtual gpu::error::Error GetLastError() OVERRIDE;
99
100 private:
101 // Send an IPC message over the GPU channel. This is private to fully
102 // encapsulate the channel; all callers of this function must explicitly
103 // verify that the context has not been lost.
104 bool Send(IPC::Message* msg);
105
106 // Message handlers:
107 void OnUpdateState(const gpu::CommandBuffer::State& state);
108 void OnNotifyRepaint();
109 void OnDestroyed(gpu::error::ContextLostReason reason);
110 void OnEchoAck();
111 void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message);
112
113 // Local cache of id to transfer buffer mapping.
114 typedef std::map<int32, gpu::Buffer> TransferBufferMap;
115 TransferBufferMap transfer_buffers_;
116
117 // Zero or more video decoder hosts owned by this proxy, keyed by their
118 // decoder_route_id.
119 typedef std::map<int, scoped_refptr<GpuVideoDecodeAcceleratorHost> > Decoders;
120 Decoders video_decoder_hosts_;
121
122 // The last cached state received from the service.
123 State last_state_;
124
125 // |*this| is owned by |*channel_| and so is always outlived by it, so using a
126 // raw pointer is ok.
127 GpuChannelHost* channel_;
128 int route_id_;
129 unsigned int flush_count_;
130
131 // Tasks to be invoked in echo responses.
132 std::queue<base::Closure> echo_tasks_;
133
134 base::Closure notify_repaint_task_;
135
136 base::Closure channel_error_callback_;
137
138 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxy);
139 };
140
141 #endif // ENABLE_GPU
142
143 #endif // CONTENT_RENDERER_GPU_COMMAND_BUFFER_PROXY_H_
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/gpu/command_buffer_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698