Bug 844693 - Remove MacIOSurfaceImage::SetUpdateCallback. r=BenWa

This commit is contained in:
Matt Woodrow 2013-04-17 14:21:06 +12:00
parent 5f2b7f2d84
commit e86ee52760
6 changed files with 7 additions and 113 deletions

View File

@ -149,22 +149,6 @@ nsPluginInstanceOwner::NotifyPaintWaiter(nsDisplayListBuilder* aBuilder)
}
}
#ifdef XP_MACOSX
static void DrawPlugin(ImageContainer* aContainer, void* aPluginInstanceOwner)
{
nsObjectFrame* frame = static_cast<nsPluginInstanceOwner*>(aPluginInstanceOwner)->GetFrame();
if (frame) {
frame->UpdateImageLayer(gfxRect(0,0,0,0));
}
}
static void OnDestroyImage(void* aPluginInstanceOwner)
{
nsPluginInstanceOwner* owner = static_cast<nsPluginInstanceOwner*>(aPluginInstanceOwner);
NS_IF_RELEASE(owner);
}
#endif // XP_MACOSX
already_AddRefed<ImageContainer>
nsPluginInstanceOwner::GetImageContainer()
{
@ -206,22 +190,7 @@ nsPluginInstanceOwner::GetImageContainer()
#endif
mInstance->GetImageContainer(getter_AddRefs(container));
if (container) {
#ifdef XP_MACOSX
AutoLockImage autoLock(container);
Image* image = autoLock.GetImage();
if (image && image->GetFormat() == MAC_IO_SURFACE && mObjectFrame) {
// With this drawing model, every call to
// nsIPluginInstance::GetImage() creates a new image.
MacIOSurfaceImage *oglImage = static_cast<MacIOSurfaceImage*>(image);
NS_ADDREF_THIS();
oglImage->SetUpdateCallback(&DrawPlugin, this);
oglImage->SetDestroyCallback(&OnDestroyImage);
}
#endif
return container.forget();
}
return nullptr;
return container.forget();
}
void
@ -634,7 +603,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(NPRect *invalidRect)
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
// Each time an asynchronously-drawing plugin sends a new surface to display,
// the image in the ImageContainer is updated and InvalidateRect is called.
// MacIOSurfaceImages callbacks are attached here.
// There are different side effects for (sync) Android plugins.
nsRefPtr<ImageContainer> container;
mInstance->GetImageContainer(getter_AddRefs(container));

View File

@ -569,14 +569,6 @@ MacIOSurfaceImage::GetAsSurface()
return imgSurface.forget();
}
void
MacIOSurfaceImage::Update(ImageContainer* aContainer)
{
if (mUpdateCallback) {
mUpdateCallback(aContainer, mPluginInstanceOwner);
}
}
#endif
already_AddRefed<gfxASurface>

View File

@ -806,17 +806,10 @@ public:
MacIOSurfaceImage()
: Image(NULL, MAC_IO_SURFACE)
, mSize(0, 0)
, mPluginInstanceOwner(NULL)
, mUpdateCallback(NULL)
, mDestroyCallback(NULL)
{}
virtual ~MacIOSurfaceImage()
{
if (mDestroyCallback) {
mDestroyCallback(mPluginInstanceOwner);
}
}
{ }
/**
* This can only be called on the main thread. It may add a reference
@ -825,24 +818,6 @@ public:
*/
virtual void SetData(const Data& aData);
/**
* Temporary hacks to force plugin drawing during an empty transaction.
* This should not be used for anything else, and will be removed
* when async plugin rendering is complete.
*/
typedef void (*UpdateSurfaceCallback)(ImageContainer* aContainer, void* aInstanceOwner);
virtual void SetUpdateCallback(UpdateSurfaceCallback aCallback, void* aInstanceOwner)
{
mUpdateCallback = aCallback;
mPluginInstanceOwner = aInstanceOwner;
}
typedef void (*DestroyCallback)(void* aInstanceOwner);
virtual void SetDestroyCallback(DestroyCallback aCallback)
{
mDestroyCallback = aCallback;
}
virtual gfxIntSize GetSize()
{
return mSize;
@ -853,16 +828,11 @@ public:
return mIOSurface;
}
void Update(ImageContainer* aContainer);
virtual already_AddRefed<gfxASurface> GetAsSurface();
private:
gfxIntSize mSize;
RefPtr<MacIOSurface> mIOSurface;
void* mPluginInstanceOwner;
UpdateSurfaceCallback mUpdateCallback;
DestroyCallback mDestroyCallback;
};
#endif

View File

@ -348,22 +348,6 @@ ImageLayerOGL::RenderLayer(int,
MacIOSurfaceImage *ioImage =
static_cast<MacIOSurfaceImage*>(image);
if (!mOGLManager->GetThebesLayerCallback()) {
// If its an empty transaction we still need to update
// the plugin IO Surface and make sure we grab the
// new image
ioImage->Update(GetContainer());
image = nullptr;
autoLock.Refresh();
image = autoLock.GetImage();
gl()->MakeCurrent();
ioImage = static_cast<MacIOSurfaceImage*>(image);
}
if (!ioImage) {
return;
}
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
if (!ioImage->GetBackendData(LAYERS_OPENGL)) {

View File

@ -1534,20 +1534,6 @@ nsObjectFrame::GetPaintedRect(nsDisplayPlugin* aItem)
return r;
}
void
nsObjectFrame::UpdateImageLayer(const gfxRect& aRect)
{
if (!mInstanceOwner) {
return;
}
#ifdef XP_MACOSX
if (!mInstanceOwner->UseAsyncRendering()) {
mInstanceOwner->DoCocoaEventDrawRect(aRect, nullptr);
}
#endif
}
LayerState
nsObjectFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager)
@ -1555,14 +1541,6 @@ nsObjectFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
if (!mInstanceOwner)
return LAYER_NONE;
#ifdef XP_MACOSX
if (!mInstanceOwner->UseAsyncRendering() &&
mInstanceOwner->IsRemoteDrawingCoreAnimation() &&
mInstanceOwner->GetEventModel() == NPEventModelCocoa) {
return LAYER_ACTIVE;
}
#endif
#ifdef MOZ_WIDGET_ANDROID
// We always want a layer on Honeycomb and later
if (AndroidBridge::Bridge()->GetAPIVersion() >= 11)
@ -1626,7 +1604,11 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
NS_ASSERTION(layer->GetType() == Layer::TYPE_IMAGE, "Bad layer type");
ImageLayer* imglayer = static_cast<ImageLayer*>(layer.get());
UpdateImageLayer(r);
#ifdef XP_MACOSX
if (!mInstanceOwner->UseAsyncRendering()) {
mInstanceOwner->DoCocoaEventDrawRect(r, nullptr);
}
#endif
imglayer->SetScaleToSize(size, ImageLayer::SCALE_STRETCH);
imglayer->SetContainer(container);

View File

@ -159,8 +159,6 @@ public:
virtual bool ReflowFinished() MOZ_OVERRIDE;
virtual void ReflowCallbackCanceled() MOZ_OVERRIDE;
void UpdateImageLayer(const gfxRect& aRect);
/**
* Builds either an ImageLayer or a ReadbackLayer, depending on the type
* of aItem (TYPE_PLUGIN or TYPE_PLUGIN_READBACK respectively).