Revive NPAPI async drawing: stub code. (bug 1217665 part 1, r=aklotz)

This commit is contained in:
David Anderson 2015-12-02 11:31:16 -08:00
parent 1e7cc8088d
commit 3e51124fc7
25 changed files with 411 additions and 45 deletions

View File

@ -121,6 +121,7 @@ public:
const nsIntRect&, gfxContext** aCtx) override;
virtual nsresult EndUpdateBackground(NPP instance,
gfxContext* aCtx, const nsIntRect&) override;
virtual void DidComposite(NPP aInstance) override { }
virtual void GetLibraryPath(nsACString& aPath) { aPath.Assign(mFilePath); }
virtual nsresult GetRunID(uint32_t* aRunID) override { return NS_ERROR_NOT_IMPLEMENTED; }
virtual void SetHasLocalInstance() override { }

View File

@ -59,7 +59,7 @@
/*----------------------------------------------------------------------*/
#define NP_VERSION_MAJOR 0
#define NP_VERSION_MINOR 28
#define NP_VERSION_MINOR 29
/* The OS/2 version of Netscape uses RC_DATA to define the
@ -186,6 +186,33 @@ typedef enum {
NPFocusPrevious = 1
} NPFocusDirection;
/* These formats describe the format in the memory byte-order. This means if
* a 32-bit value of a pixel is viewed on a little-endian system the layout will
* be 0xAARRGGBB. The Alpha channel will be stored in the most significant
* bits. */
typedef enum {
/* 32-bit per pixel 8-bit per channel - premultiplied alpha */
NPImageFormatBGRA32 = 0x1,
/* 32-bit per pixel 8-bit per channel - 1 unused channel */
NPImageFormatBGRX32 = 0x2
} NPImageFormat;
typedef struct _NPAsyncSurface
{
uint32_t version;
NPSize size;
NPImageFormat format;
union {
struct {
uint32_t stride;
void *data;
} bitmap;
#if defined(XP_WIN)
HANDLE sharedHandle;
#endif
};
} NPAsyncSurface;
/* Return values for NPP_HandleEvent */
#define kNPEventNotHandled 0
#define kNPEventHandled 1
@ -248,11 +275,9 @@ typedef enum {
#if defined(MOZ_X11)
, NPDrawingModelSyncX = 6
#endif
#if 0 /* OBSOLETE */
, NPDrawingModelAsyncBitmapSurfaceOBSOLETE = 7
, NPDrawingModelAsyncBitmapSurface = 7
#if defined(XP_WIN)
, NPDrawingModelAsyncWindowsDXGISurfaceOBSOLETE = 8
#endif
, NPDrawingModelAsyncWindowsDXGISurface = 8
#endif
} NPDrawingModel;
@ -398,11 +423,9 @@ typedef enum {
, NPNVsupportsCoreAnimationBool = 2003
, NPNVsupportsInvalidatingCoreAnimationBool = 2004
#endif
#if 0 /* OBSOLETE */
, NPNVsupportsAsyncBitmapSurfaceBoolOBSOLETE = 2007
, NPNVsupportsAsyncBitmapSurfaceBool = 2007
#if defined(XP_WIN)
, NPNVsupportsAsyncWindowsDXGISurfaceBoolOBSOLETE = 2008
#endif
, NPNVsupportsAsyncWindowsDXGISurfaceBool = 2008
#endif
#if defined(XP_MACOSX)
#ifndef NP_NO_CARBON
@ -850,6 +873,11 @@ NPBool NPN_ConvertPoint(NPP instance, double sourceX, double sourceY, NPCoo
NPBool NPN_HandleEvent(NPP instance, void *event, NPBool handled);
NPBool NPN_UnfocusInstance(NPP instance, NPFocusDirection direction);
void NPN_URLRedirectResponse(NPP instance, void* notifyData, NPBool allow);
NPError NPN_InitAsyncSurface(NPP instance, NPSize *size,
NPImageFormat format, void *initData,
NPAsyncSurface *surface);
NPError NPN_FinalizeAsyncSurface(NPP instance, NPAsyncSurface *surface);
void NPN_SetCurrentAsyncSurface(NPP instance, NPAsyncSurface *surface, NPRect *changed);
#ifdef __cplusplus
} /* end extern "C" */

View File

@ -92,6 +92,9 @@ typedef NPBool (*NPN_ConvertPointPtr)(NPP instance, double sourceX, double
typedef NPBool (*NPN_HandleEventPtr)(NPP instance, void *event, NPBool handled);
typedef NPBool (*NPN_UnfocusInstancePtr)(NPP instance, NPFocusDirection direction);
typedef void (*NPN_URLRedirectResponsePtr)(NPP instance, void* notifyData, NPBool allow);
typedef NPError (*NPN_InitAsyncSurfacePtr)(NPP instance, NPSize *size, NPImageFormat format, void *initData, NPAsyncSurface *surface);
typedef NPError (*NPN_FinalizeAsyncSurfacePtr)(NPP instance, NPAsyncSurface *surface);
typedef void (*NPN_SetCurrentAsyncSurfacePtr)(NPP instance, NPAsyncSurface *surface, NPRect *changed);
typedef void (*NPN_DummyPtr)(void);
@ -178,9 +181,9 @@ typedef struct _NPNetscapeFuncs {
NPN_HandleEventPtr handleevent;
NPN_UnfocusInstancePtr unfocusinstance;
NPN_URLRedirectResponsePtr urlredirectresponse;
NPN_DummyPtr initasyncsurfaceOBSOLETE;
NPN_DummyPtr finalizeasyncsurfaceOBSOLETE;
NPN_DummyPtr setcurrentasyncsurfaceOBSOLETE;
NPN_InitAsyncSurfacePtr initasyncsurface;
NPN_FinalizeAsyncSurfacePtr finalizeasyncsurface;
NPN_SetCurrentAsyncSurfacePtr setcurrentasyncsurface;
} NPNetscapeFuncs;
#ifdef XP_MACOSX

View File

@ -26,7 +26,7 @@ enum nsPluginTagType {
// Do not make this interface scriptable, because the virtual functions in C++
// blocks will make script call the wrong functions.
[uuid(518e7465-e1bc-4490-a30e-0ba9d791aaa8)]
[uuid(7d65452e-c167-4cba-a0e3-ddc61bdde8c3)]
interface nsIPluginInstanceOwner : nsISupports
{
/**
@ -101,6 +101,10 @@ interface nsIPluginInstanceOwner : nsISupports
%{C++
virtual NPBool ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
double *destX, double *destY, NPCoordinateSpace destSpace) = 0;
virtual NPError InitAsyncSurface(NPSize *size, NPImageFormat format,
void *initData, NPAsyncSurface *surface) = 0;
virtual NPError FinalizeAsyncSurface(NPAsyncSurface *surface) = 0;
virtual void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed) = 0;
%}
void setEventModel(in int32_t eventModel);

View File

@ -169,7 +169,10 @@ static NPNetscapeFuncs sBrowserFuncs = {
_convertpoint,
nullptr, // handleevent, unimplemented
nullptr, // unfocusinstance, unimplemented
_urlredirectresponse
_urlredirectresponse,
_initasyncsurface,
_finalizeasyncsurface,
_setcurrentasyncsurface
};
static Mutex *sPluginThreadAsyncCallLock = nullptr;
@ -2780,6 +2783,39 @@ _urlredirectresponse(NPP instance, void* notifyData, NPBool allow)
inst->URLRedirectResponse(notifyData, allow);
}
NPError
_initasyncsurface(NPP instance, NPSize *size, NPImageFormat format, void *initData, NPAsyncSurface *surface)
{
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
if (!inst) {
return NPERR_GENERIC_ERROR;
}
return inst->InitAsyncSurface(size, format, initData, surface);
}
NPError
_finalizeasyncsurface(NPP instance, NPAsyncSurface *surface)
{
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
if (!inst) {
return NPERR_GENERIC_ERROR;
}
return inst->FinalizeAsyncSurface(surface);
}
void
_setcurrentasyncsurface(NPP instance, NPAsyncSurface *surface, NPRect *changed)
{
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
if (!inst) {
return;
}
inst->SetCurrentAsyncSurface(surface, changed);
}
} /* namespace parent */
} /* namespace plugins */
} /* namespace mozilla */

View File

@ -320,6 +320,15 @@ _getJavaPeer(NPP npp);
void
_urlredirectresponse(NPP instance, void* notifyData, NPBool allow);
NPError
_initasyncsurface(NPP instance, NPSize *size, NPImageFormat format, void *initData, NPAsyncSurface *surface);
NPError
_finalizeasyncsurface(NPP instance, NPAsyncSurface *surface);
void
_setcurrentasyncsurface(NPP instance, NPAsyncSurface *surface, NPRect *changed);
} /* namespace parent */
} /* namespace plugins */
} /* namespace mozilla */

