blob: 687d66e15c4c533201dae601e7b9c2e205606f79 [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
avie029c4132015-12-23 06:45:228#include <stdint.h>
9
[email protected]eeb4e4a2011-07-19 16:22:0610#include <vector>
11
[email protected]eeb4e4a2011-07-19 16:22:0612#include "gpu/command_buffer/common/command_buffer.h"
lukasza2573ce7d2016-02-16 19:17:2213#include "gpu/command_buffer/common/command_buffer_id.h"
[email protected]fae0e942011-09-07 17:10:4614#include "ppapi/c/pp_graphics_3d.h"
[email protected]eeb4e4a2011-07-19 16:22:0615#include "ppapi/c/pp_instance.h"
[email protected]eeb4e4a2011-07-19 16:22:0616#include "ppapi/proxy/interface_proxy.h"
[email protected]dfb0d06f32014-05-30 22:45:5617#include "ppapi/proxy/ppapi_proxy_export.h"
[email protected]47a961c2012-07-13 19:18:5218#include "ppapi/proxy/proxy_completion_callback_factory.h"
[email protected]9a578392011-12-07 18:59:2719#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
[email protected]7f8b26b2011-08-18 15:41:0120#include "ppapi/shared_impl/resource.h"
[email protected]ae5ff9ae2012-01-06 22:50:3321#include "ppapi/utility/completion_callback_factory.h"
[email protected]eeb4e4a2011-07-19 16:22:0622
piman360175c2014-11-07 02:30:0123namespace gpu {
24struct Capabilities;
Antoine Labourfeab2392017-12-21 20:28:3925struct ContextCreationAttribs;
piman360175c2014-11-07 02:30:0126}
27
[email protected]be0a84b2011-08-13 04:18:4428namespace ppapi {
[email protected]be0a84b2011-08-13 04:18:4429
[email protected]4d2efd22011-08-18 21:58:0230class HostResource;
31
[email protected]eeb4e4a2011-07-19 16:22:0632namespace proxy {
33
[email protected]eb5960da2013-01-16 23:23:5334class SerializedHandle;
[email protected]744e0792013-09-27 01:18:3535class PpapiCommandBufferProxy;
[email protected]eb5960da2013-01-16 23:23:5336
[email protected]dfb0d06f32014-05-30 22:45:5637class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared {
[email protected]eeb4e4a2011-07-19 16:22:0638 public:
Daniele Castagna141a88a2018-07-30 19:41:2339 Graphics3D(const HostResource& resource,
40 const gfx::Size& size,
41 const bool single_buffer);
Peter Boström3d5b3cb2021-09-23 21:35:4542
43 Graphics3D(const Graphics3D&) = delete;
44 Graphics3D& operator=(const Graphics3D&) = delete;
45
nicke4784432015-04-23 14:01:4846 ~Graphics3D() override;
[email protected]eeb4e4a2011-07-19 16:22:0647
penghuanga206fb492014-09-09 21:27:3248 bool Init(gpu::gles2::GLES2Implementation* share_gles2,
piman360175c2014-11-07 02:30:0149 const gpu::Capabilities& capabilities,
Alexandr Ilin15bb7032018-07-13 10:09:0650 SerializedHandle shared_state,
lukasza2573ce7d2016-02-16 19:17:2251 gpu::CommandBufferId command_buffer_id);
[email protected]eeb4e4a2011-07-19 16:22:0652
[email protected]eeb4e4a2011-07-19 16:22:0653 // Graphics3DTrusted API. These are not implemented in the proxy.
nicke4784432015-04-23 14:01:4854 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,
avie029c4132015-12-23 06:45:2257 int32_t* id) override;
nicke4784432015-04-23 14:01:4858 PP_Bool DestroyTransferBuffer(int32_t id) override;
59 gpu::CommandBuffer::State WaitForTokenInRange(int32_t start,
60 int32_t end) override;
Antoine Labourd3469942017-05-16 21:23:4261 gpu::CommandBuffer::State WaitForGetOffsetInRange(
62 uint32_t set_get_buffer_count,
63 int32_t start,
64 int32_t end) override;
dyen4de3d345f2016-01-12 18:30:4265 void EnsureWorkVisible() override;
erikchen438b0442016-05-11 18:33:3066 void TakeFrontBuffer() override;
[email protected]eeb4e4a2011-07-19 16:22:0667
[email protected]84b44c552012-10-15 20:58:1768 private:
[email protected]84b44c552012-10-15 20:58:1769 // PPB_Graphics3D_Shared overrides.
nicke4784432015-04-23 14:01:4870 gpu::CommandBuffer* GetCommandBuffer() override;
71 gpu::GpuControl* GetGpuControl() override;
erikchenb13637b2016-07-08 09:38:5672 int32_t DoSwapBuffers(const gpu::SyncToken& sync_token,
pimanb36392c22016-07-13 02:11:3673 const gfx::Size& size) override;
[email protected]eeb4e4a2011-07-19 16:22:0674
dchengced92242016-04-07 00:00:1275 std::unique_ptr<PpapiCommandBufferProxy> command_buffer_;
[email protected]eeb4e4a2011-07-19 16:22:0676
Eric Karlb6b2c632018-05-07 22:45:0477 uint64_t swap_id_ = 0;
Daniele Castagna141a88a2018-07-30 19:41:2378 bool single_buffer = false;
[email protected]eeb4e4a2011-07-19 16:22:0679};
80
81class PPB_Graphics3D_Proxy : public InterfaceProxy {
82 public:
thestig774686b2015-09-15 19:34:3183 explicit PPB_Graphics3D_Proxy(Dispatcher* dispatcher);
Peter Boström3d5b3cb2021-09-23 21:35:4584
85 PPB_Graphics3D_Proxy(const PPB_Graphics3D_Proxy&) = delete;
86 PPB_Graphics3D_Proxy& operator=(const PPB_Graphics3D_Proxy&) = delete;
87
nicke4784432015-04-23 14:01:4888 ~PPB_Graphics3D_Proxy();
[email protected]eeb4e4a2011-07-19 16:22:0689
[email protected]9ed07f82012-05-29 21:54:5590 static PP_Resource CreateProxyResource(
91 PP_Instance instance,
92 PP_Resource share_context,
93 const int32_t* attrib_list);
[email protected]eeb4e4a2011-07-19 16:22:0694
[email protected]eeb4e4a2011-07-19 16:22:0695 // InterfaceProxy implementation.
nicke4784432015-04-23 14:01:4896 bool OnMessageReceived(const IPC::Message& msg) override;
[email protected]eeb4e4a2011-07-19 16:22:0697
[email protected]ac4b54d2011-10-20 23:09:2898 static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D;
[email protected]5c966022011-09-13 18:09:3799
[email protected]eeb4e4a2011-07-19 16:22:06100 private:
101 void OnMsgCreate(PP_Instance instance,
[email protected]9ed07f82012-05-29 21:54:55102 HostResource share_context,
Antoine Labourfeab2392017-12-21 20:28:39103 const gpu::ContextCreationAttribs& attrib_helper,
penghuanga206fb492014-09-09 21:27:32104 HostResource* result,
piman360175c2014-11-07 02:30:01105 gpu::Capabilities* capabilities,
dyen12e45962015-09-18 00:13:51106 SerializedHandle* handle,
lukasza2573ce7d2016-02-16 19:17:22107 gpu::CommandBufferId* command_buffer_id);
avie029c4132015-12-23 06:45:22108 void OnMsgSetGetBuffer(const HostResource& context, int32_t id);
[email protected]7fe4198b2014-03-18 21:52:36109 void OnMsgWaitForTokenInRange(const HostResource& context,
avie029c4132015-12-23 06:45:22110 int32_t start,
111 int32_t end,
[email protected]7fe4198b2014-03-18 21:52:36112 gpu::CommandBuffer::State* state,
113 bool* success);
114 void OnMsgWaitForGetOffsetInRange(const HostResource& context,
Antoine Labourd3469942017-05-16 21:23:42115 uint32_t set_get_buffer_count,
avie029c4132015-12-23 06:45:22116 int32_t start,
117 int32_t end,
[email protected]7fe4198b2014-03-18 21:52:36118 gpu::CommandBuffer::State* state,
119 bool* success);
avie029c4132015-12-23 06:45:22120 void OnMsgAsyncFlush(const HostResource& context, int32_t put_offset);
[email protected]046fa1ac2014-04-01 09:06:43121 void OnMsgCreateTransferBuffer(
122 const HostResource& context,
avie029c4132015-12-23 06:45:22123 uint32_t size,
124 int32_t* id,
[email protected]046fa1ac2014-04-01 09:06:43125 ppapi::proxy::SerializedHandle* transfer_buffer);
avie029c4132015-12-23 06:45:22126 void OnMsgDestroyTransferBuffer(const HostResource& context, int32_t id);
dyenddfdbbb2016-01-14 22:21:38127 void OnMsgSwapBuffers(const HostResource& context,
erikchenb13637b2016-07-08 09:38:56128 const gpu::SyncToken& sync_token,
pimanb36392c22016-07-13 02:11:36129 const gfx::Size& size);
erikchen438b0442016-05-11 18:33:30130 void OnMsgTakeFrontBuffer(const HostResource& context);
dyen4de3d345f2016-01-12 18:30:42131 void OnMsgEnsureWorkVisible(const HostResource& context);
[email protected]eeb4e4a2011-07-19 16:22:06132 // Renderer->plugin message handlers.
[email protected]4d2efd22011-08-18 21:58:02133 void OnMsgSwapBuffersACK(const HostResource& context,
[email protected]be0a84b2011-08-13 04:18:44134 int32_t pp_error);
[email protected]eeb4e4a2011-07-19 16:22:06135
136 void SendSwapBuffersACKToPlugin(int32_t result,
[email protected]4d2efd22011-08-18 21:58:02137 const HostResource& context);
[email protected]eeb4e4a2011-07-19 16:22:06138
[email protected]47a961c2012-07-13 19:18:52139 ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_;
[email protected]eeb4e4a2011-07-19 16:22:06140};
141
142} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:02143} // namespace ppapi
[email protected]eeb4e4a2011-07-19 16:22:06144
145#endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_