Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ppapi / proxy / ppapi_command_buffer_proxy.h
blob45daf2f281ef7da825852b24333124e6a1ee62d8
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"
15 namespace IPC {
16 class Message;
19 namespace ppapi {
20 namespace proxy {
22 class ProxyChannel;
24 class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer,
25 public gpu::GpuControl {
26 public:
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,
40 int32* id) OVERRIDE;
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,
46 size_t height,
47 unsigned internalformat,
48 unsigned usage,
49 int32* id) OVERRIDE;
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;
62 private:
63 bool Send(IPC::Message* msg);
64 void UpdateState(const gpu::CommandBuffer::State& state, bool success);
66 State last_state_;
68 HostResource resource_;
69 ProxyChannel* channel_;
71 base::Closure channel_error_callback_;
73 DISALLOW_COPY_AND_ASSIGN(PpapiCommandBufferProxy);
76 } // namespace proxy
77 } // namespace ppapi
79 #endif // PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_