Cleanup: Remove vim comment settings, tab width and expansion variables from gyp...
[chromium-blink-merge.git] / ppapi / proxy / ppapi_command_buffer_proxy.h
blobb277baff9c312f6db768a0f5743b4a1a6e72f31c
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 "base/memory/scoped_ptr.h"
11 #include "gpu/command_buffer/client/gpu_control.h"
12 #include "gpu/command_buffer/common/command_buffer.h"
13 #include "gpu/command_buffer/common/command_buffer_shared.h"
14 #include "ppapi/proxy/ppapi_proxy_export.h"
15 #include "ppapi/shared_impl/host_resource.h"
17 namespace IPC {
18 class Message;
21 namespace ppapi {
22 namespace proxy {
24 class ProxyChannel;
25 class SerializedHandle;
27 class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer,
28 public gpu::GpuControl {
29 public:
30 PpapiCommandBufferProxy(const HostResource& resource,
31 ProxyChannel* channel,
32 const gpu::Capabilities& capabilities,
33 const SerializedHandle& shared_state);
34 virtual ~PpapiCommandBufferProxy();
36 // gpu::CommandBuffer implementation:
37 virtual bool Initialize() override;
38 virtual State GetLastState() override;
39 virtual int32 GetLastToken() override;
40 virtual void Flush(int32 put_offset) override;
41 virtual void WaitForTokenInRange(int32 start, int32 end) override;
42 virtual void WaitForGetOffsetInRange(int32 start, int32 end) override;
43 virtual void SetGetBuffer(int32 transfer_buffer_id) override;
44 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
45 int32* id) override;
46 virtual void DestroyTransferBuffer(int32 id) override;
48 // gpu::GpuControl implementation:
49 virtual gpu::Capabilities GetCapabilities() override;
50 virtual int32 CreateImage(ClientBuffer buffer,
51 size_t width,
52 size_t height,
53 unsigned internalformat) override;
54 virtual void DestroyImage(int32 id) override;
55 virtual int32 CreateGpuMemoryBufferImage(size_t width,
56 size_t height,
57 unsigned internalformat,
58 unsigned usage) override;
59 virtual uint32 InsertSyncPoint() override;
60 virtual uint32 InsertFutureSyncPoint() override;
61 virtual void RetireSyncPoint(uint32 sync_point) override;
62 virtual void SignalSyncPoint(uint32 sync_point,
63 const base::Closure& callback) override;
64 virtual void SignalQuery(uint32 query,
65 const base::Closure& callback) override;
66 virtual void SetSurfaceVisible(bool visible) override;
67 virtual uint32 CreateStreamTexture(uint32 texture_id) override;
69 private:
70 bool Send(IPC::Message* msg);
71 void UpdateState(const gpu::CommandBuffer::State& state, bool success);
73 // Try to read an updated copy of the state from shared memory.
74 void TryUpdateState();
76 // The shared memory area used to update state.
77 gpu::CommandBufferSharedState* shared_state() const;
79 gpu::Capabilities capabilities_;
80 State last_state_;
81 scoped_ptr<base::SharedMemory> shared_state_shm_;
83 HostResource resource_;
84 ProxyChannel* channel_;
86 base::Closure channel_error_callback_;
88 DISALLOW_COPY_AND_ASSIGN(PpapiCommandBufferProxy);
91 } // namespace proxy
92 } // namespace ppapi
94 #endif // PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_