Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: gpu/demos/framework/main_pepper.cc

Issue 554053: Added infrastructure to run gpu demos under Pepper3D. Created a Demo class th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/demos/framework/main_exe.cc ('k') | gpu/demos/framework/platform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 #include "base/at_exit.h"
6 #include "base/logging.h"
7 #include "gpu/demos/framework/plugin.h"
8 #include "webkit/glue/plugins/nphostapi.h"
9
10 namespace {
11 // AtExitManager is used by singleton classes to delete themselves when
12 // the program terminates. There should be only one instance of this class
13 // per thread;
14 base::AtExitManager* g_at_exit_manager_;
15 } // namespace
16
17 namespace gpu {
18 namespace demos {
19 // NPP entry points.
20 NPError NPP_New(NPMIMEType pluginType,
21 NPP instance,
22 uint16 mode,
23 int16 argc, char* argn[], char* argv[],
24 NPSavedData* saved) {
25 if (g_browser->version < NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) {
26 return NPERR_INCOMPATIBLE_VERSION_ERROR;
27 }
28
29 Plugin* plugin = static_cast<Plugin*>(
30 g_browser->createobject(instance, Plugin::GetPluginClass()));
31 instance->pdata = plugin;
32 plugin->New(pluginType, argc, argn, argv);
33
34 return NPERR_NO_ERROR;
35 }
36
37 NPError NPP_Destroy(NPP instance, NPSavedData** save) {
38 Plugin* plugin = static_cast<Plugin*>(instance->pdata);
39 if (plugin) g_browser->releaseobject(plugin);
40
41 return NPERR_NO_ERROR;
42 }
43
44 NPError NPP_SetWindow(NPP instance, NPWindow* window) {
45 Plugin* plugin = static_cast<Plugin*>(instance->pdata);
46 if (plugin) plugin->SetWindow(*window);
47
48 return NPERR_NO_ERROR;
49 }
50
51 NPError NPP_NewStream(NPP instance,
52 NPMIMEType type,
53 NPStream* stream,
54 NPBool seekable,
55 uint16* stype) {
56 *stype = NP_ASFILEONLY;
57 return NPERR_NO_ERROR;
58 }
59
60 NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) {
61 return NPERR_NO_ERROR;
62 }
63
64 void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname) {
65 }
66
67 int32 NPP_Write(NPP instance,
68 NPStream* stream,
69 int32 offset,
70 int32 len,
71 void* buffer) {
72 return 0;
73 }
74
75 int32 NPP_WriteReady(NPP instance, NPStream* stream) {
76 return 0;
77 }
78
79 void NPP_Print(NPP instance, NPPrint* platformPrint) {
80 }
81
82 int16 NPP_HandleEvent(NPP instance, void* event) {
83 return 0;
84 }
85
86 void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
87 void* notify_data) {
88 }
89
90 NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
91 NPError err = NPERR_NO_ERROR;
92
93 switch (variable) {
94 case NPPVpluginScriptableNPObject: {
95 void** v = reinterpret_cast<void**>(value);
96 Plugin* plugin = static_cast<Plugin*>(instance->pdata);
97 // Return value is expected to be retained
98 g_browser->retainobject(plugin);
99 *v = plugin;
100 break;
101 }
102 default:
103 LOG(INFO) << "Unhandled variable to NPP_GetValue\n";
104 err = NPERR_GENERIC_ERROR;
105 break;
106 }
107
108 return err;
109 }
110
111 NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) {
112 return NPERR_GENERIC_ERROR;
113 }
114 } // namespace demos
115 } // namespace gpu
116
117 // NP entry points
118 extern "C" {
119 NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
120 plugin_funcs->version = NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL;
121 plugin_funcs->size = sizeof(plugin_funcs);
122 plugin_funcs->newp = gpu::demos::NPP_New;
123 plugin_funcs->destroy = gpu::demos::NPP_Destroy;
124 plugin_funcs->setwindow = gpu::demos::NPP_SetWindow;
125 plugin_funcs->newstream = gpu::demos::NPP_NewStream;
126 plugin_funcs->destroystream = gpu::demos::NPP_DestroyStream;
127 plugin_funcs->asfile = gpu::demos::NPP_StreamAsFile;
128 plugin_funcs->writeready = gpu::demos::NPP_WriteReady;
129 plugin_funcs->write = gpu::demos::NPP_Write;
130 plugin_funcs->print = gpu::demos::NPP_Print;
131 plugin_funcs->event = gpu::demos::NPP_HandleEvent;
132 plugin_funcs->urlnotify = gpu::demos::NPP_URLNotify;
133 plugin_funcs->getvalue = gpu::demos::NPP_GetValue;
134 plugin_funcs->setvalue = gpu::demos::NPP_SetValue;
135
136 return NPERR_NO_ERROR;
137 }
138
139 NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs) {
140 g_at_exit_manager_ = new base::AtExitManager();
141 gpu::demos::g_browser = browser_funcs;
142 return NPERR_NO_ERROR;
143 }
144
145 void API_CALL NP_Shutdown() {
146 delete g_at_exit_manager_;
147 }
148 } // extern "C"
OLDNEW
« no previous file with comments | « gpu/demos/framework/main_exe.cc ('k') | gpu/demos/framework/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698