diff options
-rw-r--r-- | WebCore/plugins/android/PluginViewAndroid.cpp | 12 | ||||
-rw-r--r-- | WebKit/Android.mk | 3 | ||||
-rw-r--r-- | WebKit/android/plugins/ANPSurfaceInterface.cpp | 59 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 3 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.h | 6 | ||||
-rw-r--r-- | WebKit/android/plugins/android_npapi.h | 41 |
6 files changed, 111 insertions, 13 deletions
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index 5070792..230a389 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -86,6 +86,7 @@ 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 ANPSurfaceInterfaceV0_Init(ANPInterface* value); extern void ANPTypefaceInterfaceV0_Init(ANPInterface* value); extern void ANPWindowInterfaceV0_Init(ANPInterface* value); @@ -106,6 +107,7 @@ static const VarProcPair gVarProcs[] = { { VARPROCLINE(MatrixInterfaceV0) }, { VARPROCLINE(PaintInterfaceV0) }, { VARPROCLINE(PathInterfaceV0) }, + { VARPROCLINE(SurfaceInterfaceV0) }, { VARPROCLINE(TypefaceInterfaceV0) }, { VARPROCLINE(WindowInterfaceV0) }, }; @@ -533,14 +535,8 @@ NPError PluginView::platformSetValue(NPPVariable variable, void* value) switch (variable) { case kRequestDrawingModel_ANPSetValue: { ANPDrawingModel model = reinterpret_cast<ANPDrawingModel>(value); - switch (model) { - case kBitmap_ANPDrawingModel: - m_window->setDrawingModel(model); - error = NPERR_NO_ERROR; - break; - default: - break; - } + if (m_window->setDrawingModel(model)) + error = NPERR_NO_ERROR; break; } case kAcceptEvents_ANPSetValue : { diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 95eb0e1..4fff70e 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -61,7 +61,8 @@ LOCAL_SRC_FILES := \ android/plugins/ANPPaintInterface.cpp \ android/plugins/ANPPathInterface.cpp \ android/plugins/ANPSoundInterface.cpp \ - android/plugins/ANPTypefaceInterface.cpp \ + android/plugins/ANPSurfaceInterface.cpp \ + android/plugins/ANPTypefaceInterface.cpp \ android/plugins/ANPWindowInterface.cpp \ android/plugins/PluginTimer.cpp \ android/plugins/PluginViewBridgeAndroid.cpp \ diff --git a/WebKit/android/plugins/ANPSurfaceInterface.cpp b/WebKit/android/plugins/ANPSurfaceInterface.cpp new file mode 100644 index 0000000..a64af1e --- /dev/null +++ b/WebKit/android/plugins/ANPSurfaceInterface.cpp @@ -0,0 +1,59 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// must include config.h first for webkit to fiddle with new/delete +#include "config.h" +#include "SkANP.h" + +static ANPSurface* anp_newSurface(NPP instance, ANPSurfaceType) { + return NULL; +} + +static void anp_deleteSurface(ANPSurface* surface) { + +} + +static bool anp_lock(ANPSurface* surface, ANPBitmap* bitmap, + ANPRectI* dirtyRect) { + return false; +} + +static void anp_unlock(ANPSurface* surface) { + +} + +/////////////////////////////////////////////////////////////////////////////// + +#define ASSIGN(obj, name) (obj)->name = anp_##name + +void ANPSurfaceInterfaceV0_Init(ANPInterface* value) { + ANPSurfaceInterfaceV0* i = reinterpret_cast<ANPSurfaceInterfaceV0*>(value); + + ASSIGN(i, newSurface); + ASSIGN(i, deleteSurface); + ASSIGN(i, lock); + ASSIGN(i, unlock); +} + diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index ddb07bf..7566d63 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -70,8 +70,9 @@ void PluginWidgetAndroid::setWindow(int x, int y, int width, int height, width, height); } -void PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) { +bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) { m_drawingModel = model; + return true; } void PluginWidgetAndroid::localToPageCoords(SkIRect* rect) const { diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 1b0cfa9..c8d1ffe 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -59,9 +59,11 @@ struct PluginWidgetAndroid { /* Called each time the PluginView gets a new size or position. */ void setWindow(int x, int y, int width, int height, bool isTransparent); - /* Called whenever the plugin itself requests a new drawing model + /* Called whenever the plugin itself requests a new drawing model. If the + hardware does not support the requested model then false is returned, + otherwise true is returned. */ - void setDrawingModel(ANPDrawingModel); + bool setDrawingModel(ANPDrawingModel); /* Utility method to convert from local (plugin) coordinates to docuemnt coordinates. Needed (for instance) to convert the dirty rectangle into diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index fd49eb8..7f01024 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -116,6 +116,7 @@ typedef uint32_t ANPMatrixFlag; #define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1006) #define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1007) #define kBitmapInterfaceV0_ANPGetValue ((NPNVariable)1008) +#define kSurfaceInterfaceV0_ANPGetValue ((NPNVariable)1009) /* queries for which drawing model is desired (for the draw event) @@ -143,7 +144,8 @@ enum ANPDrawingModels { /** Draw into a bitmap from the browser thread in response to a Draw event. NPWindow->window is reserved (ignore) */ - kBitmap_ANPDrawingModel = 0, + kBitmap_ANPDrawingModel = 0, + kSurface_ANPDrawingModel = 1, }; typedef int32_t ANPDrawingModel; @@ -198,6 +200,43 @@ struct ANPBitmapInterfaceV0 : ANPInterface { bool (*getPixelPacking)(ANPBitmapFormat, ANPPixelPacking* packing); }; +/** The ANPSurface acts as a handle between the plugin and the native libraries + that render the surface to the screen. + */ +struct ANPSurface; + +/** The surfaceType is the mechanism by which the plugin informs the native + libraries which type of surface view it wishes to use. + */ +enum ANPSurfaceTypes { + kRGBA_ANPSurfaceType = 0 +}; +typedef int32_t ANPSurfaceType; + +struct ANPSurfaceInterfaceV0 : ANPInterface { + /** Creates a new surface handle based on the given surface type. If the + given surface type is not supported then NULL is returned. + */ + ANPSurface* (*newSurface)(NPP instance, ANPSurfaceType); + /** Given a valid surface handle (i.e. one created by calling newSurface) + the underlying surface is removed and the pointer is set to NULL. + */ + void (*deleteSurface)(ANPSurface* surface); + /** Locks the surface from manipulation by other threads and provides a bitmap + to be written to. The dirtyRect param specifies which portion of the + bitmap will be written to. If the dirtyRect is NULL then the entire + surface will be considered dirty. If the lock was successful the function + will return true and the bitmap will be set to point to a valid bitmap. + If not the function will return false and the bitmap will be set to NULL. + */ + bool (*lock)(ANPSurface* surface, ANPBitmap* bitmap, ANPRectI* dirtyRect); + /** Given a locked surface handle (i.e. result of a successful call to lock) + the surface is unlocked and the contents of the bitmap, specifically + those inside the dirtyRect are written to the screen. + */ + void (*unlock)(ANPSurface* surface); +}; + struct ANPMatrixInterfaceV0 : ANPInterface { /* Return a new identity matrix */ |