Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / ppapi / proxy / ppb_graphics_3d_proxy.h
blob931b84f607f95d6f5afeac69045b65f9c406469f
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 PP_Bool Flush(int32_t put_offset) OVERRIDE;
39 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size,
40 int32* id) OVERRIDE;
41 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE;
42 virtual gpu::CommandBuffer::State WaitForTokenInRange(int32_t start,
43 int32_t end) OVERRIDE;
44 virtual gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start,
45 int32_t end)
46 OVERRIDE;
47 virtual uint32_t InsertSyncPoint() OVERRIDE;
49 private:
50 // PPB_Graphics3D_Shared overrides.
51 virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE;
52 virtual gpu::GpuControl* GetGpuControl() OVERRIDE;
53 virtual int32 DoSwapBuffers() OVERRIDE;
55 scoped_ptr<PpapiCommandBufferProxy> command_buffer_;
57 DISALLOW_COPY_AND_ASSIGN(Graphics3D);
60 class PPB_Graphics3D_Proxy : public InterfaceProxy {
61 public:
62 PPB_Graphics3D_Proxy(Dispatcher* dispatcher);
63 virtual ~PPB_Graphics3D_Proxy();
65 static PP_Resource CreateProxyResource(
66 PP_Instance instance,
67 PP_Resource share_context,
68 const int32_t* attrib_list);
70 // InterfaceProxy implementation.
71 virtual bool OnMessageReceived(const IPC::Message& msg);
73 static const ApiID kApiID = API_ID_PPB_GRAPHICS_3D;
75 private:
76 void OnMsgCreate(PP_Instance instance,
77 HostResource share_context,
78 const std::vector<int32_t>& attribs,
79 HostResource* result);
80 void OnMsgSetGetBuffer(const HostResource& context,
81 int32 id);
82 void OnMsgWaitForTokenInRange(const HostResource& context,
83 int32 start,
84 int32 end,
85 gpu::CommandBuffer::State* state,
86 bool* success);
87 void OnMsgWaitForGetOffsetInRange(const HostResource& context,
88 int32 start,
89 int32 end,
90 gpu::CommandBuffer::State* state,
91 bool* success);
92 void OnMsgAsyncFlush(const HostResource& context, int32 put_offset);
93 void OnMsgCreateTransferBuffer(
94 const HostResource& context,
95 uint32 size,
96 int32* id,
97 ppapi::proxy::SerializedHandle* transfer_buffer);
98 void OnMsgDestroyTransferBuffer(const HostResource& context,
99 int32 id);
100 void OnMsgSwapBuffers(const HostResource& context);
101 void OnMsgInsertSyncPoint(const HostResource& context, uint32* sync_point);
102 // Renderer->plugin message handlers.
103 void OnMsgSwapBuffersACK(const HostResource& context,
104 int32_t pp_error);
106 void SendSwapBuffersACKToPlugin(int32_t result,
107 const HostResource& context);
109 ProxyCompletionCallbackFactory<PPB_Graphics3D_Proxy> callback_factory_;
111 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy);
114 } // namespace proxy
115 } // namespace ppapi
117 #endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_