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.
5 #ifndef PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_
6 #define PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_
8 #include "base/callback.h"
9 #include "base/containers/hash_tables.h"
10 #include "gpu/command_buffer/common/command_buffer.h"
11 #include "gpu/ipc/command_buffer_proxy.h"
12 #include "ppapi/proxy/ppapi_proxy_export.h"
13 #include "ppapi/shared_impl/host_resource.h"
24 class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy
: public CommandBufferProxy
{
26 PpapiCommandBufferProxy(const HostResource
& resource
,
27 ProxyChannel
* channel
);
28 virtual ~PpapiCommandBufferProxy();
30 void ReportChannelError();
32 // CommandBufferProxy implementation:
33 virtual int GetRouteID() const OVERRIDE
;
34 virtual bool Echo(const base::Closure
& callback
) OVERRIDE
;
35 virtual bool ProduceFrontBuffer(const gpu::Mailbox
& mailbox
) OVERRIDE
;
36 virtual void SetChannelErrorCallback(const base::Closure
& callback
) OVERRIDE
;
38 // gpu::CommandBuffer implementation:
39 virtual bool Initialize();
40 virtual State
GetState();
41 virtual State
GetLastState();
42 virtual int32
GetLastToken();
43 virtual void Flush(int32 put_offset
);
44 virtual State
FlushSync(int32 put_offset
, int32 last_known_get
);
45 virtual void SetGetBuffer(int32 transfer_buffer_id
);
46 virtual void SetGetOffset(int32 get_offset
);
47 virtual gpu::Buffer
CreateTransferBuffer(size_t size
, int32
* id
);
48 virtual void DestroyTransferBuffer(int32 id
);
49 virtual gpu::Buffer
GetTransferBuffer(int32 id
);
50 virtual void SetToken(int32 token
);
51 virtual void SetParseError(gpu::error::Error error
);
52 virtual void SetContextLostReason(gpu::error::ContextLostReason reason
);
53 virtual uint32
InsertSyncPoint();
56 bool Send(IPC::Message
* msg
);
57 void UpdateState(const gpu::CommandBuffer::State
& state
, bool success
);
59 typedef base::hash_map
<int32
, gpu::Buffer
> TransferBufferMap
;
60 TransferBufferMap transfer_buffers_
;
64 HostResource resource_
;
65 ProxyChannel
* channel_
;
67 base::Closure channel_error_callback_
;
69 DISALLOW_COPY_AND_ASSIGN(PpapiCommandBufferProxy
);
75 #endif // PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_