OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ |
7 | 7 |
| 8 #include "base/callback.h" |
8 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "gfx/size.h" |
9 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 11 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
10 #include "gpu/command_buffer/client/gles2_implementation.h" | 12 #include "gpu/command_buffer/client/gles2_implementation.h" |
11 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
12 #include "webkit/glue/plugins/pepper_plugin_delegate.h" | 14 #include "webkit/glue/plugins/pepper_plugin_delegate.h" |
13 #include "webkit/glue/plugins/pepper_resource.h" | 15 #include "webkit/glue/plugins/pepper_resource.h" |
14 | 16 |
15 namespace gfx { | |
16 class Rect; | |
17 } // namespace gfx | |
18 | |
19 namespace gpu { | 17 namespace gpu { |
20 class CommandBuffer; | 18 namespace gles2 { |
| 19 class GLES2Implementation; |
| 20 } |
21 } // namespace gpu | 21 } // namespace gpu |
22 | 22 |
23 struct PPB_Graphics3D_Dev; | 23 struct PPB_Graphics3D_Dev; |
24 struct PPB_OpenGLES_Dev; | 24 struct PPB_OpenGLES_Dev; |
25 | 25 |
26 namespace pepper { | 26 namespace pepper { |
27 | 27 |
28 class Graphics3D : public Resource { | 28 class Graphics3D : public Resource { |
29 public: | 29 public: |
30 explicit Graphics3D(PluginModule* module); | 30 explicit Graphics3D(PluginModule* module); |
(...skipping 10 matching lines...) Expand all Loading... |
41 static void ResetCurrent(); | 41 static void ResetCurrent(); |
42 | 42 |
43 // Resource override. | 43 // Resource override. |
44 virtual Graphics3D* AsGraphics3D() { | 44 virtual Graphics3D* AsGraphics3D() { |
45 return this; | 45 return this; |
46 } | 46 } |
47 | 47 |
48 bool Init(PP_Instance instance_id, int32_t config, | 48 bool Init(PP_Instance instance_id, int32_t config, |
49 const int32_t* attrib_list); | 49 const int32_t* attrib_list); |
50 | 50 |
| 51 // Associates this Graphics3D with the given plugin instance. You can pass |
| 52 // NULL to clear the existing device. Returns true on success. In this case, |
| 53 // the last rendered frame is displayed. |
| 54 // TODO(apatrick): Figure out the best semantics here. |
| 55 bool BindToInstance(PluginInstance* new_instance); |
| 56 |
51 bool MakeCurrent(); | 57 bool MakeCurrent(); |
52 | 58 |
53 bool SwapBuffers(); | 59 bool SwapBuffers(); |
54 | 60 |
| 61 unsigned GetError(); |
| 62 |
| 63 void ResizeBackingTexture(const gfx::Size& size); |
| 64 |
| 65 void SetSwapBuffersCallback(Callback0::Type* callback); |
| 66 |
| 67 unsigned GetBackingTextureId(); |
| 68 |
55 gpu::gles2::GLES2Implementation* impl() { | 69 gpu::gles2::GLES2Implementation* impl() { |
56 return gles2_implementation_.get(); | 70 return gles2_implementation_; |
57 } | 71 } |
58 | 72 |
59 private: | 73 private: |
60 void HandleRepaint(PP_Instance instance_id); | |
61 void Destroy(); | 74 void Destroy(); |
62 | 75 |
| 76 // Non-owning pointer to the plugin instance this context is currently bound |
| 77 // to, if any. If the context is currently unbound, this will be NULL. |
| 78 PluginInstance* bound_instance_; |
| 79 |
63 // PluginDelegate's 3D Context. Responsible for providing the command buffer. | 80 // PluginDelegate's 3D Context. Responsible for providing the command buffer. |
64 scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_; | 81 scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_; |
65 | 82 |
66 // Command buffer is owned by the platform context. | 83 // GLES2 Implementation instance. Owned by the platform context's GGL context. |
67 gpu::CommandBuffer* command_buffer_; | 84 gpu::gles2::GLES2Implementation* gles2_implementation_; |
68 | |
69 // GLES2 Command Helper instance. | |
70 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | |
71 | |
72 // ID of the transfer buffer. | |
73 int32_t transfer_buffer_id_; | |
74 | |
75 // GLES2 Implementation instance. | |
76 scoped_ptr<gpu::gles2::GLES2Implementation> gles2_implementation_; | |
77 | |
78 // Runnable methods that must be cancelled when the 3D context is destroyed. | |
79 ScopedRunnableMethodFactory<Graphics3D> method_factory3d_; | |
80 }; | 85 }; |
81 | 86 |
82 } // namespace pepper | 87 } // namespace pepper |
83 | 88 |
84 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ | 89 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ |
85 | 90 |
OLD | NEW |