mac: Fix DownloadItemController unit tests on Yosemite.
[chromium-blink-merge.git] / ppapi / proxy / ppb_graphics_3d_proxy.h
blob848281e0280c61985e44c43d1162788a7660c507
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 virtual ~Graphics3D();
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 virtual PP_Bool SetGetBuffer(int32_t shm_id) override;
45 virtual PP_Bool Flush(int32_t put_offset) override;
46 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size,
47 int32* id) override;
48 virtual PP_Bool DestroyTransferBuffer(int32_t id) override;
49 virtual gpu::CommandBuffer::State WaitForTokenInRange(int32_t start,
50 int32_t end) override;
51 virtual gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start,
52 int32_t end)
53 override;
54 virtual uint32_t InsertSyncPoint() override;
55 virtual uint32_t InsertFutureSyncPoint() override;
56 virtual void RetireSyncPoint(uint32_t sync_point) override;
58 private:
59 // PPB_Graphics3D_Shared overrides.
60 virtual gpu::CommandBuffer* GetCommandBuffer() override;
61 virtual gpu::GpuControl* GetGpuControl() override;
62 virtual int32 DoSwapBuffers() override;
64 scoped_ptr<PpapiCommandBufferProxy> command_buffer_;
66 DISALLOW_COPY_AND_ASSIGN(Graphics3D);
69 class PPB_Graphics3D_Proxy : public InterfaceProxy {
70 public:
71 PPB_Graphics3D_Proxy(Dispatcher* dispatcher);
72 virtual ~PPB_Graphics3D_Proxy();
74 static PP_Resource CreateProxyResource(
75 PP_Instance instance,
76 PP_Resource share_context,
77 const int32_t* attrib_list);
79 // InterfaceProxy implementation.
80 virtual bool OnMessageReceived(const IPC::Message& msg);
82 static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D;
84 private:
85 void OnMsgCreate(PP_Instance instance,
86 HostResource share_context,
87 const std::vector<int32_t>& attribs,
88 HostResource* result,
89 gpu::Capabilities* capabilities,
90 SerializedHandle* handle);
91 void OnMsgSetGetBuffer(const HostResource& context,
92 int32 id);
93 void OnMsgWaitForTokenInRange(const HostResource& context,
94 int32 start,
95 int32 end,
96 gpu::CommandBuffer::State* state,
97 bool* success);
98 void OnMsgWaitForGetOffsetInRange(const HostResource& context,
99 int32 start,
100 int32 end,
101 gpu::CommandBuffer::State* state,
102 bool* success);
103 void OnMsgAsyncFlush(const HostResource& context, int32 put_offset);
104 void OnMsgCreateTransferBuffer(
105 const HostResource& context,
106 uint32 size,
107 int32* id,
108 ppapi::proxy::SerializedHandle* transfer_buffer);
109 void OnMsgDestroyTransferBuffer(const HostResource& context,
110 int32 id);
111 void OnMsgSwapBuffers(const HostResource& context);
112 void OnMsgInsertSyncPoint(const HostResource& context, uint32* sync_point);
113 void OnMsgInsertFutureSyncPoint(const HostResource& context,
114 uint32* sync_point);
115 void OnMsgRetireSyncPoint(const HostResource& context, uint32 sync_point);
116 // Renderer->plugin message handlers.
117 void OnMsgSwapBuffersACK(const HostResource& context,
118 int32_t pp_error);
120 void SendSwapBuffersACKToPlugin(int32_t result,
121 const HostResource& context);
123 ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_;
125 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy);
128 } // namespace proxy
129 } // namespace ppapi
131 #endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_