OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 O3D_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_ | 5 #ifndef O3D_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_ |
6 #define O3D_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_ | 6 #define O3D_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "o3d/gpu_plugin/command_buffer.h" | 10 #include "o3d/gpu_plugin/command_buffer.h" |
11 #include "o3d/gpu_plugin/np_utils/dispatched_np_object.h" | 11 #include "o3d/gpu_plugin/np_utils/dispatched_np_object.h" |
12 #include "o3d/gpu_plugin/np_utils/np_dispatcher.h" | 12 #include "o3d/gpu_plugin/np_utils/np_dispatcher.h" |
13 #include "o3d/gpu_plugin/np_utils/np_plugin_object.h" | 13 #include "o3d/gpu_plugin/np_utils/np_plugin_object.h" |
14 #include "o3d/gpu_plugin/np_utils/np_utils.h" | 14 #include "o3d/gpu_plugin/np_utils/np_utils.h" |
15 #include "third_party/npapi/bindings/npapi.h" | 15 #include "third_party/npapi/bindings/npapi.h" |
16 #include "third_party/npapi/bindings/npruntime.h" | 16 #include "third_party/npapi/bindings/npruntime.h" |
17 | 17 |
18 namespace o3d { | 18 namespace o3d { |
19 namespace gpu_plugin { | 19 namespace gpu_plugin { |
20 | 20 |
21 // The scriptable object for the GPU plugin. | 21 // The scriptable object for the GPU plugin. |
22 class GPUPluginObject : public DispatchedNPObject, public PluginObject { | 22 class GPUPluginObject : public DefaultNPObject<NPObject>, |
| 23 public PluginObject { |
23 public: | 24 public: |
24 static const NPUTF8 kPluginType[]; | 25 static const NPUTF8 kPluginType[]; |
25 | 26 |
26 explicit GPUPluginObject(NPP npp); | 27 explicit GPUPluginObject(NPP npp); |
27 | 28 |
28 virtual NPError New(NPMIMEType plugin_type, | 29 virtual NPError New(NPMIMEType plugin_type, |
29 int16 argc, | 30 int16 argc, |
30 char* argn[], | 31 char* argn[], |
31 char* argv[], | 32 char* argv[], |
32 NPSavedData* saved); | 33 NPSavedData* saved); |
33 | 34 |
34 virtual NPError SetWindow(NPWindow* new_window); | 35 virtual NPError SetWindow(NPWindow* new_window); |
35 const NPWindow& GetWindow() { return window_; } | 36 const NPWindow& GetWindow() { return window_; } |
36 | 37 |
37 virtual int16 HandleEvent(NPEvent* event); | 38 virtual int16 HandleEvent(NPEvent* event); |
38 | 39 |
39 virtual NPError Destroy(NPSavedData** saved); | 40 virtual NPError Destroy(NPSavedData** saved); |
40 | 41 |
41 virtual void Release(); | 42 virtual void Release(); |
42 | 43 |
43 virtual NPObject* GetScriptableNPObject(); | 44 virtual NPObject* GetScriptableNPObject(); |
44 | 45 |
45 // Initializes and returns the command buffer object. | 46 // Initializes and returns the command buffer object. |
46 NPObjectPointer<NPObject> OpenCommandBuffer(); | 47 NPObjectPointer<NPObject> OpenCommandBuffer(); |
47 | 48 |
48 protected: | 49 NP_UTILS_BEGIN_DISPATCHER_CHAIN(GPUPluginObject, DefaultNPObject<NPObject>) |
49 NP_UTILS_BEGIN_DISPATCHER_CHAIN(GPUPluginObject, DispatchedNPObject) | |
50 NP_UTILS_DISPATCHER(OpenCommandBuffer, NPObjectPointer<NPObject>()) | 50 NP_UTILS_DISPATCHER(OpenCommandBuffer, NPObjectPointer<NPObject>()) |
51 NP_UTILS_END_DISPATCHER_CHAIN | 51 NP_UTILS_END_DISPATCHER_CHAIN |
52 | 52 |
53 private: | 53 private: |
54 NPError PlatformSpecificSetWindow(NPWindow* new_window); | 54 NPError PlatformSpecificSetWindow(NPWindow* new_window); |
55 | 55 |
56 enum Status { | 56 enum Status { |
57 CREATED, | 57 CREATED, |
58 INITIALIZED, | 58 INITIALIZED, |
59 DESTROYED, | 59 DESTROYED, |
60 }; | 60 }; |
61 | 61 |
| 62 NPP npp_; |
62 Status status_; | 63 Status status_; |
63 NPWindow window_; | 64 NPWindow window_; |
64 NPObjectPointer<CommandBuffer> command_buffer_object_; | 65 NPObjectPointer<CommandBuffer> command_buffer_object_; |
65 NPSharedMemory* shared_memory_; | 66 NPSharedMemory* shared_memory_; |
66 }; | 67 }; |
67 | 68 |
68 } // namespace gpu_plugin | 69 } // namespace gpu_plugin |
69 } // namespace o3d | 70 } // namespace o3d |
70 | 71 |
71 #endif // O3D_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_ | 72 #endif // O3D_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_ |
OLD | NEW |