[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 | |
| 8 | #include <vector> |
| 9 | |
[email protected] | 8299b71 | 2013-07-17 19:55:23 | [diff] [blame] | 10 | #include "base/memory/shared_memory.h" |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 11 | #include "gpu/command_buffer/common/command_buffer.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; |
| 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: |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 36 | explicit Graphics3D(const HostResource& resource); |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame^] | 37 | ~Graphics3D() override; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 38 | |
penghuang | a206fb49 | 2014-09-09 21:27:32 | [diff] [blame] | 39 | bool Init(gpu::gles2::GLES2Implementation* share_gles2, |
piman | 360175c | 2014-11-07 02:30:01 | [diff] [blame] | 40 | const gpu::Capabilities& capabilities, |
penghuang | a206fb49 | 2014-09-09 21:27:32 | [diff] [blame] | 41 | const SerializedHandle& shared_state); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 42 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 43 | // Graphics3DTrusted API. These are not implemented in the proxy. |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame^] | 44 | PP_Bool SetGetBuffer(int32_t shm_id) override; |
| 45 | PP_Bool Flush(int32_t put_offset) override; |
| 46 | scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size, |
| 47 | int32* id) override; |
| 48 | PP_Bool DestroyTransferBuffer(int32_t id) override; |
| 49 | gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, |
| 50 | int32_t end) override; |
| 51 | gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start, |
| 52 | int32_t end) override; |
| 53 | uint32_t InsertSyncPoint() override; |
| 54 | uint32_t InsertFutureSyncPoint() override; |
| 55 | void RetireSyncPoint(uint32_t sync_point) override; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 56 | |
[email protected] | 84b44c55 | 2012-10-15 20:58:17 | [diff] [blame] | 57 | private: |
[email protected] | 84b44c55 | 2012-10-15 20:58:17 | [diff] [blame] | 58 | // PPB_Graphics3D_Shared overrides. |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame^] | 59 | gpu::CommandBuffer* GetCommandBuffer() override; |
| 60 | gpu::GpuControl* GetGpuControl() override; |
| 61 | int32 DoSwapBuffers() override; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 62 | |
[email protected] | 744e079 | 2013-09-27 01:18:35 | [diff] [blame] | 63 | scoped_ptr<PpapiCommandBufferProxy> command_buffer_; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 64 | |
| 65 | DISALLOW_COPY_AND_ASSIGN(Graphics3D); |
| 66 | }; |
| 67 | |
| 68 | class PPB_Graphics3D_Proxy : public InterfaceProxy { |
| 69 | public: |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 70 | PPB_Graphics3D_Proxy(Dispatcher* dispatcher); |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame^] | 71 | ~PPB_Graphics3D_Proxy(); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 72 | |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 73 | static PP_Resource CreateProxyResource( |
| 74 | PP_Instance instance, |
| 75 | PP_Resource share_context, |
| 76 | const int32_t* attrib_list); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 77 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 78 | // InterfaceProxy implementation. |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame^] | 79 | bool OnMessageReceived(const IPC::Message& msg) override; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 80 | |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 81 | static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D; |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 82 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 83 | private: |
| 84 | void OnMsgCreate(PP_Instance instance, |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 85 | HostResource share_context, |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 86 | const std::vector<int32_t>& attribs, |
penghuang | a206fb49 | 2014-09-09 21:27:32 | [diff] [blame] | 87 | HostResource* result, |
piman | 360175c | 2014-11-07 02:30:01 | [diff] [blame] | 88 | gpu::Capabilities* capabilities, |
penghuang | a206fb49 | 2014-09-09 21:27:32 | [diff] [blame] | 89 | SerializedHandle* handle); |
[email protected] | 503b3a2 | 2011-12-12 23:29:40 | [diff] [blame] | 90 | void OnMsgSetGetBuffer(const HostResource& context, |
| 91 | int32 id); |
[email protected] | 7fe4198b | 2014-03-18 21:52:36 | [diff] [blame] | 92 | void OnMsgWaitForTokenInRange(const HostResource& context, |
| 93 | int32 start, |
| 94 | int32 end, |
| 95 | gpu::CommandBuffer::State* state, |
| 96 | bool* success); |
| 97 | void OnMsgWaitForGetOffsetInRange(const HostResource& context, |
| 98 | int32 start, |
| 99 | int32 end, |
| 100 | gpu::CommandBuffer::State* state, |
| 101 | bool* success); |
| 102 | void OnMsgAsyncFlush(const HostResource& context, int32 put_offset); |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 103 | void OnMsgCreateTransferBuffer( |
| 104 | const HostResource& context, |
| 105 | uint32 size, |
| 106 | int32* id, |
| 107 | ppapi::proxy::SerializedHandle* transfer_buffer); |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 108 | void OnMsgDestroyTransferBuffer(const HostResource& context, |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 109 | int32 id); |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 110 | void OnMsgSwapBuffers(const HostResource& context); |
[email protected] | b096d03 | 2013-03-08 03:08:01 | [diff] [blame] | 111 | void OnMsgInsertSyncPoint(const HostResource& context, uint32* sync_point); |
[email protected] | 7035bc9 | 2014-07-01 00:27:22 | [diff] [blame] | 112 | void OnMsgInsertFutureSyncPoint(const HostResource& context, |
| 113 | uint32* sync_point); |
| 114 | void OnMsgRetireSyncPoint(const HostResource& context, uint32 sync_point); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 115 | // Renderer->plugin message handlers. |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 116 | void OnMsgSwapBuffersACK(const HostResource& context, |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 117 | int32_t pp_error); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 118 | |
| 119 | void SendSwapBuffersACKToPlugin(int32_t result, |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 120 | const HostResource& context); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 121 | |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 122 | ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 123 | |
| 124 | DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy); |
| 125 | }; |
| 126 | |
| 127 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 128 | } // namespace ppapi |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 129 | |
| 130 | #endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ |
| 131 | |