blob: 69ba5f105e4e5cfd78dcd4e23d8c3ae2a3443938 [file] [log] [blame]
Avi Drissmandb497b32022-09-15 19:47:281// Copyright 2012 The Chromium Authors
[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
avie029c4132015-12-23 06:45:228#include <stdint.h>
9
[email protected]eeb4e4a2011-07-19 16:22:0610#include "gpu/command_buffer/common/command_buffer.h"
lukasza2573ce7d2016-02-16 19:17:2211#include "gpu/command_buffer/common/command_buffer_id.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;
piman360175c2014-11-07 02:30:0123}
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:
Vasiliy Telezhnikov2a786452023-05-12 23:53:3736 Graphics3D(const HostResource& resource, const gfx::Size& size);
Peter Boström3d5b3cb2021-09-23 21:35:4537
38 Graphics3D(const Graphics3D&) = delete;
39 Graphics3D& operator=(const Graphics3D&) = delete;
40
nicke4784432015-04-23 14:01:4841 ~Graphics3D() override;
[email protected]eeb4e4a2011-07-19 16:22:0642
penghuanga206fb492014-09-09 21:27:3243 bool Init(gpu::gles2::GLES2Implementation* share_gles2,
piman360175c2014-11-07 02:30:0144 const gpu::Capabilities& capabilities,
Alexandr Ilin15bb7032018-07-13 10:09:0645 SerializedHandle shared_state,
lukasza2573ce7d2016-02-16 19:17:2246 gpu::CommandBufferId command_buffer_id);
[email protected]eeb4e4a2011-07-19 16:22:0647
[email protected]eeb4e4a2011-07-19 16:22:0648 // Graphics3DTrusted API. These are not implemented in the proxy.
nicke4784432015-04-23 14:01:4849 PP_Bool SetGetBuffer(int32_t shm_id) override;
50 PP_Bool Flush(int32_t put_offset) override;
51 scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size,
avie029c4132015-12-23 06:45:2252 int32_t* id) override;
nicke4784432015-04-23 14:01:4853 PP_Bool DestroyTransferBuffer(int32_t id) override;
54 gpu::CommandBuffer::State WaitForTokenInRange(int32_t start,
55 int32_t end) override;
Antoine Labourd3469942017-05-16 21:23:4256 gpu::CommandBuffer::State WaitForGetOffsetInRange(
57 uint32_t set_get_buffer_count,
58 int32_t start,
59 int32_t end) override;
dyen4de3d345f2016-01-12 18:30:4260 void EnsureWorkVisible() override;
Vasiliy Telezhnikov2e6fab12022-12-01 17:08:0461 void ResolveAndDetachFramebuffer() override;
[email protected]eeb4e4a2011-07-19 16:22:0662
[email protected]84b44c552012-10-15 20:58:1763 private:
[email protected]84b44c552012-10-15 20:58:1764 // PPB_Graphics3D_Shared overrides.
nicke4784432015-04-23 14:01:4865 gpu::CommandBuffer* GetCommandBuffer() override;
66 gpu::GpuControl* GetGpuControl() override;
erikchenb13637b2016-07-08 09:38:5667 int32_t DoSwapBuffers(const gpu::SyncToken& sync_token,
pimanb36392c22016-07-13 02:11:3668 const gfx::Size& size) override;
Vasiliy Telezhnikov2e6fab12022-12-01 17:08:0469 void DoResize(gfx::Size size) override;
[email protected]eeb4e4a2011-07-19 16:22:0670
dchengced92242016-04-07 00:00:1271 std::unique_ptr<PpapiCommandBufferProxy> command_buffer_;
[email protected]eeb4e4a2011-07-19 16:22:0672};
73
74class PPB_Graphics3D_Proxy : public InterfaceProxy {
75 public:
thestig774686b2015-09-15 19:34:3176 explicit PPB_Graphics3D_Proxy(Dispatcher* dispatcher);
Peter Boström3d5b3cb2021-09-23 21:35:4577
78 PPB_Graphics3D_Proxy(const PPB_Graphics3D_Proxy&) = delete;
79 PPB_Graphics3D_Proxy& operator=(const PPB_Graphics3D_Proxy&) = delete;
80
nicke4784432015-04-23 14:01:4881 ~PPB_Graphics3D_Proxy();
[email protected]eeb4e4a2011-07-19 16:22:0682
[email protected]9ed07f82012-05-29 21:54:5583 static PP_Resource CreateProxyResource(
84 PP_Instance instance,
85 PP_Resource share_context,
86 const int32_t* attrib_list);
[email protected]eeb4e4a2011-07-19 16:22:0687
[email protected]eeb4e4a2011-07-19 16:22:0688 // InterfaceProxy implementation.
nicke4784432015-04-23 14:01:4889 bool OnMessageReceived(const IPC::Message& msg) override;
[email protected]eeb4e4a2011-07-19 16:22:0690
[email protected]ac4b54d2011-10-20 23:09:2891 static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D;
[email protected]5c966022011-09-13 18:09:3792
[email protected]eeb4e4a2011-07-19 16:22:0693 private:
94 void OnMsgCreate(PP_Instance instance,
[email protected]9ed07f82012-05-29 21:54:5595 HostResource share_context,
Vasiliy Telezhnikov2741f482023-05-29 17:23:2696 const Graphics3DContextAttribs& context_attribs,
penghuanga206fb492014-09-09 21:27:3297 HostResource* result,
piman360175c2014-11-07 02:30:0198 gpu::Capabilities* capabilities,
dyen12e45962015-09-18 00:13:5199 SerializedHandle* handle,
lukasza2573ce7d2016-02-16 19:17:22100 gpu::CommandBufferId* command_buffer_id);
avie029c4132015-12-23 06:45:22101 void OnMsgSetGetBuffer(const HostResource& context, int32_t id);
[email protected]7fe4198b2014-03-18 21:52:36102 void OnMsgWaitForTokenInRange(const HostResource& context,
avie029c4132015-12-23 06:45:22103 int32_t start,
104 int32_t end,
[email protected]7fe4198b2014-03-18 21:52:36105 gpu::CommandBuffer::State* state,
106 bool* success);
107 void OnMsgWaitForGetOffsetInRange(const HostResource& context,
Antoine Labourd3469942017-05-16 21:23:42108 uint32_t set_get_buffer_count,
avie029c4132015-12-23 06:45:22109 int32_t start,
110 int32_t end,
[email protected]7fe4198b2014-03-18 21:52:36111 gpu::CommandBuffer::State* state,
112 bool* success);
avie029c4132015-12-23 06:45:22113 void OnMsgAsyncFlush(const HostResource& context, int32_t put_offset);
[email protected]046fa1ac2014-04-01 09:06:43114 void OnMsgCreateTransferBuffer(
115 const HostResource& context,
avie029c4132015-12-23 06:45:22116 uint32_t size,
117 int32_t* id,
[email protected]046fa1ac2014-04-01 09:06:43118 ppapi::proxy::SerializedHandle* transfer_buffer);
avie029c4132015-12-23 06:45:22119 void OnMsgDestroyTransferBuffer(const HostResource& context, int32_t id);
dyenddfdbbb2016-01-14 22:21:38120 void OnMsgSwapBuffers(const HostResource& context,
erikchenb13637b2016-07-08 09:38:56121 const gpu::SyncToken& sync_token,
pimanb36392c22016-07-13 02:11:36122 const gfx::Size& size);
dyen4de3d345f2016-01-12 18:30:42123 void OnMsgEnsureWorkVisible(const HostResource& context);
Vasiliy Telezhnikov2e6fab12022-12-01 17:08:04124 void OnMsgResolveAndDetachFramebuffer(const HostResource& context);
125 void OnMsgResize(const HostResource& context, gfx::Size size);
126
[email protected]eeb4e4a2011-07-19 16:22:06127 // Renderer->plugin message handlers.
[email protected]4d2efd22011-08-18 21:58:02128 void OnMsgSwapBuffersACK(const HostResource& context,
[email protected]be0a84b2011-08-13 04:18:44129 int32_t pp_error);
[email protected]eeb4e4a2011-07-19 16:22:06130
131 void SendSwapBuffersACKToPlugin(int32_t result,
[email protected]4d2efd22011-08-18 21:58:02132 const HostResource& context);
[email protected]eeb4e4a2011-07-19 16:22:06133
[email protected]47a961c2012-07-13 19:18:52134 ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_;
[email protected]eeb4e4a2011-07-19 16:22:06135};
136
137} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:02138} // namespace ppapi
[email protected]eeb4e4a2011-07-19 16:22:06139
140#endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_