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/client/gpu_control.h"
11 #include "gpu/command_buffer/common/command_buffer.h"
12 #include "ppapi/proxy/ppapi_proxy_export.h"
13 #include "ppapi/shared_impl/host_resource.h"
24 class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy
: public gpu::CommandBuffer
,
25 public gpu::GpuControl
{
27 PpapiCommandBufferProxy(const HostResource
& resource
,
28 ProxyChannel
* channel
);
29 virtual ~PpapiCommandBufferProxy();
31 // gpu::CommandBuffer implementation:
32 virtual bool Initialize() OVERRIDE
;
33 virtual State
GetLastState() OVERRIDE
;
34 virtual int32
GetLastToken() OVERRIDE
;
35 virtual void Flush(int32 put_offset
) OVERRIDE
;
36 virtual void WaitForTokenInRange(int32 start
, int32 end
) OVERRIDE
;
37 virtual void WaitForGetOffsetInRange(int32 start
, int32 end
) OVERRIDE
;
38 virtual void SetGetBuffer(int32 transfer_buffer_id
) OVERRIDE
;
39 virtual scoped_refptr
<gpu::Buffer
> CreateTransferBuffer(size_t size
,
41 virtual void DestroyTransferBuffer(int32 id
) OVERRIDE
;
43 // gpu::GpuControl implementation:
44 virtual gpu::Capabilities
GetCapabilities() OVERRIDE
;
45 virtual gfx::GpuMemoryBuffer
* CreateGpuMemoryBuffer(size_t width
,
47 unsigned internalformat
,
50 virtual void DestroyGpuMemoryBuffer(int32 id
) OVERRIDE
;
51 virtual uint32
InsertSyncPoint() OVERRIDE
;
52 virtual uint32
InsertFutureSyncPoint() OVERRIDE
;
53 virtual void RetireSyncPoint(uint32 sync_point
) OVERRIDE
;
54 virtual void SignalSyncPoint(uint32 sync_point
,
55 const base::Closure
& callback
) OVERRIDE
;
56 virtual void SignalQuery(uint32 query
,
57 const base::Closure
& callback
) OVERRIDE
;
58 virtual void SetSurfaceVisible(bool visible
) OVERRIDE
;
59 virtual void Echo(const base::Closure
& callback
) OVERRIDE
;
60 virtual uint32
CreateStreamTexture(uint32 texture_id
) OVERRIDE
;
63 bool Send(IPC::Message
* msg
);
64 void UpdateState(const gpu::CommandBuffer::State
& state
, bool success
);
68 HostResource resource_
;
69 ProxyChannel
* channel_
;
71 base::Closure channel_error_callback_
;
73 DISALLOW_COPY_AND_ASSIGN(PpapiCommandBufferProxy
);
79 #endif // PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_