Avi Drissman | db497b3 | 2022-09-15 19:47:28 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 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_PPB_GRAPHICS_3D_PROXY_H_ |
| 6 | #define PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ |
| 7 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 10 | #include "gpu/command_buffer/common/command_buffer.h" |
lukasza | 2573ce7d | 2016-02-16 19:17:22 | [diff] [blame] | 11 | #include "gpu/command_buffer/common/command_buffer_id.h" |
[email protected] | fae0e94 | 2011-09-07 17:10:46 | [diff] [blame] | 12 | #include "ppapi/c/pp_graphics_3d.h" |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 13 | #include "ppapi/c/pp_instance.h" |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 14 | #include "ppapi/proxy/interface_proxy.h" |
[email protected] | dfb0d06f3 | 2014-05-30 22:45:56 | [diff] [blame] | 15 | #include "ppapi/proxy/ppapi_proxy_export.h" |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 16 | #include "ppapi/proxy/proxy_completion_callback_factory.h" |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 17 | #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 18 | #include "ppapi/shared_impl/resource.h" |
[email protected] | ae5ff9ae | 2012-01-06 22:50:33 | [diff] [blame] | 19 | #include "ppapi/utility/completion_callback_factory.h" |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 20 | |
piman | 360175c | 2014-11-07 02:30:01 | [diff] [blame] | 21 | namespace gpu { |
| 22 | struct Capabilities; |
piman | 360175c | 2014-11-07 02:30:01 | [diff] [blame] | 23 | } |
| 24 | |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 25 | namespace ppapi { |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 26 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 27 | class HostResource; |
| 28 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 29 | namespace proxy { |
| 30 | |
[email protected] | eb5960da | 2013-01-16 23:23:53 | [diff] [blame] | 31 | class SerializedHandle; |
[email protected] | 744e079 | 2013-09-27 01:18:35 | [diff] [blame] | 32 | class PpapiCommandBufferProxy; |
[email protected] | eb5960da | 2013-01-16 23:23:53 | [diff] [blame] | 33 | |
[email protected] | dfb0d06f3 | 2014-05-30 22:45:56 | [diff] [blame] | 34 | class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared { |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 35 | public: |
Vasiliy Telezhnikov | 2a78645 | 2023-05-12 23:53:37 | [diff] [blame] | 36 | Graphics3D(const HostResource& resource, const gfx::Size& size); |
Peter Boström | 3d5b3cb | 2021-09-23 21:35:45 | [diff] [blame] | 37 | |
| 38 | Graphics3D(const Graphics3D&) = delete; |
| 39 | Graphics3D& operator=(const Graphics3D&) = delete; |
| 40 | |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 41 | ~Graphics3D() override; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 42 | |
penghuang | a206fb49 | 2014-09-09 21:27:32 | [diff] [blame] | 43 | bool Init(gpu::gles2::GLES2Implementation* share_gles2, |
piman | 360175c | 2014-11-07 02:30:01 | [diff] [blame] | 44 | const gpu::Capabilities& capabilities, |
Alexandr Ilin | 15bb703 | 2018-07-13 10:09:06 | [diff] [blame] | 45 | SerializedHandle shared_state, |
lukasza | 2573ce7d | 2016-02-16 19:17:22 | [diff] [blame] | 46 | gpu::CommandBufferId command_buffer_id); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 47 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 48 | // Graphics3DTrusted API. These are not implemented in the proxy. |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 49 | 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, |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 52 | int32_t* id) override; |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 53 | PP_Bool DestroyTransferBuffer(int32_t id) override; |
| 54 | gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, |
| 55 | int32_t end) override; |
Antoine Labour | d346994 | 2017-05-16 21:23:42 | [diff] [blame] | 56 | gpu::CommandBuffer::State WaitForGetOffsetInRange( |
| 57 | uint32_t set_get_buffer_count, |
| 58 | int32_t start, |
| 59 | int32_t end) override; |
dyen | 4de3d345f | 2016-01-12 18:30:42 | [diff] [blame] | 60 | void EnsureWorkVisible() override; |
Vasiliy Telezhnikov | 2e6fab1 | 2022-12-01 17:08:04 | [diff] [blame] | 61 | void ResolveAndDetachFramebuffer() override; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 62 | |
[email protected] | 84b44c55 | 2012-10-15 20:58:17 | [diff] [blame] | 63 | private: |
[email protected] | 84b44c55 | 2012-10-15 20:58:17 | [diff] [blame] | 64 | // PPB_Graphics3D_Shared overrides. |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 65 | gpu::CommandBuffer* GetCommandBuffer() override; |
| 66 | gpu::GpuControl* GetGpuControl() override; |
erikchen | b13637b | 2016-07-08 09:38:56 | [diff] [blame] | 67 | int32_t DoSwapBuffers(const gpu::SyncToken& sync_token, |
piman | b36392c2 | 2016-07-13 02:11:36 | [diff] [blame] | 68 | const gfx::Size& size) override; |
Vasiliy Telezhnikov | 2e6fab1 | 2022-12-01 17:08:04 | [diff] [blame] | 69 | void DoResize(gfx::Size size) override; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 70 | |
dcheng | ced9224 | 2016-04-07 00:00:12 | [diff] [blame] | 71 | std::unique_ptr<PpapiCommandBufferProxy> command_buffer_; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | class PPB_Graphics3D_Proxy : public InterfaceProxy { |
| 75 | public: |
thestig | 774686b | 2015-09-15 19:34:31 | [diff] [blame] | 76 | explicit PPB_Graphics3D_Proxy(Dispatcher* dispatcher); |
Peter Boström | 3d5b3cb | 2021-09-23 21:35:45 | [diff] [blame] | 77 | |
| 78 | PPB_Graphics3D_Proxy(const PPB_Graphics3D_Proxy&) = delete; |
| 79 | PPB_Graphics3D_Proxy& operator=(const PPB_Graphics3D_Proxy&) = delete; |
| 80 | |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 81 | ~PPB_Graphics3D_Proxy(); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 82 | |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 83 | static PP_Resource CreateProxyResource( |
| 84 | PP_Instance instance, |
| 85 | PP_Resource share_context, |
| 86 | const int32_t* attrib_list); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 87 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 88 | // InterfaceProxy implementation. |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 89 | bool OnMessageReceived(const IPC::Message& msg) override; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 90 | |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 91 | static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D; |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 92 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 93 | private: |
| 94 | void OnMsgCreate(PP_Instance instance, |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 95 | HostResource share_context, |
Vasiliy Telezhnikov | 2741f48 | 2023-05-29 17:23:26 | [diff] [blame] | 96 | const Graphics3DContextAttribs& context_attribs, |
penghuang | a206fb49 | 2014-09-09 21:27:32 | [diff] [blame] | 97 | HostResource* result, |
piman | 360175c | 2014-11-07 02:30:01 | [diff] [blame] | 98 | gpu::Capabilities* capabilities, |
dyen | 12e4596 | 2015-09-18 00:13:51 | [diff] [blame] | 99 | SerializedHandle* handle, |
lukasza | 2573ce7d | 2016-02-16 19:17:22 | [diff] [blame] | 100 | gpu::CommandBufferId* command_buffer_id); |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 101 | void OnMsgSetGetBuffer(const HostResource& context, int32_t id); |
[email protected] | 7fe4198b | 2014-03-18 21:52:36 | [diff] [blame] | 102 | void OnMsgWaitForTokenInRange(const HostResource& context, |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 103 | int32_t start, |
| 104 | int32_t end, |
[email protected] | 7fe4198b | 2014-03-18 21:52:36 | [diff] [blame] | 105 | gpu::CommandBuffer::State* state, |
| 106 | bool* success); |
| 107 | void OnMsgWaitForGetOffsetInRange(const HostResource& context, |
Antoine Labour | d346994 | 2017-05-16 21:23:42 | [diff] [blame] | 108 | uint32_t set_get_buffer_count, |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 109 | int32_t start, |
| 110 | int32_t end, |
[email protected] | 7fe4198b | 2014-03-18 21:52:36 | [diff] [blame] | 111 | gpu::CommandBuffer::State* state, |
| 112 | bool* success); |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 113 | void OnMsgAsyncFlush(const HostResource& context, int32_t put_offset); |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 114 | void OnMsgCreateTransferBuffer( |
| 115 | const HostResource& context, |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 116 | uint32_t size, |
| 117 | int32_t* id, |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 118 | ppapi::proxy::SerializedHandle* transfer_buffer); |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 119 | void OnMsgDestroyTransferBuffer(const HostResource& context, int32_t id); |
dyen | ddfdbbb | 2016-01-14 22:21:38 | [diff] [blame] | 120 | void OnMsgSwapBuffers(const HostResource& context, |
erikchen | b13637b | 2016-07-08 09:38:56 | [diff] [blame] | 121 | const gpu::SyncToken& sync_token, |
piman | b36392c2 | 2016-07-13 02:11:36 | [diff] [blame] | 122 | const gfx::Size& size); |
dyen | 4de3d345f | 2016-01-12 18:30:42 | [diff] [blame] | 123 | void OnMsgEnsureWorkVisible(const HostResource& context); |
Vasiliy Telezhnikov | 2e6fab1 | 2022-12-01 17:08:04 | [diff] [blame] | 124 | void OnMsgResolveAndDetachFramebuffer(const HostResource& context); |
| 125 | void OnMsgResize(const HostResource& context, gfx::Size size); |
| 126 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 127 | // Renderer->plugin message handlers. |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 128 | void OnMsgSwapBuffersACK(const HostResource& context, |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 129 | int32_t pp_error); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 130 | |
| 131 | void SendSwapBuffersACKToPlugin(int32_t result, |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 132 | const HostResource& context); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 133 | |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 134 | ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 138 | } // namespace ppapi |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 139 | |
| 140 | #endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ |