Merge mozilla-central with the asynchronous plugins painting branch.

This commit is contained in:
Benjamin Smedberg 2010-10-13 10:45:01 -04:00
Родитель 4f877054c9 36ae808503
Коммит a37161d8e3
10 изменённых файлов: 292 добавлений и 313 удалений

Просмотреть файл

@ -130,17 +130,17 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
, mDrawingModel(NPDrawingModelCoreGraphics)
, mCurrentEvent(nsnull)
#endif
, mLayersRendering(PR_FALSE)
, mLayersRendering(false)
, mAccumulatedInvalidRect(0,0,0,0)
, mIsTransparent(PR_FALSE)
, mIsTransparent(false)
, mSurfaceType(gfxASurface::SurfaceTypeMax)
, mPendingForcePaint(PR_FALSE)
, mPendingForcePaint(false)
, mCurrentInvalidateTask(nsnull)
, mPendingPluginCall(PR_FALSE)
, mDoAlphaExtraction(PR_FALSE)
, mPendingPluginCall(false)
, mDoAlphaExtraction(false)
, mSurfaceDifferenceRect(0,0,0,0)
#ifdef MOZ_X11
, mFlash10Quirks(PR_FALSE)
, mFlash10Quirks(false)
#endif
#if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
, mMaemoImageRendering(PR_FALSE)
@ -871,7 +871,7 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
&mWsInfo.visual, &mWsInfo.depth))
return false;
mLayersRendering = PR_FALSE;
mLayersRendering = false;
#ifdef MOZ_WIDGET_GTK2
if (gtk_check_version(2,18,7) != NULL) { // older
@ -1155,7 +1155,7 @@ PluginInstanceChild::PluginWindowProc(HWND hWnd,
// The plugin received keyboard focus, let the parent know so the dom is up to date.
if (message == WM_MOUSEACTIVATE)
self->CallPluginFocusChange(PR_TRUE);
self->CallPluginFocusChange(true);
// Prevent lockups due to plugins making rpc calls when the parent
// is making a synchronous SendMessage call to the child window. Add
@ -1173,7 +1173,7 @@ PluginInstanceChild::PluginWindowProc(HWND hWnd,
}
if (message == WM_KILLFOCUS)
self->CallPluginFocusChange(PR_FALSE);
self->CallPluginFocusChange(false);
if (message == WM_USER+1 &&
(self->mQuirks & PluginInstanceChild::QUIRK_FLASH_THROTTLE_WMUSER_EVENTS)) {
@ -2016,7 +2016,7 @@ PluginInstanceChild::RecvPaintFinished(void)
if (mPendingForcePaint) {
nsIntRect r(0, 0, mWindow.width, mWindow.height);
mAccumulatedInvalidRect.UnionRect(r, mAccumulatedInvalidRect);
mPendingForcePaint = PR_FALSE;
mPendingForcePaint = false;
}
if (!mAccumulatedInvalidRect.IsEmpty()) {
AsyncShowPluginFrame();
@ -2035,7 +2035,7 @@ PluginInstanceChild::RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
if (mWindow.width != aWindow.width || mWindow.height != aWindow.height) {
mCurrentSurface = nsnull;
mHelperSurface = nsnull;
mPendingForcePaint = PR_TRUE;
mPendingForcePaint = true;
}
mWindow.x = aWindow.x;
mWindow.y = aWindow.y;
@ -2044,9 +2044,9 @@ PluginInstanceChild::RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
mWindow.clipRect = aWindow.clipRect;
mWindow.type = aWindow.type;
mLayersRendering = PR_TRUE;
mLayersRendering = true;
mSurfaceType = aSurfaceType;
UpdateWindowAttributes(PR_TRUE);
UpdateWindowAttributes(true);
return true;
}
@ -2057,7 +2057,7 @@ GfxFromNsRect(const nsIntRect& aRect)
return gfxRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
PRBool
bool
PluginInstanceChild::CreateOptSurface(void)
{
nsRefPtr<gfxASurface> retsurf;
@ -2088,7 +2088,7 @@ PluginInstanceChild::CreateOptSurface(void)
XRenderPictFormat* xfmt = gfxXlibSurface::FindRenderFormat(dpy, format);
if (!xfmt) {
NS_ERROR("Need X falback surface, but FindRenderFormat failed");
return PR_FALSE;
return false;
}
mCurrentSurface =
gfxXlibSurface::Create(screen, xfmt,
@ -2102,33 +2102,33 @@ PluginInstanceChild::CreateOptSurface(void)
mCurrentSurface = new gfxSharedImageSurface();
if (NS_FAILED(static_cast<gfxSharedImageSurface*>(mCurrentSurface.get())->
Init(this, gfxIntSize(mWindow.width, mWindow.height), format))) {
return PR_FALSE;
return false;
}
return PR_TRUE;
return true;
}
PRBool
bool
PluginInstanceChild::MaybeCreatePlatformHelperSurface(void)
{
if (!mCurrentSurface) {
NS_ERROR("Cannot create helper surface without mCurrentSurface");
return PR_FALSE;
return false;
}
#ifdef MOZ_PLATFORM_MAEMO
// On maemo plugins support non-default visual rendering
PRBool supportNonDefaultVisual = PR_TRUE;
bool supportNonDefaultVisual = true;
#else
PRBool supportNonDefaultVisual = PR_FALSE;
bool supportNonDefaultVisual = false;
#endif
#ifdef MOZ_X11
Screen* screen = DefaultScreenOfDisplay(mWsInfo.display);
Visual* defaultVisual = DefaultVisualOfScreen(screen);
Visual* visual = nsnull;
Colormap colormap = 0;
mDoAlphaExtraction = PR_FALSE;
PRBool createHelperSurface = PR_FALSE;
mDoAlphaExtraction = false;
bool createHelperSurface = false;
if (mCurrentSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
static_cast<gfxXlibSurface*>(mCurrentSurface.get())->
@ -2136,7 +2136,7 @@ PluginInstanceChild::MaybeCreatePlatformHelperSurface(void)
// Create helper surface if layer surface visual not same as default
// and we don't support non-default visual rendering
if (!visual || (defaultVisual != visual && !supportNonDefaultVisual)) {
createHelperSurface = PR_TRUE;
createHelperSurface = true;
visual = defaultVisual;
mDoAlphaExtraction = mIsTransparent;
}
@ -2150,7 +2150,7 @@ PluginInstanceChild::MaybeCreatePlatformHelperSurface(void)
}
#endif
// For image layer surface we should always create helper surface
createHelperSurface = PR_TRUE;
createHelperSurface = true;
// Check if we can create helper surface with non-default visual
visual = gfxXlibSurface::FindVisual(screen,
static_cast<gfxImageSurface*>(mCurrentSurface.get())->Format());
@ -2163,50 +2163,50 @@ PluginInstanceChild::MaybeCreatePlatformHelperSurface(void)
if (createHelperSurface) {
if (!visual) {
NS_ERROR("Need X falback surface, but visual failed");
return PR_FALSE;
return false;
}
mHelperSurface =
gfxXlibSurface::Create(screen, visual,
mCurrentSurface->GetSize());
if (!mHelperSurface) {
NS_WARNING("Fail to create create helper surface");
return PR_FALSE;
return false;
}
}
#endif
return PR_TRUE;
return true;
}
PRBool
bool
PluginInstanceChild::EnsureCurrentBuffer(void)
{
if (mCurrentSurface) {
return PR_TRUE;
return true;
}
if (!mWindow.width || !mWindow.height) {
return PR_FALSE;
return false;
}
if (!CreateOptSurface()) {
NS_ERROR("Cannot create optimized surface");
return PR_FALSE;
return false;
}
if (!MaybeCreatePlatformHelperSurface()) {
NS_ERROR("Cannot create helper surface");
return PR_FALSE;
return false;
}
return PR_TRUE;
return true;
}
void
PluginInstanceChild::UpdateWindowAttributes(PRBool aForceSetWindow)
PluginInstanceChild::UpdateWindowAttributes(bool aForceSetWindow)
{
nsRefPtr<gfxASurface> curSurface = mHelperSurface ? mHelperSurface : mCurrentSurface;
PRBool needWindowUpdate = aForceSetWindow;
bool needWindowUpdate = aForceSetWindow;
#ifdef MOZ_X11
Visual* visual = nsnull;
Colormap colormap = 0;
@ -2216,7 +2216,7 @@ PluginInstanceChild::UpdateWindowAttributes(PRBool aForceSetWindow)
if (visual != mWsInfo.visual || colormap != mWsInfo.colormap) {
mWsInfo.visual = visual;
mWsInfo.colormap = colormap;
needWindowUpdate = PR_TRUE;
needWindowUpdate = true;
}
}
#if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
@ -2311,7 +2311,7 @@ PluginInstanceChild::PaintRectToPlatformSurface(const nsIntRect& aRect,
NS_ASSERTION(aSurface->GetType() == gfxASurface::SurfaceTypeXlib,
"Non supported platform surface type");
mPendingPluginCall = PR_TRUE;
mPendingPluginCall = true;
NPEvent pluginEvent;
XGraphicsExposeEvent& exposeEvent = pluginEvent.xgraphicsexpose;
exposeEvent.type = GraphicsExpose;
@ -2328,7 +2328,7 @@ PluginInstanceChild::PaintRectToPlatformSurface(const nsIntRect& aRect,
exposeEvent.major_code = 0;
exposeEvent.minor_code = 0;
mPluginIface->event(&mData, reinterpret_cast<void*>(&exposeEvent));
mPendingPluginCall = PR_FALSE;
mPendingPluginCall = false;
#endif
}
@ -2385,7 +2385,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
gfxASurface* aSurface)
{
// Paint onto black image
PRBool needImageSurface = PR_TRUE;
bool needImageSurface = true;
nsRefPtr<gfxImageSurface> blackImage;
gfxIntSize clipSize(aRect.width, aRect.height);
gfxPoint deviceOffset(-aRect.x, -aRect.y);
@ -2393,7 +2393,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
if (aSurface->GetType() == gfxASurface::SurfaceTypeImage) {
gfxImageSurface *surface = static_cast<gfxImageSurface*>(aSurface);
if (surface->Format() == gfxASurface::ImageFormatARGB32) {
needImageSurface = PR_FALSE;
needImageSurface = false;
blackImage = surface->GetSubimage(GfxFromNsRect(aRect));
}
}
@ -2428,15 +2428,15 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
}
}
PRBool
bool
PluginInstanceChild::ShowPluginFrame()
{
if (mPendingPluginCall) {
return PR_FALSE;
return false;
}
if (!EnsureCurrentBuffer()) {
return PR_FALSE;
return false;
}
// Make expose rect not bigger than clip rect
@ -2445,12 +2445,13 @@ PluginInstanceChild::ShowPluginFrame()
mWindow.clipRect.right - mWindow.clipRect.left,
mWindow.clipRect.bottom - mWindow.clipRect.top));
// Cleare accRect here to be able to pass test_invalidate_during_plugin_paint test
// Clear accRect here to be able to pass
// test_invalidate_during_plugin_paint test
nsIntRect rect = mAccumulatedInvalidRect;
mAccumulatedInvalidRect.Empty();
#ifdef MOZ_X11
// We can read safetly from XSurface, because PluginHost is not able to modify that surface
// We can read safely from XSurface, because PluginHost is not able to modify that surface
if (mBackSurface && mBackSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
if (!mSurfaceDifferenceRect.IsEmpty()) {
// Read back previous content
@ -2497,10 +2498,10 @@ PluginInstanceChild::ShowPluginFrame()
currSurf = static_cast<gfxSharedImageSurface*>(mCurrentSurface.get())->GetShmem();
} else {
NS_RUNTIMEABORT("Surface type is not remotable");
return PR_FALSE;
return false;
}
if (!SendShow(r, currSurf, &outSurf)) {
return PR_FALSE;
return false;
}
nsRefPtr<gfxASurface> tmp = mCurrentSurface;
@ -2513,7 +2514,7 @@ PluginInstanceChild::ShowPluginFrame()
mCurrentSurface = nsnull;
}
mSurfaceDifferenceRect = rect;
return PR_TRUE;
return true;
}
void

Просмотреть файл

@ -392,13 +392,14 @@ private:
// 2) Updated mCurrentSurface to be a complete copy of mBackSurface
// 3) Draw the invalidated plugin area into mCurrentSurface
// 4) Send it to parent process.
PRBool ShowPluginFrame(void);
bool ShowPluginFrame(void);
// Post ShowPluginFrame task
void AsyncShowPluginFrame(void);
// In the PaintRect functions, aSurface is the size of the full plugin window. Each PaintRect function
// renders into the subrectangle aRect of aSurface (possibly more if we're working around a Flash bug).
// In the PaintRect functions, aSurface is the size of the full plugin
// window. Each PaintRect function renders into the subrectangle aRect of
// aSurface (possibly more if we're working around a Flash bug).
// Paint plugin content rectangle to surface with bg color filling
void PaintRectToSurface(const nsIntRect& aRect,
@ -418,18 +419,18 @@ private:
// Update NPWindow platform attributes and call plugin "setwindow"
// @param - aForceSetWindow - call setwindow even if platform attributes are the same
void UpdateWindowAttributes(PRBool aForceSetWindow = PR_FALSE);
void UpdateWindowAttributes(bool aForceSetWindow = false);
// Create optimized mCurrentSurface for parent process rendering
// @return FALSE if optimized surface not created
PRBool CreateOptSurface(void);
bool CreateOptSurface(void);
// Create mHelperSurface if mCurrentSurface non compatible with plugins
// @return TRUE if helper surface created successfully, or not needed
PRBool MaybeCreatePlatformHelperSurface(void);
bool MaybeCreatePlatformHelperSurface(void);
// Make sure that we have surface for rendering
PRBool EnsureCurrentBuffer(void);
bool EnsureCurrentBuffer(void);
// Helper function for delayed InvalidateRect call
// non null mCurrentInvalidateTask will call this function
@ -437,31 +438,36 @@ private:
// Set as true when SetupLayer called
// and go with different path in InvalidateRect function
PRPackedBool mLayersRendering;
bool mLayersRendering;
// Current surface available for rendering
nsRefPtr<gfxASurface> mCurrentSurface;
// Back surface, just keeping reference to
// surface which is on ParentProcess side
nsRefPtr<gfxASurface> mBackSurface;
// Accumulated invalidate rect, while back buffer is not accessible
nsIntRect mAccumulatedInvalidRect;
nsIntRect mAccumulatedInvalidRect;
// Plugin only call SetTransparent
// and does not remember their transparent state
// and p->getvalue return always false
PRPackedBool mIsTransparent;
bool mIsTransparent;
// Surface type optimized of parent process
gfxSurfaceType mSurfaceType;
gfxSurfaceType mSurfaceType;
// set TRUE if plugin surface dropped in asyncSetWindow
// if TRUE then initiate full repaint in RecvPaintFinished
PRPackedBool mPendingForcePaint;
bool mPendingForcePaint;
// Keep InvalidateRect task pointer to be able Cancel it on Destroy
CancelableTask *mCurrentInvalidateTask;
CancelableTask *mCurrentInvalidateTask;
// True while plugin-child in plugin call
// Use to prevent plugin paint re-enter
PRPackedBool mPendingPluginCall;
bool mPendingPluginCall;
// On some platforms, plugins may not support rendering to a surface with
// alpha, or not support rendering to an image surface.
@ -472,15 +478,15 @@ private:
// true when plugin does not support painting to ARGB32 surface
// this is false for maemo platform, and false if plugin
// supports NPPVpluginTransparentAlphaBool (which is not part of NPAPI yet)
PRPackedBool mDoAlphaExtraction;
bool mDoAlphaExtraction;
// Cached rectangle rendered to previous surface(mBackSurface)
// Used for reading back to current surface and syncing data
nsIntRect mSurfaceDifferenceRect;
nsIntRect mSurfaceDifferenceRect;
#ifdef MOZ_X11
// Used with windowless flash plugin only, see bug 574583
PRPackedBool mFlash10Quirks;
bool mFlash10Quirks;
#endif
#if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
// Maemo5 Flash does not remember WindowlessLocal state

Просмотреть файл

@ -568,14 +568,6 @@ PluginInstanceParent::GetSurface(gfxASurface** aSurface)
return NS_ERROR_NOT_AVAILABLE;
}
nsresult
PluginInstanceParent::UseAsyncPainting(PRBool* aIsAsync)
{
NS_ENSURE_ARG_POINTER(aIsAsync);
*aIsAsync = PR_TRUE;
return NS_OK;
}
NPError
PluginInstanceParent::NPP_SetWindow(const NPWindow* aWindow)
{

Просмотреть файл

@ -263,7 +263,6 @@ public:
nsresult AsyncSetWindow(NPWindow* window);
nsresult NotifyPainted(void);
nsresult GetSurface(gfxASurface** aSurface);
nsresult UseAsyncPainting(PRBool* aIsAsync);
private:
// Quirks mode support for various plugin mime types

Просмотреть файл

@ -82,7 +82,7 @@ public:
virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window) = 0;
virtual nsresult NotifyPainted(NPP instance) = 0;
virtual nsresult GetSurface(NPP instance, gfxASurface** aSurface) = 0;
virtual nsresult UseAsyncPainting(NPP instance, PRBool* aIsAsync) = 0;
virtual bool UseAsyncPainting() = 0;
};

