Elim cr-checkbox
[chromium-blink-merge.git] / ppapi / proxy / ppapi_command_buffer_proxy.h
blobddb383891c12ab7a9ee078de325d8e09789a884b
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/plugin_dispatcher.h"
15 #include "ppapi/proxy/ppapi_proxy_export.h"
16 #include "ppapi/shared_impl/host_resource.h"
18 namespace IPC {
19 class Message;
22 namespace ppapi {
23 namespace proxy {
25 class SerializedHandle;
27 class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer,
28 public gpu::GpuControl {
29 public:
30 PpapiCommandBufferProxy(const HostResource& resource,
31 PluginDispatcher* dispatcher,
32 const gpu::Capabilities& capabilities,
33 const SerializedHandle& shared_state,
34 uint64_t command_buffer_id);
35 ~PpapiCommandBufferProxy() override;
37 // gpu::CommandBuffer implementation:
38 bool Initialize() override;
39 State GetLastState() override;
40 int32 GetLastToken() override;
41 void Flush(int32 put_offset) override;
42 void OrderingBarrier(int32 put_offset) override;
43 void WaitForTokenInRange(int32 start, int32 end) override;
44 void WaitForGetOffsetInRange(int32 start, int32 end) override;
45 void SetGetBuffer(int32 transfer_buffer_id) override;
46 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
47 int32* id) override;
48 void DestroyTransferBuffer(int32 id) override;
50 // gpu::GpuControl implementation:
51 gpu::Capabilities GetCapabilities() override;
52 int32 CreateImage(ClientBuffer buffer,
53 size_t width,
54 size_t height,
55 unsigned internalformat) override;
56 void DestroyImage(int32 id) override;
57 int32 CreateGpuMemoryBufferImage(size_t width,
58 size_t height,
59 unsigned internalformat,
60 unsigned usage) override;
61 uint32 InsertSyncPoint() override;
62 uint32 InsertFutureSyncPoint() override;
63 void RetireSyncPoint(uint32 sync_point) override;
64 void SignalSyncPoint(uint32 sync_point,
65 const base::Closure& callback) override;
66 void SignalQuery(uint32 query, const base::Closure& callback) override;
67 void SetSurfaceVisible(bool visible) override;
68 uint32 CreateStreamTexture(uint32 texture_id) override;
69 void SetLock(base::Lock*) override;
70 bool IsGpuChannelLost() override;
71 gpu::CommandBufferNamespace GetNamespaceID() const override;
72 uint64_t GetCommandBufferID() const override;
74 private:
75 bool Send(IPC::Message* msg);
76 void UpdateState(const gpu::CommandBuffer::State& state, bool success);
78 // Try to read an updated copy of the state from shared memory.
79 void TryUpdateState();
81 // The shared memory area used to update state.
82 gpu::CommandBufferSharedState* shared_state() const;
84 void FlushInternal();
86 const uint64_t command_buffer_id_;
88 gpu::Capabilities capabilities_;
89 State last_state_;
90 scoped_ptr<base::SharedMemory> shared_state_shm_;
92 HostResource resource_;
93 PluginDispatcher* dispatcher_;
95 base::Closure channel_error_callback_;
97 InstanceData::FlushInfo *flush_info_;
99 DISALLOW_COPY_AND_ASSIGN(PpapiCommandBufferProxy);
102 } // namespace proxy
103 } // namespace ppapi
105 #endif // PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_