OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef GPU_DEMOS_FRAMEWORK_PLUGIN_H_ | |
6 #define GPU_DEMOS_FRAMEWORK_PLUGIN_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "gpu/demos/framework/demo.h" | |
11 #include "gpu/pgl/pgl.h" | |
12 #include "third_party/npapi/bindings/nphostapi.h" | |
13 | |
14 namespace gpu { | |
15 namespace demos { | |
16 | |
17 // Acts as a framework for pepper3d demos. It is in fact a pepper plugin with | |
18 // a pepper3d device. It delegates all rendering tasks to demo object. | |
19 class Plugin : public NPObject { | |
20 public: | |
21 explicit Plugin(NPP npp); | |
22 ~Plugin(); | |
23 | |
24 static NPClass* GetPluginClass(); | |
25 | |
26 NPP npp() const { return npp_; } | |
27 void New(NPMIMEType pluginType, int16 argc, char* argn[], char* argv[]); | |
28 void SetWindow(const NPWindow& window); | |
29 int32 HandleEvent(const NPPepperEvent& event); | |
30 | |
31 // Called continuously for animated demos. | |
32 void Tick(); | |
33 | |
34 // Called by the browser to paint the window. | |
35 void Paint(); | |
36 | |
37 private: | |
38 bool CreateContext(); | |
39 void DestroyContext(); | |
40 | |
41 // This class object needs to be safely casted to NPObject* and cross | |
42 // c-c++ module boundaries. To accomplish that this class should not have | |
43 // any virtual member function. | |
44 NPP npp_; | |
45 | |
46 NPDevice* device3d_; | |
47 NPDeviceContext3D context3d_; | |
48 PGLContext pgl_context_; | |
49 scoped_ptr<Demo> demo_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(Plugin); | |
52 }; | |
53 | |
54 extern NPNetscapeFuncs* g_browser; | |
55 | |
56 } // namespace demos | |
57 } // namespace gpu | |
58 #endif // GPU_DEMOS_FRAMEWORK_PLUGIN_H_ | |
OLD | NEW |