diff options
Diffstat (limited to 'WebKit/android/plugins')
31 files changed, 0 insertions, 4967 deletions
diff --git a/WebKit/android/plugins/ANPBitmapInterface.cpp b/WebKit/android/plugins/ANPBitmapInterface.cpp deleted file mode 100644 index 4c6ad7c..0000000 --- a/WebKit/android/plugins/ANPBitmapInterface.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 THE COPYRIGHT OWNER 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" -#include "SkColorPriv.h" - -static bool anp_getPixelPacking(ANPBitmapFormat fmt, ANPPixelPacking* packing) { - switch (fmt) { - case kRGBA_8888_ANPBitmapFormat: - if (packing) { - packing->AShift = SK_A32_SHIFT; - packing->ABits = SK_A32_BITS; - packing->RShift = SK_R32_SHIFT; - packing->RBits = SK_R32_BITS; - packing->GShift = SK_G32_SHIFT; - packing->GBits = SK_G32_BITS; - packing->BShift = SK_B32_SHIFT; - packing->BBits = SK_B32_BITS; - } - return true; - case kRGB_565_ANPBitmapFormat: - if (packing) { - packing->AShift = 0; - packing->ABits = 0; - packing->RShift = SK_R16_SHIFT; - packing->RBits = SK_R16_BITS; - packing->GShift = SK_G16_SHIFT; - packing->GBits = SK_G16_BITS; - packing->BShift = SK_B16_SHIFT; - packing->BBits = SK_B16_BITS; - } - return true; - default: - break; - } - return false; -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPBitmapInterfaceV0_Init(ANPInterface* value) { - ANPBitmapInterfaceV0* i = reinterpret_cast<ANPBitmapInterfaceV0*>(value); - - ASSIGN(i, getPixelPacking); -} diff --git a/WebKit/android/plugins/ANPCanvasInterface.cpp b/WebKit/android/plugins/ANPCanvasInterface.cpp deleted file mode 100644 index d6d89ff..0000000 --- a/WebKit/android/plugins/ANPCanvasInterface.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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 ANPCanvas* anp_newCanvas(const ANPBitmap* bitmap) { - SkBitmap bm; - return new ANPCanvas(*SkANP::SetBitmap(&bm, *bitmap)); -} - -static void anp_deleteCanvas(ANPCanvas* canvas) { - delete canvas; -} - -static void anp_save(ANPCanvas* canvas) { - canvas->skcanvas->save(); -} - -static void anp_restore(ANPCanvas* canvas) { - canvas->skcanvas->restore(); -} - -static void anp_translate(ANPCanvas* canvas, float tx, float ty) { - canvas->skcanvas->translate(SkFloatToScalar(tx), SkFloatToScalar(ty)); -} - -static void anp_scale(ANPCanvas* canvas, float sx, float sy) { - canvas->skcanvas->scale(SkFloatToScalar(sx), SkFloatToScalar(sy)); -} - -static void anp_rotate(ANPCanvas* canvas, float degrees) { - canvas->skcanvas->rotate(SkFloatToScalar(degrees)); -} - -static void anp_skew(ANPCanvas* canvas, float kx, float ky) { - canvas->skcanvas->skew(SkFloatToScalar(kx), SkFloatToScalar(ky)); -} - -static void anp_clipRect(ANPCanvas* canvas, const ANPRectF* rect) { - SkRect r; - canvas->skcanvas->clipRect(*SkANP::SetRect(&r, *rect)); -} - -static void anp_clipPath(ANPCanvas* canvas, const ANPPath* path) { - canvas->skcanvas->clipPath(*path); -} -static void anp_concat(ANPCanvas* canvas, const ANPMatrix* matrix) { - canvas->skcanvas->concat(*matrix); -} - -static void anp_getTotalMatrix(ANPCanvas* canvas, ANPMatrix* matrix) { - const SkMatrix& src = canvas->skcanvas->getTotalMatrix(); - *matrix = *reinterpret_cast<const ANPMatrix*>(&src); -} - -static bool anp_getLocalClipBounds(ANPCanvas* canvas, ANPRectF* r, - bool antialias) { - SkRect bounds; - if (canvas->skcanvas->getClipBounds(&bounds, - antialias ? SkCanvas::kAA_EdgeType : SkCanvas::kBW_EdgeType)) { - SkANP::SetRect(r, bounds); - return true; - } - return false; -} - -static bool anp_getDeviceClipBounds(ANPCanvas* canvas, ANPRectI* r) { - const SkRegion& clip = canvas->skcanvas->getTotalClip(); - if (!clip.isEmpty()) { - SkANP::SetRect(r, clip.getBounds()); - return true; - } - return false; -} - -static void anp_drawColor(ANPCanvas* canvas, ANPColor color) { - canvas->skcanvas->drawColor(color); -} - -static void anp_drawPaint(ANPCanvas* canvas, const ANPPaint* paint) { - canvas->skcanvas->drawPaint(*paint); -} - -static void anp_drawLine(ANPCanvas* canvas, float x0, float y0, - float x1, float y1, const ANPPaint* paint) { - canvas->skcanvas->drawLine(SkFloatToScalar(x0), SkFloatToScalar(y0), - SkFloatToScalar(x1), SkFloatToScalar(y1), *paint); -} - -static void anp_drawRect(ANPCanvas* canvas, const ANPRectF* rect, - const ANPPaint* paint) { - SkRect r; - canvas->skcanvas->drawRect(*SkANP::SetRect(&r, *rect), *paint); -} - -static void anp_drawOval(ANPCanvas* canvas, const ANPRectF* rect, - const ANPPaint* paint) { - SkRect r; - canvas->skcanvas->drawOval(*SkANP::SetRect(&r, *rect), *paint); -} - -static void anp_drawPath(ANPCanvas* canvas, const ANPPath* path, - const ANPPaint* paint) { - canvas->skcanvas->drawPath(*path, *paint); -} - -static void anp_drawText(ANPCanvas* canvas, const void* text, uint32_t length, - float x, float y, const ANPPaint* paint) { - canvas->skcanvas->drawText(text, length, - SkFloatToScalar(x), SkFloatToScalar(y), - *paint); -} - -static void anp_drawPosText(ANPCanvas* canvas, const void* text, - uint32_t byteLength, const float xy[], const ANPPaint* paint) { - canvas->skcanvas->drawPosText(text, byteLength, - reinterpret_cast<const SkPoint*>(xy), *paint); -} - -static void anp_drawBitmap(ANPCanvas* canvas, const ANPBitmap* bitmap, - float x, float y, const ANPPaint* paint) { - SkBitmap bm; - canvas->skcanvas->drawBitmap(*SkANP::SetBitmap(&bm, *bitmap), - SkFloatToScalar(x), SkFloatToScalar(y), - paint); -} - -static void anp_drawBitmapRect(ANPCanvas* canvas, const ANPBitmap* bitmap, - const ANPRectI* src, const ANPRectF* dst, - const ANPPaint* paint) { - SkBitmap bm; - SkRect dstR; - SkIRect srcR, *srcPtr = NULL; - - if (src) { - srcPtr = SkANP::SetRect(&srcR, *src); - } - canvas->skcanvas->drawBitmapRect(*SkANP::SetBitmap(&bm, *bitmap), srcPtr, - *SkANP::SetRect(&dstR, *dst), paint); -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPCanvasInterfaceV0_Init(ANPInterface* value) { - ANPCanvasInterfaceV0* i = reinterpret_cast<ANPCanvasInterfaceV0*>(value); - - ASSIGN(i, newCanvas); - ASSIGN(i, deleteCanvas); - ASSIGN(i, save); - ASSIGN(i, restore); - ASSIGN(i, translate); - ASSIGN(i, scale); - ASSIGN(i, rotate); - ASSIGN(i, skew); - ASSIGN(i, clipRect); - ASSIGN(i, clipPath); - ASSIGN(i, concat); - ASSIGN(i, getTotalMatrix); - ASSIGN(i, getLocalClipBounds); - ASSIGN(i, getDeviceClipBounds); - ASSIGN(i, drawColor); - ASSIGN(i, drawPaint); - ASSIGN(i, drawLine); - ASSIGN(i, drawRect); - ASSIGN(i, drawOval); - ASSIGN(i, drawPath); - ASSIGN(i, drawText); - ASSIGN(i, drawPosText); - ASSIGN(i, drawBitmap); - ASSIGN(i, drawBitmapRect); -} diff --git a/WebKit/android/plugins/ANPEventInterface.cpp b/WebKit/android/plugins/ANPEventInterface.cpp deleted file mode 100644 index 2fdf159..0000000 --- a/WebKit/android/plugins/ANPEventInterface.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 THE COPYRIGHT OWNER 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" -#include "WebViewCore.h" -#include "PluginView.h" -#include "PluginWidgetAndroid.h" - -#include "JavaSharedClient.h" - -using namespace android; - -struct WrappedANPEvent { - WebViewCore* fWVC; - PluginWidgetAndroid* fPWA; - ANPEvent fEvent; -}; - -/* Its possible we may be called after the plugin that initiated the event - has been torn-down. Thus we check that the assicated webviewcore and - pluginwidget are still active before dispatching the event. - */ -static void send_anpevent(void* data) { - WrappedANPEvent* wrapper = static_cast<WrappedANPEvent*>(data); - WebViewCore* core = wrapper->fWVC; - PluginWidgetAndroid* widget = wrapper->fPWA; - - // be sure we're still alive before delivering the event - if (WebViewCore::isInstance(core) && core->isPlugin(widget)) { - widget->sendEvent(wrapper->fEvent); - } - delete wrapper; -} - -static void anp_postEvent(NPP instance, const ANPEvent* event) { - if (instance && instance->ndata && event) { - PluginView* pluginView = static_cast<PluginView*>(instance->ndata); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - WebViewCore* wvc = pluginWidget->webViewCore(); - - WrappedANPEvent* wrapper = new WrappedANPEvent; - // recored these, and recheck that they are valid before delivery - // in send_anpevent - wrapper->fWVC = pluginWidget->webViewCore(); - wrapper->fPWA = pluginWidget; - // make a copy of the event - wrapper->fEvent = *event; - JavaSharedClient::EnqueueFunctionPtr(send_anpevent, wrapper); - } -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPEventInterfaceV0_Init(ANPInterface* value) { - ANPEventInterfaceV0* i = reinterpret_cast<ANPEventInterfaceV0*>(value); - - ASSIGN(i, postEvent); -} diff --git a/WebKit/android/plugins/ANPKeyCodes.h b/WebKit/android/plugins/ANPKeyCodes.h deleted file mode 100644 index 969679f..0000000 --- a/WebKit/android/plugins/ANPKeyCodes.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef ANPKeyCodes_DEFINED -#define ANPKeyCodes_DEFINED - -/* List the key codes that are set to a plugin in the ANPKeyEvent. - - These exactly match the values in android/view/KeyEvent.java and the - corresponding .h file android/keycodes.h. -*/ -enum ANPKeyCodes { - kUnknown_ANPKeyCode = 0, - - kSoftLeft_ANPKeyCode = 1, - kSoftRight_ANPKeyCode = 2, - kHome_ANPKeyCode = 3, - kBack_ANPKeyCode = 4, - kCall_ANPKeyCode = 5, - kEndCall_ANPKeyCode = 6, - k0_ANPKeyCode = 7, - k1_ANPKeyCode = 8, - k2_ANPKeyCode = 9, - k3_ANPKeyCode = 10, - k4_ANPKeyCode = 11, - k5_ANPKeyCode = 12, - k6_ANPKeyCode = 13, - k7_ANPKeyCode = 14, - k8_ANPKeyCode = 15, - k9_ANPKeyCode = 16, - kStar_ANPKeyCode = 17, - kPound_ANPKeyCode = 18, - kDpadUp_ANPKeyCode = 19, - kDpadDown_ANPKeyCode = 20, - kDpadLeft_ANPKeyCode = 21, - kDpadRight_ANPKeyCode = 22, - kDpadCenter_ANPKeyCode = 23, - kVolumeUp_ANPKeyCode = 24, - kVolumeDown_ANPKeyCode = 25, - kPower_ANPKeyCode = 26, - kCamera_ANPKeyCode = 27, - kClear_ANPKeyCode = 28, - kA_ANPKeyCode = 29, - kB_ANPKeyCode = 30, - kC_ANPKeyCode = 31, - kD_ANPKeyCode = 32, - kE_ANPKeyCode = 33, - kF_ANPKeyCode = 34, - kG_ANPKeyCode = 35, - kH_ANPKeyCode = 36, - kI_ANPKeyCode = 37, - kJ_ANPKeyCode = 38, - kK_ANPKeyCode = 39, - kL_ANPKeyCode = 40, - kM_ANPKeyCode = 41, - kN_ANPKeyCode = 42, - kO_ANPKeyCode = 43, - kP_ANPKeyCode = 44, - kQ_ANPKeyCode = 45, - kR_ANPKeyCode = 46, - kS_ANPKeyCode = 47, - kT_ANPKeyCode = 48, - kU_ANPKeyCode = 49, - kV_ANPKeyCode = 50, - kW_ANPKeyCode = 51, - kX_ANPKeyCode = 52, - kY_ANPKeyCode = 53, - kZ_ANPKeyCode = 54, - kComma_ANPKeyCode = 55, - kPeriod_ANPKeyCode = 56, - kAltLeft_ANPKeyCode = 57, - kAltRight_ANPKeyCode = 58, - kShiftLeft_ANPKeyCode = 59, - kShiftRight_ANPKeyCode = 60, - kTab_ANPKeyCode = 61, - kSpace_ANPKeyCode = 62, - kSym_ANPKeyCode = 63, - kExplorer_ANPKeyCode = 64, - kEnvelope_ANPKeyCode = 65, - kNewline_ANPKeyCode = 66, - kDel_ANPKeyCode = 67, - kGrave_ANPKeyCode = 68, - kMinus_ANPKeyCode = 69, - kEquals_ANPKeyCode = 70, - kLeftBracket_ANPKeyCode = 71, - kRightBracket_ANPKeyCode = 72, - kBackslash_ANPKeyCode = 73, - kSemicolon_ANPKeyCode = 74, - kApostrophe_ANPKeyCode = 75, - kSlash_ANPKeyCode = 76, - kAt_ANPKeyCode = 77, - kNum_ANPKeyCode = 78, - kHeadSetHook_ANPKeyCode = 79, - kFocus_ANPKeyCode = 80, - kPlus_ANPKeyCode = 81, - kMenu_ANPKeyCode = 82, - kNotification_ANPKeyCode = 83, - kSearch_ANPKeyCode = 84, - kMediaPlayPause_ANPKeyCode = 85, - kMediaStop_ANPKeyCode = 86, - kMediaNext_ANPKeyCode = 87, - kMediaPrevious_ANPKeyCode = 88, - kMediaRewind_ANPKeyCode = 89, - kMediaFastForward_ANPKeyCode = 90, - kMute_ANPKeyCode = 91, - kPageUp_ANPKeyCode = 92, - kPageDown_ANPKeyCode = 93, - kPictsymbols_ANPKeyCode = 94, - kSwitchCharset_ANPKeyCode = 95, - kButtonA_ANPKeyCode = 96, - kButtonB_ANPKeyCode = 97, - kButtonC_ANPKeyCode = 98, - kButtonX_ANPKeyCode = 99, - kButtonY_ANPKeyCode = 100, - kButtonZ_ANPKeyCode = 101, - kButtonL1_ANPKeyCode = 102, - kButtonR1_ANPKeyCode = 103, - kButtonL2_ANPKeyCode = 104, - kButtonR2_ANPKeyCode = 105, - kButtonThumbL_ANPKeyCode = 106, - kButtonThumbR_ANPKeyCode = 107, - kButtonStart_ANPKeyCode = 108, - kButtonSelect_ANPKeyCode = 109, - kButtonMode_ANPKeyCode = 110, - kEscape_ANPKeyCode = 111, - kForwardDel_ANPKeyCode = 112, - kCtrlLeft_ANPKeyCode = 113, - kCtrlRight_ANPKeyCode = 114, - kCapsLock_ANPKeyCode = 115, - kScrollLock_ANPKeyCode = 116, - kMetaLeft_ANPKeyCode = 117, - kMetaRight_ANPKeyCode = 118, - kFunction_ANPKeyCode = 119, - kSysRq_ANPKeyCode = 120, - kBreak_ANPKeyCode = 121, - kMoveHome_ANPKeyCode = 122, - kMoveEnd_ANPKeyCode = 123, - kInsert_ANPKeyCode = 124, - kForward_ANPKeyCode = 125, - kMediaPlay_ANPKeyCode = 126, - kMediaPause_ANPKeyCode = 127, - kMediaClose_ANPKeyCode = 128, - kMediaEject_ANPKeyCode = 129, - kMediaRecord_ANPKeyCode = 130, - kF1_ANPKeyCode = 131, - kF2_ANPKeyCode = 132, - kF3_ANPKeyCode = 133, - kF4_ANPKeyCode = 134, - kF5_ANPKeyCode = 135, - kF6_ANPKeyCode = 136, - kF7_ANPKeyCode = 137, - kF8_ANPKeyCode = 138, - kF9_ANPKeyCode = 139, - kF10_ANPKeyCode = 140, - kF11_ANPKeyCode = 141, - kF12_ANPKeyCode = 142, - kNumLock_ANPKeyCode = 143, - kNumPad0_ANPKeyCode = 144, - kNumPad1_ANPKeyCode = 145, - kNumPad2_ANPKeyCode = 146, - kNumPad3_ANPKeyCode = 147, - kNumPad4_ANPKeyCode = 148, - kNumPad5_ANPKeyCode = 149, - kNumPad6_ANPKeyCode = 150, - kNumPad7_ANPKeyCode = 151, - kNumPad8_ANPKeyCode = 152, - kNumPad9_ANPKeyCode = 153, - kNumPadDivide_ANPKeyCode = 154, - kNumPadMultiply_ANPKeyCode = 155, - kNumPadSubtract_ANPKeyCode = 156, - kNumPadAdd_ANPKeyCode = 157, - kNumPadDot_ANPKeyCode = 158, - kNumPadComma_ANPKeyCode = 159, - kNumPadEnter_ANPKeyCode = 160, - kNumPadEquals_ANPKeyCode = 161, - kNumPadLeftParen_ANPKeyCode = 162, - kNumPadRightParen_ANPKeyCode = 163, - kVolumeMute_ANPKeyCode = 164, - kInfo_ANPKeyCode = 165, - kChannelUp_ANPKeyCode = 166, - kChannelDown_ANPKeyCode = 167, - kZoomIn_ANPKeyCode = 168, - kZoomOut_ANPKeyCode = 169, - kTv_ANPKeyCode = 170, - kWindow_ANPKeyCode = 171, - kGuide_ANPKeyCode = 172, - kDvr_ANPKeyCode = 173, - kBookmark_ANPKeyCode = 174, - kCaptions_ANPKeyCode = 175, - kSettings_ANPKeyCode = 176, - kTvPower_ANPKeyCode = 177, - kTvInput_ANPKeyCode = 178, - kStbPower_ANPKeyCode = 179, - kStbInput_ANPKeyCode = 180, - kAvrPower_ANPKeyCode = 181, - kAvrInput_ANPKeyCode = 182, - kProgRed_ANPKeyCode = 183, - kProgGreen_ANPKeyCode = 184, - kProgYellow_ANPKeyCode = 185, - kProgBlue_ANPKeyCode = 186, - kAppSwitch_ANPKeyCode = 187, - - // NOTE: If you add a new keycode here you must also add it to several other files. - // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. -}; - -#endif diff --git a/WebKit/android/plugins/ANPLogInterface.cpp b/WebKit/android/plugins/ANPLogInterface.cpp deleted file mode 100644 index 23a4ed6..0000000 --- a/WebKit/android/plugins/ANPLogInterface.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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. - */ - -#define LOG_TAG "webkitPlugin" - -#include "utils/Log.h" -#include "android_npapi.h" -#include <stdarg.h> - -static void anp_log(ANPLogType logType, const char format[], ...) { - va_list args; - va_start(args, format); - - android_LogPriority priority; - switch (logType) { - case kError_ANPLogType: - priority = ANDROID_LOG_ERROR; - break; - case kWarning_ANPLogType: - priority = ANDROID_LOG_WARN; - break; - case kDebug_ANPLogType: - priority = ANDROID_LOG_DEBUG; - break; - default: - priority = ANDROID_LOG_UNKNOWN; - break; - } - LOG_PRI_VA(priority, "plugin", format, args); - - va_end(args); -} - -void ANPLogInterfaceV0_Init(ANPInterface* value) { - ANPLogInterfaceV0* i = reinterpret_cast<ANPLogInterfaceV0*>(value); - - i->log = anp_log; -} diff --git a/WebKit/android/plugins/ANPMatrixInterface.cpp b/WebKit/android/plugins/ANPMatrixInterface.cpp deleted file mode 100644 index f322315..0000000 --- a/WebKit/android/plugins/ANPMatrixInterface.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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 THE COPYRIGHT OWNER 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" - -#ifdef SK_SCALAR_IS_FIXED -static void fromFloat(SkScalar dst[], const float src[], int n) { - for (int i = 0; i < n; i++) { - dst[i] = SkFloatToScalar(src[i]); - } -} - -static void toFloat(float dst[], const SkScalar src[], int n) { - for (int i = 0; i < n; i++) { - dst[i] = SkScalarToFloat(src[i]); - } -} -#endif - -static ANPMatrix* anp_newMatrix() { - return new ANPMatrix; -} - -static void anp_deleteMatrix(ANPMatrix* matrix) { - delete matrix; -} - -static ANPMatrixFlag anp_getFlags(const ANPMatrix* matrix) { - return matrix->getType(); -} - -static void anp_copy(ANPMatrix* dst, const ANPMatrix* src) { - *dst = *src; -} - -static void anp_get3x3(const ANPMatrix* matrix, float dst[9]) { - for (int i = 0; i < 9; i++) { - dst[i] = SkScalarToFloat(matrix->get(i)); - } -} - -static void anp_set3x3(ANPMatrix* matrix, const float src[9]) { - for (int i = 0; i < 9; i++) { - matrix->set(i, SkFloatToScalar(src[i])); - } -} - -static void anp_setIdentity(ANPMatrix* matrix) { - matrix->reset(); -} - -static void anp_preTranslate(ANPMatrix* matrix, float tx, float ty) { - matrix->preTranslate(SkFloatToScalar(tx), SkFloatToScalar(ty)); -} - -static void anp_postTranslate(ANPMatrix* matrix, float tx, float ty) { - matrix->postTranslate(SkFloatToScalar(tx), SkFloatToScalar(ty)); -} - -static void anp_preScale(ANPMatrix* matrix, float sx, float sy) { - matrix->preScale(SkFloatToScalar(sx), SkFloatToScalar(sy)); -} - -static void anp_postScale(ANPMatrix* matrix, float sx, float sy) { - matrix->postScale(SkFloatToScalar(sx), SkFloatToScalar(sy)); -} - -static void anp_preSkew(ANPMatrix* matrix, float kx, float ky) { - matrix->preSkew(SkFloatToScalar(kx), SkFloatToScalar(ky)); -} - -static void anp_postSkew(ANPMatrix* matrix, float kx, float ky) { - matrix->postSkew(SkFloatToScalar(kx), SkFloatToScalar(ky)); -} - -static void anp_preRotate(ANPMatrix* matrix, float degrees) { - matrix->preRotate(SkFloatToScalar(degrees)); -} - -static void anp_postRotate(ANPMatrix* matrix, float degrees) { - matrix->postRotate(SkFloatToScalar(degrees)); -} - -static void anp_preConcat(ANPMatrix* matrix, const ANPMatrix* other) { - matrix->preConcat(*other); -} - -static void anp_postConcat(ANPMatrix* matrix, const ANPMatrix* other) { - matrix->postConcat(*other); -} - -static bool anp_invert(ANPMatrix* dst, const ANPMatrix* src) { - return src->invert(dst); -} - -static void anp_mapPoints(ANPMatrix* matrix, float dst[], const float src[], - int32_t count) { -#ifdef SK_SCALAR_IS_FLOAT - matrix->mapPoints(reinterpret_cast<SkPoint*>(dst), - reinterpret_cast<const SkPoint*>(src), count); -#else - const int N = 64; - SkPoint tmp[N]; - do { - int n = count; - if (n > N) { - n = N; - } - fromFloat(&tmp[0].fX, src, n*2); - matrix->mapPoints(tmp, n); - toFloat(dst, &tmp[0].fX, n*2); - count -= n; - } while (count > 0); -#endif -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPMatrixInterfaceV0_Init(ANPInterface* value) { - ANPMatrixInterfaceV0* i = reinterpret_cast<ANPMatrixInterfaceV0*>(value); - - ASSIGN(i, newMatrix); - ASSIGN(i, deleteMatrix); - ASSIGN(i, getFlags); - ASSIGN(i, copy); - ASSIGN(i, get3x3); - ASSIGN(i, set3x3); - ASSIGN(i, setIdentity); - ASSIGN(i, preTranslate); - ASSIGN(i, postTranslate); - ASSIGN(i, preScale); - ASSIGN(i, postScale); - ASSIGN(i, preSkew); - ASSIGN(i, postSkew); - ASSIGN(i, preRotate); - ASSIGN(i, postRotate); - ASSIGN(i, preConcat); - ASSIGN(i, postConcat); - ASSIGN(i, invert); - ASSIGN(i, mapPoints); -} diff --git a/WebKit/android/plugins/ANPOpenGLInterface.cpp b/WebKit/android/plugins/ANPOpenGLInterface.cpp deleted file mode 100644 index 839ec17..0000000 --- a/WebKit/android/plugins/ANPOpenGLInterface.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2010, 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 THE COPYRIGHT OWNER 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 "ANPOpenGL_npapi.h" -#include "PluginView.h" -#include "PluginWidgetAndroid.h" -#include "MediaLayer.h" -#include "WebViewCore.h" -#include "Frame.h" -#include "Page.h" -#include "Chrome.h" -#include "ChromeClient.h" - -using namespace android; - -static WebCore::PluginView* pluginViewForInstance(NPP instance) { - if (instance && instance->ndata) - return static_cast<WebCore::PluginView*>(instance->ndata); - return WebCore::PluginView::currentPluginView(); -} - -static EGLContext anp_acquireContext(NPP instance) { - WebCore::PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - WebCore::MediaLayer* mediaLayer = pluginWidget->getLayer(); - - if (!mediaLayer) - return EGL_NO_CONTEXT; - - return mediaLayer->getTexture()->producerAcquireContext(); -} - -static ANPTextureInfo anp_lockTexture(NPP instance) { - WebCore::PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - WebCore::MediaLayer* mediaLayer = pluginWidget->getLayer(); - WebCore::DoubleBufferedTexture* texture = mediaLayer->getTexture(); - - // lock the texture and cache the internal info - WebCore::TextureInfo* info = texture->producerLock(); - mediaLayer->setCurrentTextureInfo(info); - - ANPTextureInfo anpInfo; - anpInfo.textureId = info->m_textureId; - anpInfo.width = (int32_t) info->m_width; - anpInfo.height = (int32_t) info->m_height; - anpInfo.internalFormat = info->m_internalFormat; - return anpInfo; -} - -static void anp_releaseTexture(NPP instance, const ANPTextureInfo* textureInfo) { - WebCore::PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - WebCore::MediaLayer* mediaLayer = pluginWidget->getLayer(); - WebCore::DoubleBufferedTexture* texture = mediaLayer->getTexture(); - - //copy the info into our internal structure - WebCore::TextureInfo* info = mediaLayer->getCurrentTextureInfo(); - info->m_textureId = textureInfo->textureId; - info->m_width = textureInfo->width; - info->m_height = textureInfo->height; - info->m_internalFormat = textureInfo->internalFormat; - - texture->producerReleaseAndSwap(); - - // invalidate the java view so that this content is drawn - pluginWidget->viewInvalidate(); -} - -static void anp_invertPluginContent(NPP instance, bool isContentInverted) { - WebCore::PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - WebCore::MediaLayer* mediaLayer = pluginWidget->getLayer(); - - mediaLayer->invertContents(isContentInverted); - - //force the layer to sync to the UI thread - WebViewCore* wvc = pluginWidget->webViewCore(); - if (wvc) - wvc->mainFrame()->page()->chrome()->client()->scheduleCompositingLayerSync(); -} - - - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPOpenGLInterfaceV0_Init(ANPInterface* v) { - ANPOpenGLInterfaceV0* i = reinterpret_cast<ANPOpenGLInterfaceV0*>(v); - - ASSIGN(i, acquireContext); - ASSIGN(i, lockTexture); - ASSIGN(i, releaseTexture); - ASSIGN(i, invertPluginContent); -} diff --git a/WebKit/android/plugins/ANPOpenGL_npapi.h b/WebKit/android/plugins/ANPOpenGL_npapi.h deleted file mode 100644 index 5aabbc4..0000000 --- a/WebKit/android/plugins/ANPOpenGL_npapi.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2010, 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef ANPOpenGL_npapi_H -#define ANPOpenGL_npapi_H - -#include "android_npapi.h" -#include <EGL/egl.h> -#include <GLES2/gl2.h> - -/** - * TODO should we not use EGL and GL data types for ABI safety? - */ -struct ANPTextureInfo { - GLuint textureId; - uint32_t width; - uint32_t height; - GLenum internalFormat; -}; - -struct ANPOpenGLInterfaceV0 : ANPInterface { - /** - */ - EGLContext (*acquireContext)(NPP instance); - - /** - */ - ANPTextureInfo (*lockTexture)(NPP instance); - - /** - */ - void (*releaseTexture)(NPP instance, const ANPTextureInfo*); - - /** - * Invert the contents of the plugin on the y-axis. - * default is to not be inverted (i.e. use OpenGL coordinates) - */ - void (*invertPluginContent)(NPP instance, bool isContentInverted); -}; - -#endif //ANPOpenGL_npapi_H diff --git a/WebKit/android/plugins/ANPPaintInterface.cpp b/WebKit/android/plugins/ANPPaintInterface.cpp deleted file mode 100644 index 5c59df9..0000000 --- a/WebKit/android/plugins/ANPPaintInterface.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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" -#include "SkTypeface.h" - -static ANPPaint* anp_newPaint() { - return new ANPPaint; -} - -static void anp_deletePaint(ANPPaint* paint) { - delete paint; -} - -static ANPPaintFlags anp_getFlags(const ANPPaint* paint) { - return paint->getFlags(); -} - -static void anp_setFlags(ANPPaint* paint, ANPPaintFlags flags) { - paint->setFlags(flags); -} - -static ANPColor anp_getColor(const ANPPaint* paint) { - return paint->getColor(); -} - -static void anp_setColor(ANPPaint* paint, ANPColor color) { - paint->setColor(color); -} - -static ANPPaintStyle anp_getStyle(const ANPPaint* paint) { - return paint->getStyle(); -} - -static void anp_setStyle(ANPPaint* paint, ANPPaintStyle style) { - paint->setStyle(static_cast<SkPaint::Style>(style)); -} - -static float anp_getStrokeWidth(const ANPPaint* paint) { - return SkScalarToFloat(paint->getStrokeWidth()); -} - -static float anp_getStrokeMiter(const ANPPaint* paint) { - return SkScalarToFloat(paint->getStrokeMiter()); -} - -static ANPPaintCap anp_getStrokeCap(const ANPPaint* paint) { - return paint->getStrokeCap(); -} - -static ANPPaintJoin anp_getStrokeJoin(const ANPPaint* paint) { - return paint->getStrokeJoin(); -} - -static void anp_setStrokeWidth(ANPPaint* paint, float width) { - paint->setStrokeWidth(SkFloatToScalar(width)); -} - -static void anp_setStrokeMiter(ANPPaint* paint, float miter) { - paint->setStrokeMiter(SkFloatToScalar(miter)); -} - -static void anp_setStrokeCap(ANPPaint* paint, ANPPaintCap cap) { - paint->setStrokeCap(static_cast<SkPaint::Cap>(cap)); -} - -static void anp_setStrokeJoin(ANPPaint* paint, ANPPaintJoin join) { - paint->setStrokeJoin(static_cast<SkPaint::Join>(join)); -} - -static ANPTextEncoding anp_getTextEncoding(const ANPPaint* paint) { - return paint->getTextEncoding(); -} - -static ANPPaintAlign anp_getTextAlign(const ANPPaint* paint) { - return paint->getTextAlign(); -} - -static float anp_getTextSize(const ANPPaint* paint) { - return SkScalarToFloat(paint->getTextSize()); -} - -static float anp_getTextScaleX(const ANPPaint* paint) { - return SkScalarToFloat(paint->getTextScaleX()); -} - -static float anp_getTextSkewX(const ANPPaint* paint) { - return SkScalarToFloat(paint->getTextSkewX()); -} - -static ANPTypeface* anp_getTypeface(const ANPPaint* paint) { - return reinterpret_cast<ANPTypeface*>(paint->getTypeface()); -} - -static void anp_setTextEncoding(ANPPaint* paint, ANPTextEncoding encoding) { - paint->setTextEncoding(static_cast<SkPaint::TextEncoding>(encoding)); -} - -static void anp_setTextAlign(ANPPaint* paint, ANPPaintAlign align) { - paint->setTextAlign(static_cast<SkPaint::Align>(align)); -} - -static void anp_setTextSize(ANPPaint* paint, float textSize) { - paint->setTextSize(SkFloatToScalar(textSize)); -} - -static void anp_setTextScaleX(ANPPaint* paint, float scaleX) { - paint->setTextScaleX(SkFloatToScalar(scaleX)); -} - -static void anp_setTextSkewX(ANPPaint* paint, float skewX) { - paint->setTextSkewX(SkFloatToScalar(skewX)); -} - -static void anp_setTypeface(ANPPaint* paint, ANPTypeface* tf) { - paint->setTypeface(tf); -} - -static float anp_measureText(ANPPaint* paint, const void* text, - uint32_t byteLength, ANPRectF* bounds) { - SkScalar w = paint->measureText(text, byteLength, - reinterpret_cast<SkRect*>(bounds)); - return SkScalarToFloat(w); -} - -/** Return the number of unichars specifed by the text. - If widths is not null, returns the array of advance widths for each - unichar. - If bounds is not null, returns the array of bounds for each unichar. - */ -static int anp_getTextWidths(ANPPaint* paint, const void* text, - uint32_t byteLength, float widths[], ANPRectF bounds[]) { - return paint->getTextWidths(text, byteLength, widths, - reinterpret_cast<SkRect*>(bounds)); -} - -static float anp_getFontMetrics(ANPPaint* paint, ANPFontMetrics* metrics) { - SkPaint::FontMetrics fm; - SkScalar spacing = paint->getFontMetrics(&fm); - if (metrics) { - metrics->fTop = SkScalarToFloat(fm.fTop); - metrics->fAscent = SkScalarToFloat(fm.fAscent); - metrics->fDescent = SkScalarToFloat(fm.fDescent); - metrics->fBottom = SkScalarToFloat(fm.fBottom); - metrics->fLeading = SkScalarToFloat(fm.fLeading); - } - return SkScalarToFloat(spacing); -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPPaintInterfaceV0_Init(ANPInterface* value) { - ANPPaintInterfaceV0* i = reinterpret_cast<ANPPaintInterfaceV0*>(value); - - ASSIGN(i, newPaint); - ASSIGN(i, deletePaint); - ASSIGN(i, getFlags); - ASSIGN(i, setFlags); - ASSIGN(i, getColor); - ASSIGN(i, setColor); - ASSIGN(i, getStyle); - ASSIGN(i, setStyle); - ASSIGN(i, getStrokeWidth); - ASSIGN(i, getStrokeMiter); - ASSIGN(i, getStrokeCap); - ASSIGN(i, getStrokeJoin); - ASSIGN(i, setStrokeWidth); - ASSIGN(i, setStrokeMiter); - ASSIGN(i, setStrokeCap); - ASSIGN(i, setStrokeJoin); - ASSIGN(i, getTextEncoding); - ASSIGN(i, getTextAlign); - ASSIGN(i, getTextSize); - ASSIGN(i, getTextScaleX); - ASSIGN(i, getTextSkewX); - ASSIGN(i, getTypeface); - ASSIGN(i, setTextEncoding); - ASSIGN(i, setTextAlign); - ASSIGN(i, setTextSize); - ASSIGN(i, setTextScaleX); - ASSIGN(i, setTextSkewX); - ASSIGN(i, setTypeface); - ASSIGN(i, measureText); - ASSIGN(i, getTextWidths); - ASSIGN(i, getFontMetrics); -} diff --git a/WebKit/android/plugins/ANPPathInterface.cpp b/WebKit/android/plugins/ANPPathInterface.cpp deleted file mode 100644 index 69cabcf..0000000 --- a/WebKit/android/plugins/ANPPathInterface.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 THE COPYRIGHT OWNER 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 ANPPath* anp_newPath() { - return new ANPPath; -} - -static void anp_deletePath(ANPPath* path) { - delete path; -} - -static void anp_copy(ANPPath* dst, const ANPPath* src) { - *dst = *src; -} - -static bool anp_equal(const ANPPath* p0, const ANPPath* p1) { - return *p0 == *p1; -} - -static void anp_reset(ANPPath* path) { - path->reset(); -} - -static bool anp_isEmpty(const ANPPath* path) { - return path->isEmpty(); -} - -static void anp_getBounds(const ANPPath* path, ANPRectF* bounds) { - SkANP::SetRect(bounds, path->getBounds()); -} - -static void anp_moveTo(ANPPath* path, float x, float y) { - path->moveTo(SkFloatToScalar(x), SkFloatToScalar(y)); -} - -static void anp_lineTo(ANPPath* path, float x, float y) { - path->lineTo(SkFloatToScalar(x), SkFloatToScalar(y)); -} - -static void anp_quadTo(ANPPath* path, float x0, float y0, float x1, float y1) { - path->quadTo(SkFloatToScalar(x0), SkFloatToScalar(y0), - SkFloatToScalar(x1), SkFloatToScalar(y1)); -} - -static void anp_cubicTo(ANPPath* path, float x0, float y0, - float x1, float y1, float x2, float y2) { - path->cubicTo(SkFloatToScalar(x0), SkFloatToScalar(y0), - SkFloatToScalar(x1), SkFloatToScalar(y1), - SkFloatToScalar(x2), SkFloatToScalar(y2)); -} - -static void anp_close(ANPPath* path) { - path->close(); -} - -static void anp_offset(ANPPath* path, float dx, float dy, ANPPath* dst) { - path->offset(SkFloatToScalar(dx), SkFloatToScalar(dy), dst); -} - -static void anp_transform(ANPPath* src, const ANPMatrix* matrix, - ANPPath* dst) { - src->transform(*matrix, dst); -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPPathInterfaceV0_Init(ANPInterface* value) { - ANPPathInterfaceV0* i = reinterpret_cast<ANPPathInterfaceV0*>(value); - - ASSIGN(i, newPath); - ASSIGN(i, deletePath); - ASSIGN(i, copy); - ASSIGN(i, equal); - ASSIGN(i, reset); - ASSIGN(i, isEmpty); - ASSIGN(i, getBounds); - ASSIGN(i, moveTo); - ASSIGN(i, lineTo); - ASSIGN(i, quadTo); - ASSIGN(i, cubicTo); - ASSIGN(i, close); - ASSIGN(i, offset); - ASSIGN(i, transform); -} diff --git a/WebKit/android/plugins/ANPSoundInterface.cpp b/WebKit/android/plugins/ANPSoundInterface.cpp deleted file mode 100644 index c238872..0000000 --- a/WebKit/android/plugins/ANPSoundInterface.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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 "android_npapi.h" - -#include "SkTypes.h" -#include "media/AudioTrack.h" - -#include <system/audio.h> - -struct ANPAudioTrack { - void* mUser; - ANPAudioCallbackProc mProc; - android::AudioTrack* mTrack; -}; - -static ANPSampleFormat toANPFormat(int fm) { - switch (fm) { - case AUDIO_FORMAT_PCM_16_BIT: - return kPCM16Bit_ANPSampleFormat; - case AUDIO_FORMAT_PCM_8_BIT: - return kPCM8Bit_ANPSampleFormat; - default: - return kUnknown_ANPSamleFormat; - } -} - -static int fromANPFormat(ANPSampleFormat fm) { - switch (fm) { - case kPCM16Bit_ANPSampleFormat: - return AUDIO_FORMAT_PCM_16_BIT; - case kPCM8Bit_ANPSampleFormat: - return AUDIO_FORMAT_PCM_8_BIT; - default: - return AUDIO_FORMAT_INVALID; - } -} - -static void callbackProc(int event, void* user, void* info) { - ANPAudioTrack* track = reinterpret_cast<ANPAudioTrack*>(user); - - switch (event) { - case android::AudioTrack::EVENT_MORE_DATA: { - ANPAudioBuffer dst; - android::AudioTrack::Buffer* src; - - src = reinterpret_cast<android::AudioTrack::Buffer*>(info); - dst.bufferData = src->raw; - dst.channelCount = src->channelCount; - dst.format = toANPFormat(src->format); - dst.size = src->size; - track->mProc(kMoreData_ANPAudioEvent, track->mUser, &dst); - // return the updated size field - src->size = dst.size; - break; - } - case android::AudioTrack::EVENT_UNDERRUN: - track->mProc(kUnderRun_ANPAudioEvent, track->mUser, NULL); - break; - default: - SkDebugf("------ unknown audio event for plugin %d\n", event); - break; - } -} - -static ANPAudioTrack* ANPCreateTrack(uint32_t sampleRate, - ANPSampleFormat format, - int channelCount, - ANPAudioCallbackProc proc, - void* user) { - - ANPAudioTrack* track = new ANPAudioTrack; - - track->mUser = user; - track->mProc = proc; - track->mTrack = new android::AudioTrack(AUDIO_STREAM_MUSIC, - sampleRate, - fromANPFormat(format), - (channelCount > 1) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO, - 0, // frameCount - 0, // flags - callbackProc, - track, - 0); - - if (track->mTrack->initCheck() != 0) { // failure - delete track->mTrack; - delete track; - track = NULL; - } - return track; -} - -static void ANPDeleteTrack(ANPAudioTrack* track) { - if (track) { - delete track->mTrack; - delete track; - } -} - -static void ANPTrackStart(ANPAudioTrack* track) { - track->mTrack->start(); -} - -static void ANPTrackPause(ANPAudioTrack* track) { - track->mTrack->pause(); -} - -static void ANPTrackStop(ANPAudioTrack* track) { - track->mTrack->stop(); -} - -static bool ANPTrackIsStopped(ANPAudioTrack* track) { - return track->mTrack->stopped(); -} - -static uint32_t ANPTrackLatency(ANPAudioTrack* track) { - return track->mTrack->latency(); -} - -/////////////////////////////////////////////////////////////////////////////// - -void ANPAudioTrackInterfaceV0_Init(ANPInterface* value) { - ANPAudioTrackInterfaceV0* si = reinterpret_cast<ANPAudioTrackInterfaceV0*>(value); - si->newTrack = ANPCreateTrack; - si->deleteTrack = ANPDeleteTrack; - si->start = ANPTrackStart; - si->pause = ANPTrackPause; - si->stop = ANPTrackStop; - si->isStopped = ANPTrackIsStopped; -} - -void ANPAudioTrackInterfaceV1_Init(ANPInterface* value) { - // initialize the functions from the previous interface - ANPAudioTrackInterfaceV0_Init(value); - // add any new functions or override existing functions - ANPAudioTrackInterfaceV1* si = reinterpret_cast<ANPAudioTrackInterfaceV1*>(value); - si->trackLatency = ANPTrackLatency; -} diff --git a/WebKit/android/plugins/ANPSurfaceInterface.cpp b/WebKit/android/plugins/ANPSurfaceInterface.cpp deleted file mode 100644 index 4b99b31..0000000 --- a/WebKit/android/plugins/ANPSurfaceInterface.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 THE COPYRIGHT OWNER 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 "ANPSurface_npapi.h" - -#include "PluginView.h" -#include "PluginWidgetAndroid.h" -#include "SkANP.h" -#include "android_graphics.h" -#include <JNIUtility.h> -#include <surfaceflinger/Surface.h> -#include <ui/Rect.h> -#include <ui/Region.h> -#include <utils/RefBase.h> - -using namespace android; - -// used to cache JNI method and field IDs for Surface Objects -static struct ANPSurfaceInterfaceJavaGlue { - bool initialized; - jmethodID getSurfaceHolder; - jmethodID getSurface; - jfieldID surfacePointer; -} gSurfaceJavaGlue; - -static inline sp<Surface> getSurface(JNIEnv* env, jobject view) { - if (!env || !view) { - return NULL; - } - - if (!gSurfaceJavaGlue.initialized) { - - jclass surfaceViewClass = env->FindClass("android/view/SurfaceView"); - gSurfaceJavaGlue.getSurfaceHolder = env->GetMethodID(surfaceViewClass, "getHolder", - "()Landroid/view/SurfaceHolder;"); - - jclass surfaceHolderClass = env->FindClass("android/view/SurfaceHolder"); - gSurfaceJavaGlue.getSurface = env->GetMethodID(surfaceHolderClass, "getSurface", - "()Landroid/view/Surface;"); - - jclass surfaceClass = env->FindClass("android/view/Surface"); - gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass, - ANDROID_VIEW_SURFACE_JNI_ID, "I"); - - env->DeleteLocalRef(surfaceClass); - env->DeleteLocalRef(surfaceViewClass); - env->DeleteLocalRef(surfaceHolderClass); - - gSurfaceJavaGlue.initialized = true; - } - - jobject holder = env->CallObjectMethod(view, gSurfaceJavaGlue.getSurfaceHolder); - jobject surface = env->CallObjectMethod(holder, gSurfaceJavaGlue.getSurface); - jint surfacePointer = env->GetIntField(surface, gSurfaceJavaGlue.surfacePointer); - - env->DeleteLocalRef(holder); - env->DeleteLocalRef(surface); - - return sp<Surface>((Surface*) surfacePointer); -} - -static inline ANPBitmapFormat convertPixelFormat(PixelFormat format) { - switch (format) { - case PIXEL_FORMAT_RGBA_8888: return kRGBA_8888_ANPBitmapFormat; - case PIXEL_FORMAT_RGB_565: return kRGB_565_ANPBitmapFormat; - default: return kUnknown_ANPBitmapFormat; - } -} - -static bool anp_lock(JNIEnv* env, jobject surfaceView, ANPBitmap* bitmap, ANPRectI* dirtyRect) { - if (!bitmap || !surfaceView) { - return false; - } - - sp<Surface> surface = getSurface(env, surfaceView); - - if (!bitmap || !Surface::isValid(surface)) { - return false; - } - - Region dirtyRegion; - if (dirtyRect) { - Rect rect(dirtyRect->left, dirtyRect->top, dirtyRect->right, dirtyRect->bottom); - if (!rect.isEmpty()) { - dirtyRegion.set(rect); - } - } else { - dirtyRegion.set(Rect(0x3FFF, 0x3FFF)); - } - - Surface::SurfaceInfo info; - status_t err = surface->lock(&info, &dirtyRegion); - if (err < 0) { - return false; - } - - // the surface may have expanded the dirty region so we must to pass that - // information back to the plugin. - if (dirtyRect) { - Rect dirtyBounds = dirtyRegion.getBounds(); - dirtyRect->left = dirtyBounds.left; - dirtyRect->right = dirtyBounds.right; - dirtyRect->top = dirtyBounds.top; - dirtyRect->bottom = dirtyBounds.bottom; - } - - ssize_t bpr = info.s * bytesPerPixel(info.format); - - bitmap->format = convertPixelFormat(info.format); - bitmap->width = info.w; - bitmap->height = info.h; - bitmap->rowBytes = bpr; - - if (info.w > 0 && info.h > 0) { - bitmap->baseAddr = info.bits; - } else { - bitmap->baseAddr = NULL; - return false; - } - - return true; -} - -static void anp_unlock(JNIEnv* env, jobject surfaceView) { - if (!surfaceView) { - return; - } - - sp<Surface> surface = getSurface(env, surfaceView); - - if (!Surface::isValid(surface)) { - return; - } - - surface->unlockAndPost(); -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPSurfaceInterfaceV0_Init(ANPInterface* value) { - ANPSurfaceInterfaceV0* i = reinterpret_cast<ANPSurfaceInterfaceV0*>(value); - - ASSIGN(i, lock); - ASSIGN(i, unlock); - - // setup the java glue struct - gSurfaceJavaGlue.initialized = false; -} diff --git a/WebKit/android/plugins/ANPSurface_npapi.h b/WebKit/android/plugins/ANPSurface_npapi.h deleted file mode 100644 index 910a948..0000000 --- a/WebKit/android/plugins/ANPSurface_npapi.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef ANPSurface_npapi_H -#define ANPSurface_npapi_H - -#include "android_npapi.h" -#include <jni.h> - -struct ANPSurfaceInterfaceV0 : ANPInterface { - /** 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)(JNIEnv* env, jobject 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)(JNIEnv* env, jobject surface); -}; - -#endif //ANPSurface_npapi_H diff --git a/WebKit/android/plugins/ANPSystemInterface.cpp b/WebKit/android/plugins/ANPSystemInterface.cpp deleted file mode 100644 index 7199635..0000000 --- a/WebKit/android/plugins/ANPSystemInterface.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * 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 THE COPYRIGHT OWNER 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 "ANPSystem_npapi.h" -#include "Frame.h" -#include "JavaSharedClient.h" -#include "PluginClient.h" -#include "PluginPackage.h" -#include "PluginView.h" -#include "PluginWidgetAndroid.h" -#include "Settings.h" -#include "SkString.h" -#include "WebViewCore.h" -#include <wtf/text/CString.h> - -#include <dirent.h> - -//#define PLUGIN_DEBUG_LOCAL // controls the printing of log messages -#include "PluginDebugAndroid.h" - -static const char* gApplicationDataDir = NULL; -static const char* gApplicationDataDirIncognito = NULL; - -using namespace android; - -static WebCore::PluginView* pluginViewForInstance(NPP instance) { - if (instance && instance->ndata) - return static_cast<WebCore::PluginView*>(instance->ndata); - return WebCore::PluginView::currentPluginView(); -} - -static const char* anp_getApplicationDataDirectory() { - if (NULL == gApplicationDataDir) { - PluginClient* client = JavaSharedClient::GetPluginClient(); - if (!client) - return NULL; - - WTF::String path = client->getPluginSharedDataDirectory(); - int length = path.length(); - if (length == 0) - return NULL; - - char* storage = (char*) malloc(length + 1); - if (NULL == storage) - return NULL; - - memcpy(storage, path.utf8().data(), length); - storage[length] = '\0'; - - static const char incognitoPath[] = "/incognito_plugins"; - char* incognitoStorage = (char*) malloc(length + strlen(incognitoPath) + 1); - - strcpy(incognitoStorage, storage); - strcat(incognitoStorage, incognitoPath); - - // save this assignment for last, so that if multiple threads call us - // (which should never happen), we never return an incomplete global. - // At worst, we would allocate storage for the path twice. - gApplicationDataDir = storage; - gApplicationDataDirIncognito = incognitoStorage; - } - - return gApplicationDataDir; -} - -static const char* anp_getApplicationDataDirectoryV2(NPP instance) { - WebCore::PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - - if (NULL == gApplicationDataDir) { - anp_getApplicationDataDirectory(); - } - - WebCore::Settings* settings = pluginWidget->webViewCore()->mainFrame()->settings(); - if (settings && settings->privateBrowsingEnabled()) { - // if this is an incognito view then check the path to see if it exists - // and if it is a directory, otherwise if it does not exist create it. - struct stat st; - if (stat(gApplicationDataDirIncognito, &st) == 0) { - if (!S_ISDIR(st.st_mode)) { - return NULL; - } - } else { - if (mkdir(gApplicationDataDirIncognito, S_IRWXU) != 0) { - return NULL; - } - } - - return gApplicationDataDirIncognito; - } - - return gApplicationDataDir; -} - -static jclass anp_loadJavaClass(NPP instance, const char* className) { - WebCore::PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - - jclass result; - result = pluginWidget->webViewCore()->getPluginClass(pluginView->plugin()->path(), - className); - return result; -} - -static void anp_setPowerState(NPP instance, ANPPowerState powerState) { - WebCore::PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - - pluginWidget->setPowerState(powerState); -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPSystemInterfaceV0_Init(ANPInterface* v) { - ANPSystemInterfaceV0* i = reinterpret_cast<ANPSystemInterfaceV0*>(v); - - ASSIGN(i, getApplicationDataDirectory); - ASSIGN(i, loadJavaClass); -} - -void ANPSystemInterfaceV1_Init(ANPInterface* v) { - // initialize the functions from the previous interface - ANPSystemInterfaceV0_Init(v); - // add any new functions or override existing functions - ANPSystemInterfaceV1* i = reinterpret_cast<ANPSystemInterfaceV1*>(v); - ASSIGN(i, setPowerState); -} - -void ANPSystemInterfaceV2_Init(ANPInterface* v) { - // initialize the functions from the previous interface - ANPSystemInterfaceV1_Init(v); - // add any new functions or override existing functions - ANPSystemInterfaceV2* i = reinterpret_cast<ANPSystemInterfaceV2*>(v); - i->getApplicationDataDirectory = anp_getApplicationDataDirectoryV2; -} - -/////////////////////////////////////////////////////////////////////////////// - -static bool isDirectory(const char* path) { - struct stat st; - return stat(path, &st) == 0 && S_ISDIR(st.st_mode); -} - -static void removeDirectory(const char* path) { - // create a pointer to a directory - DIR *dir = NULL; - dir = opendir(path); - if (!dir) - return; - - struct dirent* entry = 0; - while ((entry = readdir(dir))) { // while there is still something in the directory to list - if (!entry) - return; - - if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name)) { - PLUGIN_LOG(". file: %s", entry->d_name); - continue; - } - - // concatenate the strings to get the complete path - static const char separator[] = "/"; - char* file = (char*) malloc(strlen(path) + strlen(separator) + strlen(entry->d_name) + 1); - strcpy(file, path); - strcat(file, separator); - strcat(file, entry->d_name); - - if (isDirectory(file) == true) { - PLUGIN_LOG("remove dir: %s", file); - removeDirectory(file); - } else { // it's a file, we can use remove - PLUGIN_LOG("remove file: %s", file); - remove(file); - } - - free(file); - } - - // clean up - closedir (dir); // close the directory - rmdir(path); // delete the directory -} - -void ANPSystemInterface_CleanupIncognito() { - PLUGIN_LOG("cleanup incognito plugin directory"); - - if (gApplicationDataDirIncognito == NULL) - anp_getApplicationDataDirectory(); - if (gApplicationDataDirIncognito == NULL) - return; - - // check to see if the directory exists and if so delete it - if (isDirectory(gApplicationDataDirIncognito)) - removeDirectory(gApplicationDataDirIncognito); -} diff --git a/WebKit/android/plugins/ANPSystem_npapi.h b/WebKit/android/plugins/ANPSystem_npapi.h deleted file mode 100644 index 835bc7c..0000000 --- a/WebKit/android/plugins/ANPSystem_npapi.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef ANPSystem_npapi_H -#define ANPSystem_npapi_H - -#include "android_npapi.h" -#include <jni.h> - -struct ANPSystemInterfaceV0 : ANPInterface { - /** Return the path name for the current Application's plugin data directory, - or NULL if not supported - */ - const char* (*getApplicationDataDirectory)(); - - /** A helper function to load java classes from the plugin's apk. The - function looks for a class given the fully qualified and null terminated - string representing the className. For example, - - const char* className = "com.android.mypackage.MyClass"; - - If the class cannot be found or there is a problem loading the class - NULL will be returned. - */ - jclass (*loadJavaClass)(NPP instance, const char* className); -}; - -enum ANPPowerStates { - kDefault_ANPPowerState = 0, - kScreenOn_ANPPowerState = 1 -}; -typedef int32_t ANPPowerState; - -struct ANPSystemInterfaceV1 : ANPSystemInterfaceV0 { - void (*setPowerState)(NPP instance, ANPPowerState powerState); -}; - -struct ANPSystemInterfaceV2 : ANPInterface { - /** Return the path name for the current Application's plugin data directory, - or NULL if not supported. This directory will change depending on whether - or not the plugin is found within an incognito tab. - */ - const char* (*getApplicationDataDirectory)(NPP instance); - - // redeclaration of existing features - jclass (*loadJavaClass)(NPP instance, const char* className); - void (*setPowerState)(NPP instance, ANPPowerState powerState); -}; - -#endif //ANPSystem_npapi_H diff --git a/WebKit/android/plugins/ANPTypefaceInterface.cpp b/WebKit/android/plugins/ANPTypefaceInterface.cpp deleted file mode 100644 index 99734a7..0000000 --- a/WebKit/android/plugins/ANPTypefaceInterface.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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" -#include "SkFontHost.h" - -static ANPTypeface* anp_createFromName(const char name[], ANPTypefaceStyle s) { - SkTypeface* tf = SkTypeface::CreateFromName(name, - static_cast<SkTypeface::Style>(s)); - return reinterpret_cast<ANPTypeface*>(tf); -} - -static ANPTypeface* anp_createFromTypeface(const ANPTypeface* family, - ANPTypefaceStyle s) { - SkTypeface* tf = SkTypeface::CreateFromTypeface(family, - static_cast<SkTypeface::Style>(s)); - return reinterpret_cast<ANPTypeface*>(tf); -} - -static int32_t anp_getRefCount(const ANPTypeface* tf) { - return tf ? tf->getRefCnt() : 0; -} - -static void anp_ref(ANPTypeface* tf) { - SkSafeRef(tf); -} - -static void anp_unref(ANPTypeface* tf) { - SkSafeUnref(tf); -} - -static ANPTypefaceStyle anp_getStyle(const ANPTypeface* tf) { - SkTypeface::Style s = tf ? tf->style() : SkTypeface::kNormal; - return static_cast<ANPTypefaceStyle>(s); -} - -static int32_t anp_getFontPath(const ANPTypeface* tf, char fileName[], - int32_t length, int32_t* index) { - size_t size = SkFontHost::GetFileName(SkTypeface::UniqueID(tf), fileName, - length, index); - return static_cast<int32_t>(size); -} - -static const char* gFontDir; -#define FONT_DIR_SUFFIX "/fonts/" - -static const char* anp_getFontDirectoryPath() { - if (NULL == gFontDir) { - const char* root = getenv("ANDROID_ROOT"); - size_t len = strlen(root); - char* storage = (char*)malloc(len + sizeof(FONT_DIR_SUFFIX)); - if (NULL == storage) { - return NULL; - } - memcpy(storage, root, len); - memcpy(storage + len, FONT_DIR_SUFFIX, sizeof(FONT_DIR_SUFFIX)); - // save this assignment for last, so that if multiple threads call us - // (which should never happen), we never return an incomplete global. - // At worst, we would allocate storage for the path twice. - gFontDir = storage; - } - return gFontDir; -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPTypefaceInterfaceV0_Init(ANPInterface* v) { - ANPTypefaceInterfaceV0* i = reinterpret_cast<ANPTypefaceInterfaceV0*>(v); - - ASSIGN(i, createFromName); - ASSIGN(i, createFromTypeface); - ASSIGN(i, getRefCount); - ASSIGN(i, ref); - ASSIGN(i, unref); - ASSIGN(i, getStyle); - ASSIGN(i, getFontPath); - ASSIGN(i, getFontDirectoryPath); -} diff --git a/WebKit/android/plugins/ANPVideoInterface.cpp b/WebKit/android/plugins/ANPVideoInterface.cpp deleted file mode 100644 index 8eb9846..0000000 --- a/WebKit/android/plugins/ANPVideoInterface.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2011, 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 THE COPYRIGHT OWNER 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 "ANPVideo_npapi.h" -#include "SkANP.h" - -#include "PluginView.h" -#include "PluginWidgetAndroid.h" -#include "MediaLayer.h" - -static WebCore::PluginView* pluginViewForInstance(NPP instance) { - if (instance && instance->ndata) - return static_cast<WebCore::PluginView*>(instance->ndata); - return WebCore::PluginView::currentPluginView(); -} - -static WebCore::MediaLayer* mediaLayerForInstance(NPP instance) { - WebCore::PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - return pluginWidget->getLayer(); -} - -static ANativeWindow* anp_acquireNativeWindow(NPP instance) { - WebCore::MediaLayer* mediaLayer = mediaLayerForInstance(instance); - - return mediaLayer->acquireNativeWindowForVideo(); -} - -static void anp_setWindowDimensions(NPP instance, const ANativeWindow* window, - const ANPRectF* dimensions) { - - WebCore::MediaLayer* mediaLayer = mediaLayerForInstance(instance); - if (!mediaLayer) - return; - - SkRect rect; - mediaLayer->setWindowDimensionsForVideo(window, *SkANP::SetRect(&rect, *dimensions)); -} - - -static void anp_releaseNativeWindow(NPP instance, ANativeWindow* window) { - WebCore::MediaLayer* mediaLayer = mediaLayerForInstance(instance); - if (!mediaLayer) - return; - - mediaLayer->releaseNativeWindowForVideo(window); -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPVideoInterfaceV0_Init(ANPInterface* value) { - ANPVideoInterfaceV0* i = reinterpret_cast<ANPVideoInterfaceV0*>(value); - - ASSIGN(i, acquireNativeWindow); - ASSIGN(i, setWindowDimensions); - ASSIGN(i, releaseNativeWindow); -} diff --git a/WebKit/android/plugins/ANPVideo_npapi.h b/WebKit/android/plugins/ANPVideo_npapi.h deleted file mode 100644 index 18e0231..0000000 --- a/WebKit/android/plugins/ANPVideo_npapi.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2011, 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef ANPVideo_npapi_H -#define ANPVideo_npapi_H - -#include "android_npapi.h" -#include <android/native_window.h> - -struct ANPVideoInterfaceV0 : ANPInterface { - - /** - * Constructs a new native window to be used for rendering video content. - * - * Subsequent calls will produce new windows, but may also return NULL after - * n attempts if the browser has reached it's limit. Further, if the browser - * is unable to acquire the window quickly it may also return NULL in order - * to not prevent the plugin from executing. A subsequent call will then - * return the window if it is avaiable. - * - * NOTE: The hardware may fail if you try to decode more than the allowable - * number of videos supported on that device. - */ - ANativeWindow* (*acquireNativeWindow)(NPP instance); - - /** - * Sets the rectangle that specifies where the video content is to be drawn. - * The dimensions are in document space. Further, if the rect is NULL the - * browser will not attempt to draw the window, therefore do not set the - * dimensions until you queue the first buffer in the window. - */ - void (*setWindowDimensions)(NPP instance, const ANativeWindow* window, const ANPRectF* dimensions); - - /** - */ - void (*releaseNativeWindow)(NPP instance, ANativeWindow* window); -}; - -#endif //ANPVideo_npapi_H diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp deleted file mode 100644 index a74616c..0000000 --- a/WebKit/android/plugins/ANPWindowInterface.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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" -#include "WebViewCore.h" -#include "PluginView.h" -#include "PluginWidgetAndroid.h" - -static PluginView* pluginViewForInstance(NPP instance) { - if (instance && instance->ndata) - return static_cast<PluginView*>(instance->ndata); - return PluginView::currentPluginView(); -} - -static void anp_setVisibleRects(NPP instance, const ANPRectI rects[], int32_t count) { - PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - pluginWidget->setVisibleRects(rects, count); -} - -static void anp_clearVisibleRects(NPP instance) { - anp_setVisibleRects(instance, NULL, 0); -} - -static void anp_showKeyboard(NPP instance, bool value) { - PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - if(pluginWidget->hasFocus()) - pluginWidget->webViewCore()->requestKeyboard(value); -} - -static void anp_requestFullScreen(NPP instance) { - PluginView* pluginView = pluginViewForInstance(instance); - // call focusPluginElement() so that the pluginView receives keyboard events - pluginView->focusPluginElement(); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - pluginWidget->requestFullScreen(); -} - -static void anp_exitFullScreen(NPP instance) { - PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - pluginWidget->exitFullScreen(true); -} - -static void anp_requestCenterFitZoom(NPP instance) { - PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - pluginWidget->requestCenterFitZoom(); -} - -static ANPRectI anp_visibleRect(NPP instance) { - PluginView* pluginView = pluginViewForInstance(instance); - PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); - return pluginWidget->visibleRect(); -} - -/////////////////////////////////////////////////////////////////////////////// - -#define ASSIGN(obj, name) (obj)->name = anp_##name - -void ANPWindowInterfaceV0_Init(ANPInterface* value) { - ANPWindowInterfaceV0* i = reinterpret_cast<ANPWindowInterfaceV0*>(value); - - ASSIGN(i, setVisibleRects); - ASSIGN(i, clearVisibleRects); - ASSIGN(i, showKeyboard); - ASSIGN(i, requestFullScreen); - ASSIGN(i, exitFullScreen); - ASSIGN(i, requestCenterFitZoom); -} - -void ANPWindowInterfaceV1_Init(ANPInterface* value) { - // initialize the functions from the previous interface - ANPWindowInterfaceV0_Init(value); - // add any new functions or override existing functions - ANPWindowInterfaceV1* i = reinterpret_cast<ANPWindowInterfaceV1*>(value); - ASSIGN(i, visibleRect); -} diff --git a/WebKit/android/plugins/PluginDebugAndroid.cpp b/WebKit/android/plugins/PluginDebugAndroid.cpp deleted file mode 100644 index 3958714..0000000 --- a/WebKit/android/plugins/PluginDebugAndroid.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2010, 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 THE COPYRIGHT OWNER 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. - */ - -#include "PluginDebugAndroid.h" -#include "utils/Log.h" -#include "utils/SystemClock.h" -#include <stdarg.h> - -#define ARRAY_COUNT(array) static_cast<int32_t>(sizeof(array) / sizeof(array[0])) - -// used for key, mouse, and touch inputs -static const char* const inputActions[] = { - "down", - "up", - "move", /* touch only */ - "cancel", /* touch only */ - "longPress", /* touch only */ - "doubleTap" /* touch only */ -}; - -static const char* const lifecycleActions[] = { - "kPause_ANPLifecycleAction", - "kResume_ANPLifecycleAction", - "kGainFocus_ANPLifecycleAction", - "kLoseFocus_ANPLifecycleAction", - "kFreeMemory_ANPLifecycleAction", - "kOnLoad_ANPLifecycleAction", - "kEnterFullScreen_ANPLifecycleAction", - "kExitFullScreen_ANPLifecycleAction", - "kOnScreen_ANPLifecycleAction", - "kOffScreen_ANPLifecycleAction" -}; - -void anp_logPlugin(const char format[], ...) { - va_list args; - va_start(args, format); - LOG_PRI_VA(ANDROID_LOG_DEBUG, "webkit_plugin", format, args); - va_end(args); -} - -void anp_logPluginEvent(void* npp, const ANPEvent* evt, int16_t returnVal, int elapsedTime) { - - switch(evt->eventType) { - - case kNull_ANPEventType: - PLUGIN_LOG("%p EVENT::NULL", npp); - break; - - case kKey_ANPEventType: - if(evt->data.key.action < ARRAY_COUNT(inputActions)) { - anp_logPlugin("%p EVENT::KEY[%d] time=%d action=%s code=%d vcode=%d unichar=%d repeat=%d mods=%x", - npp, returnVal, elapsedTime, inputActions[evt->data.key.action], - evt->data.key.nativeCode, evt->data.key.virtualCode, - evt->data.key.unichar, evt->data.key.repeatCount, - evt->data.key.modifiers); - } else { - PLUGIN_LOG("%p EVENT::KEY[%d] unknown action", npp, returnVal); - } - break; - - case kMouse_ANPEventType: - if(evt->data.mouse.action < ARRAY_COUNT(inputActions)) { - anp_logPlugin("%p EVENT::MOUSE[%d] time=%d action=%s [%d %d]", npp, - returnVal, elapsedTime, inputActions[evt->data.mouse.action], - evt->data.touch.x, evt->data.touch.y); - } else { - anp_logPlugin("%p EVENT::MOUSE[%d] unknown action", npp, returnVal); - } - break; - - case kTouch_ANPEventType: - if(evt->data.touch.action < ARRAY_COUNT(inputActions)) { - - anp_logPlugin("%p EVENT::TOUCH[%d] time=%d action=%s [%d %d]", - npp, returnVal, elapsedTime, - inputActions[evt->data.touch.action], evt->data.touch.x, - evt->data.touch.y); - } else { - anp_logPlugin("%p EVENT::TOUCH[%d] unknown action", npp, returnVal); - } - break; - - case kDraw_ANPEventType: - if (evt->data.draw.model == kBitmap_ANPDrawingModel) { - anp_logPlugin("%p EVENT::DRAW bitmap time=%d format=%d clip=[%d,%d,%d,%d]", - npp, elapsedTime, evt->data.draw.data.bitmap.format, - evt->data.draw.clip.left, evt->data.draw.clip.top, - evt->data.draw.clip.right, evt->data.draw.clip.bottom); - } else if (evt->data.draw.model == kOpenGL_ANPDrawingModel) { - anp_logPlugin("%p EVENT::DRAW openGL time=%d dimensions=[%d,%d]", - npp, elapsedTime, evt->data.draw.data.surface.width, - evt->data.draw.data.surface.height); - } else { - anp_logPlugin("%p EVENT::DRAW unknown drawing model", npp); - } - break; - - case kLifecycle_ANPEventType: - if(evt->data.lifecycle.action < ARRAY_COUNT(lifecycleActions)) { - anp_logPlugin("%p EVENT::LIFECYCLE time=%d action=%s", npp, elapsedTime, - lifecycleActions[evt->data.lifecycle.action]); - } else { - anp_logPlugin("%p EVENT::LIFECYCLE unknown action", npp); - } - break; - - case kCustom_ANPEventType: - anp_logPlugin("%p EVENT::CUSTOM time=%d", npp, elapsedTime); - break; - - default: - anp_logPlugin("%p EVENT::UNKNOWN", npp); - break; - } -} diff --git a/WebKit/android/plugins/PluginDebugAndroid.h b/WebKit/android/plugins/PluginDebugAndroid.h deleted file mode 100644 index 5002882..0000000 --- a/WebKit/android/plugins/PluginDebugAndroid.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2010, 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef PLUGIN_DEBUG_ANDROID_H__ -#define PLUGIN_DEBUG_ANDROID_H__ - -#include "android_npapi.h" - -// Define PLUGIN_DEBUG_LOCAL in an individual C++ file to enable for -// that file only. - -// Define PLUGIN_DEBUG_GLOBAL to 1 to turn plug-in debug for all -// Android plug-in code in this directory. -#define PLUGIN_DEBUG_GLOBAL 0 - -#if PLUGIN_DEBUG_GLOBAL || defined(PLUGIN_DEBUG_LOCAL) -# define PLUGIN_LOG(FORMAT, ARGS...) do { anp_logPlugin(FORMAT, ## ARGS); } while(0) -# define PLUGIN_LOG_EVENT(NPP, EVT, RET, TIME) do { anp_logPluginEvent(NPP, EVT, RET, TIME); } while(0) - -/* Logs the given character array and optional arguments. All log entries use - the DEBUG priority and use the same "webkit_plugin" log tag. - */ -void anp_logPlugin(const char format[], ...); -/* Logs a user readable description of a plugin event. The relevant contents of - each event are logged, as well as the value returned by the plugin instance - and how long the instance took to process the event (in milliseconds). - */ -void anp_logPluginEvent(void* npp, const ANPEvent* event, int16_t returnVal, int elapsedTime); - -#else -# define PLUGIN_LOG(A, B...) do { } while(0) -# define PLUGIN_LOG_EVENT(NPP, EVT, RET, TIME) do { } while(0) - -#endif - -#endif // defined(PLUGIN_DEBUG_ANDROID_H__) diff --git a/WebKit/android/plugins/PluginTimer.cpp b/WebKit/android/plugins/PluginTimer.cpp deleted file mode 100644 index dfa7272..0000000 --- a/WebKit/android/plugins/PluginTimer.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2009, The Android Open Source Project - * Copyright (C) 2008 Google Inc. All rights reserved. - * - * 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 THE COPYRIGHT OWNER 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. - */ - -#include "config.h" -#include "PluginTimer.h" -#include "RefPtr.h" - -namespace WebCore { - - static uint32_t gTimerID; - - PluginTimer::PluginTimer(PluginTimer** list, NPP instance, bool repeat, - void (*timerFunc)(NPP npp, uint32_t timerID)) - : m_list(list), - m_instance(instance), - m_timerFunc(timerFunc), - m_repeat(repeat), - m_unscheduled(false) - { - m_timerID = ++gTimerID; - - m_next = *list; - if (m_next) { - m_next->m_prev = this; - } - m_prev = 0; - *list = this; - relaxAdoptionRequirement(); - } - - PluginTimer::~PluginTimer() - { - if (m_next) { - m_next->m_prev = m_prev; - } - if (m_prev) { - m_prev->m_next = m_next; - } else { - *m_list = m_next; - } - } - - void PluginTimer::fired() - { - // ensure the timer cannot be deleted until this method completes - RefPtr<PluginTimer> protector(this); - - if (!m_unscheduled) - m_timerFunc(m_instance, m_timerID); - - // remove the timer if it is a one-shot timer (!m_repeat) or if is a - // repeating timer that has been unscheduled. In either case we must - // ensure that the refcount is 2 or greater since the PluginTimerList - // could have been deleted by the timerFunc and we must ensure that we - // do not double delete. - if ((!m_repeat || m_unscheduled) && refCount() > 1) - deref(); // mark the timer for deletion as it is no longer needed - } - - // may return null if timerID is not found - PluginTimer* PluginTimer::Find(PluginTimer* list, uint32_t timerID) - { - PluginTimer* curr = list; - while (curr) { - if (curr->m_timerID == timerID) { - break; - } - curr = curr->m_next; - } - return curr; - } - - /////////////////////////////////////////////////////////////////////////// - - PluginTimerList::~PluginTimerList() - { - PluginTimer* curr = m_list; - PluginTimer* next; - while (curr) { - next = curr->next(); - curr->deref(); - curr = next; - } - } - - uint32_t PluginTimerList::schedule(NPP instance, uint32_t interval, bool repeat, - void (*proc)(NPP npp, uint32_t timerID)) - { - PluginTimer* timer = new PluginTimer(&m_list, instance, repeat, proc); - - double dinterval = interval * 0.001; // milliseconds to seconds - if (repeat) { - timer->startRepeating(dinterval); - } else { - timer->startOneShot(dinterval); - } - return timer->timerID(); - } - - void PluginTimerList::unschedule(NPP instance, uint32_t timerID) - { - // Although it looks like simply deleting the timer would work here - // (stop() will be executed by the dtor), we cannot do this, as - // the plugin can call us while we are in the fired() method, - // (when we execute the timerFunc callback). Deleting the object - // we are in would then be a rather bad move... - PluginTimer* timer = PluginTimer::Find(m_list, timerID); - if (timer) - timer->unschedule(); - } - -} // namespace WebCore diff --git a/WebKit/android/plugins/PluginTimer.h b/WebKit/android/plugins/PluginTimer.h deleted file mode 100644 index 20c0816..0000000 --- a/WebKit/android/plugins/PluginTimer.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2009, The Android Open Source Project - * Copyright (C) 2008 Google Inc. All rights reserved. - * - * 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef PluginTimer_H -#define PluginTimer_H - -#include "RefCounted.h" -#include "Timer.h" -#include "npapi.h" - -namespace WebCore { - - class PluginTimerList; - - class PluginTimer : public TimerBase, public RefCounted<PluginTimer> { - public: - PluginTimer(PluginTimer** list, NPP instance, bool repeat, - void (*proc)(NPP npp, uint32_t timerID)); - virtual ~PluginTimer(); - - uint32_t timerID() const { return m_timerID; } - - void unschedule() { m_unscheduled = true; } - - static PluginTimer* Find(PluginTimer* list, uint32_t timerID); - - private: - // override from TimerBase - virtual void fired(); - - PluginTimer* next() const { return m_next; } - friend class PluginTimerList; - - PluginTimer** m_list; - PluginTimer* m_prev; - PluginTimer* m_next; - NPP m_instance; - void (*m_timerFunc)(NPP, uint32_t); - uint32_t m_timerID; - bool m_repeat; - bool m_unscheduled; - }; - - class PluginTimerList { - public: - PluginTimerList() : m_list(0) {} - ~PluginTimerList(); - - uint32_t schedule(NPP instance, uint32_t interval, bool repeat, - void (*proc)(NPP npp, uint32_t timerID)); - void unschedule(NPP instance, uint32_t timerID); - - private: - PluginTimer* m_list; - }; - -} // namespace WebCore - -#endif diff --git a/WebKit/android/plugins/PluginViewBridgeAndroid.cpp b/WebKit/android/plugins/PluginViewBridgeAndroid.cpp deleted file mode 100644 index 2be9dc3..0000000 --- a/WebKit/android/plugins/PluginViewBridgeAndroid.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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. - */ - -#include "config.h" -#include "PluginViewBridgeAndroid.h" - -namespace WebCore { - - void PluginViewBridgeAndroid::draw(GraphicsContext* gc, - const IntRect& rect) {} - - bool PluginViewBridgeAndroid::forPluginView() const { - return true; - } - -} diff --git a/WebKit/android/plugins/PluginViewBridgeAndroid.h b/WebKit/android/plugins/PluginViewBridgeAndroid.h deleted file mode 100644 index 5d16f46..0000000 --- a/WebKit/android/plugins/PluginViewBridgeAndroid.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2009, The Android Open Source Project - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2008 Collabora Ltd. All rights reserved. - * - * 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef PluginViewBridgeAndroid_H -#define PluginViewBridgeAndroid_H - -#include "PluginView.h" -#include "WebCoreViewBridge.h" - -namespace WebCore { - - // (Dummy for now) WebCoreViewBridge associated with a PluginView Widget. - class PluginViewBridgeAndroid : public WebCoreViewBridge { - public: - PluginViewBridgeAndroid() {} - - // overrides - virtual void draw(GraphicsContext* gc, const IntRect& rect); - virtual bool forPluginView() const; - }; - -} // namespace WebCore - -#endif diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp deleted file mode 100644 index b8a10cc..0000000 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ /dev/null @@ -1,690 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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. - */ - -#include "config.h" -#include "PluginWidgetAndroid.h" - -#if ENABLE(TOUCH_EVENTS) -#include "ChromeClient.h" -#endif -#include "Document.h" -#include "Element.h" -#include "Frame.h" -#include "Page.h" -#include "PluginPackage.h" -#include "PluginView.h" -#include "PluginWidgetAndroid.h" -#include "ScrollView.h" -#include "SkANP.h" -#include "SkFlipPixelRef.h" -#include "SkString.h" -#include "SkTime.h" -#include "WebViewCore.h" -#include "android_graphics.h" -#include <JNIUtility.h> - -// #define PLUGIN_DEBUG_LOCAL // controls the printing of log messages -#define DEBUG_EVENTS 0 // logs event contents, return value, and processing time -#define DEBUG_VISIBLE_RECTS 0 // temporary debug printfs and fixes - -// this include statement must follow the declaration of PLUGIN_DEBUG_LOCAL -#include "PluginDebugAndroid.h" - -PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) - : m_pluginView(view) { - m_flipPixelRef = NULL; - m_core = NULL; - m_drawingModel = kBitmap_ANPDrawingModel; - m_eventFlags = 0; - m_pluginWindow = NULL; - m_requestedVisibleRectCount = 0; - m_requestedVisibleRect.setEmpty(); - m_visibleDocRect.setEmpty(); - m_pluginBounds.setEmpty(); - m_hasFocus = false; - m_isFullScreen = false; - m_visible = false; - m_cachedZoomLevel = 0; - m_embeddedView = NULL; - m_embeddedViewAttached = false; - m_acceptEvents = false; - m_isSurfaceClippedOut = false; - m_layer = 0; - m_powerState = kDefault_ANPPowerState; -} - -PluginWidgetAndroid::~PluginWidgetAndroid() { - PLUGIN_LOG("%p Deleting Plugin", m_pluginView->instance()); - m_acceptEvents = false; - if (m_core) { - setPowerState(kDefault_ANPPowerState); - m_core->removePlugin(this); - if (m_isFullScreen) { - exitFullScreen(true); - } - if (m_embeddedView) { - m_core->destroySurface(m_embeddedView); - } - } - - // cleanup any remaining JNI References - JNIEnv* env = JSC::Bindings::getJNIEnv(); - if (m_embeddedView) { - env->DeleteGlobalRef(m_embeddedView); - } - - SkSafeUnref(m_flipPixelRef); - - if (m_layer) - m_layer->unref(); -} - -void PluginWidgetAndroid::init(android::WebViewCore* core) { - m_core = core; - m_core->addPlugin(this); - m_acceptEvents = true; - PLUGIN_LOG("%p Initialized Plugin", m_pluginView->instance()); -} - -static SkBitmap::Config computeConfig(bool isTransparent) { - return isTransparent ? SkBitmap::kARGB_8888_Config - : SkBitmap::kRGB_565_Config; -} - -void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) { - - // store the reference locally for easy lookup - m_pluginWindow = window; - - // make a copy of the previous bounds - SkIRect oldPluginBounds = m_pluginBounds; - - // keep a local copy of the plugin bounds because the m_pluginWindow pointer - // gets updated values prior to this method being called - m_pluginBounds.set(m_pluginWindow->x, m_pluginWindow->y, - m_pluginWindow->x + m_pluginWindow->width, - m_pluginWindow->y + m_pluginWindow->height); - - PLUGIN_LOG("%p PluginBounds (%d,%d,%d,%d)", m_pluginView->instance(), - m_pluginBounds.fLeft, m_pluginBounds.fTop, - m_pluginBounds.fRight, m_pluginBounds.fBottom); - - const bool boundsChanged = m_pluginBounds != oldPluginBounds; - - //TODO hack to ensure that we grab the most recent screen dimensions and scale - ANPRectI screenCoords; - m_core->getVisibleScreen(screenCoords); - float scale = m_core->scale(); - bool scaleChanged = m_cachedZoomLevel != scale; - setVisibleScreen(screenCoords, scale); - - // if the scale changed then setVisibleScreen will call this function and - // this call will potentially fire a duplicate draw event - if (!scaleChanged) { - sendSizeAndVisibilityEvents(boundsChanged); - } - layoutSurface(boundsChanged); - - if (m_drawingModel != kSurface_ANPDrawingModel) { - SkSafeUnref(m_flipPixelRef); - m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent), - window->width, window->height); - } -} - -bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) { - - if (model == kOpenGL_ANPDrawingModel && m_layer == 0) { - JNIEnv* env = JSC::Bindings::getJNIEnv(); - jobject webview = m_core->getWebViewJavaObject(); - jobject weakWebViewRef = 0; - if (webview) - weakWebViewRef = env->NewWeakGlobalRef(webview); - m_layer = new WebCore::MediaLayer(weakWebViewRef); - } - else if (model != kOpenGL_ANPDrawingModel && m_layer != 0) { - m_layer->unref(); - m_layer = 0; - } - - if (m_drawingModel != model) { - // Trigger layer computation in RenderLayerCompositor - m_pluginView->getElement()->setNeedsStyleRecalc(SyntheticStyleChange); - } - - m_drawingModel = model; - return true; -} - -// returned rect is in the page coordinate -bool PluginWidgetAndroid::isDirty(SkIRect* rect) const { - // nothing to report if we haven't had setWindow() called yet - if (NULL == m_flipPixelRef) { - return false; - } - - const SkRegion& dirty = m_flipPixelRef->dirtyRgn(); - if (dirty.isEmpty()) { - return false; - } else { - if (rect) { - *rect = dirty.getBounds(); - rect->offset(m_pluginWindow->x, m_pluginWindow->y); - } - return true; - } -} - -void PluginWidgetAndroid::inval(const WebCore::IntRect& rect, - bool signalRedraw) { - // nothing to do if we haven't had setWindow() called yet. m_flipPixelRef - // will also be null if this is a Surface model. - if (NULL == m_flipPixelRef) { - return; - } - - m_flipPixelRef->inval(rect); - - if (signalRedraw && m_flipPixelRef->isDirty()) { - m_core->invalPlugin(this); - } -} - -void PluginWidgetAndroid::viewInvalidate() { - WebCore::IntRect rect(m_pluginBounds.fLeft, m_pluginBounds.fTop, - m_pluginBounds.width(), m_pluginBounds.height()); - m_core->viewInvalidate(rect); -} - -void PluginWidgetAndroid::draw(SkCanvas* canvas) { - if (NULL == m_flipPixelRef || !m_flipPixelRef->isDirty()) { - return; - } - - SkAutoFlipUpdate update(m_flipPixelRef); - const SkBitmap& bitmap = update.bitmap(); - const SkRegion& dirty = update.dirty(); - - ANPEvent event; - SkANP::InitEvent(&event, kDraw_ANPEventType); - - event.data.draw.model = m_drawingModel; - SkANP::SetRect(&event.data.draw.clip, dirty.getBounds()); - - switch (m_drawingModel) { - case kBitmap_ANPDrawingModel: { - WebCore::PluginPackage* pkg = m_pluginView->plugin(); - NPP instance = m_pluginView->instance(); - - if (SkANP::SetBitmap(&event.data.draw.data.bitmap, - bitmap) && - pkg->pluginFuncs()->event(instance, &event)) { - - if (canvas && m_pluginWindow) { - SkBitmap bm(bitmap); - bm.setPixelRef(m_flipPixelRef); - canvas->drawBitmap(bm, 0, 0); - } - } - break; - } - default: - break; - } -} - -void PluginWidgetAndroid::setSurfaceClip(const SkIRect& clip) { - - if (m_drawingModel != kSurface_ANPDrawingModel) - return; - - /* don't display surfaces that are either entirely clipped or only 1x1 in - size. It appears that when an element is absolutely positioned and has - been completely clipped in CSS that webkit still sends a clip of 1x1. - */ - bool clippedOut = (clip.width() <= 1 && clip.height() <= 1); - if(clippedOut != m_isSurfaceClippedOut) { - m_isSurfaceClippedOut = clippedOut; - layoutSurface(); - } -} - -void PluginWidgetAndroid::layoutSurface(bool pluginBoundsChanged) { - - if (m_drawingModel != kSurface_ANPDrawingModel) - return; - if (!m_pluginWindow) - return; - - - bool displayPlugin = m_pluginView->isVisible() && !m_isSurfaceClippedOut; - PLUGIN_LOG("%p DisplayPlugin[%d] visible=[%d] clipped=[%d]", - m_pluginView->instance(), displayPlugin, - m_pluginView->isVisible(), m_isSurfaceClippedOut); - - // if the surface does not exist then create a new surface - if (!m_embeddedView && displayPlugin) { - - WebCore::PluginPackage* pkg = m_pluginView->plugin(); - NPP instance = m_pluginView->instance(); - - jobject pluginSurface; - pkg->pluginFuncs()->getvalue(instance, kJavaSurface_ANPGetValue, - static_cast<void*>(&pluginSurface)); - - jobject tempObj = m_core->addSurface(pluginSurface, - m_pluginWindow->x, m_pluginWindow->y, - m_pluginWindow->width, m_pluginWindow->height); - - if (tempObj) { - JNIEnv* env = JSC::Bindings::getJNIEnv(); - m_embeddedView = env->NewGlobalRef(tempObj); - m_embeddedViewAttached = true; - } - // if the view is unattached but visible then attach it - } else if (m_embeddedView && !m_embeddedViewAttached && displayPlugin && !m_isFullScreen) { - m_core->updateSurface(m_embeddedView, m_pluginWindow->x, m_pluginWindow->y, - m_pluginWindow->width, m_pluginWindow->height); - m_embeddedViewAttached = true; - // if the view is attached but invisible then remove it - } else if (m_embeddedView && m_embeddedViewAttached && !displayPlugin) { - m_core->destroySurface(m_embeddedView); - m_embeddedViewAttached = false; - // if the plugin's bounds have changed and it's visible then update it - } else if (pluginBoundsChanged && displayPlugin && !m_isFullScreen) { - m_core->updateSurface(m_embeddedView, m_pluginWindow->x, m_pluginWindow->y, - m_pluginWindow->width, m_pluginWindow->height); - - } -} - -int16_t PluginWidgetAndroid::sendEvent(const ANPEvent& evt) { - if (!m_acceptEvents) - return 0; - WebCore::PluginPackage* pkg = m_pluginView->plugin(); - NPP instance = m_pluginView->instance(); - // "missing" plugins won't have these - if (pkg && instance) { - - // if the plugin is gaining focus then update our state now to allow - // the plugin's event handler to perform actions that require focus - if (evt.eventType == kLifecycle_ANPEventType && - evt.data.lifecycle.action == kGainFocus_ANPLifecycleAction) { - m_hasFocus = true; - } - -#if DEBUG_EVENTS - SkMSec startTime = SkTime::GetMSecs(); -#endif - - // make a localCopy since the actual plugin may not respect its constness, - // and so we don't want our caller to have its param modified - ANPEvent localCopy = evt; - int16_t result = pkg->pluginFuncs()->event(instance, &localCopy); - -#if DEBUG_EVENTS - SkMSec endTime = SkTime::GetMSecs(); - PLUGIN_LOG_EVENT(instance, &evt, result, endTime - startTime); -#endif - - // if the plugin is losing focus then delay the update of our state - // until after we notify the plugin and allow them to perform actions - // that may require focus - if (evt.eventType == kLifecycle_ANPEventType && - evt.data.lifecycle.action == kLoseFocus_ANPLifecycleAction) { - m_hasFocus = false; - } - - return result; - } - return 0; -} - -void PluginWidgetAndroid::updateEventFlags(ANPEventFlags flags) { - - // if there are no differences then immediately return - if (m_eventFlags == flags) { - return; - } - - Document* doc = m_pluginView->parentFrame()->document(); -#if ENABLE(TOUCH_EVENTS) - if((m_eventFlags ^ flags) & kTouch_ANPEventFlag) { - if (flags & kTouch_ANPEventFlag) - doc->addListenerTypeIfNeeded(eventNames().touchstartEvent); - } -#endif - - m_eventFlags = flags; -} - -bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) { - return m_eventFlags & flag; -} - -void PluginWidgetAndroid::sendSizeAndVisibilityEvents(const bool updateDimensions) { - // TODO update the bitmap size based on the zoom? (for kBitmap_ANPDrawingModel) - - const float zoomLevel = m_core->scale(); - - // notify the plugin of the new size - if (m_drawingModel == kOpenGL_ANPDrawingModel && updateDimensions && m_pluginWindow) { - PLUGIN_LOG("%s (%d,%d)[%f]", __FUNCTION__, m_pluginWindow->width, - m_pluginWindow->height, zoomLevel); - ANPEvent event; - SkANP::InitEvent(&event, kDraw_ANPEventType); - event.data.draw.model = kOpenGL_ANPDrawingModel; - event.data.draw.data.surface.width = m_pluginWindow->width * zoomLevel; - event.data.draw.data.surface.height = m_pluginWindow->height * zoomLevel; - sendEvent(event); - } - - bool visible = SkIRect::Intersects(m_visibleDocRect, m_pluginBounds); - if(m_visible != visible) { - -#if DEBUG_VISIBLE_RECTS - PLUGIN_LOG("%p changeVisiblity[%d] pluginBounds(%d,%d,%d,%d)", - m_pluginView->instance(), visible, - m_pluginBounds.fLeft, m_pluginBounds.fTop, - m_pluginBounds.fRight, m_pluginBounds.fBottom); -#endif - - // change the visibility - m_visible = visible; - // send the event - ANPEvent event; - SkANP::InitEvent(&event, kLifecycle_ANPEventType); - event.data.lifecycle.action = visible ? kOnScreen_ANPLifecycleAction - : kOffScreen_ANPLifecycleAction; - sendEvent(event); - } -} - -void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float zoom) { -#if DEBUG_VISIBLE_RECTS - PLUGIN_LOG("%s (%d,%d,%d,%d)[%f]", __FUNCTION__, visibleDocRect.left, - visibleDocRect.top, visibleDocRect.right, - visibleDocRect.bottom, zoom); -#endif - int oldScreenW = m_visibleDocRect.width(); - int oldScreenH = m_visibleDocRect.height(); - - const bool zoomChanged = m_cachedZoomLevel != zoom; - - // make local copies of the parameters - m_cachedZoomLevel = zoom; - m_visibleDocRect.set(visibleDocRect.left, - visibleDocRect.top, - visibleDocRect.right, - visibleDocRect.bottom); - - int newScreenW = m_visibleDocRect.width(); - int newScreenH = m_visibleDocRect.height(); - - // if the screen dimensions have changed by more than 5 pixels in either - // direction then recompute the plugin's visible rectangle - if (abs(oldScreenW - newScreenW) > 5 || abs(oldScreenH - newScreenH) > 5) { - PLUGIN_LOG("%s VisibleDoc old=[%d,%d] new=[%d,%d] ", __FUNCTION__, - oldScreenW, oldScreenH, newScreenW, newScreenH); - computeVisiblePluginRect(); - } - - sendSizeAndVisibilityEvents(zoomChanged); -} - -ANPRectI PluginWidgetAndroid::visibleRect() { - - SkIRect visibleRect; - visibleRect.setEmpty(); - - // compute the interesection of the visible screen and the plugin - bool visible = visibleRect.intersect(m_visibleDocRect, m_pluginBounds); - if (visible) { - // convert from absolute coordinates to the plugin's relative coordinates - visibleRect.offset(-m_pluginBounds.fLeft, -m_pluginBounds.fTop); - } - - // convert from SkRect to ANPRect - ANPRectI result; - memcpy(&result, &visibleRect, sizeof(ANPRectI)); - return result; -} - -void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) { -#if DEBUG_VISIBLE_RECTS - PLUGIN_LOG("%s count=%d", __FUNCTION__, count); -#endif - // ensure the count does not exceed our allocated space - if (count > MAX_REQUESTED_RECTS) - count = MAX_REQUESTED_RECTS; - - // store the values in member variables - m_requestedVisibleRectCount = count; - memcpy(m_requestedVisibleRects, rects, count * sizeof(rects[0])); - -#if DEBUG_VISIBLE_RECTS // FIXME: this fixes bad data from the plugin - // take it out once plugin supplies better data - for (int index = 0; index < count; index++) { - PLUGIN_LOG("%s [%d](%d,%d,%d,%d)", __FUNCTION__, index, - m_requestedVisibleRects[index].left, - m_requestedVisibleRects[index].top, - m_requestedVisibleRects[index].right, - m_requestedVisibleRects[index].bottom); - if (m_requestedVisibleRects[index].left == - m_requestedVisibleRects[index].right) { - m_requestedVisibleRects[index].right += 1; - } - if (m_requestedVisibleRects[index].top == - m_requestedVisibleRects[index].bottom) { - m_requestedVisibleRects[index].bottom += 1; - } - } -#endif - computeVisiblePluginRect(); -} - -void PluginWidgetAndroid::computeVisiblePluginRect() { - - // ensure the visibleDocRect has been set (i.e. not equal to zero) - if (m_visibleDocRect.isEmpty() || !m_pluginWindow || m_requestedVisibleRectCount < 1) - return; - - // create a rect that will contain as many of the rects that will fit on screen - SkIRect visibleRect; - visibleRect.setEmpty(); - - for (int counter = 0; counter < m_requestedVisibleRectCount; counter++) { - - ANPRectI* rect = &m_requestedVisibleRects[counter]; - - // create skia rect for easier manipulation and convert it to page coordinates - SkIRect pluginRect; - pluginRect.set(rect->left, rect->top, rect->right, rect->bottom); - pluginRect.offset(m_pluginWindow->x, m_pluginWindow->y); - - // ensure the rect falls within the plugin's bounds - if (!m_pluginBounds.contains(pluginRect)) { -#if DEBUG_VISIBLE_RECTS - PLUGIN_LOG("%s (%d,%d,%d,%d) !contain (%d,%d,%d,%d)", __FUNCTION__, - m_pluginBounds.fLeft, m_pluginBounds.fTop, - m_pluginBounds.fRight, m_pluginBounds.fBottom, - pluginRect.fLeft, pluginRect.fTop, - pluginRect.fRight, pluginRect.fBottom); - // assume that the desired outcome is to clamp to the container - if (pluginRect.intersect(m_pluginBounds)) { - visibleRect = pluginRect; - } -#endif - continue; - } - - // combine this new rect with the higher priority rects - pluginRect.join(visibleRect); - - // check to see if the new rect could be made to fit within the screen - // bounds. If this is the highest priority rect then attempt to center - // even if it doesn't fit on the screen. - if (counter > 0 && (m_visibleDocRect.width() < pluginRect.width() || - m_visibleDocRect.height() < pluginRect.height())) - break; - - // set the new visible rect - visibleRect = pluginRect; - } - - m_requestedVisibleRect = visibleRect; - scrollToVisiblePluginRect(); -} - -void PluginWidgetAndroid::scrollToVisiblePluginRect() { - - if (!m_hasFocus || m_requestedVisibleRect.isEmpty() || m_visibleDocRect.isEmpty()) { -#if DEBUG_VISIBLE_RECTS - PLUGIN_LOG("%s call m_hasFocus=%d m_requestedVisibleRect.isEmpty()=%d" - " m_visibleDocRect.isEmpty()=%d", __FUNCTION__, m_hasFocus, - m_requestedVisibleRect.isEmpty(), m_visibleDocRect.isEmpty()); -#endif - return; - } - // if the entire rect is already visible then we don't need to scroll - if (m_visibleDocRect.contains(m_requestedVisibleRect)) - return; - - // find the center of the visibleRect in document coordinates - int rectCenterX = m_requestedVisibleRect.fLeft + m_requestedVisibleRect.width()/2; - int rectCenterY = m_requestedVisibleRect.fTop + m_requestedVisibleRect.height()/2; - - // find document coordinates for center of the visible screen - int visibleDocCenterX = m_visibleDocRect.fLeft + m_visibleDocRect.width()/2; - int visibleDocCenterY = m_visibleDocRect.fTop + m_visibleDocRect.height()/2; - - //compute the delta of the two points and scale to screen coordinates - int deltaX = rectCenterX - visibleDocCenterX; - int deltaY = rectCenterY - visibleDocCenterY; - - ScrollView* scrollView = m_pluginView->parent(); - android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView); -#if DEBUG_VISIBLE_RECTS - PLUGIN_LOG("%s call scrollBy (%d,%d)", __FUNCTION__, deltaX, deltaY); -#endif - core->scrollTo(rectCenterX, rectCenterY, true); -} - -void PluginWidgetAndroid::requestFullScreen() { - if (m_isFullScreen) { - return; - } - - if (!m_embeddedView && m_drawingModel == kOpenGL_ANPDrawingModel) { - WebCore::PluginPackage* pkg = m_pluginView->plugin(); - NPP instance = m_pluginView->instance(); - - jobject pluginSurface; - pkg->pluginFuncs()->getvalue(instance, kJavaSurface_ANPGetValue, - static_cast<void*>(&pluginSurface)); - - // create the surface, but do not add it to the view hierarchy - jobject tempObj = m_core->createSurface(pluginSurface); - - if (tempObj) { - JNIEnv* env = JSC::Bindings::getJNIEnv(); - m_embeddedView = env->NewGlobalRef(tempObj); - m_embeddedViewAttached = false; - } - } - - if (!m_embeddedView) { - return; - } - - // send event to notify plugin of full screen change - ANPEvent event; - SkANP::InitEvent(&event, kLifecycle_ANPEventType); - event.data.lifecycle.action = kEnterFullScreen_ANPLifecycleAction; - sendEvent(event); - - // remove the embedded surface from the view hierarchy - if (m_drawingModel != kOpenGL_ANPDrawingModel) - m_core->destroySurface(m_embeddedView); - - // add the full screen view - m_core->showFullScreenPlugin(m_embeddedView, m_pluginView->instance()); - m_isFullScreen = true; -} - -void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) { - if (!m_isFullScreen || !m_embeddedView) { - return; - } - - // remove the full screen surface from the view hierarchy - if (pluginInitiated) { - m_core->hideFullScreenPlugin(); - } - - // add the embedded view back - if (m_drawingModel != kOpenGL_ANPDrawingModel) - m_core->updateSurface(m_embeddedView, m_pluginWindow->x, m_pluginWindow->y, - m_pluginWindow->width, m_pluginWindow->height); - - // send event to notify plugin of full screen change - ANPEvent event; - SkANP::InitEvent(&event, kLifecycle_ANPEventType); - event.data.lifecycle.action = kExitFullScreen_ANPLifecycleAction; - sendEvent(event); - - m_isFullScreen = false; -} - -void PluginWidgetAndroid::requestCenterFitZoom() { - m_core->centerFitRect(m_pluginWindow->x, m_pluginWindow->y, - m_pluginWindow->width, m_pluginWindow->height); -} - -void PluginWidgetAndroid::setPowerState(ANPPowerState powerState) { - if(m_powerState == powerState) - return; - - // cleanup the old power state - switch (m_powerState) { - case kDefault_ANPPowerState: - break; - case kScreenOn_ANPPowerState: - m_core->keepScreenOn(false); - break; - } - - // setup the new power state - switch (powerState) { - case kDefault_ANPPowerState: - break; - case kScreenOn_ANPPowerState: - m_core->keepScreenOn(true); - break; - } - - m_powerState = powerState; -} - diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h deleted file mode 100644 index 5d586b1..0000000 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef PluginWidgetAndroid_H -#define PluginWidgetAndroid_H - -#include "android_npapi.h" -#include "ANPSystem_npapi.h" -#include "IntPoint.h" -#include "IntRect.h" -#include "MediaLayer.h" -#include "SkRect.h" -#include <jni.h> - -namespace WebCore { - class PluginView; -} - -namespace android { - class PluginSurface; - class WebViewCore; -} - -class SkCanvas; -class SkFlipPixelRef; - -/* - This is our extended state in a PluginView. This object is created and - kept insync with the PluginView, but is also available to WebViewCore - to allow its draw() method to be called from outside of the PluginView. - */ -struct PluginWidgetAndroid { - // initialize with our host pluginview. This will delete us when it is - // destroyed. - PluginWidgetAndroid(WebCore::PluginView* view); - ~PluginWidgetAndroid(); - - WebCore::PluginView* pluginView() const { return m_pluginView; } - - // Needed by PluginSurface to manage the java SurfaceView. - android::WebViewCore* webViewCore() const { return m_core; } - - /* Can't determine our core at construction time, so PluginView calls this - as soon as it has a parent. - */ - void init(android::WebViewCore*); - /* Called each time the PluginView gets a new size or position. - */ - void setWindow(NPWindow* window, bool isTransparent); - - /* 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. - */ - bool setDrawingModel(ANPDrawingModel); - - /* Called to check if the plugin is running in "windowed" mode (i.e. surface - view). - */ - bool isSurfaceDrawingModel() const { return kSurface_ANPDrawingModel == m_drawingModel; } - - bool isOpenGLDrawingModel() const { return kOpenGL_ANPDrawingModel == m_drawingModel; } - - /* Returns true (and optionally updates rect with the dirty bounds in the - page coordinate) if the plugin has invalidate us. - */ - bool isDirty(SkIRect* dirtyBounds = NULL) const; - /* Called by PluginView to invalidate a portion of the plugin area (in - local plugin coordinates). If signalRedraw is true, this also triggers - a subsequent call to draw(NULL). - */ - void inval(const WebCore::IntRect&, bool signalRedraw); - - /* Called to draw into the plugin's bitmap. If canvas is non-null, the - bitmap itself is then drawn into the canvas. - */ - void draw(SkCanvas* canvas = NULL); - - /* Send this event to the plugin instance. A non-zero value will be - returned if the plugin handled the event. - */ - int16_t sendEvent(const ANPEvent&); - - /* Update the plugins event flags. If a flag is set to true then the plugin - wants to be notified of events of this type. - */ - void updateEventFlags(ANPEventFlags); - - /* Called to check if a plugin wants to accept a given event type. It - returns true if the plugin wants the events and false otherwise. - */ - bool isAcceptingEvent(ANPEventFlag); - - /* Notify the plugin of the currently visible screen coordinates (document - space) and the current zoom level. - */ - void setVisibleScreen(const ANPRectI& visibleScreenRect, float zoom); - - /** Returns a rectangle representing the visible area of the plugin on - screen. The coordinates are relative to the size of the plugin in the - document and will not be negative or exceed the plugin's size. - */ - ANPRectI visibleRect(); - - /** Registers a set of rectangles that the plugin would like to keep on - screen. The rectangles are listed in order of priority with the highest - priority rectangle in location rects[0]. The browser will attempt to keep - as many of the rectangles on screen as possible and will scroll them into - view in response to the invocation of this method and other various events. - The count specifies how many rectangles are in the array. If the count is - zero it signals the plugin that any existing rectangles should be cleared - and no rectangles will be tracked. - */ - void setVisibleRects(const ANPRectI rects[], int32_t count); - - /** Called when a plugin wishes to enter into full screen mode. It invokes - the plugin's Java class (defined in the plugin's apk manifest), which is - called asynchronously and provides a View to be displayed full screen. - */ - void requestFullScreen(); - - /** Called when a plugin wishes to exit from full screen mode. As a result, - the plugin's full-screen view is discarded by the view system. It is also - called in order to notify the native code that the browser has discarded - the view. - */ - void exitFullScreen(bool pluginInitiated); - - bool inFullScreen() { return m_isFullScreen; } - - /** Called to check if a plugin currently has document focus, which is - required for certain operations (e.g. show/hide keyboard). It returns - true if the plugin currently has focus and false otherwise. - */ - bool hasFocus() const { return m_hasFocus; } - - /** Called to ensure the surface is being correctly displayed within the - view hierarchy. For instance, if the visibility of the plugin has - changed then we need to ensure the surface is added or removed from the - view system. - */ - void layoutSurface(bool pluginBoundsChanged = false); - - /** send the surface the currently visible portion of the plugin. This is not - the portion of the plugin visible on the screen but rather the portion of - the plugin that is not obscured by other HTML content. - */ - void setSurfaceClip(const SkIRect& clip); - - /** Called when a plugin wishes to be zoomed and centered in the current view. - */ - void requestCenterFitZoom(); - - WebCore::MediaLayer* getLayer() const { return m_layer; } - - void setPowerState(ANPPowerState powerState); - - void viewInvalidate(); - -private: - void computeVisiblePluginRect(); - void scrollToVisiblePluginRect(); - void sendSizeAndVisibilityEvents(const bool updateDimensions); - - WebCore::MediaLayer* m_layer; - - WebCore::PluginView* m_pluginView; - android::WebViewCore* m_core; - SkFlipPixelRef* m_flipPixelRef; - ANPDrawingModel m_drawingModel; - ANPEventFlags m_eventFlags; - NPWindow* m_pluginWindow; - SkIRect m_pluginBounds; // relative to the page - SkIRect m_visibleDocRect; // relative to the page - SkIRect m_requestedVisibleRect; // relative to the page - bool m_hasFocus; - bool m_isFullScreen; - bool m_visible; - float m_cachedZoomLevel; // used for comparison only - jobject m_embeddedView; - bool m_embeddedViewAttached; - bool m_acceptEvents; - bool m_isSurfaceClippedOut; - ANPPowerState m_powerState; - - /* We limit the number of rectangles to minimize storage and ensure adequate - speed. - */ - enum { - MAX_REQUESTED_RECTS = 5, - }; - - ANPRectI m_requestedVisibleRects[MAX_REQUESTED_RECTS]; - int32_t m_requestedVisibleRectCount; -}; - -#endif diff --git a/WebKit/android/plugins/SkANP.cpp b/WebKit/android/plugins/SkANP.cpp deleted file mode 100644 index 720387d..0000000 --- a/WebKit/android/plugins/SkANP.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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" -#include <wtf/CurrentTime.h> - -SkRect* SkANP::SetRect(SkRect* dst, const ANPRectF& src) { - dst->set(SkFloatToScalar(src.left), - SkFloatToScalar(src.top), - SkFloatToScalar(src.right), - SkFloatToScalar(src.bottom)); - return dst; -} - -SkIRect* SkANP::SetRect(SkIRect* dst, const ANPRectI& src) { - dst->set(src.left, src.top, src.right, src.bottom); - return dst; -} - -ANPRectI* SkANP::SetRect(ANPRectI* dst, const SkIRect& src) { - dst->left = src.fLeft; - dst->top = src.fTop; - dst->right = src.fRight; - dst->bottom = src.fBottom; - return dst; -} - -ANPRectF* SkANP::SetRect(ANPRectF* dst, const SkRect& src) { - dst->left = SkScalarToFloat(src.fLeft); - dst->top = SkScalarToFloat(src.fTop); - dst->right = SkScalarToFloat(src.fRight); - dst->bottom = SkScalarToFloat(src.fBottom); - return dst; -} - -SkBitmap* SkANP::SetBitmap(SkBitmap* dst, const ANPBitmap& src) { - SkBitmap::Config config = SkBitmap::kNo_Config; - - switch (src.format) { - case kRGBA_8888_ANPBitmapFormat: - config = SkBitmap::kARGB_8888_Config; - break; - case kRGB_565_ANPBitmapFormat: - config = SkBitmap::kRGB_565_Config; - break; - default: - break; - } - - dst->setConfig(config, src.width, src.height, src.rowBytes); - dst->setPixels(src.baseAddr); - return dst; -} - -bool SkANP::SetBitmap(ANPBitmap* dst, const SkBitmap& src) { - if (!(dst->baseAddr = src.getPixels())) { - SkDebugf("SkANP::SetBitmap - getPixels() returned null\n"); - return false; - } - - switch (src.config()) { - case SkBitmap::kARGB_8888_Config: - dst->format = kRGBA_8888_ANPBitmapFormat; - break; - case SkBitmap::kRGB_565_Config: - dst->format = kRGB_565_ANPBitmapFormat; - break; - default: - SkDebugf("SkANP::SetBitmap - unsupported src.config %d\n", src.config()); - return false; - } - - dst->width = src.width(); - dst->height = src.height(); - dst->rowBytes = src.rowBytes(); - return true; -} - -void SkANP::InitEvent(ANPEvent* event, ANPEventType et) { - event->inSize = sizeof(ANPEvent); - event->eventType = et; -} diff --git a/WebKit/android/plugins/SkANP.h b/WebKit/android/plugins/SkANP.h deleted file mode 100644 index 5c2a936..0000000 --- a/WebKit/android/plugins/SkANP.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2008, 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef SkANP_DEFINED -#define SkANP_DEFINED - -#include "android_npapi.h" -#include "SkCanvas.h" -#include "SkMatrix.h" -#include "SkPaint.h" -#include "SkPath.h" -#include "SkTypeface.h" - -struct ANPMatrix : SkMatrix { -}; - -struct ANPPath : SkPath { -}; - -struct ANPPaint : SkPaint { -}; - -struct ANPTypeface : SkTypeface { -}; - -struct ANPCanvas { - SkCanvas* skcanvas; - - // draw into the specified bitmap - explicit ANPCanvas(const SkBitmap& bm) { - skcanvas = new SkCanvas(bm); - } - - // redirect all drawing to the specific SkCanvas - explicit ANPCanvas(SkCanvas* other) { - skcanvas = other; - skcanvas->ref(); - } - - ~ANPCanvas() { - skcanvas->unref(); - } -}; - -class SkANP { -public: - static SkRect* SetRect(SkRect* dst, const ANPRectF& src); - static SkIRect* SetRect(SkIRect* dst, const ANPRectI& src); - static ANPRectI* SetRect(ANPRectI* dst, const SkIRect& src); - static ANPRectF* SetRect(ANPRectF* dst, const SkRect& src); - static SkBitmap* SetBitmap(SkBitmap* dst, const ANPBitmap& src); - static bool SetBitmap(ANPBitmap* dst, const SkBitmap& src); - - static void InitEvent(ANPEvent* event, ANPEventType et); -}; - -#endif diff --git a/WebKit/android/plugins/SurfaceCallback.h b/WebKit/android/plugins/SurfaceCallback.h deleted file mode 100644 index 945fc3f..0000000 --- a/WebKit/android/plugins/SurfaceCallback.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2009, The Android Open Source Project - * Copyright (C) 2008 Google Inc. All rights reserved. - * - * 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 THE COPYRIGHT OWNER 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. - */ - -#ifndef SurfaceCallback_H -#define SurfaceCallback_H - -namespace android { - - class SurfaceCallback { - public: - virtual ~SurfaceCallback() {} - virtual void surfaceCreated() = 0; - virtual void surfaceChanged(int format, int width, int height) = 0; - virtual void surfaceDestroyed() = 0; - }; - -} // namespace android - -#endif diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h deleted file mode 100644 index b0c3765..0000000 --- a/WebKit/android/plugins/android_npapi.h +++ /dev/null @@ -1,987 +0,0 @@ -/* - * 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 THE COPYRIGHT OWNER 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. - */ - -/* Defines the android-specific types and functions as part of npapi - - In particular, defines the window and event types that are passed to - NPN_GetValue, NPP_SetWindow and NPP_HandleEvent. - - To minimize what native libraries the plugin links against, some - functionality is provided via function-ptrs (e.g. time, sound) - */ - -#ifndef android_npapi_H -#define android_npapi_H - -#include <stdint.h> - -#include "npapi.h" - -/////////////////////////////////////////////////////////////////////////////// -// General types - -enum ANPBitmapFormats { - kUnknown_ANPBitmapFormat = 0, - kRGBA_8888_ANPBitmapFormat = 1, - kRGB_565_ANPBitmapFormat = 2 -}; -typedef int32_t ANPBitmapFormat; - -struct ANPPixelPacking { - uint8_t AShift; - uint8_t ABits; - uint8_t RShift; - uint8_t RBits; - uint8_t GShift; - uint8_t GBits; - uint8_t BShift; - uint8_t BBits; -}; - -struct ANPBitmap { - void* baseAddr; - ANPBitmapFormat format; - int32_t width; - int32_t height; - int32_t rowBytes; -}; - -struct ANPRectF { - float left; - float top; - float right; - float bottom; -}; - -struct ANPRectI { - int32_t left; - int32_t top; - int32_t right; - int32_t bottom; -}; - -struct ANPCanvas; -struct ANPMatrix; -struct ANPPaint; -struct ANPPath; -struct ANPRegion; -struct ANPTypeface; - -enum ANPMatrixFlags { - kIdentity_ANPMatrixFlag = 0, - kTranslate_ANPMatrixFlag = 0x01, - kScale_ANPMatrixFlag = 0x02, - kAffine_ANPMatrixFlag = 0x04, - kPerspective_ANPMatrixFlag = 0x08, -}; -typedef uint32_t ANPMatrixFlag; - -/////////////////////////////////////////////////////////////////////////////// -// NPN_GetValue - -/** queries for a specific ANPInterface. - - Maybe called with NULL for the NPP instance - - NPN_GetValue(inst, interface_enum, ANPInterface*) - */ -#define kLogInterfaceV0_ANPGetValue ((NPNVariable)1000) -#define kAudioTrackInterfaceV0_ANPGetValue ((NPNVariable)1001) -#define kCanvasInterfaceV0_ANPGetValue ((NPNVariable)1002) -#define kMatrixInterfaceV0_ANPGetValue ((NPNVariable)1003) -#define kPaintInterfaceV0_ANPGetValue ((NPNVariable)1004) -#define kPathInterfaceV0_ANPGetValue ((NPNVariable)1005) -#define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1006) -#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1007) -#define kBitmapInterfaceV0_ANPGetValue ((NPNVariable)1008) -#define kSurfaceInterfaceV0_ANPGetValue ((NPNVariable)1009) -#define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010) -#define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011) - -#define kAudioTrackInterfaceV1_ANPGetValue ((NPNVariable)1012) -#define kOpenGLInterfaceV0_ANPGetValue ((NPNVariable)1013) -#define kWindowInterfaceV1_ANPGetValue ((NPNVariable)1014) -#define kVideoInterfaceV0_ANPGetValue ((NPNVariable)1015) -#define kSystemInterfaceV1_ANPGetValue ((NPNVariable)1016) - -#define kSystemInterfaceV2_ANPGetValue ((NPNVariable)1017) - -/** queries for the drawing models supported on this device. - - NPN_GetValue(inst, kSupportedDrawingModel_ANPGetValue, uint32_t* bits) - */ -#define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) - -/** queries for the context (android.content.Context) of the plugin. If no - instance is specified the application's context is returned. If the instance - is given then the context returned is identical to the context used to - create the webview in which that instance resides. - - NOTE: Holding onto a non-application context after your instance has been - destroyed will cause a memory leak. Refer to the android documentation to - determine what context is best suited for your particular scenario. - - NPN_GetValue(inst, kJavaContext_ANPGetValue, jobject context) - */ -#define kJavaContext_ANPGetValue ((NPNVariable)2001) - -/////////////////////////////////////////////////////////////////////////////// -// NPN_SetValue - -/** Request to set the drawing model. SetValue will return false if the drawing - model is not supported or has insufficient information for configuration. - - NPN_SetValue(inst, kRequestDrawingModel_ANPSetValue, (void*)foo_ANPDrawingModel) - */ -#define kRequestDrawingModel_ANPSetValue ((NPPVariable)1000) - -/** These are used as bitfields in ANPSupportedDrawingModels_EnumValue, - and as-is in ANPRequestDrawingModel_EnumValue. The drawing model determines - how to interpret the ANPDrawingContext provided in the Draw event and how - to interpret the NPWindow->window field. - */ -enum ANPDrawingModels { - /** Draw into a bitmap from the browser thread in response to a Draw event. - NPWindow->window is reserved (ignore) - */ - kBitmap_ANPDrawingModel = 1 << 0, - /** Draw into a surface (e.g. raster, openGL, etc.) using the Java surface - interface. When this model is used the browser will invoke the Java - class specified in the plugin's apk manifest. From that class the browser - will invoke the appropriate method to return an an instance of a android - Java View. The instance is then embedded in the html. The plugin can then - manipulate the view as it would any normal Java View in android. - - Unlike the bitmap model, a surface model is opaque so no html content - behind the plugin will be visible. Unless the plugin needs to be - transparent the surface model should be chosen over the bitmap model as - it will have better performance. - - Further, a plugin can manipulate some surfaces in native code using the - ANPSurfaceInterface. This interface can be used to manipulate Java - objects that extend Surface.class by allowing them to access the - surface's underlying bitmap in native code. For instance, if a raster - surface is used the plugin can lock, draw directly into the bitmap, and - unlock the surface in native code without making JNI calls to the Java - surface object. - */ - kSurface_ANPDrawingModel = 1 << 1, - kOpenGL_ANPDrawingModel = 1 << 2, -}; -typedef int32_t ANPDrawingModel; - -/** Request to receive/disable events. If the pointer is NULL then all flags will - be disabled. Otherwise, the event type will be enabled iff its corresponding - bit in the EventFlags bit field is set. - - NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags) - */ -#define kAcceptEvents_ANPSetValue ((NPPVariable)1001) - -/** The EventFlags are a set of bits used to determine which types of events the - plugin wishes to receive. For example, if the value is 0x03 then both key - and touch events will be provided to the plugin. - */ -enum ANPEventFlag { - kKey_ANPEventFlag = 0x01, - kTouch_ANPEventFlag = 0x02, -}; -typedef uint32_t ANPEventFlags; - -/////////////////////////////////////////////////////////////////////////////// -// NPP_GetValue - -/** Requests that the plugin return a java surface to be displayed. This will - only be used if the plugin has choosen the kSurface_ANPDrawingModel. - - NPP_GetValue(inst, kJavaSurface_ANPGetValue, jobject surface) - */ -#define kJavaSurface_ANPGetValue ((NPPVariable)2000) - - -/////////////////////////////////////////////////////////////////////////////// -// ANDROID INTERFACE DEFINITIONS - -/** Interfaces provide additional functionality to the plugin via function ptrs. - Once an interface is retrieved, it is valid for the lifetime of the plugin - (just like browserfuncs). - - All ANPInterfaces begin with an inSize field, which must be set by the - caller (plugin) with the number of bytes allocated for the interface. - e.g. SomeInterface si; si.inSize = sizeof(si); browser->getvalue(..., &si); - */ -struct ANPInterface { - uint32_t inSize; // size (in bytes) of this struct -}; - -enum ANPLogTypes { - kError_ANPLogType = 0, // error - kWarning_ANPLogType = 1, // warning - kDebug_ANPLogType = 2 // debug only (informational) -}; -typedef int32_t ANPLogType; - -struct ANPLogInterfaceV0 : ANPInterface { - /** dumps printf messages to the log file - e.g. interface->log(instance, kWarning_ANPLogType, "value is %d", value); - */ - void (*log)(ANPLogType, const char format[], ...); -}; - -struct ANPBitmapInterfaceV0 : ANPInterface { - /** Returns true if the specified bitmap format is supported, and if packing - is non-null, sets it to the packing info for that format. - */ - bool (*getPixelPacking)(ANPBitmapFormat, ANPPixelPacking* packing); -}; - -struct ANPMatrixInterfaceV0 : ANPInterface { - /** Return a new identity matrix - */ - ANPMatrix* (*newMatrix)(); - /** Delete a matrix previously allocated by newMatrix() - */ - void (*deleteMatrix)(ANPMatrix*); - - ANPMatrixFlag (*getFlags)(const ANPMatrix*); - - void (*copy)(ANPMatrix* dst, const ANPMatrix* src); - - /** Return the matrix values in a float array (allcoated by the caller), - where the values are treated as follows: - w = x * [6] + y * [7] + [8]; - x' = (x * [0] + y * [1] + [2]) / w; - y' = (x * [3] + y * [4] + [5]) / w; - */ - void (*get3x3)(const ANPMatrix*, float[9]); - /** Initialize the matrix from values in a float array, - where the values are treated as follows: - w = x * [6] + y * [7] + [8]; - x' = (x * [0] + y * [1] + [2]) / w; - y' = (x * [3] + y * [4] + [5]) / w; - */ - void (*set3x3)(ANPMatrix*, const float[9]); - - void (*setIdentity)(ANPMatrix*); - void (*preTranslate)(ANPMatrix*, float tx, float ty); - void (*postTranslate)(ANPMatrix*, float tx, float ty); - void (*preScale)(ANPMatrix*, float sx, float sy); - void (*postScale)(ANPMatrix*, float sx, float sy); - void (*preSkew)(ANPMatrix*, float kx, float ky); - void (*postSkew)(ANPMatrix*, float kx, float ky); - void (*preRotate)(ANPMatrix*, float degrees); - void (*postRotate)(ANPMatrix*, float degrees); - void (*preConcat)(ANPMatrix*, const ANPMatrix*); - void (*postConcat)(ANPMatrix*, const ANPMatrix*); - - /** Return true if src is invertible, and if so, return its inverse in dst. - If src is not invertible, return false and ignore dst. - */ - bool (*invert)(ANPMatrix* dst, const ANPMatrix* src); - - /** Transform the x,y pairs in src[] by this matrix, and store the results - in dst[]. The count parameter is treated as the number of pairs in the - array. It is legal for src and dst to point to the same memory, but - illegal for the two arrays to partially overlap. - */ - void (*mapPoints)(ANPMatrix*, float dst[], const float src[], - int32_t count); -}; - -struct ANPPathInterfaceV0 : ANPInterface { - /** Return a new path */ - ANPPath* (*newPath)(); - - /** Delete a path previously allocated by ANPPath() */ - void (*deletePath)(ANPPath*); - - /** Make a deep copy of the src path, into the dst path (already allocated - by the caller). - */ - void (*copy)(ANPPath* dst, const ANPPath* src); - - /** Returns true if the two paths are the same (i.e. have the same points) - */ - bool (*equal)(const ANPPath* path0, const ANPPath* path1); - - /** Remove any previous points, initializing the path back to empty. */ - void (*reset)(ANPPath*); - - /** Return true if the path is empty (has no lines, quads or cubics). */ - bool (*isEmpty)(const ANPPath*); - - /** Return the path's bounds in bounds. */ - void (*getBounds)(const ANPPath*, ANPRectF* bounds); - - void (*moveTo)(ANPPath*, float x, float y); - void (*lineTo)(ANPPath*, float x, float y); - void (*quadTo)(ANPPath*, float x0, float y0, float x1, float y1); - void (*cubicTo)(ANPPath*, float x0, float y0, float x1, float y1, - float x2, float y2); - void (*close)(ANPPath*); - - /** Offset the src path by [dx, dy]. If dst is null, apply the - change directly to the src path. If dst is not null, write the - changed path into dst, and leave the src path unchanged. In that case - dst must have been previously allocated by the caller. - */ - void (*offset)(ANPPath* src, float dx, float dy, ANPPath* dst); - - /** Transform the path by the matrix. If dst is null, apply the - change directly to the src path. If dst is not null, write the - changed path into dst, and leave the src path unchanged. In that case - dst must have been previously allocated by the caller. - */ - void (*transform)(ANPPath* src, const ANPMatrix*, ANPPath* dst); -}; - -/** ANPColor is always defined to have the same packing on all platforms, and - it is always unpremultiplied. - - This is in contrast to 32bit format(s) in bitmaps, which are premultiplied, - and their packing may vary depending on the platform, hence the need for - ANPBitmapInterface::getPixelPacking() - */ -typedef uint32_t ANPColor; -#define ANPColor_ASHIFT 24 -#define ANPColor_RSHIFT 16 -#define ANPColor_GSHIFT 8 -#define ANPColor_BSHIFT 0 -#define ANP_MAKE_COLOR(a, r, g, b) \ - (((a) << ANPColor_ASHIFT) | \ - ((r) << ANPColor_RSHIFT) | \ - ((g) << ANPColor_GSHIFT) | \ - ((b) << ANPColor_BSHIFT)) - -enum ANPPaintFlag { - kAntiAlias_ANPPaintFlag = 1 << 0, - kFilterBitmap_ANPPaintFlag = 1 << 1, - kDither_ANPPaintFlag = 1 << 2, - kUnderlineText_ANPPaintFlag = 1 << 3, - kStrikeThruText_ANPPaintFlag = 1 << 4, - kFakeBoldText_ANPPaintFlag = 1 << 5, -}; -typedef uint32_t ANPPaintFlags; - -enum ANPPaintStyles { - kFill_ANPPaintStyle = 0, - kStroke_ANPPaintStyle = 1, - kFillAndStroke_ANPPaintStyle = 2 -}; -typedef int32_t ANPPaintStyle; - -enum ANPPaintCaps { - kButt_ANPPaintCap = 0, - kRound_ANPPaintCap = 1, - kSquare_ANPPaintCap = 2 -}; -typedef int32_t ANPPaintCap; - -enum ANPPaintJoins { - kMiter_ANPPaintJoin = 0, - kRound_ANPPaintJoin = 1, - kBevel_ANPPaintJoin = 2 -}; -typedef int32_t ANPPaintJoin; - -enum ANPPaintAligns { - kLeft_ANPPaintAlign = 0, - kCenter_ANPPaintAlign = 1, - kRight_ANPPaintAlign = 2 -}; -typedef int32_t ANPPaintAlign; - -enum ANPTextEncodings { - kUTF8_ANPTextEncoding = 0, - kUTF16_ANPTextEncoding = 1, -}; -typedef int32_t ANPTextEncoding; - -enum ANPTypefaceStyles { - kBold_ANPTypefaceStyle = 1 << 0, - kItalic_ANPTypefaceStyle = 1 << 1 -}; -typedef uint32_t ANPTypefaceStyle; - -typedef uint32_t ANPFontTableTag; - -struct ANPFontMetrics { - /** The greatest distance above the baseline for any glyph (will be <= 0) */ - float fTop; - /** The recommended distance above the baseline (will be <= 0) */ - float fAscent; - /** The recommended distance below the baseline (will be >= 0) */ - float fDescent; - /** The greatest distance below the baseline for any glyph (will be >= 0) */ - float fBottom; - /** The recommended distance to add between lines of text (will be >= 0) */ - float fLeading; -}; - -struct ANPTypefaceInterfaceV0 : ANPInterface { - /** Return a new reference to the typeface that most closely matches the - requested name and style. Pass null as the name to return - the default font for the requested style. Will never return null - - The 5 generic font names "serif", "sans-serif", "monospace", "cursive", - "fantasy" are recognized, and will be mapped to their logical font - automatically by this call. - - @param name May be NULL. The name of the font family. - @param style The style (normal, bold, italic) of the typeface. - @return reference to the closest-matching typeface. Caller must call - unref() when they are done with the typeface. - */ - ANPTypeface* (*createFromName)(const char name[], ANPTypefaceStyle); - - /** Return a new reference to the typeface that most closely matches the - requested typeface and specified Style. Use this call if you want to - pick a new style from the same family of the existing typeface. - If family is NULL, this selects from the default font's family. - - @param family May be NULL. The name of the existing type face. - @param s The style (normal, bold, italic) of the type face. - @return reference to the closest-matching typeface. Call must call - unref() when they are done. - */ - ANPTypeface* (*createFromTypeface)(const ANPTypeface* family, - ANPTypefaceStyle); - - /** Return the owner count of the typeface. A newly created typeface has an - owner count of 1. When the owner count is reaches 0, the typeface is - deleted. - */ - int32_t (*getRefCount)(const ANPTypeface*); - - /** Increment the owner count on the typeface - */ - void (*ref)(ANPTypeface*); - - /** Decrement the owner count on the typeface. When the count goes to 0, - the typeface is deleted. - */ - void (*unref)(ANPTypeface*); - - /** Return the style bits for the specified typeface - */ - ANPTypefaceStyle (*getStyle)(const ANPTypeface*); - - /** Some fonts are stored in files. If that is true for the fontID, then - this returns the byte length of the full file path. If path is not null, - then the full path is copied into path (allocated by the caller), up to - length bytes. If index is not null, then it is set to the truetype - collection index for this font, or 0 if the font is not in a collection. - - Note: getFontPath does not assume that path is a null-terminated string, - so when it succeeds, it only copies the bytes of the file name and - nothing else (i.e. it copies exactly the number of bytes returned by the - function. If the caller wants to treat path[] as a C string, it must be - sure that it is allocated at least 1 byte larger than the returned size, - and it must copy in the terminating 0. - - If the fontID does not correspond to a file, then the function returns - 0, and the path and index parameters are ignored. - - @param fontID The font whose file name is being queried - @param path Either NULL, or storage for receiving up to length bytes - of the font's file name. Allocated by the caller. - @param length The maximum space allocated in path (by the caller). - Ignored if path is NULL. - @param index Either NULL, or receives the TTC index for this font. - If the font is not a TTC, then will be set to 0. - @return The byte length of th font's file name, or 0 if the font is not - baked by a file. - */ - int32_t (*getFontPath)(const ANPTypeface*, char path[], int32_t length, - int32_t* index); - - /** Return a UTF8 encoded path name for the font directory, or NULL if not - supported. If returned, this string address will be valid for the life - of the plugin instance. It will always end with a '/' character. - */ - const char* (*getFontDirectoryPath)(); -}; - -struct ANPPaintInterfaceV0 : ANPInterface { - /** Return a new paint object, which holds all of the color and style - attributes that affect how things (geometry, text, bitmaps) are drawn - in a ANPCanvas. - - The paint that is returned is not tied to any particular plugin - instance, but it must only be accessed from one thread at a time. - */ - ANPPaint* (*newPaint)(); - void (*deletePaint)(ANPPaint*); - - ANPPaintFlags (*getFlags)(const ANPPaint*); - void (*setFlags)(ANPPaint*, ANPPaintFlags); - - ANPColor (*getColor)(const ANPPaint*); - void (*setColor)(ANPPaint*, ANPColor); - - ANPPaintStyle (*getStyle)(const ANPPaint*); - void (*setStyle)(ANPPaint*, ANPPaintStyle); - - float (*getStrokeWidth)(const ANPPaint*); - float (*getStrokeMiter)(const ANPPaint*); - ANPPaintCap (*getStrokeCap)(const ANPPaint*); - ANPPaintJoin (*getStrokeJoin)(const ANPPaint*); - void (*setStrokeWidth)(ANPPaint*, float); - void (*setStrokeMiter)(ANPPaint*, float); - void (*setStrokeCap)(ANPPaint*, ANPPaintCap); - void (*setStrokeJoin)(ANPPaint*, ANPPaintJoin); - - ANPTextEncoding (*getTextEncoding)(const ANPPaint*); - ANPPaintAlign (*getTextAlign)(const ANPPaint*); - float (*getTextSize)(const ANPPaint*); - float (*getTextScaleX)(const ANPPaint*); - float (*getTextSkewX)(const ANPPaint*); - void (*setTextEncoding)(ANPPaint*, ANPTextEncoding); - void (*setTextAlign)(ANPPaint*, ANPPaintAlign); - void (*setTextSize)(ANPPaint*, float); - void (*setTextScaleX)(ANPPaint*, float); - void (*setTextSkewX)(ANPPaint*, float); - - /** Return the typeface ine paint, or null if there is none. This does not - modify the owner count of the returned typeface. - */ - ANPTypeface* (*getTypeface)(const ANPPaint*); - - /** Set the paint's typeface. If the paint already had a non-null typeface, - its owner count is decremented. If the new typeface is non-null, its - owner count is incremented. - */ - void (*setTypeface)(ANPPaint*, ANPTypeface*); - - /** Return the width of the text. If bounds is not null, return the bounds - of the text in that rectangle. - */ - float (*measureText)(ANPPaint*, const void* text, uint32_t byteLength, - ANPRectF* bounds); - - /** Return the number of unichars specifed by the text. - If widths is not null, returns the array of advance widths for each - unichar. - If bounds is not null, returns the array of bounds for each unichar. - */ - int (*getTextWidths)(ANPPaint*, const void* text, uint32_t byteLength, - float widths[], ANPRectF bounds[]); - - /** Return in metrics the spacing values for text, respecting the paint's - typeface and pointsize, and return the spacing between lines - (descent - ascent + leading). If metrics is NULL, it will be ignored. - */ - float (*getFontMetrics)(ANPPaint*, ANPFontMetrics* metrics); -}; - -struct ANPCanvasInterfaceV0 : ANPInterface { - /** Return a canvas that will draw into the specified bitmap. Note: the - canvas copies the fields of the bitmap, so it need not persist after - this call, but the canvas DOES point to the same pixel memory that the - bitmap did, so the canvas should not be used after that pixel memory - goes out of scope. In the case of creating a canvas to draw into the - pixels provided by kDraw_ANPEventType, those pixels are only while - handling that event. - - The canvas that is returned is not tied to any particular plugin - instance, but it must only be accessed from one thread at a time. - */ - ANPCanvas* (*newCanvas)(const ANPBitmap*); - void (*deleteCanvas)(ANPCanvas*); - - void (*save)(ANPCanvas*); - void (*restore)(ANPCanvas*); - void (*translate)(ANPCanvas*, float tx, float ty); - void (*scale)(ANPCanvas*, float sx, float sy); - void (*rotate)(ANPCanvas*, float degrees); - void (*skew)(ANPCanvas*, float kx, float ky); - void (*concat)(ANPCanvas*, const ANPMatrix*); - void (*clipRect)(ANPCanvas*, const ANPRectF*); - void (*clipPath)(ANPCanvas*, const ANPPath*); - - /** Return the current matrix on the canvas - */ - void (*getTotalMatrix)(ANPCanvas*, ANPMatrix*); - /** Return the current clip bounds in local coordinates, expanding it to - account for antialiasing edge effects if aa is true. If the - current clip is empty, return false and ignore the bounds argument. - */ - bool (*getLocalClipBounds)(ANPCanvas*, ANPRectF* bounds, bool aa); - /** Return the current clip bounds in device coordinates in bounds. If the - current clip is empty, return false and ignore the bounds argument. - */ - bool (*getDeviceClipBounds)(ANPCanvas*, ANPRectI* bounds); - - void (*drawColor)(ANPCanvas*, ANPColor); - void (*drawPaint)(ANPCanvas*, const ANPPaint*); - void (*drawLine)(ANPCanvas*, float x0, float y0, float x1, float y1, - const ANPPaint*); - void (*drawRect)(ANPCanvas*, const ANPRectF*, const ANPPaint*); - void (*drawOval)(ANPCanvas*, const ANPRectF*, const ANPPaint*); - void (*drawPath)(ANPCanvas*, const ANPPath*, const ANPPaint*); - void (*drawText)(ANPCanvas*, const void* text, uint32_t byteLength, - float x, float y, const ANPPaint*); - void (*drawPosText)(ANPCanvas*, const void* text, uint32_t byteLength, - const float xy[], const ANPPaint*); - void (*drawBitmap)(ANPCanvas*, const ANPBitmap*, float x, float y, - const ANPPaint*); - void (*drawBitmapRect)(ANPCanvas*, const ANPBitmap*, - const ANPRectI* src, const ANPRectF* dst, - const ANPPaint*); -}; - -struct ANPWindowInterfaceV0 : ANPInterface { - /** Registers a set of rectangles that the plugin would like to keep on - screen. The rectangles are listed in order of priority with the highest - priority rectangle in location rects[0]. The browser will attempt to keep - as many of the rectangles on screen as possible and will scroll them into - view in response to the invocation of this method and other various events. - The count specifies how many rectangles are in the array. If the count is - zero it signals the browser that any existing rectangles should be cleared - and no rectangles will be tracked. - */ - void (*setVisibleRects)(NPP instance, const ANPRectI rects[], int32_t count); - /** Clears any rectangles that are being tracked as a result of a call to - setVisibleRects. This call is equivalent to setVisibleRect(inst, NULL, 0). - */ - void (*clearVisibleRects)(NPP instance); - /** Given a boolean value of true the device will be requested to provide - a keyboard. A value of false will result in a request to hide the - keyboard. Further, the on-screen keyboard will not be displayed if a - physical keyboard is active. - */ - void (*showKeyboard)(NPP instance, bool value); - /** Called when a plugin wishes to enter into full screen mode. The plugin's - Java class (defined in the plugin's apk manifest) will be called - asynchronously to provide a View object to be displayed full screen. - */ - void (*requestFullScreen)(NPP instance); - /** Called when a plugin wishes to exit from full screen mode. As a result, - the plugin's full screen view will be discarded by the view system. - */ - void (*exitFullScreen)(NPP instance); - /** Called when a plugin wishes to be zoomed and centered in the current view. - */ - void (*requestCenterFitZoom)(NPP instance); -}; - -struct ANPWindowInterfaceV1 : ANPWindowInterfaceV0 { - /** Returns a rectangle representing the visible area of the plugin on - screen. The coordinates are relative to the size of the plugin in the - document and therefore will never be negative or exceed the plugin's size. - */ - ANPRectI (*visibleRect)(NPP instance); -}; - -/////////////////////////////////////////////////////////////////////////////// - -enum ANPSampleFormats { - kUnknown_ANPSamleFormat = 0, - kPCM16Bit_ANPSampleFormat = 1, - kPCM8Bit_ANPSampleFormat = 2 -}; -typedef int32_t ANPSampleFormat; - -/** The audio buffer is passed to the callback proc to request more samples. - It is owned by the system, and the callback may read it, but should not - maintain a pointer to it outside of the scope of the callback proc. - */ -struct ANPAudioBuffer { - // RO - repeat what was specified in newTrack() - int32_t channelCount; - // RO - repeat what was specified in newTrack() - ANPSampleFormat format; - /** This buffer is owned by the caller. Inside the callback proc, up to - "size" bytes of sample data should be written into this buffer. The - address is only valid for the scope of a single invocation of the - callback proc. - */ - void* bufferData; - /** On input, specifies the maximum number of bytes that can be written - to "bufferData". On output, specifies the actual number of bytes that - the callback proc wrote into "bufferData". - */ - uint32_t size; -}; - -enum ANPAudioEvents { - /** This event is passed to the callback proc when the audio-track needs - more sample data written to the provided buffer parameter. - */ - kMoreData_ANPAudioEvent = 0, - /** This event is passed to the callback proc if the audio system runs out - of sample data. In this event, no buffer parameter will be specified - (i.e. NULL will be passed to the 3rd parameter). - */ - kUnderRun_ANPAudioEvent = 1 -}; -typedef int32_t ANPAudioEvent; - -/** Called to feed sample data to the track. This will be called in a separate - thread. However, you may call trackStop() from the callback (but you - cannot delete the track). - - For example, when you have written the last chunk of sample data, you can - immediately call trackStop(). This will take effect after the current - buffer has been played. - - The "user" parameter is the same value that was passed to newTrack() - */ -typedef void (*ANPAudioCallbackProc)(ANPAudioEvent event, void* user, - ANPAudioBuffer* buffer); - -struct ANPAudioTrack; // abstract type for audio tracks - -struct ANPAudioTrackInterfaceV0 : ANPInterface { - /** Create a new audio track, or NULL on failure. The track is initially in - the stopped state and therefore ANPAudioCallbackProc will not be called - until the track is started. - */ - ANPAudioTrack* (*newTrack)(uint32_t sampleRate, // sampling rate in Hz - ANPSampleFormat, - int channelCount, // MONO=1, STEREO=2 - ANPAudioCallbackProc, - void* user); - /** Deletes a track that was created using newTrack. The track can be - deleted in any state and it waits for the ANPAudioCallbackProc thread - to exit before returning. - */ - void (*deleteTrack)(ANPAudioTrack*); - - void (*start)(ANPAudioTrack*); - void (*pause)(ANPAudioTrack*); - void (*stop)(ANPAudioTrack*); - /** Returns true if the track is not playing (e.g. pause or stop was called, - or start was never called. - */ - bool (*isStopped)(ANPAudioTrack*); -}; - -struct ANPAudioTrackInterfaceV1 : ANPAudioTrackInterfaceV0 { - /** Returns the track's latency in milliseconds. */ - uint32_t (*trackLatency)(ANPAudioTrack*); -}; - -/////////////////////////////////////////////////////////////////////////////// -// DEFINITION OF VALUES PASSED THROUGH NPP_HandleEvent - -enum ANPEventTypes { - kNull_ANPEventType = 0, - kKey_ANPEventType = 1, - /** Mouse events are triggered by either clicking with the navigational pad - or by tapping the touchscreen (if the kDown_ANPTouchAction is handled by - the plugin then no mouse event is generated). The kKey_ANPEventFlag has - to be set to true in order to receive these events. - */ - kMouse_ANPEventType = 2, - /** Touch events are generated when the user touches on the screen. The - kTouch_ANPEventFlag has to be set to true in order to receive these - events. - */ - kTouch_ANPEventType = 3, - /** Only triggered by a plugin using the kBitmap_ANPDrawingModel. This event - signals that the plugin needs to redraw itself into the provided bitmap. - */ - kDraw_ANPEventType = 4, - kLifecycle_ANPEventType = 5, - - /** This event type is completely defined by the plugin. - When creating an event, the caller must always set the first - two fields, the remaining data is optional. - ANPEvent evt; - evt.inSize = sizeof(ANPEvent); - evt.eventType = kCustom_ANPEventType - // other data slots are optional - evt.other[] = ...; - To post a copy of the event, call - eventInterface->postEvent(myNPPInstance, &evt); - That call makes a copy of the event struct, and post that on the event - queue for the plugin. - */ - kCustom_ANPEventType = 6, - /** MultiTouch events are generated when the user touches on the screen. The - kTouch_ANPEventFlag has to be set to true in order to receive these - events. This type is a replacement for the older kTouch_ANPEventType. - */ - kMultiTouch_ANPEventType = 7, -}; -typedef int32_t ANPEventType; - -enum ANPKeyActions { - kDown_ANPKeyAction = 0, - kUp_ANPKeyAction = 1, -}; -typedef int32_t ANPKeyAction; - -#include "ANPKeyCodes.h" -typedef int32_t ANPKeyCode; - -enum ANPKeyModifiers { - kAlt_ANPKeyModifier = 1 << 0, - kShift_ANPKeyModifier = 1 << 1, -}; -// bit-field containing some number of ANPKeyModifier bits -typedef uint32_t ANPKeyModifier; - -enum ANPMouseActions { - kDown_ANPMouseAction = 0, - kUp_ANPMouseAction = 1, -}; -typedef int32_t ANPMouseAction; - -enum ANPTouchActions { - /** This occurs when the user first touches on the screen. As such, this - action will always occur prior to any of the other touch actions. If - the plugin chooses to not handle this action then no other events - related to that particular touch gesture will be generated. - */ - kDown_ANPTouchAction = 0, - kUp_ANPTouchAction = 1, - kMove_ANPTouchAction = 2, - kCancel_ANPTouchAction = 3, - // The web view will ignore the return value from the following actions - kLongPress_ANPTouchAction = 4, - kDoubleTap_ANPTouchAction = 5, -}; -typedef int32_t ANPTouchAction; - -enum ANPLifecycleActions { - /** The web view containing this plugin has been paused. See documentation - on the android activity lifecycle for more information. - */ - kPause_ANPLifecycleAction = 0, - /** The web view containing this plugin has been resumed. See documentation - on the android activity lifecycle for more information. - */ - kResume_ANPLifecycleAction = 1, - /** The plugin has focus and is now the recipient of input events (e.g. key, - touch, etc.) - */ - kGainFocus_ANPLifecycleAction = 2, - /** The plugin has lost focus and will not receive any input events until it - regains focus. This event is always preceded by a GainFocus action. - */ - kLoseFocus_ANPLifecycleAction = 3, - /** The browser is running low on available memory and is requesting that - the plugin free any unused/inactive resources to prevent a performance - degradation. - */ - kFreeMemory_ANPLifecycleAction = 4, - /** The page has finished loading. This happens when the page's top level - frame reports that it has completed loading. - */ - kOnLoad_ANPLifecycleAction = 5, - /** The browser is honoring the plugin's request to go full screen. Upon - returning from this event the browser will resize the plugin's java - surface to full-screen coordinates. - */ - kEnterFullScreen_ANPLifecycleAction = 6, - /** The browser has exited from full screen mode. Immediately prior to - sending this event the browser has resized the plugin's java surface to - its original coordinates. - */ - kExitFullScreen_ANPLifecycleAction = 7, - /** The plugin is visible to the user on the screen. This event will always - occur after a kOffScreen_ANPLifecycleAction event. - */ - kOnScreen_ANPLifecycleAction = 8, - /** The plugin is no longer visible to the user on the screen. This event - will always occur prior to an kOnScreen_ANPLifecycleAction event. - */ - kOffScreen_ANPLifecycleAction = 9, -}; -typedef uint32_t ANPLifecycleAction; - -struct TouchPoint { - int32_t id; - float x; // relative to your "window" (0...width) - float y; // relative to your "window" (0...height) - float pressure; - float size; // normalized to a value between 0...1 -}; - -/* This is what is passed to NPP_HandleEvent() */ -struct ANPEvent { - uint32_t inSize; // size of this struct in bytes - ANPEventType eventType; - // use based on the value in eventType - union { - struct { - ANPKeyAction action; - ANPKeyCode nativeCode; - int32_t virtualCode; // windows virtual key code - ANPKeyModifier modifiers; - int32_t repeatCount; // 0 for initial down (or up) - int32_t unichar; // 0 if there is no value - } key; - struct { - ANPMouseAction action; - int32_t x; // relative to your "window" (0...width) - int32_t y; // relative to your "window" (0...height) - } mouse; - struct { - ANPTouchAction action; - ANPKeyModifier modifiers; - int32_t x; // relative to your "window" (0...width) - int32_t y; // relative to your "window" (0...height) - } touch; - struct { - ANPLifecycleAction action; - } lifecycle; - struct { - ANPDrawingModel model; - // relative to (0,0) in top-left of your plugin - ANPRectI clip; - // use based on the value in model - union { - ANPBitmap bitmap; - struct { - int32_t width; - int32_t height; - } surface; - } data; - } draw; - struct { - int64_t timestamp; - int32_t id; - ANPTouchAction action; - int32_t pointerCount; - TouchPoint* touchPoint; - } multiTouch; - int32_t other[8]; - } data; -}; - -struct ANPEventInterfaceV0 : ANPInterface { - /** Post a copy of the specified event to the plugin. The event will be - delivered to the plugin in its main thread (the thread that receives - other ANPEvents). If, after posting before delivery, the NPP instance - is torn down, the event will be discarded. - */ - void (*postEvent)(NPP inst, const ANPEvent* event); -}; - - -#endif |
