OLD | NEW |
1 // Copyright (c) 2010 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_GRAPHICS_3D_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_ |
7 | 7 |
| 8 #include "base/memory/scoped_callback_factory.h" |
| 9 #include "base/memory/scoped_ptr.h" |
8 #include "ppapi/c/dev/ppb_graphics_3d_dev.h" | 10 #include "ppapi/c/dev/ppb_graphics_3d_dev.h" |
| 11 #include "webkit/plugins/ppapi/plugin_delegate.h" |
9 #include "webkit/plugins/ppapi/resource.h" | 12 #include "webkit/plugins/ppapi/resource.h" |
10 | 13 |
| 14 struct PPB_Context3DTrusted_Dev; |
| 15 |
| 16 namespace gpu { |
| 17 class CommandBuffer; |
| 18 namespace gles2 { |
| 19 class GLES2CmdHelper; |
| 20 class GLES2Implementation; |
| 21 } // namespace gles2 |
| 22 } // namespace gpu |
| 23 |
11 namespace webkit { | 24 namespace webkit { |
12 namespace ppapi { | 25 namespace ppapi { |
13 | 26 |
14 class PPB_Graphics3D_Impl : public Resource { | 27 class PPB_Graphics3D_Impl : public Resource { |
15 public: | 28 public: |
16 explicit PPB_Graphics3D_Impl(PluginInstance* instance); | 29 explicit PPB_Graphics3D_Impl(PluginInstance* instance); |
17 virtual ~PPB_Graphics3D_Impl(); | 30 virtual ~PPB_Graphics3D_Impl(); |
18 | 31 |
19 static const PPB_Graphics3D_Dev* GetInterface(); | 32 static const PPB_Graphics3D_Dev* GetInterface(); |
| 33 // TODO(alokp): Rename PPB_Context3DTrusted_Dev to PPB_Graphics3DTrusted_Dev. |
| 34 static const PPB_Context3DTrusted_Dev* GetTrustedInterface(); |
20 | 35 |
21 // Resource override. | 36 // Resource override. |
22 virtual PPB_Graphics3D_Impl* AsPPB_Graphics3D_Impl(); | 37 virtual PPB_Graphics3D_Impl* AsPPB_Graphics3D_Impl(); |
23 | 38 |
24 bool Init(PP_Config3D_Dev config, | 39 bool Init(PP_Config3D_Dev config, |
25 PP_Resource share_context, | 40 PP_Resource share_context, |
26 const int32_t* attrib_list); | 41 const int32_t* attrib_list); |
| 42 bool InitRaw(PP_Config3D_Dev config, |
| 43 PP_Resource share_context, |
| 44 const int32_t* attrib_list); |
| 45 |
| 46 PluginDelegate::PlatformContext3D* platform_context() { |
| 47 return platform_context_.get(); |
| 48 } |
| 49 gpu::gles2::GLES2Implementation* gles2_impl() { |
| 50 return gles2_impl_.get(); |
| 51 } |
| 52 gpu::CommandBuffer* GetCommandBuffer(); |
| 53 unsigned int GetBackingTextureId(); |
| 54 |
| 55 // Binds/unbinds the graphics of this surface with the associated instance. |
| 56 // If the surface is bound, anything drawn on the surface appears on instance |
| 57 // window. Returns true if binding/unbinding is successful. |
| 58 bool BindToInstance(bool bind); |
| 59 |
| 60 void ViewInitiatedPaint(); |
| 61 void ViewFlushedPaint(); |
| 62 int32_t SwapBuffers(PP_CompletionCallback callback); |
27 | 63 |
28 private: | 64 private: |
| 65 bool CreateImplementation(); |
| 66 void OnSwapBuffers(); |
| 67 void OnContextLost(); |
| 68 void SendSwapBuffers(); |
| 69 void SendContextLost(); |
| 70 |
| 71 // True if the context is bound to plugin instance. |
| 72 bool bound_to_instance_; |
| 73 |
| 74 // PluginDelegate's 3D Context. Responsible for providing the command buffer. |
| 75 scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_; |
| 76 |
| 77 int32 transfer_buffer_id_; |
| 78 scoped_ptr<gpu::gles2::GLES2CmdHelper> command_buffer_helper_; |
| 79 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; |
| 80 |
| 81 // True when the compositor has been asked to commit texture but has |
| 82 // not returned yet. |
| 83 bool commit_initiated_; |
| 84 // Callback provided by the plugin that needs to be called at the |
| 85 // completion of swap buffers. |
| 86 PP_CompletionCallback swap_callback_; |
| 87 base::ScopedCallbackFactory<PPB_Graphics3D_Impl> callback_factory_; |
| 88 |
29 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); | 89 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); |
30 }; | 90 }; |
31 | 91 |
32 } // namespace ppapi | 92 } // namespace ppapi |
33 } // namespace webkit | 93 } // namespace webkit |
34 | 94 |
35 #endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_ | 95 #endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_ |
36 | 96 |
OLD | NEW |