blob: 54c4c7a75f98b4ee92f500d1b144922f416ee749 [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
avie029c4132015-12-23 06:45:2212#include "base/macros.h"
[email protected]eeb4e4a2011-07-19 16:22:0613#include "gpu/command_buffer/common/command_buffer.h"
lukasza2573ce7d2016-02-16 19:17:2214#include "gpu/command_buffer/common/command_buffer_id.h"
[email protected]fae0e942011-09-07 17:10:4615#include "ppapi/c/pp_graphics_3d.h"
[email protected]eeb4e4a2011-07-19 16:22:0616#include "ppapi/c/pp_instance.h"
[email protected]eeb4e4a2011-07-19 16:22:0617#include "ppapi/proxy/interface_proxy.h"
[email protected]dfb0d06f32014-05-30 22:45:5618#include "ppapi/proxy/ppapi_proxy_export.h"
[email protected]47a961c2012-07-13 19:18:5219#include "ppapi/proxy/proxy_completion_callback_factory.h"
[email protected]9a578392011-12-07 18:59:2720#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
[email protected]7f8b26b2011-08-18 15:41:0121#include "ppapi/shared_impl/resource.h"
[email protected]ae5ff9ae2012-01-06 22:50:3322#include "ppapi/utility/completion_callback_factory.h"
[email protected]eeb4e4a2011-07-19 16:22:0623
piman360175c2014-11-07 02:30:0124namespace gpu {
pimanfe4e4882016-07-09 01:18:2125namespace gles2 {
26struct ContextCreationAttribHelper;
27}
piman360175c2014-11-07 02:30:0128struct Capabilities;
29}
30
[email protected]be0a84b2011-08-13 04:18:4431namespace ppapi {
[email protected]be0a84b2011-08-13 04:18:4432
[email protected]4d2efd22011-08-18 21:58:0233class HostResource;
34
[email protected]eeb4e4a2011-07-19 16:22:0635namespace proxy {
36
[email protected]eb5960da2013-01-16 23:23:5337class SerializedHandle;
[email protected]744e0792013-09-27 01:18:3538class PpapiCommandBufferProxy;
[email protected]eb5960da2013-01-16 23:23:5339
[email protected]dfb0d06f32014-05-30 22:45:5640class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared {
[email protected]eeb4e4a2011-07-19 16:22:0641 public:
pimanb36392c22016-07-13 02:11:3642 Graphics3D(const HostResource& resource, const gfx::Size& size);
nicke4784432015-04-23 14:01:4843 ~Graphics3D() override;
[email protected]eeb4e4a2011-07-19 16:22:0644
penghuanga206fb492014-09-09 21:27:3245 bool Init(gpu::gles2::GLES2Implementation* share_gles2,
piman360175c2014-11-07 02:30:0146 const gpu::Capabilities& capabilities,
dyen12e45962015-09-18 00:13:5147 const SerializedHandle& shared_state,
lukasza2573ce7d2016-02-16 19:17:2248 gpu::CommandBufferId command_buffer_id);
[email protected]eeb4e4a2011-07-19 16:22:0649
[email protected]eeb4e4a2011-07-19 16:22:0650 // Graphics3DTrusted API. These are not implemented in the proxy.
nicke4784432015-04-23 14:01:4851 PP_Bool SetGetBuffer(int32_t shm_id) override;
52 PP_Bool Flush(int32_t put_offset) override;
53 scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size,
avie029c4132015-12-23 06:45:2254 int32_t* id) override;
nicke4784432015-04-23 14:01:4855 PP_Bool DestroyTransferBuffer(int32_t id) override;
56 gpu::CommandBuffer::State WaitForTokenInRange(int32_t start,
57 int32_t end) override;
58 gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start,
59 int32_t end) override;
dyen4de3d345f2016-01-12 18:30:4260 void EnsureWorkVisible() override;
erikchen438b0442016-05-11 18:33:3061 void TakeFrontBuffer() 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;
[email protected]eeb4e4a2011-07-19 16:22:0669
dchengced92242016-04-07 00:00:1270 std::unique_ptr<PpapiCommandBufferProxy> command_buffer_;
[email protected]eeb4e4a2011-07-19 16:22:0671
72 DISALLOW_COPY_AND_ASSIGN(Graphics3D);
73};
74
75class PPB_Graphics3D_Proxy : public InterfaceProxy {
76 public:
thestig774686b2015-09-15 19:34:3177 explicit PPB_Graphics3D_Proxy(Dispatcher* dispatcher);
nicke4784432015-04-23 14:01:4878 ~PPB_Graphics3D_Proxy();
[email protected]eeb4e4a2011-07-19 16:22:0679
[email protected]9ed07f82012-05-29 21:54:5580 static PP_Resource CreateProxyResource(
81 PP_Instance instance,
82 PP_Resource share_context,
83 const int32_t* attrib_list);
[email protected]eeb4e4a2011-07-19 16:22:0684
[email protected]eeb4e4a2011-07-19 16:22:0685 // InterfaceProxy implementation.
nicke4784432015-04-23 14:01:4886 bool OnMessageReceived(const IPC::Message& msg) override;
[email protected]eeb4e4a2011-07-19 16:22:0687
[email protected]ac4b54d2011-10-20 23:09:2888 static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D;
[email protected]5c966022011-09-13 18:09:3789
[email protected]eeb4e4a2011-07-19 16:22:0690 private:
91 void OnMsgCreate(PP_Instance instance,
[email protected]9ed07f82012-05-29 21:54:5592 HostResource share_context,
pimanfe4e4882016-07-09 01:18:2193 const gpu::gles2::ContextCreationAttribHelper& attrib_helper,
penghuanga206fb492014-09-09 21:27:3294 HostResource* result,
piman360175c2014-11-07 02:30:0195 gpu::Capabilities* capabilities,
dyen12e45962015-09-18 00:13:5196 SerializedHandle* handle,
lukasza2573ce7d2016-02-16 19:17:2297 gpu::CommandBufferId* command_buffer_id);
avie029c4132015-12-23 06:45:2298 void OnMsgSetGetBuffer(const HostResource& context, int32_t id);
[email protected]7fe4198b2014-03-18 21:52:3699 void OnMsgWaitForTokenInRange(const HostResource& context,
avie029c4132015-12-23 06:45:22100 int32_t start,
101 int32_t end,
[email protected]7fe4198b2014-03-18 21:52:36102 gpu::CommandBuffer::State* state,
103 bool* success);
104 void OnMsgWaitForGetOffsetInRange(const HostResource& context,
avie029c4132015-12-23 06:45:22105 int32_t start,
106 int32_t end,
[email protected]7fe4198b2014-03-18 21:52:36107 gpu::CommandBuffer::State* state,
108 bool* success);
avie029c4132015-12-23 06:45:22109 void OnMsgAsyncFlush(const HostResource& context, int32_t put_offset);
[email protected]046fa1ac2014-04-01 09:06:43110 void OnMsgCreateTransferBuffer(
111 const HostResource& context,
avie029c4132015-12-23 06:45:22112 uint32_t size,
113 int32_t* id,
[email protected]046fa1ac2014-04-01 09:06:43114 ppapi::proxy::SerializedHandle* transfer_buffer);
avie029c4132015-12-23 06:45:22115 void OnMsgDestroyTransferBuffer(const HostResource& context, int32_t id);
dyenddfdbbb2016-01-14 22:21:38116 void OnMsgSwapBuffers(const HostResource& context,
erikchenb13637b2016-07-08 09:38:56117 const gpu::SyncToken& sync_token,
pimanb36392c22016-07-13 02:11:36118 const gfx::Size& size);
erikchen438b0442016-05-11 18:33:30119 void OnMsgTakeFrontBuffer(const HostResource& context);
dyen4de3d345f2016-01-12 18:30:42120 void OnMsgEnsureWorkVisible(const HostResource& context);
[email protected]eeb4e4a2011-07-19 16:22:06121 // Renderer->plugin message handlers.
[email protected]4d2efd22011-08-18 21:58:02122 void OnMsgSwapBuffersACK(const HostResource& context,
[email protected]be0a84b2011-08-13 04:18:44123 int32_t pp_error);
[email protected]eeb4e4a2011-07-19 16:22:06124
125 void SendSwapBuffersACKToPlugin(int32_t result,
[email protected]4d2efd22011-08-18 21:58:02126 const HostResource& context);
[email protected]eeb4e4a2011-07-19 16:22:06127
[email protected]47a961c2012-07-13 19:18:52128 ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_;
[email protected]eeb4e4a2011-07-19 16:22:06129
130 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy);
131};
132
133} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:02134} // namespace ppapi
[email protected]eeb4e4a2011-07-19 16:22:06135
136#endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_
137