updating sample plugins to support fixed surface dimensions.
diff --git a/samples/BrowserPlugin/jni/PluginObject.cpp b/samples/BrowserPlugin/jni/PluginObject.cpp
index 80f5e7c..7d92f7d 100644
--- a/samples/BrowserPlugin/jni/PluginObject.cpp
+++ b/samples/BrowserPlugin/jni/PluginObject.cpp
@@ -35,6 +35,16 @@
#include "main.h"
#include "PluginObject.h"
+int SubPlugin::getPluginWidth() {
+ PluginObject *obj = (PluginObject*) inst()->pdata;
+ return obj->window->width;
+}
+
+int SubPlugin::getPluginHeight() {
+ PluginObject *obj = (PluginObject*) inst()->pdata;
+ return obj->window->height;
+}
+
static void pluginInvalidate(NPObject *obj);
static bool pluginHasProperty(NPObject *obj, NPIdentifier name);
static bool pluginHasMethod(NPObject *obj, NPIdentifier name);
diff --git a/samples/BrowserPlugin/jni/PluginObject.h b/samples/BrowserPlugin/jni/PluginObject.h
index deb60ea..21b7707 100644
--- a/samples/BrowserPlugin/jni/PluginObject.h
+++ b/samples/BrowserPlugin/jni/PluginObject.h
@@ -44,6 +44,9 @@
virtual int16 handleEvent(const ANPEvent* evt) = 0;
virtual bool supportsDrawingModel(ANPDrawingModel) = 0;
+ int getPluginWidth();
+ int getPluginHeight();
+
NPP inst() const { return m_inst; }
private:
diff --git a/samples/BrowserPlugin/jni/jni-bridge.cpp b/samples/BrowserPlugin/jni/jni-bridge.cpp
index 22e76da..08e7f5a 100644
--- a/samples/BrowserPlugin/jni/jni-bridge.cpp
+++ b/samples/BrowserPlugin/jni/jni-bridge.cpp
@@ -51,6 +51,16 @@
}
}
+static jint getSurfaceWidth(JNIEnv* env, jobject thiz, jint npp) {
+ SurfaceSubPlugin* obj = getPluginObject(npp);
+ return obj->getPluginWidth();
+}
+
+static jint getSurfaceHeight(JNIEnv* env, jobject thiz, jint npp) {
+ SurfaceSubPlugin* obj = getPluginObject(npp);
+ return obj->getPluginHeight();
+}
+
static jboolean isFixedSurface(JNIEnv* env, jobject thiz, jint npp) {
SurfaceSubPlugin* obj = getPluginObject(npp);
return obj->isFixedSurface();
@@ -63,6 +73,8 @@
{ "nativeSurfaceCreated", "(ILandroid/view/View;)V", (void*) surfaceCreated },
{ "nativeSurfaceChanged", "(IIII)V", (void*) surfaceChanged },
{ "nativeSurfaceDestroyed", "(I)V", (void*) surfaceDestroyed },
+ { "nativeGetSurfaceWidth", "(I)I", (void*) getSurfaceWidth },
+ { "nativeGetSurfaceHeight", "(I)I", (void*) getSurfaceHeight },
{ "nativeIsFixedSurface", "(I)Z", (void*) isFixedSurface },
};
diff --git a/samples/BrowserPlugin/src/com/android/sampleplugin/SamplePluginStub.java b/samples/BrowserPlugin/src/com/android/sampleplugin/SamplePluginStub.java
index 3c0a0c7..22b7b44 100644
--- a/samples/BrowserPlugin/src/com/android/sampleplugin/SamplePluginStub.java
+++ b/samples/BrowserPlugin/src/com/android/sampleplugin/SamplePluginStub.java
@@ -63,10 +63,12 @@
}
});
-
+
+ // TODO provide way for native plugin code to reset the size
if (nativeIsFixedSurface(npp)) {
- //TODO get the fixed dimensions from the plugin
- //view.getHolder().setFixedSize(width, height);
+ int width = nativeGetSurfaceWidth(npp);
+ int height = nativeGetSurfaceHeight(npp);
+ view.getHolder().setFixedSize(width, height);
}
return view;
@@ -114,5 +116,7 @@
private native void nativeSurfaceCreated(int npp, View surfaceView);
private native void nativeSurfaceChanged(int npp, int format, int width, int height);
private native void nativeSurfaceDestroyed(int npp);
+ private native int nativeGetSurfaceWidth(int npp);
+ private native int nativeGetSurfaceHeight(int npp);
private native boolean nativeIsFixedSurface(int npp);
}