View File

@ -1067,12 +1067,8 @@ nsNPAPIPluginInstance* nsNPAPIPluginInstance::GetFromNPP(NPP npp)
nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel)
{
#if defined(XP_MACOSX)
*aModel = (int32_t)mDrawingModel;
return NS_OK;
#else
return NS_ERROR_FAILURE;
#endif
}
nsresult nsNPAPIPluginInstance::IsRemoteDrawingCoreAnimation(bool* aDrawing)
@ -1211,6 +1207,16 @@ nsNPAPIPluginInstance::GetImageSize(nsIntSize* aSize)
return !library ? NS_ERROR_FAILURE : library->GetImageSize(&mNPP, aSize);
}
void
nsNPAPIPluginInstance::DidComposite()
{
if (RUNNING != mRunning)
return;
AutoPluginLibraryCall library(this);
library->DidComposite(&mNPP);
}
nsresult
nsNPAPIPluginInstance::NotifyPainted(void)
{
@ -1625,6 +1631,35 @@ nsNPAPIPluginInstance::URLRedirectResponse(void* notifyData, NPBool allow)
}
}
NPError
nsNPAPIPluginInstance::InitAsyncSurface(NPSize *size, NPImageFormat format,
void *initData, NPAsyncSurface *surface)
{
if (mOwner) {
return mOwner->InitAsyncSurface(size, format, initData, surface);
}
return NPERR_GENERIC_ERROR;
}
NPError
nsNPAPIPluginInstance::FinalizeAsyncSurface(NPAsyncSurface *surface)
{
if (mOwner) {
return mOwner->FinalizeAsyncSurface(surface);
}
return NPERR_GENERIC_ERROR;
}
void
nsNPAPIPluginInstance::SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed)
{
if (mOwner) {
mOwner->SetCurrentAsyncSurface(surface, changed);
}
}
class CarbonEventModelFailureEvent : public nsRunnable {
public:
nsCOMPtr<nsIContent> mContent;

View File

@ -121,6 +121,7 @@ public:
nsresult GetJSContext(JSContext* *outContext);
nsPluginInstanceOwner* GetOwner();
void SetOwner(nsPluginInstanceOwner *aOwner);
void DidComposite();
bool HasAudioChannelAgent() const
{
@ -292,6 +293,11 @@ public:
void URLRedirectResponse(void* notifyData, NPBool allow);
NPError InitAsyncSurface(NPSize *size, NPImageFormat format,
void *initData, NPAsyncSurface *surface);
NPError FinalizeAsyncSurface(NPAsyncSurface *surface);
void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed);
// Called when the instance fails to instantiate beceause the Carbon
// event model is not supported.
void CarbonNPAPIFailure();

View File

@ -1036,6 +1036,21 @@ NPBool nsPluginInstanceOwner::ConvertPoint(double sourceX, double sourceY, NPCoo
#endif
}
NPError nsPluginInstanceOwner::InitAsyncSurface(NPSize *size, NPImageFormat format,
void *initData, NPAsyncSurface *surface)
{
return NPERR_INCOMPATIBLE_VERSION_ERROR;
}
NPError nsPluginInstanceOwner::FinalizeAsyncSurface(NPAsyncSurface *)
{
return NPERR_INCOMPATIBLE_VERSION_ERROR;
}
void nsPluginInstanceOwner::SetCurrentAsyncSurface(NPAsyncSurface *, NPRect*)
{
}
NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
{
NS_ENSURE_ARG_POINTER(result);

View File

@ -66,7 +66,12 @@ public:
NPBool ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
double *destX, double *destY, NPCoordinateSpace destSpace) override;
NPError InitAsyncSurface(NPSize *size, NPImageFormat format,
void *initData, NPAsyncSurface *surface) override;
NPError FinalizeAsyncSurface(NPAsyncSurface *surface) override;
void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed) override;
/**
* Get the type of the HTML tag that was used ot instantiate this
* plugin. Currently supported tags are EMBED, OBJECT and APPLET.

View File

@ -146,6 +146,10 @@ parent:
returns (nsCString value, NPError result);
intr NPN_GetValue_DrawingModelSupport(NPNVariable model)
returns (bool value);
intr NPN_GetValue_SupportsAsyncBitmapSurface()
returns (bool value);
intr NPN_GetValue_SupportsAsyncDXGISurface()
returns (bool value);
intr NPN_SetValue_NPPVpluginWindow(bool windowed)
returns (NPError result);

View File

@ -442,6 +442,22 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar,
#endif
}
case NPNVsupportsAsyncBitmapSurfaceBool: {
bool value = false;
CallNPN_GetValue_SupportsAsyncBitmapSurface(&value);
*((NPBool*)aValue) = value;
return NPERR_NO_ERROR;
}
#ifdef XP_WIN
case NPNVsupportsAsyncWindowsDXGISurfaceBool: {
bool value = false;
CallNPN_GetValue_SupportsAsyncDXGISurface(&value);
*((NPBool*)aValue) = value;
return NPERR_NO_ERROR;
}
#endif
#ifdef XP_MACOSX
case NPNVsupportsCoreGraphicsBool: {
*((NPBool*)aValue) = true;
@ -2531,6 +2547,50 @@ PluginInstanceChild::NPN_URLRedirectResponse(void* notifyData, NPBool allow)
NS_ASSERTION(false, "Couldn't find stream for redirect response!");
}
bool
PluginInstanceChild::IsUsingDirectDrawing()
{
return IsDrawingModelDirect(mDrawingModel);
}
NPError
PluginInstanceChild::NPN_InitAsyncSurface(NPSize *size, NPImageFormat format,
void *initData, NPAsyncSurface *surface)
{
AssertPluginThread();
surface->bitmap.data = NULL;
if (!IsUsingDirectDrawing()) {
return NPERR_GENERIC_ERROR;
}
MOZ_CRASH("NYI");
return NPERR_GENERIC_ERROR;
}
NPError
PluginInstanceChild::NPN_FinalizeAsyncSurface(NPAsyncSurface *surface)
{
AssertPluginThread();
if (!IsUsingDirectDrawing()) {
return NPERR_GENERIC_ERROR;
}
MOZ_CRASH("NYI");
return NPERR_GENERIC_ERROR;
}
void
PluginInstanceChild::NPN_SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed)
{
if (!IsUsingDirectDrawing()) {
return;
}
MOZ_CRASH("NYI");
}
void
PluginInstanceChild::DoAsyncRedraw()
{

View File

@ -261,6 +261,13 @@ public:
void NPN_URLRedirectResponse(void* notifyData, NPBool allow);
NPError NPN_InitAsyncSurface(NPSize *size, NPImageFormat format,
void *initData, NPAsyncSurface *surface);
NPError NPN_FinalizeAsyncSurface(NPAsyncSurface *surface);
void NPN_SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed);
void DoAsyncRedraw();
private:
friend class PluginModuleChild;
@ -269,7 +276,7 @@ private:
InternalGetNPObjectForValue(NPNVariable aValue,
NPObject** aObject);
bool IsAsyncDrawing();
bool IsUsingDirectDrawing();
virtual bool RecvUpdateBackground(const SurfaceDescriptor& aBackground,
const nsIntRect& aRect) override;

View File

@ -37,6 +37,7 @@
#include "ImageContainer.h"
#include "GLContext.h"
#include "GLContextProvider.h"
#include "gfxPrefs.h"
#ifdef XP_MACOSX
#include "MacIOSurfaceImage.h"
@ -210,6 +211,12 @@ PluginInstanceParent::Destroy()
return retval;
}
bool
PluginInstanceParent::IsUsingDirectDrawing()
{
return IsDrawingModelDirect(mDrawingModel);
}
PBrowserStreamParent*
PluginInstanceParent::AllocPBrowserStreamParent(const nsCString& url,
const uint32_t& length,
@ -342,6 +349,42 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVdocumentOrigin(nsCString* value,
return true;
}
static inline bool
AllowDirectBitmapSurfaceDrawing()
{
if (!gfxPrefs::PluginAsyncDrawingEnabled()) {
return false;
}
return gfxPlatform::GetPlatform()->SupportsPluginDirectBitmapDrawing();
}
static inline bool
AllowDirectDXGISurfaceDrawing()
{
if (!gfxPrefs::PluginAsyncDrawingEnabled()) {
return false;
}
#if defined(XP_WIN)
return gfxWindowsPlatform::GetPlatform()->SupportsPluginDirectDXGIDrawing();
#else
return false;
#endif
}
bool
PluginInstanceParent::AnswerNPN_GetValue_SupportsAsyncBitmapSurface(bool* value)
{
*value = AllowDirectBitmapSurfaceDrawing();
return true;
}
bool
PluginInstanceParent::AnswerNPN_GetValue_SupportsAsyncDXGISurface(bool* value)
{
*value = AllowDirectDXGISurfaceDrawing();
return true;
}
bool
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginWindow(
const bool& windowed, NPError* result)
@ -376,35 +419,58 @@ bool
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel(
const int& drawingModel, NPError* result)
{
bool allowed = false;
switch (drawingModel) {
#if defined(XP_MACOSX)
case NPDrawingModelCoreAnimation:
case NPDrawingModelInvalidatingCoreAnimation:
case NPDrawingModelOpenGL:
case NPDrawingModelCoreGraphics:
allowed = true;
break;
#elif defined(XP_WIN)
case NPDrawingModelSyncWin:
allowed = true;
break;
case NPDrawingModelAsyncWindowsDXGISurface:
allowed = AllowDirectDXGISurfaceDrawing();
break;
#elif defined(MOZ_X11)
case NPDrawingModelSyncX:
allowed = true;
break;
#endif
case NPDrawingModelAsyncBitmapSurface:
allowed = AllowDirectBitmapSurfaceDrawing();
break;
default:
allowed = false;
break;
}
if (!allowed) {
*result = NPERR_GENERIC_ERROR;
return true;
}
mDrawingModel = drawingModel;
int requestModel = drawingModel;
#ifdef XP_MACOSX
if (drawingModel == NPDrawingModelCoreAnimation ||
drawingModel == NPDrawingModelInvalidatingCoreAnimation) {
// We need to request CoreGraphics otherwise
// the nsPluginFrame will try to draw a CALayer
// that can not be shared across process.
mDrawingModel = drawingModel;
*result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel,
(void*)NPDrawingModelCoreGraphics);
} else
#endif
if (
#if defined(XP_WIN)
drawingModel == NPDrawingModelSyncWin
#elif defined(XP_MACOSX)
drawingModel == NPDrawingModelOpenGL ||
drawingModel == NPDrawingModelCoreGraphics
#elif defined(MOZ_X11)
drawingModel == NPDrawingModelSyncX
#else
false
#endif
) {
mDrawingModel = drawingModel;
*result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel,
(void*)(intptr_t)drawingModel);
} else {
*result = NPERR_GENERIC_ERROR;
requestModel = NPDrawingModelCoreGraphics;
}
#endif
*result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel,
(void*)(intptr_t)requestModel);
return true;
}
@ -730,6 +796,15 @@ PluginInstanceParent::GetImageSize(nsIntSize* aSize)
return NS_ERROR_NOT_AVAILABLE;
}
void
PluginInstanceParent::DidComposite()
{
if (!IsUsingDirectDrawing()) {
return;
}
Unused << SendNPP_DidComposite();
}
#ifdef XP_MACOSX
nsresult
PluginInstanceParent::IsRemoteDrawingCoreAnimation(bool *aDrawing)

View File

@ -114,6 +114,12 @@ public:
virtual bool
AnswerNPN_GetValue_NPNVdocumentOrigin(nsCString* value, NPError* result) override;
virtual bool
AnswerNPN_GetValue_SupportsAsyncBitmapSurface(bool* value) override;
virtual bool
AnswerNPN_GetValue_SupportsAsyncDXGISurface(bool* value) override;
virtual bool
AnswerNPN_SetValue_NPPVpluginWindow(const bool& windowed, NPError* result) override;
virtual bool
@ -307,7 +313,9 @@ public:
gfxContext** aCtx);
nsresult EndUpdateBackground(gfxContext* aCtx,
const nsIntRect& aRect);
void DidComposite() { Unused << SendNPP_DidComposite(); }
void DidComposite();
bool IsUsingDirectDrawing();
virtual PluginAsyncSurrogate* GetAsyncSurrogate() override;
@ -347,7 +355,7 @@ private:
nsCString mSrcAttribute;
bool mIsWhitelistedForShumway;
NPWindowType mWindowType;
int16_t mDrawingModel;
int16_t mDrawingModel;
nsDataHashtable<nsPtrHashKey<NPObject>, PluginScriptableObjectParent*> mScriptableObjects;

View File

@ -77,6 +77,7 @@ public:
virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window) = 0;
virtual nsresult GetImageContainer(NPP instance, mozilla::layers::ImageContainer** aContainer) = 0;
virtual nsresult GetImageSize(NPP instance, nsIntSize* aSize) = 0;
virtual void DidComposite(NPP instance) = 0;
virtual bool IsOOP() = 0;
#if defined(XP_MACOSX)
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing) = 0;

View File

@ -220,6 +220,15 @@ inline void AssertPluginThread()
void DeferNPObjectLastRelease(const NPNetscapeFuncs* f, NPObject* o);
void DeferNPVariantLastRelease(const NPNetscapeFuncs* f, NPVariant* v);
inline bool IsDrawingModelDirect(int16_t aModel)
{
return aModel == NPDrawingModelAsyncBitmapSurface
#if defined(XP_WIN)
|| aModel == NPDrawingModelAsyncWindowsDXGISurface
#endif
;
}
// in NPAPI, char* == nullptr is sometimes meaningful. the following is
// helper code for dealing with nullable nsCString's
inline nsCString

View File

@ -1027,6 +1027,17 @@ _convertpoint(NPP instance,
static void
_urlredirectresponse(NPP instance, void* notifyData, NPBool allow);
static NPError
_initasyncsurface(NPP instance, NPSize *size,
NPImageFormat format, void *initData,
NPAsyncSurface *surface);
static NPError
_finalizeasyncsurface(NPP instance, NPAsyncSurface *surface);
static void
_setcurrentasyncsurface(NPP instance, NPAsyncSurface *surface, NPRect *changed);
} /* namespace child */
} /* namespace plugins */
} /* namespace mozilla */
@ -1088,7 +1099,10 @@ const NPNetscapeFuncs PluginModuleChild::sBrowserFuncs = {
mozilla::plugins::child::_convertpoint,
nullptr, // handleevent, unimplemented
nullptr, // unfocusinstance, unimplemented
mozilla::plugins::child::_urlredirectresponse
mozilla::plugins::child::_urlredirectresponse,
mozilla::plugins::child::_initasyncsurface,
mozilla::plugins::child::_finalizeasyncsurface,
mozilla::plugins::child::_setcurrentasyncsurface,
};
PluginInstanceChild*
@ -1862,6 +1876,26 @@ _urlredirectresponse(NPP instance, void* notifyData, NPBool allow)
InstCast(instance)->NPN_URLRedirectResponse(notifyData, allow);
}
NPError
_initasyncsurface(NPP instance, NPSize *size,
NPImageFormat format, void *initData,
NPAsyncSurface *surface)
{
return InstCast(instance)->NPN_InitAsyncSurface(size, format, initData, surface);
}
NPError
_finalizeasyncsurface(NPP instance, NPAsyncSurface *surface)
{
return InstCast(instance)->NPN_FinalizeAsyncSurface(surface);
}
void
_setcurrentasyncsurface(NPP instance, NPAsyncSurface *surface, NPRect *changed)
{
InstCast(instance)->NPN_SetCurrentAsyncSurface(surface, changed);
}
} /* namespace child */
} /* namespace plugins */
} /* namespace mozilla */

