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_PPB_CONTEXT_3D_PROXY_H_ | 5 #ifndef PPAPI_PROXY_PPB_CONTEXT_3D_PROXY_H_ |
6 #define PPAPI_PPB_CONTEXT_3D_PROXY_H_ | 6 #define PPAPI_PROXY_PPB_CONTEXT_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/proxy/interface_proxy.h" | 14 #include "ppapi/proxy/interface_proxy.h" |
15 #include "ppapi/proxy/plugin_resource.h" | 15 #include "ppapi/proxy/plugin_resource.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/thunk/ppb_context_3d_api.h" | |
17 | 18 |
18 struct PPB_Context3D_Dev; | 19 struct PPB_Context3D_Dev; |
19 struct PPB_Context3DTrusted_Dev; | 20 struct PPB_Context3DTrusted_Dev; |
20 | 21 |
21 namespace gpu { | 22 namespace gpu { |
22 class CommandBuffer; | 23 class CommandBuffer; |
23 | 24 |
24 namespace gles2 { | 25 namespace gles2 { |
25 class GLES2CmdHelper; | 26 class GLES2CmdHelper; |
26 class GLES2Implementation; | 27 class GLES2Implementation; |
27 } // namespace gles2 | 28 } // namespace gles2 |
28 | 29 |
29 } // namespace gpu | 30 } // namespace gpu |
30 | 31 |
31 namespace pp { | 32 namespace pp { |
32 namespace proxy { | 33 namespace proxy { |
33 | 34 |
34 class Surface3D; | 35 class Surface3D; |
35 | 36 |
36 class Context3D : public PluginResource { | 37 class Context3D : public PluginResource, |
38 public ::ppapi::thunk::PPB_Context3D_API { | |
alokp
2011/06/20 16:36:03
nit: is it necessary to prepend :: to ppapi::thunk
brettw
2011/06/20 19:31:03
Nope, got used to doing it for webkit/plugins/ppap
| |
37 public: | 39 public: |
38 explicit Context3D(const HostResource& resource); | 40 explicit Context3D(const HostResource& resource); |
39 virtual ~Context3D(); | 41 virtual ~Context3D(); |
40 | 42 |
41 // Resource overrides. | 43 // ResourceObjectBase overrides. |
42 virtual Context3D* AsContext3D() { return this; } | 44 virtual ::ppapi::thunk::PPB_Context3D_API* AsPPB_Context3D_API() OVERRIDE; |
43 | |
44 bool CreateImplementation(); | |
45 | |
46 Surface3D* get_draw_surface() const { | |
47 return draw_; | |
48 } | |
49 | |
50 Surface3D* get_read_surface() const { | |
51 return read_; | |
52 } | |
53 | |
54 void BindSurfaces(Surface3D* draw, Surface3D* read); | |
55 | 45 |
56 gpu::gles2::GLES2Implementation* gles2_impl() const { | 46 gpu::gles2::GLES2Implementation* gles2_impl() const { |
57 return gles2_impl_.get(); | 47 return gles2_impl_.get(); |
58 } | 48 } |
59 | 49 |
50 // PPB_Context3D_API implementation. | |
51 virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE; | |
52 virtual int32_t BindSurfaces(PP_Resource draw, PP_Resource read) OVERRIDE; | |
53 virtual int32_t GetBoundSurfaces(PP_Resource* draw, | |
54 PP_Resource* read) OVERRIDE; | |
55 virtual PP_Bool InitializeTrusted(int32_t size) OVERRIDE; | |
56 virtual PP_Bool GetRingBuffer(int* shm_handle, | |
57 uint32_t* shm_size) OVERRIDE; | |
58 virtual PP_Context3DTrustedState GetState() OVERRIDE; | |
59 virtual PP_Bool Flush(int32_t put_offset) OVERRIDE; | |
60 virtual PP_Context3DTrustedState FlushSync(int32_t put_offset) OVERRIDE; | |
61 virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE; | |
62 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE; | |
63 virtual PP_Bool GetTransferBuffer(int32_t id, | |
64 int* shm_handle, | |
65 uint32_t* shm_size) OVERRIDE; | |
66 virtual PP_Context3DTrustedState FlushSyncFast( | |
67 int32_t put_offset, | |
68 int32_t last_known_get) OVERRIDE; | |
69 virtual void* MapTexSubImage2DCHROMIUM(GLenum target, | |
70 GLint level, | |
71 GLint xoffset, | |
72 GLint yoffset, | |
73 GLsizei width, | |
74 GLsizei height, | |
75 GLenum format, | |
76 GLenum type, | |
77 GLenum access) OVERRIDE; | |
78 virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; | |
79 | |
80 bool CreateImplementation(); | |
81 | |
60 private: | 82 private: |
61 Surface3D* draw_; | 83 Surface3D* draw_; |
62 Surface3D* read_; | 84 Surface3D* read_; |
63 | 85 |
64 scoped_ptr<gpu::CommandBuffer> command_buffer_; | 86 scoped_ptr<gpu::CommandBuffer> command_buffer_; |
65 scoped_ptr<gpu::gles2::GLES2CmdHelper> helper_; | 87 scoped_ptr<gpu::gles2::GLES2CmdHelper> helper_; |
66 int32 transfer_buffer_id_; | 88 int32 transfer_buffer_id_; |
67 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; | 89 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; |
68 | 90 |
69 DISALLOW_COPY_AND_ASSIGN(Context3D); | 91 DISALLOW_COPY_AND_ASSIGN(Context3D); |
70 }; | 92 }; |
71 | 93 |
72 class PPB_Context3D_Proxy : public InterfaceProxy { | 94 class PPB_Context3D_Proxy : public InterfaceProxy { |
73 public: | 95 public: |
74 PPB_Context3D_Proxy(Dispatcher* dispatcher, const void* target_interface); | 96 PPB_Context3D_Proxy(Dispatcher* dispatcher, const void* target_interface); |
75 virtual ~PPB_Context3D_Proxy(); | 97 virtual ~PPB_Context3D_Proxy(); |
76 | 98 |
77 static const Info* GetInfo(); | 99 static const Info* GetInfo(); |
100 static const Info* GetTextureMappingInfo(); | |
78 | 101 |
79 const PPB_Context3D_Dev* ppb_context_3d_target() const { | 102 static PP_Resource Create(PP_Instance instance, |
80 return reinterpret_cast<const PPB_Context3D_Dev*>(target_interface()); | 103 PP_Config3D_Dev config, |
81 } | 104 PP_Resource share_context, |
82 const PPB_Context3DTrusted_Dev* ppb_context_3d_trusted() const; | 105 const int32_t* attrib_list); |
83 | 106 |
84 // InterfaceProxy implementation. | 107 // InterfaceProxy implementation. |
85 virtual bool OnMessageReceived(const IPC::Message& msg); | 108 virtual bool OnMessageReceived(const IPC::Message& msg); |
86 | 109 |
87 private: | 110 private: |
88 void OnMsgCreate(PP_Instance instance, | 111 void OnMsgCreate(PP_Instance instance, |
89 PP_Config3D_Dev config, | 112 PP_Config3D_Dev config, |
90 std::vector<int32_t> attribs, | 113 std::vector<int32_t> attribs, |
91 HostResource* result); | 114 HostResource* result); |
92 void OnMsgBindSurfaces(const HostResource& context, | 115 void OnMsgBindSurfaces(const HostResource& context, |
(...skipping 18 matching lines...) Expand all Loading... | |
111 int32 id); | 134 int32 id); |
112 void OnMsgGetTransferBuffer(const HostResource& context, | 135 void OnMsgGetTransferBuffer(const HostResource& context, |
113 int32 id, | 136 int32 id, |
114 base::SharedMemoryHandle* transfer_buffer, | 137 base::SharedMemoryHandle* transfer_buffer, |
115 uint32* size); | 138 uint32* size); |
116 }; | 139 }; |
117 | 140 |
118 } // namespace proxy | 141 } // namespace proxy |
119 } // namespace pp | 142 } // namespace pp |
120 | 143 |
121 #endif // PPAPI_PPB_CONTEXT_3D_PROXY_H_ | 144 #endif // PPAPI_PROXY_PPB_CONTEXT_3D_PROXY_H_ |
OLD | NEW |