Revert 251029 "Move Windows-specific code into NativeAppWindowVi..."
[chromium-blink-merge.git] / ppapi / proxy / ppb_graphics_3d_proxy.h
blob18ba9dd5e3c54fd9c121ed585e501b0400ec1e10
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_
6 #define PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_
8 #include <vector>
10 #include "base/memory/shared_memory.h"
11 #include "gpu/command_buffer/common/command_buffer.h"
12 #include "ppapi/c/pp_graphics_3d.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/proxy/interface_proxy.h"
15 #include "ppapi/proxy/proxy_completion_callback_factory.h"
16 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
17 #include "ppapi/shared_impl/resource.h"
18 #include "ppapi/utility/completion_callback_factory.h"
20 namespace ppapi {
22 class HostResource;
24 namespace proxy {
26 class SerializedHandle;
27 class PpapiCommandBufferProxy;
29 class Graphics3D : public PPB_Graphics3D_Shared {
30 public:
31 explicit Graphics3D(const HostResource& resource);
32 virtual ~Graphics3D();
34 bool Init(gpu::gles2::GLES2Implementation* share_gles2);
36 // Graphics3DTrusted API. These are not implemented in the proxy.
37 virtual PP_Bool SetGetBuffer(int32_t shm_id) OVERRIDE;
38 virtual gpu::CommandBuffer::State GetState() OVERRIDE;
39 virtual PP_Bool Flush(int32_t put_offset) OVERRIDE;
40 virtual gpu::CommandBuffer::State FlushSync(int32_t put_offset) OVERRIDE;
41 virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE;
42 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE;
43 virtual PP_Bool GetTransferBuffer(int32_t id,
44 int* shm_handle,
45 uint32_t* shm_size) OVERRIDE;
46 virtual gpu::CommandBuffer::State FlushSyncFast(
47 int32_t put_offset,
48 int32_t last_known_get) OVERRIDE;
49 virtual uint32_t InsertSyncPoint() OVERRIDE;
51 private:
52 // PPB_Graphics3D_Shared overrides.
53 virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE;
54 virtual gpu::GpuControl* GetGpuControl() OVERRIDE;
55 virtual int32 DoSwapBuffers() OVERRIDE;
57 scoped_ptr<PpapiCommandBufferProxy> command_buffer_;
59 DISALLOW_COPY_AND_ASSIGN(Graphics3D);
62 class PPB_Graphics3D_Proxy : public InterfaceProxy {
63 public:
64 PPB_Graphics3D_Proxy(Dispatcher* dispatcher);
65 virtual ~PPB_Graphics3D_Proxy();
67 static PP_Resource CreateProxyResource(
68 PP_Instance instance,
69 PP_Resource share_context,
70 const int32_t* attrib_list);
72 // InterfaceProxy implementation.
73 virtual bool OnMessageReceived(const IPC::Message& msg);
75 static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D;
77 private:
78 void OnMsgCreate(PP_Instance instance,
79 HostResource share_context,
80 const std::vector<int32_t>& attribs,
81 HostResource* result);
82 void OnMsgSetGetBuffer(const HostResource& context,
83 int32 id);
84 void OnMsgGetState(const HostResource& context,
85 gpu::CommandBuffer::State* state,
86 bool* success);
87 void OnMsgFlush(const HostResource& context,
88 int32 put_offset,
89 int32 last_known_get,
90 gpu::CommandBuffer::State* state,
91 bool* success);
92 void OnMsgAsyncFlush(const HostResource& context,
93 int32 put_offset);
94 void OnMsgCreateTransferBuffer(const HostResource& context,
95 uint32 size,
96 int32* id);
97 void OnMsgDestroyTransferBuffer(const HostResource& context,
98 int32 id);
99 void OnMsgGetTransferBuffer(const HostResource& context,
100 int32 id,
101 ppapi::proxy::SerializedHandle* transfer_buffer);
102 void OnMsgSwapBuffers(const HostResource& context);
103 void OnMsgInsertSyncPoint(const HostResource& context, uint32* sync_point);
104 // Renderer->plugin message handlers.
105 void OnMsgSwapBuffersACK(const HostResource& context,
106 int32_t pp_error);
108 void SendSwapBuffersACKToPlugin(int32_t result,
109 const HostResource& context);
111 ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_;
113 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy);
116 } // namespace proxy
117 } // namespace ppapi
119 #endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_