Просмотреть файл

@ -643,17 +643,6 @@ PluginModuleParent::GetSurface(NPP instance, gfxASurface** aSurface)
return i->GetSurface(aSurface);
}
nsresult
PluginModuleParent::UseAsyncPainting(NPP instance, PRBool* aIsAsync)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return NS_ERROR_FAILURE;
return i->UseAsyncPainting(aIsAsync);
}
#if defined(XP_UNIX) && !defined(XP_MACOSX)
nsresult
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)

Просмотреть файл

@ -224,7 +224,7 @@ private:
virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window);
virtual nsresult NotifyPainted(NPP instance);
virtual nsresult GetSurface(NPP instance, gfxASurface** aSurface);
virtual nsresult UseAsyncPainting(NPP instance, PRBool* aIsAsync);
NS_OVERRIDE virtual bool UseAsyncPainting() { return true; }
#if defined(XP_UNIX) && !defined(XP_MACOSX)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error);

Просмотреть файл

@ -1,223 +1,214 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Josh Aas <josh@mozilla.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/PluginPRLibrary.h"
// Some plugins on Windows, notably Quake Live, implement NP_Initialize using
// cdecl instead of the documented stdcall. In order to work around this,
// we force the caller to use a frame pointer.
#if defined(XP_WIN) && defined(_M_IX86)
#include <malloc.h>
// gNotOptimized exists so that the compiler will not optimize the alloca
// below.
static int gNotOptimized;
#define CALLING_CONVENTION_HACK void* foo = _alloca(gNotOptimized);
#else
#define CALLING_CONVENTION_HACK
#endif
namespace mozilla {
#if defined(XP_UNIX) && !defined(XP_MACOSX)
nsresult
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
NPPluginFuncs* pFuncs, NPError* error)
{
if (mNP_Initialize) {
*error = mNP_Initialize(bFuncs, pFuncs);
} else {
NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
if (!pfNP_Initialize)
return NS_ERROR_FAILURE;
*error = pfNP_Initialize(bFuncs, pFuncs);
}
// save NPP_New
mNPP_New = pFuncs->newp;
return NS_OK;
}
#else
nsresult
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
{
CALLING_CONVENTION_HACK
if (mNP_Initialize) {
*error = mNP_Initialize(bFuncs);
} else {
NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
if (!pfNP_Initialize)
return NS_ERROR_FAILURE;
*error = pfNP_Initialize(bFuncs);
}
return NS_OK;
}
#endif
nsresult
PluginPRLibrary::NP_Shutdown(NPError* error)
{
CALLING_CONVENTION_HACK
if (mNP_Shutdown) {
*error = mNP_Shutdown();
} else {
NP_ShutdownFunc pfNP_Shutdown = (NP_ShutdownFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
if (!pfNP_Shutdown)
return NS_ERROR_FAILURE;
*error = pfNP_Shutdown();
}
return NS_OK;
}
nsresult
PluginPRLibrary::NP_GetMIMEDescription(const char** mimeDesc)
{
CALLING_CONVENTION_HACK
if (mNP_GetMIMEDescription) {
*mimeDesc = mNP_GetMIMEDescription();
}
else {
NP_GetMIMEDescriptionFunc pfNP_GetMIMEDescription =
(NP_GetMIMEDescriptionFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription");
if (!pfNP_GetMIMEDescription) {
*mimeDesc = "";
return NS_ERROR_FAILURE;
}
*mimeDesc = pfNP_GetMIMEDescription();
}
return NS_OK;
}
nsresult
PluginPRLibrary::NP_GetValue(void *future, NPPVariable aVariable,
void *aValue, NPError* error)
{
#if defined(XP_UNIX) && !defined(XP_MACOSX)
if (mNP_GetValue) {
*error = mNP_GetValue(future, aVariable, aValue);
} else {
NP_GetValueFunc pfNP_GetValue = (NP_GetValueFunc)PR_FindFunctionSymbol(mLibrary, "NP_GetValue");
if (!pfNP_GetValue)
return NS_ERROR_FAILURE;
*error = pfNP_GetValue(future, aVariable, aValue);
}
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_OS2)
nsresult
PluginPRLibrary::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
{
CALLING_CONVENTION_HACK
if (mNP_GetEntryPoints) {
*error = mNP_GetEntryPoints(pFuncs);
} else {
NP_GetEntryPointsFunc pfNP_GetEntryPoints = (NP_GetEntryPointsFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints");
if (!pfNP_GetEntryPoints)
return NS_ERROR_FAILURE;
*error = pfNP_GetEntryPoints(pFuncs);
}
// save NPP_New
mNPP_New = pFuncs->newp;
return NS_OK;
}
#endif
nsresult
PluginPRLibrary::NPP_New(NPMIMEType pluginType, NPP instance,
uint16_t mode, int16_t argc, char* argn[],
char* argv[], NPSavedData* saved,
NPError* error)
{
if (!mNPP_New)
return NS_ERROR_FAILURE;
*error = mNPP_New(pluginType, instance, mode, argc, argn, argv, saved);
return NS_OK;
}
nsresult
PluginPRLibrary::AsyncSetWindow(NPP instance, NPWindow* window)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
PluginPRLibrary::NotifyPainted(NPP instance)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
PluginPRLibrary::GetSurface(NPP instance, gfxASurface** aSurface)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
*aSurface = nsnull;
return NS_OK;
}
nsresult
PluginPRLibrary::UseAsyncPainting(NPP instance, PRBool* aIsAsync)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
*aIsAsync = PR_FALSE;
return NS_OK;
}
} // namespace mozilla
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Josh Aas <josh@mozilla.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/PluginPRLibrary.h"
// Some plugins on Windows, notably Quake Live, implement NP_Initialize using
// cdecl instead of the documented stdcall. In order to work around this,
// we force the caller to use a frame pointer.
#if defined(XP_WIN) && defined(_M_IX86)
#include <malloc.h>
// gNotOptimized exists so that the compiler will not optimize the alloca
// below.
static int gNotOptimized;
#define CALLING_CONVENTION_HACK void* foo = _alloca(gNotOptimized);
#else
#define CALLING_CONVENTION_HACK
#endif
namespace mozilla {
#if defined(XP_UNIX) && !defined(XP_MACOSX)
nsresult
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
NPPluginFuncs* pFuncs, NPError* error)
{
if (mNP_Initialize) {
*error = mNP_Initialize(bFuncs, pFuncs);
} else {
NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
if (!pfNP_Initialize)
return NS_ERROR_FAILURE;
*error = pfNP_Initialize(bFuncs, pFuncs);
}
// save NPP_New
mNPP_New = pFuncs->newp;
return NS_OK;
}
#else
nsresult
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
{
CALLING_CONVENTION_HACK
if (mNP_Initialize) {
*error = mNP_Initialize(bFuncs);
} else {
NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
if (!pfNP_Initialize)
return NS_ERROR_FAILURE;
*error = pfNP_Initialize(bFuncs);
}
return NS_OK;
}
#endif
nsresult
PluginPRLibrary::NP_Shutdown(NPError* error)
{
CALLING_CONVENTION_HACK
if (mNP_Shutdown) {
*error = mNP_Shutdown();
} else {
NP_ShutdownFunc pfNP_Shutdown = (NP_ShutdownFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
if (!pfNP_Shutdown)
return NS_ERROR_FAILURE;
*error = pfNP_Shutdown();
}
return NS_OK;
}
nsresult
PluginPRLibrary::NP_GetMIMEDescription(const char** mimeDesc)
{
CALLING_CONVENTION_HACK
if (mNP_GetMIMEDescription) {
*mimeDesc = mNP_GetMIMEDescription();
}
else {
NP_GetMIMEDescriptionFunc pfNP_GetMIMEDescription =
(NP_GetMIMEDescriptionFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription");
if (!pfNP_GetMIMEDescription) {
*mimeDesc = "";
return NS_ERROR_FAILURE;
}
*mimeDesc = pfNP_GetMIMEDescription();
}
return NS_OK;
}
nsresult
PluginPRLibrary::NP_GetValue(void *future, NPPVariable aVariable,
void *aValue, NPError* error)
{
#if defined(XP_UNIX) && !defined(XP_MACOSX)
if (mNP_GetValue) {
*error = mNP_GetValue(future, aVariable, aValue);
} else {
NP_GetValueFunc pfNP_GetValue = (NP_GetValueFunc)PR_FindFunctionSymbol(mLibrary, "NP_GetValue");
if (!pfNP_GetValue)
return NS_ERROR_FAILURE;
*error = pfNP_GetValue(future, aVariable, aValue);
}
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_OS2)
nsresult
PluginPRLibrary::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
{
CALLING_CONVENTION_HACK
if (mNP_GetEntryPoints) {
*error = mNP_GetEntryPoints(pFuncs);
} else {
NP_GetEntryPointsFunc pfNP_GetEntryPoints = (NP_GetEntryPointsFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints");
if (!pfNP_GetEntryPoints)
return NS_ERROR_FAILURE;
*error = pfNP_GetEntryPoints(pFuncs);
}
// save NPP_New
mNPP_New = pFuncs->newp;
return NS_OK;
}
#endif
nsresult
PluginPRLibrary::NPP_New(NPMIMEType pluginType, NPP instance,
uint16_t mode, int16_t argc, char* argn[],
char* argv[], NPSavedData* saved,
NPError* error)
{
if (!mNPP_New)
return NS_ERROR_FAILURE;
*error = mNPP_New(pluginType, instance, mode, argc, argn, argv, saved);
return NS_OK;
}
nsresult
PluginPRLibrary::AsyncSetWindow(NPP instance, NPWindow* window)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
PluginPRLibrary::NotifyPainted(NPP instance)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
PluginPRLibrary::GetSurface(NPP instance, gfxASurface** aSurface)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
*aSurface = nsnull;
return NS_OK;
}
} // namespace mozilla

Просмотреть файл

@ -136,7 +136,7 @@ public:
virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window);
virtual nsresult NotifyPainted(NPP instance);
virtual nsresult GetSurface(NPP instance, gfxASurface** aSurface);
virtual nsresult UseAsyncPainting(NPP instance, PRBool* aIsAsync);
NS_OVERRIDE virtual bool UseAsyncPainting() { return false; }
private:
NP_InitializeFunc mNP_Initialize;

Просмотреть файл

@ -905,7 +905,8 @@ nsNPAPIPluginInstance::UseAsyncPainting(PRBool* aIsAsync)
if (!library)
return NS_ERROR_FAILURE;
return library->UseAsyncPainting(&mNPP, aIsAsync);
*aIsAsync = library->UseAsyncPainting();
return NS_OK;
}
NS_IMETHODIMP