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. 4 5 #ifndef PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_ 6 #define PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_ 7 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" 14 15 namespace IPC { 16 class Message; 17 } 18 19 namespace ppapi { 20 namespace proxy { 21 22 class ProxyChannel; 23 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(); 30 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; 42 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 void SignalSyncPoint(uint32 sync_point, 53 const base::Closure& callback) OVERRIDE; 54 virtual void SignalQuery(uint32 query, 55 const base::Closure& callback) OVERRIDE; 56 virtual void SetSurfaceVisible(bool visible) OVERRIDE; 57 virtual void Echo(const base::Closure& callback) OVERRIDE; 58 virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE; 59 60 private: 61 bool Send(IPC::Message* msg); 62 void UpdateState(const gpu::CommandBuffer::State& state, bool success); 63 64 State last_state_; 65 66 HostResource resource_; 67 ProxyChannel* channel_; 68 69 base::Closure channel_error_callback_; 70 71 DISALLOW_COPY_AND_ASSIGN(PpapiCommandBufferProxy); 72 }; 73 74 } // namespace proxy 75 } // namespace ppapi 76 77 #endif // PPAPI_PROXY_COMMAND_BUFFER_PROXY_H_ 78