updating sample plugins to support fixed surface dimensions.

This commit is contained in:
Derek Sollenberger
2009-10-13 11:43:48 -04:00
parent 46ab498e50
commit bb660dd555
4 changed files with 32 additions and 3 deletions

View File

@@ -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);

View File

@@ -44,6 +44,9 @@ public:
virtual int16 handleEvent(const ANPEvent* evt) = 0;
virtual bool supportsDrawingModel(ANPDrawingModel) = 0;
int getPluginWidth();
int getPluginHeight();
NPP inst() const { return m_inst; }
private:

View File

@@ -51,6 +51,16 @@ static void surfaceDestroyed(JNIEnv* env, jobject thiz, jint npp) {
}
}
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 @@ static JNINativeMethod gJavaSamplePluginStubMethods[] = {
{ "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 },
};

View File

@@ -64,9 +64,11 @@ public class SamplePluginStub implements PluginStub {
});
// 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 @@ public class SamplePluginStub implements PluginStub {
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);
}