blob: de6afd0e255707f438ce3270e8a0af105858b117 [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
8#include <vector>
9
10#include "base/shared_memory.h"
11#include "gpu/command_buffer/common/command_buffer.h"
[email protected]fae0e942011-09-07 17:10:4612#include "ppapi/c/pp_graphics_3d.h"
[email protected]eeb4e4a2011-07-19 16:22:0613#include "ppapi/c/pp_instance.h"
[email protected]eeb4e4a2011-07-19 16:22:0614#include "ppapi/proxy/interface_proxy.h"
[email protected]47a961c2012-07-13 19:18:5215#include "ppapi/proxy/proxy_completion_callback_factory.h"
[email protected]246fc492012-08-27 20:28:1816#include "ppapi/proxy/serialized_structs.h"
[email protected]9a578392011-12-07 18:59:2717#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
[email protected]7f8b26b2011-08-18 15:41:0118#include "ppapi/shared_impl/resource.h"
[email protected]ae5ff9ae2012-01-06 22:50:3319#include "ppapi/utility/completion_callback_factory.h"
[email protected]eeb4e4a2011-07-19 16:22:0620
[email protected]be0a84b2011-08-13 04:18:4421namespace ppapi {
[email protected]be0a84b2011-08-13 04:18:4422
[email protected]4d2efd22011-08-18 21:58:0223class HostResource;
24
[email protected]eeb4e4a2011-07-19 16:22:0625namespace proxy {
26
[email protected]614888b2012-01-05 06:18:1227class Graphics3D : public PPB_Graphics3D_Shared {
[email protected]eeb4e4a2011-07-19 16:22:0628 public:
[email protected]4d2efd22011-08-18 21:58:0229 explicit Graphics3D(const HostResource& resource);
[email protected]eeb4e4a2011-07-19 16:22:0630 virtual ~Graphics3D();
31
[email protected]9ed07f82012-05-29 21:54:5532 bool Init(gpu::gles2::GLES2Implementation* share_gles2);
[email protected]eeb4e4a2011-07-19 16:22:0633
[email protected]eeb4e4a2011-07-19 16:22:0634 // Graphics3DTrusted API. These are not implemented in the proxy.
[email protected]503b3a22011-12-12 23:29:4035 virtual PP_Bool InitCommandBuffer() OVERRIDE;
36 virtual PP_Bool SetGetBuffer(int32_t shm_id) OVERRIDE;
[email protected]eeb4e4a2011-07-19 16:22:0637 virtual PP_Graphics3DTrustedState GetState() OVERRIDE;
38 virtual PP_Bool Flush(int32_t put_offset) OVERRIDE;
39 virtual PP_Graphics3DTrustedState FlushSync(int32_t put_offset) OVERRIDE;
40 virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE;
41 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE;
42 virtual PP_Bool GetTransferBuffer(int32_t id,
43 int* shm_handle,
44 uint32_t* shm_size) OVERRIDE;
45 virtual PP_Graphics3DTrustedState FlushSyncFast(
46 int32_t put_offset,
47 int32_t last_known_get) OVERRIDE;
48
[email protected]84b44c552012-10-15 20:58:1749 private:
50 class LockingCommandBuffer;
51
52 // PPB_Graphics3D_Shared overrides.
[email protected]eeb4e4a2011-07-19 16:22:0653 virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE;
54 virtual int32 DoSwapBuffers() OVERRIDE;
[email protected]84b44c552012-10-15 20:58:1755 virtual void PushAlreadyLocked() OVERRIDE;
56 virtual void PopAlreadyLocked() OVERRIDE;
[email protected]eeb4e4a2011-07-19 16:22:0657
[email protected]84b44c552012-10-15 20:58:1758 int num_already_locked_calls_;
[email protected]eeb4e4a2011-07-19 16:22:0659 scoped_ptr<gpu::CommandBuffer> command_buffer_;
[email protected]84b44c552012-10-15 20:58:1760 scoped_ptr<LockingCommandBuffer> locking_command_buffer_;
[email protected]eeb4e4a2011-07-19 16:22:0661
62 DISALLOW_COPY_AND_ASSIGN(Graphics3D);
63};
64
65class PPB_Graphics3D_Proxy : public InterfaceProxy {
66 public:
[email protected]5c966022011-09-13 18:09:3767 PPB_Graphics3D_Proxy(Dispatcher* dispatcher);
[email protected]eeb4e4a2011-07-19 16:22:0668 virtual ~PPB_Graphics3D_Proxy();
69
[email protected]9ed07f82012-05-29 21:54:5570 static PP_Resource CreateProxyResource(
71 PP_Instance instance,
72 PP_Resource share_context,
73 const int32_t* attrib_list);
[email protected]eeb4e4a2011-07-19 16:22:0674
[email protected]eeb4e4a2011-07-19 16:22:0675 // InterfaceProxy implementation.
76 virtual bool OnMessageReceived(const IPC::Message& msg);
77
[email protected]ac4b54d2011-10-20 23:09:2878 static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D;
[email protected]5c966022011-09-13 18:09:3779
[email protected]eeb4e4a2011-07-19 16:22:0680 private:
81 void OnMsgCreate(PP_Instance instance,
[email protected]9ed07f82012-05-29 21:54:5582 HostResource share_context,
[email protected]eeb4e4a2011-07-19 16:22:0683 const std::vector<int32_t>& attribs,
[email protected]4d2efd22011-08-18 21:58:0284 HostResource* result);
[email protected]503b3a22011-12-12 23:29:4085 void OnMsgInitCommandBuffer(const HostResource& context);
86 void OnMsgSetGetBuffer(const HostResource& context,
87 int32 id);
[email protected]4d2efd22011-08-18 21:58:0288 void OnMsgGetState(const HostResource& context,
[email protected]571b35e82012-05-19 00:04:3589 gpu::CommandBuffer::State* state,
90 bool* success);
[email protected]4d2efd22011-08-18 21:58:0291 void OnMsgFlush(const HostResource& context,
[email protected]eeb4e4a2011-07-19 16:22:0692 int32 put_offset,
93 int32 last_known_get,
[email protected]571b35e82012-05-19 00:04:3594 gpu::CommandBuffer::State* state,
95 bool* success);
[email protected]4d2efd22011-08-18 21:58:0296 void OnMsgAsyncFlush(const HostResource& context,
[email protected]eeb4e4a2011-07-19 16:22:0697 int32 put_offset);
[email protected]4d2efd22011-08-18 21:58:0298 void OnMsgCreateTransferBuffer(const HostResource& context,
[email protected]eeb4e4a2011-07-19 16:22:0699 int32 size,
100 int32* id);
[email protected]4d2efd22011-08-18 21:58:02101 void OnMsgDestroyTransferBuffer(const HostResource& context,
[email protected]eeb4e4a2011-07-19 16:22:06102 int32 id);
[email protected]4d2efd22011-08-18 21:58:02103 void OnMsgGetTransferBuffer(const HostResource& context,
[email protected]eeb4e4a2011-07-19 16:22:06104 int32 id,
[email protected]246fc492012-08-27 20:28:18105 ppapi::proxy::SerializedHandle* transfer_buffer);
[email protected]4d2efd22011-08-18 21:58:02106 void OnMsgSwapBuffers(const HostResource& context);
[email protected]eeb4e4a2011-07-19 16:22:06107 // Renderer->plugin message handlers.
[email protected]4d2efd22011-08-18 21:58:02108 void OnMsgSwapBuffersACK(const HostResource& context,
[email protected]be0a84b2011-08-13 04:18:44109 int32_t pp_error);
[email protected]eeb4e4a2011-07-19 16:22:06110
111 void SendSwapBuffersACKToPlugin(int32_t result,
[email protected]4d2efd22011-08-18 21:58:02112 const HostResource& context);
[email protected]eeb4e4a2011-07-19 16:22:06113
[email protected]47a961c2012-07-13 19:18:52114 ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_;
[email protected]eeb4e4a2011-07-19 16:22:06115
116 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy);
117};
118
119} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:02120} // namespace ppapi
[email protected]eeb4e4a2011-07-19 16:22:06121
122#endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_
123