blob: 98e7d3c31755883f7c3135b4438e20b5f7c240bc [file] [log] [blame]
[email protected]aaa11b32012-03-08 12:30:131// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]eeb4e4a2011-07-19 16:22:062// 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_PPB_GRAPHICS_3D_PROXY_H_
6#define PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_
7
8#include <vector>
9
[email protected]8299b712013-07-17 19:55:2310#include "base/memory/shared_memory.h"
[email protected]eeb4e4a2011-07-19 16:22:0611#include "gpu/command_buffer/common/command_buffer.h"
[email protected]fae0e942011-09-07 17:10:4612#include "ppapi/c/pp_graphics_3d.h"
[email protected]eeb4e4a2011-07-19 16:22:0613#include "ppapi/c/pp_instance.h"
[email protected]eeb4e4a2011-07-19 16:22:0614#include "ppapi/proxy/interface_proxy.h"
[email protected]dfb0d06f32014-05-30 22:45:5615#include "ppapi/proxy/ppapi_proxy_export.h"
[email protected]47a961c2012-07-13 19:18:5216#include "ppapi/proxy/proxy_completion_callback_factory.h"
[email protected]9a578392011-12-07 18:59:2717#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
[email protected]7f8b26b2011-08-18 15:41:0118#include "ppapi/shared_impl/resource.h"
[email protected]ae5ff9ae2012-01-06 22:50:3319#include "ppapi/utility/completion_callback_factory.h"
[email protected]eeb4e4a2011-07-19 16:22:0620
piman360175c2014-11-07 02:30:0121namespace gpu {
22struct Capabilities;
23}
24
[email protected]be0a84b2011-08-13 04:18:4425namespace ppapi {
[email protected]be0a84b2011-08-13 04:18:4426
[email protected]4d2efd22011-08-18 21:58:0227class HostResource;
28
[email protected]eeb4e4a2011-07-19 16:22:0629namespace proxy {
30
[email protected]eb5960da2013-01-16 23:23:5331class SerializedHandle;
[email protected]744e0792013-09-27 01:18:3532class PpapiCommandBufferProxy;
[email protected]eb5960da2013-01-16 23:23:5333
[email protected]dfb0d06f32014-05-30 22:45:5634class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared {
[email protected]eeb4e4a2011-07-19 16:22:0635 public:
[email protected]4d2efd22011-08-18 21:58:0236 explicit Graphics3D(const HostResource& resource);
nicke4784432015-04-23 14:01:4837 ~Graphics3D() override;
[email protected]eeb4e4a2011-07-19 16:22:0638
penghuanga206fb492014-09-09 21:27:3239 bool Init(gpu::gles2::GLES2Implementation* share_gles2,
piman360175c2014-11-07 02:30:0140 const gpu::Capabilities& capabilities,
penghuanga206fb492014-09-09 21:27:3241 const SerializedHandle& shared_state);
[email protected]eeb4e4a2011-07-19 16:22:0642
[email protected]eeb4e4a2011-07-19 16:22:0643 // Graphics3DTrusted API. These are not implemented in the proxy.
nicke4784432015-04-23 14:01:4844 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;
[email protected]eeb4e4a2011-07-19 16:22:0656
[email protected]84b44c552012-10-15 20:58:1757 private:
[email protected]84b44c552012-10-15 20:58:1758 // PPB_Graphics3D_Shared overrides.
nicke4784432015-04-23 14:01:4859 gpu::CommandBuffer* GetCommandBuffer() override;
60 gpu::GpuControl* GetGpuControl() override;
61 int32 DoSwapBuffers() override;
[email protected]eeb4e4a2011-07-19 16:22:0662
[email protected]744e0792013-09-27 01:18:3563 scoped_ptr<PpapiCommandBufferProxy> command_buffer_;
[email protected]eeb4e4a2011-07-19 16:22:0664
65 DISALLOW_COPY_AND_ASSIGN(Graphics3D);
66};
67
68class PPB_Graphics3D_Proxy : public InterfaceProxy {
69 public:
[email protected]5c966022011-09-13 18:09:3770 PPB_Graphics3D_Proxy(Dispatcher* dispatcher);
nicke4784432015-04-23 14:01:4871 ~PPB_Graphics3D_Proxy();
[email protected]eeb4e4a2011-07-19 16:22:0672
[email protected]9ed07f82012-05-29 21:54:5573 static PP_Resource CreateProxyResource(
74 PP_Instance instance,
75 PP_Resource share_context,
76 const int32_t* attrib_list);
[email protected]eeb4e4a2011-07-19 16:22:0677
[email protected]eeb4e4a2011-07-19 16:22:0678 // InterfaceProxy implementation.
nicke4784432015-04-23 14:01:4879 bool OnMessageReceived(const IPC::Message& msg) override;
[email protected]eeb4e4a2011-07-19 16:22:0680
[email protected]ac4b54d2011-10-20 23:09:2881 static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D;
[email protected]5c966022011-09-13 18:09:3782
[email protected]eeb4e4a2011-07-19 16:22:0683 private:
84 void OnMsgCreate(PP_Instance instance,
[email protected]9ed07f82012-05-29 21:54:5585 HostResource share_context,
[email protected]eeb4e4a2011-07-19 16:22:0686 const std::vector<int32_t>& attribs,
penghuanga206fb492014-09-09 21:27:3287 HostResource* result,
piman360175c2014-11-07 02:30:0188 gpu::Capabilities* capabilities,
penghuanga206fb492014-09-09 21:27:3289 SerializedHandle* handle);
[email protected]503b3a22011-12-12 23:29:4090 void OnMsgSetGetBuffer(const HostResource& context,
91 int32 id);
[email protected]7fe4198b2014-03-18 21:52:3692 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);
[email protected]046fa1ac2014-04-01 09:06:43103 void OnMsgCreateTransferBuffer(
104 const HostResource& context,
105 uint32 size,
106 int32* id,
107 ppapi::proxy::SerializedHandle* transfer_buffer);
[email protected]4d2efd22011-08-18 21:58:02108 void OnMsgDestroyTransferBuffer(const HostResource& context,
[email protected]eeb4e4a2011-07-19 16:22:06109 int32 id);
[email protected]4d2efd22011-08-18 21:58:02110 void OnMsgSwapBuffers(const HostResource& context);
[email protected]b096d032013-03-08 03:08:01111 void OnMsgInsertSyncPoint(const HostResource& context, uint32* sync_point);
[email protected]7035bc92014-07-01 00:27:22112 void OnMsgInsertFutureSyncPoint(const HostResource& context,
113 uint32* sync_point);
114 void OnMsgRetireSyncPoint(const HostResource& context, uint32 sync_point);
[email protected]eeb4e4a2011-07-19 16:22:06115 // Renderer->plugin message handlers.
[email protected]4d2efd22011-08-18 21:58:02116 void OnMsgSwapBuffersACK(const HostResource& context,
[email protected]be0a84b2011-08-13 04:18:44117 int32_t pp_error);
[email protected]eeb4e4a2011-07-19 16:22:06118
119 void SendSwapBuffersACKToPlugin(int32_t result,
[email protected]4d2efd22011-08-18 21:58:02120 const HostResource& context);
[email protected]eeb4e4a2011-07-19 16:22:06121
[email protected]47a961c2012-07-13 19:18:52122 ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_;
[email protected]eeb4e4a2011-07-19 16:22:06123
124 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy);
125};
126
127} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:02128} // namespace ppapi
[email protected]eeb4e4a2011-07-19 16:22:06129
130#endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_
131