diff --git a/api/current.xml b/api/current.xml
index 7562f2e27b345..36d083d8efcfb 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -167285,6 +167285,8 @@
deprecated="not deprecated"
visibility="public"
>
+
+
@@ -167438,24 +167440,13 @@
-
-
-
-
-
+
+
-
+
stubClass =
- pluginCL.loadClass(className);
- Constructor> stubConstructor =
- stubClass.getConstructor(int.class);
- Object stubObject = stubConstructor.newInstance(NPP);
+ Class> stubClass = pluginCL.loadClass(className);
+ Object stubObject = stubClass.newInstance();
if (stubObject instanceof PluginStub) {
return (PluginStub) stubObject;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 5f2d65e5da865..ac3334c7376f7 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -34,6 +34,7 @@ import android.util.SparseBooleanArray;
import android.view.KeyEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import android.view.View;
import java.util.ArrayList;
import java.util.Map;
@@ -2060,84 +2061,32 @@ final class WebViewCore {
}
}
- // This class looks like a SurfaceView to native code. In java, we can
- // assume the passed in SurfaceView is this class so we can talk to the
- // ViewManager through the ChildView.
- private class SurfaceViewProxy extends SurfaceView
- implements SurfaceHolder.Callback {
- private final ViewManager.ChildView mChildView;
- private int mPointer;
- private final boolean mIsFixedSize;
- SurfaceViewProxy(Context context, ViewManager.ChildView childView,
- int pointer, int pixelFormat, boolean isFixedSize) {
- super(context);
- setWillNotDraw(false); // this prevents the black box artifact
- getHolder().addCallback(this);
- getHolder().setFormat(pixelFormat);
- mChildView = childView;
- mChildView.mView = this;
- mPointer = pointer;
- mIsFixedSize = isFixedSize;
- }
- void destroy() {
- mPointer = 0;
- mChildView.removeView();
- }
- void attach(int x, int y, int width, int height) {
- mChildView.attachView(x, y, width, height);
-
- if (mIsFixedSize) {
- getHolder().setFixedSize(width, height);
- }
- }
-
- // SurfaceHolder.Callback methods
- public void surfaceCreated(SurfaceHolder holder) {
- if (mPointer != 0) {
- nativeSurfaceChanged(mPointer, 0, 0, 0, 0);
- }
- }
- public void surfaceChanged(SurfaceHolder holder, int format, int width,
- int height) {
- if (mPointer != 0) {
- nativeSurfaceChanged(mPointer, 1, format, width, height);
- }
- }
- public void surfaceDestroyed(SurfaceHolder holder) {
- if (mPointer != 0) {
- nativeSurfaceChanged(mPointer, 2, 0, 0, 0);
- }
- }
- }
-
- // PluginWidget functions for mainting SurfaceViews for the Surface drawing
+ // PluginWidget functions for creating SurfaceViews for the Surface drawing
// model.
- private SurfaceView createSurface(int nativePointer, int pixelFormat,
- boolean isFixedSize) {
+ private ViewManager.ChildView createSurface(String packageName, String className,
+ int npp, int x, int y, int width, int height) {
if (mWebView == null) {
return null;
}
- return new SurfaceViewProxy(mContext, mWebView.mViewManager.createView(),
- nativePointer, pixelFormat, isFixedSize);
+ PluginStub stub = PluginUtil.getPluginStub(mWebView.getContext(), packageName, className);
+ if (stub == null) {
+ Log.e(LOGTAG, "Unable to find plugin class (" + className +
+ ") in the apk (" + packageName + ")");
+ return null;
+ }
+
+ View pluginView = stub.getEmbeddedView(npp, mWebView.getContext());
+
+ ViewManager.ChildView view = mWebView.mViewManager.createView();
+ view.mView = pluginView;
+ view.attachView(x, y, width, height);
+ return view;
}
-
- private void destroySurface(SurfaceView surface) {
- SurfaceViewProxy proxy = (SurfaceViewProxy) surface;
- proxy.destroy();
+
+ private void destroySurface(ViewManager.ChildView childView) {
+ childView.removeView();
}
- private void attachSurface(SurfaceView surface, int x, int y,
- int width, int height) {
- SurfaceViewProxy proxy = (SurfaceViewProxy) surface;
- proxy.attach(x, y, width, height);
- }
-
- // Callback for the SurfaceHolder.Callback. Called for all the surface
- // callbacks. The state parameter is one of Created(0), Changed(1),
- // Destroyed(2).
- private native void nativeSurfaceChanged(int pointer, int state, int format,
- int width, int height);
-
private native void nativePause();
private native void nativeResume();
private native void nativeFreeMemory();
diff --git a/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp b/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp
index 1263204431958..706c27edddadf 100644
--- a/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp
+++ b/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp
@@ -36,27 +36,18 @@ extern NPNetscapeFuncs* browser;
extern ANPCanvasInterfaceV0 gCanvasI;
extern ANPLogInterfaceV0 gLogI;
extern ANPPaintInterfaceV0 gPaintI;
-extern ANPSurfaceInterfaceV0 gSurfaceI;
extern ANPTypefaceInterfaceV0 gTypefaceI;
///////////////////////////////////////////////////////////////////////////////
-EventPlugin::EventPlugin(NPP inst) : SubPlugin(inst) {
+EventPlugin::EventPlugin(NPP inst) : SubPlugin(inst) { }
- // initialize the drawing surface
- m_surfaceReady = false;
- m_surface = gSurfaceI.newRasterSurface(inst, kRGB_565_ANPBitmapFormat, false);
- if(!m_surface)
- gLogI.log(inst, kError_ANPLogType, "----%p Unable to create Raster surface", inst);
-}
+EventPlugin::~EventPlugin() { }
-EventPlugin::~EventPlugin() {
- gSurfaceI.deleteSurface(m_surface);
-}
+void EventPlugin::drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip) {
-void EventPlugin::drawPlugin(int surfaceWidth, int surfaceHeight) {
-
- gLogI.log(inst(), kDebug_ANPLogType, " ------ %p drawing the plugin (%d,%d)", inst(), surfaceWidth, surfaceHeight);
+ gLogI.log(inst(), kDebug_ANPLogType, " ------ %p drawing the plugin (%d,%d)",
+ inst(), bitmap.width, bitmap.height);
// get the plugin's dimensions according to the DOM
PluginObject *obj = (PluginObject*) inst()->pdata;
@@ -64,8 +55,8 @@ void EventPlugin::drawPlugin(int surfaceWidth, int surfaceHeight) {
const int H = obj->window->height;
// compute the current zoom level
- const float zoomFactorW = static_cast(surfaceWidth) / W;
- const float zoomFactorH = static_cast(surfaceHeight) / H;
+ const float zoomFactorW = static_cast(bitmap.width) / W;
+ const float zoomFactorH = static_cast(bitmap.height) / H;
// check to make sure the zoom level is uniform
if (zoomFactorW + .01 < zoomFactorH && zoomFactorW - .01 > zoomFactorH)
@@ -76,15 +67,16 @@ void EventPlugin::drawPlugin(int surfaceWidth, int surfaceHeight) {
const int fontSize = (int)(zoomFactorW * 16);
const int leftMargin = (int)(zoomFactorW * 10);
- // lock the surface
- ANPBitmap bitmap;
- if (!m_surfaceReady || !gSurfaceI.lock(m_surface, &bitmap, NULL)) {
- gLogI.log(inst(), kError_ANPLogType, " ------ %p unable to lock the plugin", inst());
- return;
- }
-
- // create a canvas
+ // create and clip a canvas
ANPCanvas* canvas = gCanvasI.newCanvas(&bitmap);
+
+ ANPRectF clipR;
+ clipR.left = clip.left;
+ clipR.top = clip.top;
+ clipR.right = clip.right;
+ clipR.bottom = clip.bottom;
+ gCanvasI.clipRect(canvas, &clipR);
+
gCanvasI.drawColor(canvas, 0xFFFFFFFF);
// configure the paint
@@ -106,10 +98,9 @@ void EventPlugin::drawPlugin(int surfaceWidth, int surfaceHeight) {
const char c[] = "Browser Test Plugin";
gCanvasI.drawText(canvas, c, sizeof(c)-1, leftMargin, -fm.fTop, paint);
- // clean up variables and unlock the surface
+ // clean up variables
gPaintI.deletePaint(paint);
gCanvasI.deleteCanvas(canvas);
- gSurfaceI.unlock(m_surface);
}
void EventPlugin::printToDiv(const char* text, int length) {
@@ -149,23 +140,16 @@ void EventPlugin::printToDiv(const char* text, int length) {
int16 EventPlugin::handleEvent(const ANPEvent* evt) {
switch (evt->eventType) {
- case kDraw_ANPEventType:
- gLogI.log(inst(), kError_ANPLogType, " ------ %p the plugin did not request draw events", inst());
- break;
- case kSurface_ANPEventType:
- switch (evt->data.surface.action) {
- case kCreated_ANPSurfaceAction:
- m_surfaceReady = true;
- return 1;
- case kDestroyed_ANPSurfaceAction:
- m_surfaceReady = false;
- return 1;
- case kChanged_ANPSurfaceAction:
- drawPlugin(evt->data.surface.data.changed.width,
- evt->data.surface.data.changed.height);
+
+ case kDraw_ANPEventType: {
+ switch (evt->data.draw.model) {
+ case kBitmap_ANPDrawingModel:
+ drawPlugin(evt->data.draw.data.bitmap, evt->data.draw.clip);
return 1;
+ default:
+ break; // unknown drawing model
}
- break;
+ }
case kLifecycle_ANPEventType:
switch (evt->data.lifecycle.action) {
case kOnLoad_ANPLifecycleAction: {
diff --git a/tests/BrowserTestPlugin/jni/event/EventPlugin.h b/tests/BrowserTestPlugin/jni/event/EventPlugin.h
index 73dd6ea4dfb11..88b7c9d1bc370 100644
--- a/tests/BrowserTestPlugin/jni/event/EventPlugin.h
+++ b/tests/BrowserTestPlugin/jni/event/EventPlugin.h
@@ -35,11 +35,8 @@ public:
virtual int16 handleEvent(const ANPEvent* evt);
private:
- void drawPlugin(int surfaceWidth, int surfaceHeight);
+ void drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip);
void printToDiv(const char* text, int length);
-
- bool m_surfaceReady;
- ANPSurface* m_surface;
};
#endif // eventPlugin__DEFINED
diff --git a/tests/BrowserTestPlugin/jni/main.cpp b/tests/BrowserTestPlugin/jni/main.cpp
index 056ec4ddfae15..e3ad4a739c819 100644
--- a/tests/BrowserTestPlugin/jni/main.cpp
+++ b/tests/BrowserTestPlugin/jni/main.cpp
@@ -65,7 +65,6 @@ ANPCanvasInterfaceV0 gCanvasI;
ANPLogInterfaceV0 gLogI;
ANPPaintInterfaceV0 gPaintI;
ANPPathInterfaceV0 gPathI;
-ANPSurfaceInterfaceV0 gSurfaceI;
ANPSystemInterfaceV0 gSystemI;
ANPTypefaceInterfaceV0 gTypefaceI;
ANPWindowInterfaceV0 gWindowI;
@@ -105,16 +104,10 @@ NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs,
uint32_t size;
ANPInterface* i;
} gPairs[] = {
- { kAudioTrackInterfaceV0_ANPGetValue, sizeof(gSoundI), &gSoundI },
- { kBitmapInterfaceV0_ANPGetValue, sizeof(gBitmapI), &gBitmapI },
{ kCanvasInterfaceV0_ANPGetValue, sizeof(gCanvasI), &gCanvasI },
{ kLogInterfaceV0_ANPGetValue, sizeof(gLogI), &gLogI },
{ kPaintInterfaceV0_ANPGetValue, sizeof(gPaintI), &gPaintI },
- { kPathInterfaceV0_ANPGetValue, sizeof(gPathI), &gPathI },
- { kSurfaceInterfaceV0_ANPGetValue, sizeof(gSurfaceI), &gSurfaceI },
- { kSystemInterfaceV0_ANPGetValue, sizeof(gSystemI), &gSystemI },
{ kTypefaceInterfaceV0_ANPGetValue, sizeof(gTypefaceI), &gTypefaceI },
- { kWindowInterfaceV0_ANPGetValue, sizeof(gWindowI), &gWindowI },
};
for (size_t i = 0; i < ARRAY_COUNT(gPairs); i++) {
gPairs[i].i->inSize = gPairs[i].size;
@@ -156,7 +149,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
}
// select the drawing model
- ANPDrawingModel model = kSurface_ANPDrawingModel;
+ ANPDrawingModel model = kBitmap_ANPDrawingModel;
// notify the plugin API of the drawing model we wish to use. This must be
// done prior to creating certain subPlugin objects (e.g. surfaceViews)