| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ | |
| 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/scoped_ptr.h" | |
| 10 #include "gfx/size.h" | |
| 11 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | |
| 12 #include "gpu/command_buffer/client/gles2_implementation.h" | |
| 13 #include "ppapi/c/pp_instance.h" | |
| 14 #include "webkit/glue/plugins/pepper_plugin_delegate.h" | |
| 15 #include "webkit/glue/plugins/pepper_resource.h" | |
| 16 | |
| 17 namespace gpu { | |
| 18 namespace gles2 { | |
| 19 class GLES2Implementation; | |
| 20 } | |
| 21 } // namespace gpu | |
| 22 | |
| 23 struct PPB_Graphics3D_Dev; | |
| 24 struct PPB_OpenGLES_Dev; | |
| 25 | |
| 26 namespace pepper { | |
| 27 | |
| 28 class Graphics3D : public Resource { | |
| 29 public: | |
| 30 explicit Graphics3D(PluginModule* module); | |
| 31 | |
| 32 virtual ~Graphics3D(); | |
| 33 | |
| 34 static const PPB_Graphics3D_Dev* GetInterface(); | |
| 35 static const PPB_OpenGLES_Dev* GetOpenGLESInterface(); | |
| 36 | |
| 37 static bool Shutdown(); | |
| 38 | |
| 39 static Graphics3D* GetCurrent(); | |
| 40 | |
| 41 static void ResetCurrent(); | |
| 42 | |
| 43 // Resource override. | |
| 44 virtual Graphics3D* AsGraphics3D(); | |
| 45 | |
| 46 bool Init(PP_Instance instance_id, int32_t config, | |
| 47 const int32_t* attrib_list); | |
| 48 | |
| 49 // Associates this Graphics3D with the given plugin instance. You can pass | |
| 50 // NULL to clear the existing device. Returns true on success. In this case, | |
| 51 // the last rendered frame is displayed. | |
| 52 // TODO(apatrick): Figure out the best semantics here. | |
| 53 bool BindToInstance(PluginInstance* new_instance); | |
| 54 | |
| 55 bool MakeCurrent(); | |
| 56 | |
| 57 bool SwapBuffers(); | |
| 58 | |
| 59 unsigned GetError(); | |
| 60 | |
| 61 void ResizeBackingTexture(const gfx::Size& size); | |
| 62 | |
| 63 void SetSwapBuffersCallback(Callback0::Type* callback); | |
| 64 | |
| 65 unsigned GetBackingTextureId(); | |
| 66 | |
| 67 gpu::gles2::GLES2Implementation* impl() { | |
| 68 return gles2_implementation_; | |
| 69 } | |
| 70 | |
| 71 private: | |
| 72 void Destroy(); | |
| 73 | |
| 74 // Non-owning pointer to the plugin instance this context is currently bound | |
| 75 // to, if any. If the context is currently unbound, this will be NULL. | |
| 76 PluginInstance* bound_instance_; | |
| 77 | |
| 78 // PluginDelegate's 3D Context. Responsible for providing the command buffer. | |
| 79 scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_; | |
| 80 | |
| 81 // GLES2 Implementation instance. Owned by the platform context's GGL context. | |
| 82 gpu::gles2::GLES2Implementation* gles2_implementation_; | |
| 83 }; | |
| 84 | |
| 85 } // namespace pepper | |
| 86 | |
| 87 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ | |
| 88 | |
| OLD | NEW |