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 WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_ |
7 | 7 |
8 #include "base/memory/scoped_callback_factory.h" | 8 #include "base/memory/scoped_callback_factory.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ppapi/c/dev/ppb_context_3d_dev.h" | 10 #include "ppapi/thunk/ppb_context_3d_api.h" |
11 #include "webkit/plugins/ppapi/plugin_delegate.h" | 11 #include "webkit/plugins/ppapi/plugin_delegate.h" |
12 #include "webkit/plugins/ppapi/resource.h" | 12 #include "webkit/plugins/ppapi/resource.h" |
13 | 13 |
14 struct PPB_Context3DTrusted_Dev; | 14 struct PPB_Context3DTrusted_Dev; |
15 | 15 |
16 namespace gpu { | 16 namespace gpu { |
17 class CommandBuffer; | 17 class CommandBuffer; |
18 namespace gles2 { | 18 namespace gles2 { |
19 class GLES2CmdHelper; | 19 class GLES2CmdHelper; |
20 class GLES2Implementation; | 20 class GLES2Implementation; |
21 } // namespace gles2 | 21 } // namespace gles2 |
22 } // namespace gpu | 22 } // namespace gpu |
23 | 23 |
24 namespace webkit { | 24 namespace webkit { |
25 namespace ppapi { | 25 namespace ppapi { |
26 | 26 |
27 class PPB_Surface3D_Impl; | 27 class PPB_Surface3D_Impl; |
28 | 28 |
29 class PPB_Context3D_Impl : public Resource { | 29 class PPB_Context3D_Impl : public Resource, |
30 public ::ppapi::thunk::PPB_Context3D_API { | |
30 public: | 31 public: |
31 explicit PPB_Context3D_Impl(PluginInstance* instance); | |
32 virtual ~PPB_Context3D_Impl(); | 32 virtual ~PPB_Context3D_Impl(); |
33 | 33 |
34 static const PPB_Context3D_Dev* GetInterface(); | 34 static PP_Resource Create(PP_Instance instance, |
35 static const PPB_Context3DTrusted_Dev* GetTrustedInterface(); | 35 PP_Config3D_Dev config, |
36 PP_Resource share_context, | |
37 const int32_t* attrib_list); | |
38 static PP_Resource CreateRaw(PP_Instance instance, | |
39 PP_Config3D_Dev config, | |
40 PP_Resource share_context, | |
41 const int32_t* attrib_list); | |
36 | 42 |
37 // Resource override. | 43 // ResourceObjectBase override. |
38 virtual PPB_Context3D_Impl* AsPPB_Context3D_Impl(); | 44 virtual ::ppapi::thunk::PPB_Context3D_API* AsPPB_Context3D_API(); |
45 | |
46 // PPB_Context3D_API implementation. | |
47 virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE; | |
48 virtual int32_t BindSurfaces(PP_Resource draw, PP_Resource read) OVERRIDE; | |
49 virtual int32_t GetBoundSurfaces(PP_Resource* draw, | |
50 PP_Resource* read) OVERRIDE; | |
51 virtual PP_Bool InitializeTrusted(int32_t size) OVERRIDE; | |
52 virtual PP_Bool GetRingBuffer(int* shm_handle, | |
53 uint32_t* shm_size) OVERRIDE; | |
54 virtual PP_Context3DTrustedState GetState() OVERRIDE; | |
55 virtual PP_Bool Flush(int32_t put_offset) OVERRIDE; | |
56 virtual PP_Context3DTrustedState FlushSync(int32_t put_offset) OVERRIDE; | |
57 virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE; | |
58 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE; | |
59 virtual PP_Bool GetTransferBuffer(int32_t id, | |
60 int* shm_handle, | |
61 uint32_t* shm_size) OVERRIDE; | |
62 virtual PP_Context3DTrustedState FlushSyncFast( | |
63 int32_t put_offset, | |
64 int32_t last_known_get) OVERRIDE; | |
65 virtual void* MapTexSubImage2DCHROMIUM(GLenum target, | |
66 GLint level, | |
67 GLint xoffset, | |
68 GLint yoffset, | |
69 GLsizei width, | |
70 GLsizei height, | |
71 GLenum format, | |
72 GLenum type, | |
73 GLenum access) OVERRIDE; | |
74 virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; | |
75 | |
76 gpu::gles2::GLES2Implementation* gles2_impl() { | |
77 return gles2_impl_.get(); | |
78 } | |
79 | |
80 // Possibly NULL if initialization fails. | |
81 PluginDelegate::PlatformContext3D* platform_context() { | |
82 return platform_context_.get(); | |
83 } | |
84 | |
85 private: | |
86 explicit PPB_Context3D_Impl(PluginInstance* instance); | |
39 | 87 |
40 bool Init(PP_Config3D_Dev config, | 88 bool Init(PP_Config3D_Dev config, |
41 PP_Resource share_context, | 89 PP_Resource share_context, |
42 const int32_t* attrib_list); | 90 const int32_t* attrib_list); |
43 bool InitRaw(PP_Config3D_Dev config, | 91 bool InitRaw(PP_Config3D_Dev config, |
44 PP_Resource share_context, | 92 PP_Resource share_context, |
45 const int32_t* attrib_list); | 93 const int32_t* attrib_list); |
46 | 94 |
47 PluginInstance* instance() { | 95 bool CreateImplementation(); |
48 return instance_; | |
49 } | |
50 | |
51 PluginDelegate::PlatformContext3D* platform_context() { | |
52 return platform_context_.get(); | |
53 } | |
54 | |
55 gpu::gles2::GLES2Implementation* gles2_impl() { | |
56 return gles2_impl_.get(); | |
57 } | |
58 | |
59 gpu::CommandBuffer* command_buffer(); | |
60 | |
61 int32_t BindSurfaces(PPB_Surface3D_Impl* draw, | |
62 PPB_Surface3D_Impl* read); | |
63 | |
64 private: | |
65 void Destroy(); | 96 void Destroy(); |
66 bool CreateImplementation(); | |
67 void OnContextLost(); | 97 void OnContextLost(); |
68 | 98 |
69 // Plugin instance this context is associated with. | 99 // Plugin instance this context is associated with. |
70 PluginInstance* instance_; | 100 PluginInstance* instance_; |
71 | 101 |
72 // PluginDelegate's 3D Context. Responsible for providing the command buffer. | 102 // PluginDelegate's 3D Context. Responsible for providing the command buffer. |
103 // Possibly NULL. | |
104 // TODO(brettw) in which cases is this NULL? | |
piman
2011/06/20 20:26:14
I don't think it should be NULL, except for a botc
| |
73 scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_; | 105 scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_; |
74 | 106 |
75 scoped_ptr<gpu::gles2::GLES2CmdHelper> helper_; | 107 scoped_ptr<gpu::gles2::GLES2CmdHelper> helper_; |
76 int32 transfer_buffer_id_; | 108 int32 transfer_buffer_id_; |
77 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; | 109 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; |
78 | 110 |
79 PPB_Surface3D_Impl* draw_surface_; | 111 PPB_Surface3D_Impl* draw_surface_; |
80 PPB_Surface3D_Impl* read_surface_; | 112 PPB_Surface3D_Impl* read_surface_; |
81 | 113 |
82 base::ScopedCallbackFactory<PPB_Context3D_Impl> callback_factory_; | 114 base::ScopedCallbackFactory<PPB_Context3D_Impl> callback_factory_; |
83 | 115 |
84 DISALLOW_COPY_AND_ASSIGN(PPB_Context3D_Impl); | 116 DISALLOW_COPY_AND_ASSIGN(PPB_Context3D_Impl); |
85 }; | 117 }; |
86 | 118 |
87 } // namespace ppapi | 119 } // namespace ppapi |
88 } // namespace webkit | 120 } // namespace webkit |
89 | 121 |
90 #endif // WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_ | 122 #endif // WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_ |
OLD | NEW |