Delete unused downloads page asset.
[chromium-blink-merge.git] / ppapi / proxy / ppb_graphics_3d_proxy.h
blob98e7d3c31755883f7c3135b4438e20b5f7c240bc
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_PPB_GRAPHICS_3D_PROXY_H_
6 #define PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_
8 #include <vector>
10 #include "base/memory/shared_memory.h"
11 #include "gpu/command_buffer/common/command_buffer.h"
12 #include "ppapi/c/pp_graphics_3d.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/proxy/interface_proxy.h"
15 #include "ppapi/proxy/ppapi_proxy_export.h"
16 #include "ppapi/proxy/proxy_completion_callback_factory.h"
17 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
18 #include "ppapi/shared_impl/resource.h"
19 #include "ppapi/utility/completion_callback_factory.h"
21 namespace gpu {
22 struct Capabilities;
25 namespace ppapi {
27 class HostResource;
29 namespace proxy {
31 class SerializedHandle;
32 class PpapiCommandBufferProxy;
34 class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared {
35 public:
36 explicit Graphics3D(const HostResource& resource);
37 ~Graphics3D() override;
39 bool Init(gpu::gles2::GLES2Implementation* share_gles2,
40 const gpu::Capabilities& capabilities,
41 const SerializedHandle& shared_state);
43 // Graphics3DTrusted API. These are not implemented in the proxy.
44 PP_Bool SetGetBuffer(int32_t shm_id) override;
45 PP_Bool Flush(int32_t put_offset) override;
46 scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size,
47 int32* id) override;
48 PP_Bool DestroyTransferBuffer(int32_t id) override;
49 gpu::CommandBuffer::State WaitForTokenInRange(int32_t start,
50 int32_t end) override;
51 gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start,
52 int32_t end) override;
53 uint32_t InsertSyncPoint() override;
54 uint32_t InsertFutureSyncPoint() override;
55 void RetireSyncPoint(uint32_t sync_point) override;
57 private:
58 // PPB_Graphics3D_Shared overrides.
59 gpu::CommandBuffer* GetCommandBuffer() override;
60 gpu::GpuControl* GetGpuControl() override;
61 int32 DoSwapBuffers() override;
63 scoped_ptr<PpapiCommandBufferProxy> command_buffer_;
65 DISALLOW_COPY_AND_ASSIGN(Graphics3D);
68 class PPB_Graphics3D_Proxy : public InterfaceProxy {
69 public:
70 PPB_Graphics3D_Proxy(Dispatcher* dispatcher);
71 ~PPB_Graphics3D_Proxy();
73 static PP_Resource CreateProxyResource(
74 PP_Instance instance,
75 PP_Resource share_context,
76 const int32_t* attrib_list);
78 // InterfaceProxy implementation.
79 bool OnMessageReceived(const IPC::Message& msg) override;
81 static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D;
83 private:
84 void OnMsgCreate(PP_Instance instance,
85 HostResource share_context,
86 const std::vector<int32_t>& attribs,
87 HostResource* result,
88 gpu::Capabilities* capabilities,
89 SerializedHandle* handle);
90 void OnMsgSetGetBuffer(const HostResource& context,
91 int32 id);
92 void OnMsgWaitForTokenInRange(const HostResource& context,
93 int32 start,
94 int32 end,
95 gpu::CommandBuffer::State* state,
96 bool* success);
97 void OnMsgWaitForGetOffsetInRange(const HostResource& context,
98 int32 start,
99 int32 end,
100 gpu::CommandBuffer::State* state,
101 bool* success);
102 void OnMsgAsyncFlush(const HostResource& context, int32 put_offset);
103 void OnMsgCreateTransferBuffer(
104 const HostResource& context,
105 uint32 size,
106 int32* id,
107 ppapi::proxy::SerializedHandle* transfer_buffer);
108 void OnMsgDestroyTransferBuffer(const HostResource& context,
109 int32 id);
110 void OnMsgSwapBuffers(const HostResource& context);
111 void OnMsgInsertSyncPoint(const HostResource& context, uint32* sync_point);
112 void OnMsgInsertFutureSyncPoint(const HostResource& context,
113 uint32* sync_point);
114 void OnMsgRetireSyncPoint(const HostResource& context, uint32 sync_point);
115 // Renderer->plugin message handlers.
116 void OnMsgSwapBuffersACK(const HostResource& context,
117 int32_t pp_error);
119 void SendSwapBuffersACKToPlugin(int32_t result,
120 const HostResource& context);
122 ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_;
124 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy);
127 } // namespace proxy
128 } // namespace ppapi
130 #endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_