Removed dependence on java interfaces and use only one surface for both embedded and fullscreen surfaces.
diff --git a/samples/BrowserPlugin/jni/main.cpp b/samples/BrowserPlugin/jni/main.cpp
index 85632e4..35dd5d6 100644
--- a/samples/BrowserPlugin/jni/main.cpp
+++ b/samples/BrowserPlugin/jni/main.cpp
@@ -68,6 +68,7 @@
ANPAudioTrackInterfaceV0 gSoundI;
ANPBitmapInterfaceV0 gBitmapI;
ANPCanvasInterfaceV0 gCanvasI;
+ANPEventInterfaceV0 gEventI;
ANPLogInterfaceV0 gLogI;
ANPPaintInterfaceV0 gPaintI;
ANPPathInterfaceV0 gPathI;
@@ -115,6 +116,7 @@
{ kAudioTrackInterfaceV0_ANPGetValue, sizeof(gSoundI), &gSoundI },
{ kBitmapInterfaceV0_ANPGetValue, sizeof(gBitmapI), &gBitmapI },
{ kCanvasInterfaceV0_ANPGetValue, sizeof(gCanvasI), &gCanvasI },
+ { kEventInterfaceV0_ANPGetValue, sizeof(gEventI), &gEventI },
{ kLogInterfaceV0_ANPGetValue, sizeof(gLogI), &gLogI },
{ kPaintInterfaceV0_ANPGetValue, sizeof(gPaintI), &gPaintI },
{ kPathInterfaceV0_ANPGetValue, sizeof(gPathI), &gPathI },
@@ -239,6 +241,22 @@
return NPERR_GENERIC_ERROR;
}
+ // if the plugin uses the surface drawing model then set the java context
+ if (model == kSurface_ANPDrawingModel) {
+ SurfaceSubPlugin* surfacePlugin = static_cast<SurfaceSubPlugin*>(obj->activePlugin);
+
+ jobject context;
+ NPError err = browser->getvalue(instance, kJavaContext_ANPGetValue,
+ static_cast<void*>(&context));
+ if (err) {
+ gLogI.log(kError_ANPLogType, "request context err: %d", err);
+ return err;
+ }
+
+ surfacePlugin->setContext(context);
+ }
+
+
return NPERR_NO_ERROR;
}
@@ -393,7 +411,7 @@
return NPERR_GENERIC_ERROR;
}
-NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
+NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value)
{
if (variable == NPPVpluginScriptableNPObject) {
void **v = (void **)value;
@@ -406,6 +424,24 @@
return NPERR_NO_ERROR;
}
+ if (variable == kJavaSurface_ANPGetValue) {
+ //get the surface sub-plugin
+ PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
+ if (obj && obj->activePlugin) {
+
+ if(obj->activePlugin->supportsDrawingModel(kSurface_ANPDrawingModel)) {
+ SurfaceSubPlugin* plugin = static_cast<SurfaceSubPlugin*>(obj->activePlugin);
+ jobject* surface = static_cast<jobject*>(value);
+ *surface = plugin->getSurface();
+ return NPERR_NO_ERROR;
+ } else {
+ gLogI.log(kError_ANPLogType,
+ "-- %p Tried to retrieve surface for non-surface plugin",
+ instance);
+ }
+ }
+ }
+
return NPERR_GENERIC_ERROR;
}