Bug 626602, part 8: Dig a tunnel from nsObjectFrame to PluginInstanceParent for background copying. r=bsmedberg sr=roc

This commit is contained in:
Chris Jones 2011-02-16 16:43:31 -06:00
Родитель 3e5b9df077
Коммит 42f9cd63c6
9 изменённых файлов: 201 добавлений и 24 удалений

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

@ -282,6 +282,11 @@ public:
#ifdef XP_MACOSX #ifdef XP_MACOSX
nsresult IsRemoteDrawingCoreAnimation(PRBool *aDrawing); nsresult IsRemoteDrawingCoreAnimation(PRBool *aDrawing);
#endif #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: private:
// Quirks mode support for various plugin mime types // Quirks mode support for various plugin mime types

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

@ -46,9 +46,11 @@
#include "nsTArray.h" #include "nsTArray.h"
#include "nsPluginError.h" #include "nsPluginError.h"
class nsNPAPIPlugin;
class gfxASurface; class gfxASurface;
class gfxContext;
class nsCString; class nsCString;
struct nsIntRect;
class nsNPAPIPlugin;
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -102,6 +104,16 @@ public:
#if defined(XP_MACOSX) #if defined(XP_MACOSX)
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing) = 0; virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing) = 0;
#endif #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); 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) #if defined(XP_UNIX) && !defined(XP_MACOSX)
nsresult nsresult
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)

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

@ -233,6 +233,16 @@ private:
virtual nsresult GetSurface(NPP instance, gfxASurface** aSurface); virtual nsresult GetSurface(NPP instance, gfxASurface** aSurface);
virtual nsresult GetImage(NPP instance, mozilla::layers::ImageContainer* aContainer, mozilla::layers::Image** aImage); virtual nsresult GetImage(NPP instance, mozilla::layers::ImageContainer* aContainer, mozilla::layers::Image** aImage);
NS_OVERRIDE virtual bool UseAsyncPainting() { return true; } 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) #if defined(XP_UNIX) && !defined(XP_MACOSX)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error); virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error);

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

@ -470,10 +470,12 @@ public:
// Return true if we set image with valid surface // Return true if we set image with valid surface
PRBool SetCurrentImage(ImageContainer* aContainer); PRBool SetCurrentImage(ImageContainer* aContainer);
// Methods to update the background image we send to async plugins // Methods to update the background image we send to async plugins.
void SetBackgroundUnknown() {} // The eventual target of these operations is PluginInstanceParent,
already_AddRefed<gfxContext> BeginUpdateBackground(const nsIntRect& aRect) { return nsnull; } // but it takes several hops to get there.
void EndUpdateBackground(gfxContext* aContext, const nsIntRect& aRect) {} void SetBackgroundUnknown();
already_AddRefed<gfxContext> BeginUpdateBackground(const nsIntRect& aRect);
void EndUpdateBackground(gfxContext* aContext, const nsIntRect& aRect);
PRBool UseAsyncRendering() PRBool UseAsyncRendering()
{ {
@ -511,6 +513,13 @@ private:
return PR_TRUE; 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); void FixUpURLS(const nsString &name, nsAString &value);
nsPluginNativeWindow *mPluginWindow; nsPluginNativeWindow *mPluginWindow;
@ -1982,6 +1991,39 @@ nsPluginInstanceOwner::SetCurrentImage(ImageContainer* aContainer)
return PR_FALSE; 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 mozilla::LayerState
nsObjectFrame::GetLayerState(nsDisplayListBuilder* aBuilder, nsObjectFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager) LayerManager* aManager)

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

@ -49,6 +49,8 @@ interface nsIOutputStream;
struct JSContext; struct JSContext;
struct JSObject; struct JSObject;
class gfxASurface; class gfxASurface;
class gfxContext;
struct nsIntRect;
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -63,8 +65,10 @@ class ImageContainer;
[ptr] native JSContextPtr(JSContext); [ptr] native JSContextPtr(JSContext);
[ptr] native JSObjectPtr(JSObject); [ptr] native JSObjectPtr(JSObject);
[ptr] native gfxASurfacePtr(gfxASurface); [ptr] native gfxASurfacePtr(gfxASurface);
[ptr] native gfxContextPtr(gfxContext);
[ptr] native ImagePtr(mozilla::layers::Image); [ptr] native ImagePtr(mozilla::layers::Image);
[ptr] native ImageContainerPtr(mozilla::layers::ImageContainer); [ptr] native ImageContainerPtr(mozilla::layers::ImageContainer);
[ptr] native nsIntRectPtr(nsIntRect);
[uuid(84994340-E120-4051-824F-D4EE8AEF1A3E)] [uuid(84994340-E120-4051-824F-D4EE8AEF1A3E)]
interface nsIPluginInstance : nsISupports interface nsIPluginInstance : nsISupports
@ -258,10 +262,18 @@ interface nsIPluginInstance : nsISupports
PRBool useAsyncPainting(); PRBool useAsyncPainting();
}; };
// XXX kill me after branching // 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 interface nsIPluginInstance_MOZILLA_2_0_BRANCH : nsIPluginInstance
{ {
PRBool isRemoteDrawingCoreAnimation(); PRBool isRemoteDrawingCoreAnimation();
void getImage(in ImageContainerPtr aContainer, out ImagePtr aImage); 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 #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 } // namespace mozilla

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

@ -146,6 +146,14 @@ public:
#if defined(XP_MACOSX) #if defined(XP_MACOSX)
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing); virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing);
#endif #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: private:
NP_InitializeFunc mNP_Initialize; NP_InitializeFunc mNP_Initialize;

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

@ -850,12 +850,7 @@ nsNPAPIPluginInstance::AsyncSetWindow(NPWindow* window)
if (RUNNING != mRunning) if (RUNNING != mRunning)
return NS_OK; return NS_OK;
PluginDestructionGuard guard(this); AutoPluginLibraryCall library(this);
if (!mPlugin)
return NS_ERROR_FAILURE;
PluginLibrary* library = mPlugin->GetLibrary();
if (!library) if (!library)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -868,12 +863,7 @@ nsNPAPIPluginInstance::GetSurface(gfxASurface** aSurface)
if (RUNNING != mRunning) if (RUNNING != mRunning)
return NS_OK; return NS_OK;
PluginDestructionGuard guard(this); AutoPluginLibraryCall library(this);
if (!mPlugin)
return NS_ERROR_FAILURE;
PluginLibrary* library = mPlugin->GetLibrary();
if (!library) if (!library)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -905,12 +895,7 @@ nsNPAPIPluginInstance::UseAsyncPainting(PRBool* aIsAsync)
return NS_OK; return NS_OK;
} }
PluginDestructionGuard guard(this); AutoPluginLibraryCall library(this);
if (!mPlugin)
return NS_ERROR_FAILURE;
PluginLibrary* library = mPlugin->GetLibrary();
if (!library) if (!library)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -918,6 +903,47 @@ nsNPAPIPluginInstance::UseAsyncPainting(PRBool* aIsAsync)
return NS_OK; 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 NS_IMETHODIMP
nsNPAPIPluginInstance::IsTransparent(PRBool* isTransparent) nsNPAPIPluginInstance::IsTransparent(PRBool* isTransparent)
{ {