summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp2
-rw-r--r--WebKit/android/plugins/android_npapi.h5
-rw-r--r--WebKit/android/plugins/sample/main.cpp14
-rw-r--r--WebKit/android/plugins/sample/pluginGraphics.cpp31
4 files changed, 42 insertions, 10 deletions
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index 084765b..9a2f7f6 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -83,6 +83,7 @@ extern void ANPLogInterfaceV0_Init(ANPInterface* value);
extern void ANPMatrixInterfaceV0_Init(ANPInterface* value);
extern void ANPOffscreenInterfaceV0_Init(ANPInterface* value);
extern void ANPPaintInterfaceV0_Init(ANPInterface* value);
+extern void ANPPathInterfaceV0_Init(ANPInterface* value);
extern void ANPTypefaceInterfaceV0_Init(ANPInterface* value);
extern void ANPWindowInterfaceV0_Init(ANPInterface* value);
@@ -101,6 +102,7 @@ static const VarProcPair gVarProcs[] = {
{ VARPROCLINE(CanvasInterfaceV0) },
{ VARPROCLINE(MatrixInterfaceV0) },
{ VARPROCLINE(PaintInterfaceV0) },
+ { VARPROCLINE(PathInterfaceV0) },
{ VARPROCLINE(TypefaceInterfaceV0) },
{ VARPROCLINE(WindowInterfaceV0) },
};
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 85a8c99..83fe3a9 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -101,8 +101,9 @@ typedef uint32_t ANPMatrixFlag;
#define kCanvasInterfaceV0_ANPGetValue ((NPNVariable)1002)
#define kMatrixInterfaceV0_ANPGetValue ((NPNVariable)1003)
#define kPaintInterfaceV0_ANPGetValue ((NPNVariable)1004)
-#define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1005)
-#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1006)
+#define kPathInterfaceV0_ANPGetValue ((NPNVariable)1005)
+#define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1006)
+#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1007)
/* queries for which drawing model is desired (for the draw event)
diff --git a/WebKit/android/plugins/sample/main.cpp b/WebKit/android/plugins/sample/main.cpp
index e34cee6..4abc07c 100644
--- a/WebKit/android/plugins/sample/main.cpp
+++ b/WebKit/android/plugins/sample/main.cpp
@@ -63,6 +63,7 @@ ANPAudioTrackInterfaceV0 gSoundI;
ANPCanvasInterfaceV0 gCanvasI;
ANPLogInterfaceV0 gLogI;
ANPPaintInterfaceV0 gPaintI;
+ANPPathInterfaceV0 gPathI;
ANPTypefaceInterfaceV0 gTypefaceI;
#define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
@@ -103,6 +104,7 @@ NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs,
{ kLogInterfaceV0_ANPGetValue, sizeof(gLogI), &gLogI },
{ kCanvasInterfaceV0_ANPGetValue, sizeof(gCanvasI), &gCanvasI },
{ kPaintInterfaceV0_ANPGetValue, sizeof(gPaintI), &gPaintI },
+ { kPathInterfaceV0_ANPGetValue, sizeof(gPathI), &gPathI },
{ kTypefaceInterfaceV0_ANPGetValue, sizeof(gPaintI), &gTypefaceI },
{ kAudioTrackInterfaceV0_ANPGetValue, sizeof(gSoundI), &gSoundI },
};
@@ -367,19 +369,17 @@ int16 NPP_HandleEvent(NPP instance, void* event)
instance, evt->data.touch.action, evt->data.touch.x,
evt->data.touch.y);
if (kUp_ANPTouchAction == evt->data.touch.action) {
+ if (NULL == obj->track) {
+ obj->track = createTrack(instance, "/sdcard/sample.snd");
+ }
if (obj->track) {
+ gLogI.log(instance, kDebug_ANPLogType, "track %p %d",
+ obj->track, gSoundI.isStopped(obj->track));
if (gSoundI.isStopped(obj->track)) {
gSoundI.start(obj->track);
} else {
gSoundI.pause(obj->track);
}
- } else {
- obj->track = createTrack(instance, "/sdcard/sample.snd");
- gLogI.log(instance, kDebug_ANPLogType, "track %p %d",
- obj->track, gSoundI.isStopped(obj->track));
- gSoundI.start(obj->track);
- gLogI.log(instance, kDebug_ANPLogType, "track %p %d",
- obj->track, gSoundI.isStopped(obj->track));
}
}
return 1;
diff --git a/WebKit/android/plugins/sample/pluginGraphics.cpp b/WebKit/android/plugins/sample/pluginGraphics.cpp
index ffa43e5..7fbf7a7 100644
--- a/WebKit/android/plugins/sample/pluginGraphics.cpp
+++ b/WebKit/android/plugins/sample/pluginGraphics.cpp
@@ -36,6 +36,7 @@ extern NPNetscapeFuncs* browser;
extern ANPLogInterfaceV0 gLogI;
extern ANPCanvasInterfaceV0 gCanvasI;
extern ANPPaintInterfaceV0 gPaintI;
+extern ANPPathInterfaceV0 gPathI;
extern ANPTypefaceInterfaceV0 gTypefaceI;
static void inval(NPP instance) {
@@ -128,6 +129,8 @@ void BallAnimation::draw(ANPCanvas* canvas) {
PluginObject *obj = (PluginObject*) instance->pdata;
const float OW = 20;
const float OH = 20;
+ const int W = obj->window->width;
+ const int H = obj->window->height;
inval(instance, m_oval, true); // inval the old
m_oval.left = m_x;
@@ -135,9 +138,35 @@ void BallAnimation::draw(ANPCanvas* canvas) {
m_oval.right = m_x + OW;
m_oval.bottom = m_y + OH;
inval(instance, m_oval, true); // inval the new
-
+
gCanvasI.drawColor(canvas, 0xFFFFFFFF);
+ // test out the Path API
+ {
+ ANPPath* path = gPathI.newPath();
+
+ float cx = W * 0.5f;
+ float cy = H * 0.5f;
+ gPathI.moveTo(path, 0, 0);
+ gPathI.quadTo(path, cx, cy, W, 0);
+ gPathI.quadTo(path, cx, cy, W, H);
+ gPathI.quadTo(path, cx, cy, 0, H);
+ gPathI.quadTo(path, cx, cy, 0, 0);
+
+ gPaintI.setColor(m_paint, 0xFF0000FF);
+ gCanvasI.drawPath(canvas, path, m_paint);
+
+ ANPRectF bounds;
+ memset(&bounds, 0, sizeof(bounds));
+ gPathI.getBounds(path, &bounds);
+#if 0
+ gLogI.log(instance, kDebug_ANPLogType, "drawpath: center %g %g bounds [%g %g %g %g]\n",
+ cx, cy,
+ bounds.left, bounds.top, bounds.right, bounds.bottom);
+#endif
+ gPathI.deletePath(path);
+ }
+
gPaintI.setColor(m_paint, 0xFFFF0000);
gCanvasI.drawOval(canvas, &m_oval, m_paint);