View File

@ -1945,6 +1945,14 @@ PluginModuleParent::GetImageSize(NPP instance,
return !i ? NS_ERROR_FAILURE : i->GetImageSize(aSize);
}
void
PluginModuleParent::DidComposite(NPP aInstance)
{
if (PluginInstanceParent* i = PluginInstanceParent::Cast(aInstance)) {
i->DidComposite();
}
}
nsresult
PluginModuleParent::SetBackgroundUnknown(NPP instance)
{

View File

@ -246,6 +246,7 @@ protected:
virtual nsresult AsyncSetWindow(NPP aInstance, NPWindow* aWindow) override;
virtual nsresult GetImageContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override;
virtual nsresult GetImageSize(NPP aInstance, nsIntSize* aSize) override;
virtual void DidComposite(NPP aInstance) override;
virtual bool IsOOP() override { return true; }
virtual nsresult SetBackgroundUnknown(NPP instance) override;
virtual nsresult BeginUpdateBackground(NPP instance,

View File

@ -633,6 +633,11 @@ public:
// devices. Currently this is only used on Windows.
virtual void GetDeviceInitData(mozilla::gfx::DeviceInitData* aOut);
// Plugin async drawing support.
virtual bool SupportsPluginDirectBitmapDrawing() {
return false;
}
protected:
gfxPlatform();
virtual ~gfxPlatform();

View File

@ -194,6 +194,7 @@ private:
DECL_GFX_PREF(Live, "browser.ui.zoom.force-user-scalable", ForceUserScalable, bool, false);
DECL_GFX_PREF(Live, "browser.viewport.desktopWidth", DesktopViewportWidth, int32_t, 980);
DECL_GFX_PREF(Live, "dom.ipc.plugins.asyncdrawing.enabled", PluginAsyncDrawingEnabled, bool, false);
DECL_GFX_PREF(Live, "dom.meta-viewport.enabled", MetaViewportEnabled, bool, false);
DECL_GFX_PREF(Once, "dom.vr.enabled", VREnabled, bool, false);
DECL_GFX_PREF(Once, "dom.vr.oculus.enabled", VROculusEnabled, bool, true);

View File

@ -3061,3 +3061,9 @@ gfxWindowsPlatform::GetDeviceInitData(DeviceInitData* aOut)
aOut->adapter() = DxgiAdapterDesc::From(desc);
}
}
bool
gfxWindowsPlatform::SupportsPluginDirectDXGIDrawing()
{
return false;
}

View File

@ -295,6 +295,8 @@ public:
void GetDeviceInitData(mozilla::gfx::DeviceInitData* aOut) override;
bool SupportsPluginDirectDXGIDrawing();
protected:
bool AccelerateLayersByDefault() override {
return true;

View File

@ -2589,6 +2589,9 @@ pref("dom.ipc.plugins.asyncInit.enabled", false);
pref("dom.ipc.plugins.asyncInit.enabled", true);
#endif
// Allow the AsyncDrawing mode to be used for plugins.
pref("dom.ipc.plugins.asyncdrawing.enabled", false);
pref("dom.ipc.processCount", 1);
// Enable caching of Moz2D Path objects for SVG geometry elements