OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ | 5 #ifndef PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ |
6 #define PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ | 6 #define PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
11 #include "gpu/command_buffer/common/command_buffer.h" | 11 #include "gpu/command_buffer/common/command_buffer.h" |
12 #include "ppapi/c/dev/pp_graphics_3d_dev.h" | 12 #include "ppapi/c/dev/pp_graphics_3d_dev.h" |
13 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
14 #include "ppapi/cpp/completion_callback.h" | 14 #include "ppapi/cpp/completion_callback.h" |
15 #include "ppapi/proxy/interface_proxy.h" | 15 #include "ppapi/proxy/interface_proxy.h" |
16 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" | 16 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" |
17 #include "ppapi/shared_impl/graphics_3d_impl.h" | 17 #include "ppapi/shared_impl/graphics_3d_impl.h" |
18 #include "ppapi/shared_impl/resource.h" | 18 #include "ppapi/shared_impl/resource.h" |
19 | 19 |
20 namespace ppapi { | 20 namespace ppapi { |
| 21 |
21 class HostResource; | 22 class HostResource; |
22 } | |
23 | 23 |
24 namespace pp { | |
25 namespace proxy { | 24 namespace proxy { |
26 | 25 |
27 class Graphics3D : public ppapi::Resource, | 26 class Graphics3D : public Resource, public Graphics3DImpl { |
28 public ppapi::Graphics3DImpl { | |
29 public: | 27 public: |
30 explicit Graphics3D(const ppapi::HostResource& resource); | 28 explicit Graphics3D(const HostResource& resource); |
31 virtual ~Graphics3D(); | 29 virtual ~Graphics3D(); |
32 | 30 |
33 bool Init(); | 31 bool Init(); |
34 | 32 |
35 // Resource overrides. | 33 // Resource overrides. |
36 virtual ::ppapi::thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE { | 34 virtual thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE { |
37 return this; | 35 return this; |
38 } | 36 } |
39 | 37 |
40 // Graphics3DTrusted API. These are not implemented in the proxy. | 38 // Graphics3DTrusted API. These are not implemented in the proxy. |
41 virtual PP_Bool InitCommandBuffer(int32_t size) OVERRIDE; | 39 virtual PP_Bool InitCommandBuffer(int32_t size) OVERRIDE; |
42 virtual PP_Bool GetRingBuffer(int* shm_handle, uint32_t* shm_size) OVERRIDE; | 40 virtual PP_Bool GetRingBuffer(int* shm_handle, uint32_t* shm_size) OVERRIDE; |
43 virtual PP_Graphics3DTrustedState GetState() OVERRIDE; | 41 virtual PP_Graphics3DTrustedState GetState() OVERRIDE; |
44 virtual PP_Bool Flush(int32_t put_offset) OVERRIDE; | 42 virtual PP_Bool Flush(int32_t put_offset) OVERRIDE; |
45 virtual PP_Graphics3DTrustedState FlushSync(int32_t put_offset) OVERRIDE; | 43 virtual PP_Graphics3DTrustedState FlushSync(int32_t put_offset) OVERRIDE; |
46 virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE; | 44 virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE; |
47 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE; | 45 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE; |
48 virtual PP_Bool GetTransferBuffer(int32_t id, | 46 virtual PP_Bool GetTransferBuffer(int32_t id, |
49 int* shm_handle, | 47 int* shm_handle, |
50 uint32_t* shm_size) OVERRIDE; | 48 uint32_t* shm_size) OVERRIDE; |
51 virtual PP_Graphics3DTrustedState FlushSyncFast( | 49 virtual PP_Graphics3DTrustedState FlushSyncFast( |
52 int32_t put_offset, | 50 int32_t put_offset, |
53 int32_t last_known_get) OVERRIDE; | 51 int32_t last_known_get) OVERRIDE; |
54 | 52 |
55 protected: | 53 protected: |
56 // ppapi::Graphics3DImpl overrides. | 54 // Graphics3DImpl overrides. |
57 virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE; | 55 virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE; |
58 virtual int32 DoSwapBuffers() OVERRIDE; | 56 virtual int32 DoSwapBuffers() OVERRIDE; |
59 | 57 |
60 private: | 58 private: |
61 scoped_ptr<gpu::CommandBuffer> command_buffer_; | 59 scoped_ptr<gpu::CommandBuffer> command_buffer_; |
62 | 60 |
63 DISALLOW_COPY_AND_ASSIGN(Graphics3D); | 61 DISALLOW_COPY_AND_ASSIGN(Graphics3D); |
64 }; | 62 }; |
65 | 63 |
66 class PPB_Graphics3D_Proxy : public InterfaceProxy { | 64 class PPB_Graphics3D_Proxy : public InterfaceProxy { |
(...skipping 12 matching lines...) Expand all Loading... |
79 return static_cast<const PPB_Graphics3D_Dev*>(target_interface()); | 77 return static_cast<const PPB_Graphics3D_Dev*>(target_interface()); |
80 } | 78 } |
81 | 79 |
82 // InterfaceProxy implementation. | 80 // InterfaceProxy implementation. |
83 virtual bool OnMessageReceived(const IPC::Message& msg); | 81 virtual bool OnMessageReceived(const IPC::Message& msg); |
84 | 82 |
85 private: | 83 private: |
86 void OnMsgCreate(PP_Instance instance, | 84 void OnMsgCreate(PP_Instance instance, |
87 PP_Config3D_Dev config, | 85 PP_Config3D_Dev config, |
88 const std::vector<int32_t>& attribs, | 86 const std::vector<int32_t>& attribs, |
89 ppapi::HostResource* result); | 87 HostResource* result); |
90 void OnMsgInitCommandBuffer(const ppapi::HostResource& context, | 88 void OnMsgInitCommandBuffer(const HostResource& context, |
91 int32 size, | 89 int32 size, |
92 base::SharedMemoryHandle* ring_buffer); | 90 base::SharedMemoryHandle* ring_buffer); |
93 void OnMsgGetState(const ppapi::HostResource& context, | 91 void OnMsgGetState(const HostResource& context, |
94 gpu::CommandBuffer::State* state); | 92 gpu::CommandBuffer::State* state); |
95 void OnMsgFlush(const ppapi::HostResource& context, | 93 void OnMsgFlush(const HostResource& context, |
96 int32 put_offset, | 94 int32 put_offset, |
97 int32 last_known_get, | 95 int32 last_known_get, |
98 gpu::CommandBuffer::State* state); | 96 gpu::CommandBuffer::State* state); |
99 void OnMsgAsyncFlush(const ppapi::HostResource& context, | 97 void OnMsgAsyncFlush(const HostResource& context, |
100 int32 put_offset); | 98 int32 put_offset); |
101 void OnMsgCreateTransferBuffer(const ppapi::HostResource& context, | 99 void OnMsgCreateTransferBuffer(const HostResource& context, |
102 int32 size, | 100 int32 size, |
103 int32* id); | 101 int32* id); |
104 void OnMsgDestroyTransferBuffer(const ppapi::HostResource& context, | 102 void OnMsgDestroyTransferBuffer(const HostResource& context, |
105 int32 id); | 103 int32 id); |
106 void OnMsgGetTransferBuffer(const ppapi::HostResource& context, | 104 void OnMsgGetTransferBuffer(const HostResource& context, |
107 int32 id, | 105 int32 id, |
108 base::SharedMemoryHandle* transfer_buffer, | 106 base::SharedMemoryHandle* transfer_buffer, |
109 uint32* size); | 107 uint32* size); |
110 void OnMsgSwapBuffers(const ppapi::HostResource& context); | 108 void OnMsgSwapBuffers(const HostResource& context); |
111 // Renderer->plugin message handlers. | 109 // Renderer->plugin message handlers. |
112 void OnMsgSwapBuffersACK(const ppapi::HostResource& context, | 110 void OnMsgSwapBuffersACK(const HostResource& context, |
113 int32_t pp_error); | 111 int32_t pp_error); |
114 | 112 |
115 void SendSwapBuffersACKToPlugin(int32_t result, | 113 void SendSwapBuffersACKToPlugin(int32_t result, |
116 const ppapi::HostResource& context); | 114 const HostResource& context); |
117 | 115 |
118 CompletionCallbackFactory<PPB_Graphics3D_Proxy, | 116 pp::CompletionCallbackFactory<PPB_Graphics3D_Proxy, |
119 ProxyNonThreadSafeRefCount> callback_factory_; | 117 ProxyNonThreadSafeRefCount> callback_factory_; |
120 | 118 |
121 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy); | 119 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Proxy); |
122 }; | 120 }; |
123 | 121 |
124 } // namespace proxy | 122 } // namespace proxy |
125 } // namespace pp | 123 } // namespace ppapi |
126 | 124 |
127 #endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ | 125 #endif // PPAPI_PROXY_PPB_GRAPHICS_3D_PROXY_H_ |
128 | 126 |
OLD | NEW |