зеркало из https://github.com/mozilla/pjs.git
Bug 626602, part 8: Dig a tunnel from nsObjectFrame to PluginInstanceParent for background copying. r=bsmedberg sr=roc
This commit is contained in:
Родитель
d67e7e741b
Коммит
8170357a77
|
@ -282,6 +282,11 @@ public:
|
|||
#ifdef XP_MACOSX
|
||||
nsresult IsRemoteDrawingCoreAnimation(PRBool *aDrawing);
|
||||
#endif
|
||||
nsresult SetBackgroundUnknown() { return NS_OK; }
|
||||
nsresult BeginUpdateBackground(const nsIntRect& aRect,
|
||||
gfxContext** aCtx) { return NS_OK; }
|
||||
nsresult EndUpdateBackground(gfxContext* aCtx,
|
||||
const nsIntRect& aRect) { return NS_OK; }
|
||||
|
||||
private:
|
||||
// Quirks mode support for various plugin mime types
|
||||
|
|
|
@ -46,9 +46,11 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsPluginError.h"
|
||||
|
||||
class nsNPAPIPlugin;
|
||||
class gfxASurface;
|
||||
class gfxContext;
|
||||
class nsCString;
|
||||
struct nsIntRect;
|
||||
class nsNPAPIPlugin;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -102,6 +104,16 @@ public:
|
|||
#if defined(XP_MACOSX)
|
||||
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing) = 0;
|
||||
#endif
|
||||
/**
|
||||
* The next three methods are the third leg in the trip to
|
||||
* PluginInstanceParent. They approximately follow the ReadbackSink
|
||||
* API.
|
||||
*/
|
||||
virtual nsresult SetBackgroundUnknown(NPP instance) = 0;
|
||||
virtual nsresult BeginUpdateBackground(NPP instance,
|
||||
const nsIntRect&, gfxContext**) = 0;
|
||||
virtual nsresult EndUpdateBackground(NPP instance,
|
||||
gfxContext*, const nsIntRect&) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -691,6 +691,40 @@ PluginModuleParent::GetImage(NPP instance,
|
|||
return !i ? NS_ERROR_FAILURE : i->GetImage(aContainer, aImage);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PluginModuleParent::SetBackgroundUnknown(NPP instance)
|
||||
{
|
||||
PluginInstanceParent* i = InstCast(instance);
|
||||
if (!i)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return i->SetBackgroundUnknown();
|
||||
}
|
||||
|
||||
nsresult
|
||||
PluginModuleParent::BeginUpdateBackground(NPP instance,
|
||||
const nsIntRect& aRect,
|
||||
gfxContext** aCtx)
|
||||
{
|
||||
PluginInstanceParent* i = InstCast(instance);
|
||||
if (!i)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return i->BeginUpdateBackground(aRect, aCtx);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PluginModuleParent::EndUpdateBackground(NPP instance,
|
||||
gfxContext* aCtx,
|
||||
const nsIntRect& aRect)
|
||||
{
|
||||
PluginInstanceParent* i = InstCast(instance);
|
||||
if (!i)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return i->EndUpdateBackground(aCtx, aRect);
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
nsresult
|
||||
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)
|
||||
|
|
|
@ -233,6 +233,16 @@ private:
|
|||
virtual nsresult GetSurface(NPP instance, gfxASurface** aSurface);
|
||||
virtual nsresult GetImage(NPP instance, mozilla::layers::ImageContainer* aContainer, mozilla::layers::Image** aImage);
|
||||
NS_OVERRIDE virtual bool UseAsyncPainting() { return true; }
|
||||
NS_OVERRIDE
|
||||
virtual nsresult SetBackgroundUnknown(NPP instance);
|
||||
NS_OVERRIDE
|
||||
virtual nsresult BeginUpdateBackground(NPP instance,
|
||||
const nsIntRect& aRect,
|
||||
gfxContext** aCtx);
|
||||
NS_OVERRIDE
|
||||
virtual nsresult EndUpdateBackground(NPP instance,
|
||||
gfxContext* aCtx,
|
||||
const nsIntRect& aRect);
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error);
|
||||
|
|
|
@ -470,10 +470,12 @@ public:
|
|||
// Return true if we set image with valid surface
|
||||
PRBool SetCurrentImage(ImageContainer* aContainer);
|
||||
|
||||
// Methods to update the background image we send to async plugins
|
||||
void SetBackgroundUnknown() {}
|
||||
already_AddRefed<gfxContext> BeginUpdateBackground(const nsIntRect& aRect) { return nsnull; }
|
||||
void EndUpdateBackground(gfxContext* aContext, const nsIntRect& aRect) {}
|
||||
// Methods to update the background image we send to async plugins.
|
||||
// The eventual target of these operations is PluginInstanceParent,
|
||||
// but it takes several hops to get there.
|
||||
void SetBackgroundUnknown();
|
||||
already_AddRefed<gfxContext> BeginUpdateBackground(const nsIntRect& aRect);
|
||||
void EndUpdateBackground(gfxContext* aContext, const nsIntRect& aRect);
|
||||
|
||||
PRBool UseAsyncRendering()
|
||||
{
|
||||
|
@ -511,6 +513,13 @@ private:
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIPluginInstance_MOZILLA_2_0_BRANCH>
|
||||
GetInstance()
|
||||
{
|
||||
nsCOMPtr<nsIPluginInstance_MOZILLA_2_0_BRANCH> inst = do_QueryInterface(mInstance);
|
||||
return inst.forget();
|
||||
}
|
||||
|
||||
void FixUpURLS(const nsString &name, nsAString &value);
|
||||
|
||||
nsPluginNativeWindow *mPluginWindow;
|
||||
|
@ -1982,6 +1991,39 @@ nsPluginInstanceOwner::SetCurrentImage(ImageContainer* aContainer)
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsPluginInstanceOwner::SetBackgroundUnknown()
|
||||
{
|
||||
nsCOMPtr<nsIPluginInstance_MOZILLA_2_0_BRANCH> inst = GetInstance();
|
||||
if (inst) {
|
||||
inst->SetBackgroundUnknown();
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<gfxContext>
|
||||
nsPluginInstanceOwner::BeginUpdateBackground(const nsIntRect& aRect)
|
||||
{
|
||||
nsIntRect rect = aRect;
|
||||
nsCOMPtr<nsIPluginInstance_MOZILLA_2_0_BRANCH> inst = GetInstance();
|
||||
nsRefPtr<gfxContext> ctx;
|
||||
if (inst &&
|
||||
NS_SUCCEEDED(inst->BeginUpdateBackground(&rect, getter_AddRefs(ctx)))) {
|
||||
return ctx.forget();
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsPluginInstanceOwner::EndUpdateBackground(gfxContext* aContext,
|
||||
const nsIntRect& aRect)
|
||||
{
|
||||
nsIntRect rect = aRect;
|
||||
nsCOMPtr<nsIPluginInstance_MOZILLA_2_0_BRANCH> inst = GetInstance();
|
||||
if (inst) {
|
||||
inst->EndUpdateBackground(aContext, &rect);
|
||||
}
|
||||
}
|
||||
|
||||
mozilla::LayerState
|
||||
nsObjectFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager)
|
||||
|
|
|
@ -49,6 +49,8 @@ interface nsIOutputStream;
|
|||
struct JSContext;
|
||||
struct JSObject;
|
||||
class gfxASurface;
|
||||
class gfxContext;
|
||||
struct nsIntRect;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -63,8 +65,10 @@ class ImageContainer;
|
|||
[ptr] native JSContextPtr(JSContext);
|
||||
[ptr] native JSObjectPtr(JSObject);
|
||||
[ptr] native gfxASurfacePtr(gfxASurface);
|
||||
[ptr] native gfxContextPtr(gfxContext);
|
||||
[ptr] native ImagePtr(mozilla::layers::Image);
|
||||
[ptr] native ImageContainerPtr(mozilla::layers::ImageContainer);
|
||||
[ptr] native nsIntRectPtr(nsIntRect);
|
||||
|
||||
[uuid(84994340-E120-4051-824F-D4EE8AEF1A3E)]
|
||||
interface nsIPluginInstance : nsISupports
|
||||
|
@ -258,10 +262,18 @@ interface nsIPluginInstance : nsISupports
|
|||
PRBool useAsyncPainting();
|
||||
};
|
||||
|
||||
|
||||
// XXX kill me after branching
|
||||
[noscript, uuid(2b012762-9a55-458b-929e-7ea094812567)]
|
||||
[noscript, uuid(324f3c02-4fbd-430b-8afa-db083d3867fc)]
|
||||
interface nsIPluginInstance_MOZILLA_2_0_BRANCH : nsIPluginInstance
|
||||
{
|
||||
PRBool isRemoteDrawingCoreAnimation();
|
||||
void getImage(in ImageContainerPtr aContainer, out ImagePtr aImage);
|
||||
/**
|
||||
* This is the second leg in the trip to PluginInstanceParent. It
|
||||
* approximately follows the ReadbackSink API.
|
||||
*/
|
||||
void setBackgroundUnknown();
|
||||
void beginUpdateBackground(in nsIntRectPtr rect, out gfxContextPtr ctx);
|
||||
void endUpdateBackground(in gfxContextPtr ctx, in nsIntRectPtr rect);
|
||||
};
|
||||
|
|
|
@ -275,4 +275,32 @@ PluginPRLibrary::IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing)
|
|||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
PluginPRLibrary::SetBackgroundUnknown(NPP instance)
|
||||
{
|
||||
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
|
||||
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
|
||||
NS_ERROR("Unexpected use of async APIs for in-process plugin.");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PluginPRLibrary::BeginUpdateBackground(NPP instance,
|
||||
const nsIntRect&, gfxContext** aCtx)
|
||||
{
|
||||
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
|
||||
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
|
||||
NS_ERROR("Unexpected use of async APIs for in-process plugin.");
|
||||
*aCtx = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PluginPRLibrary::EndUpdateBackground(NPP instance,
|
||||
gfxContext*, const nsIntRect&)
|
||||
{
|
||||
NS_RUNTIMEABORT("This should never be called");
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -146,6 +146,14 @@ public:
|
|||
#if defined(XP_MACOSX)
|
||||
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing);
|
||||
#endif
|
||||
NS_OVERRIDE
|
||||
virtual nsresult SetBackgroundUnknown(NPP instance);
|
||||
NS_OVERRIDE
|
||||
virtual nsresult BeginUpdateBackground(NPP instance,
|
||||
const nsIntRect&, gfxContext** aCtx);
|
||||
NS_OVERRIDE
|
||||
virtual nsresult EndUpdateBackground(NPP instance,
|
||||
gfxContext* aCtx, const nsIntRect&);
|
||||
|
||||
private:
|
||||
NP_InitializeFunc mNP_Initialize;
|
||||
|
|
|
@ -850,12 +850,7 @@ nsNPAPIPluginInstance::AsyncSetWindow(NPWindow* window)
|
|||
if (RUNNING != mRunning)
|
||||
return NS_OK;
|
||||
|
||||
PluginDestructionGuard guard(this);
|
||||
|
||||
if (!mPlugin)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PluginLibrary* library = mPlugin->GetLibrary();
|
||||
AutoPluginLibraryCall library(this);
|
||||
if (!library)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -868,12 +863,7 @@ nsNPAPIPluginInstance::GetSurface(gfxASurface** aSurface)
|
|||
if (RUNNING != mRunning)
|
||||
return NS_OK;
|
||||
|
||||
PluginDestructionGuard guard(this);
|
||||
|
||||
if (!mPlugin)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PluginLibrary* library = mPlugin->GetLibrary();
|
||||
AutoPluginLibraryCall library(this);
|
||||
if (!library)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -905,12 +895,7 @@ nsNPAPIPluginInstance::UseAsyncPainting(PRBool* aIsAsync)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PluginDestructionGuard guard(this);
|
||||
|
||||
if (!mPlugin)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PluginLibrary* library = mPlugin->GetLibrary();
|
||||
AutoPluginLibraryCall library(this);
|
||||
if (!library)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -918,6 +903,47 @@ nsNPAPIPluginInstance::UseAsyncPainting(PRBool* aIsAsync)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNPAPIPluginInstance::SetBackgroundUnknown()
|
||||
{
|
||||
if (RUNNING != mRunning)
|
||||
return NS_OK;
|
||||
|
||||
AutoPluginLibraryCall library(this);
|
||||
if (!library)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return library->SetBackgroundUnknown(&mNPP);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNPAPIPluginInstance::BeginUpdateBackground(nsIntRect* aRect,
|
||||
gfxContext** aContext)
|
||||
{
|
||||
if (RUNNING != mRunning)
|
||||
return NS_OK;
|
||||
|
||||
AutoPluginLibraryCall library(this);
|
||||
if (!library)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return library->BeginUpdateBackground(&mNPP, *aRect, aContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNPAPIPluginInstance::EndUpdateBackground(gfxContext* aContext,
|
||||
nsIntRect* aRect)
|
||||
{
|
||||
if (RUNNING != mRunning)
|
||||
return NS_OK;
|
||||
|
||||
AutoPluginLibraryCall library(this);
|
||||
if (!library)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return library->EndUpdateBackground(&mNPP, aContext, *aRect);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNPAPIPluginInstance::IsTransparent(PRBool* isTransparent)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче