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