Bug 634521 - Let mac plugins trigger empty transactions. r=roc a=roc

This commit is contained in:
Matt Woodrow 2011-02-17 16:56:06 +13:00
Родитель 071232a5b8
Коммит df6d09eb2c
7 изменённых файлов: 66 добавлений и 7 удалений

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

@ -361,6 +361,14 @@ public:
*/
virtual void SetData(const Data& aData) = 0;
/**
* 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 SetCallback(UpdateSurfaceCallback aCallback, void* aInstanceOwner) =0;
protected:
MacIOSurfaceImage(void* aImplData) : Image(aImplData, MAC_IO_SURFACE) {}
};

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

@ -295,6 +295,7 @@ ContainerRender(Container* aContainer,
}
layerToRender->RenderLayer(frameBuffer, childOffset);
aContainer->gl()->MakeCurrent();
}
aContainer->gl()->PopScissorRect();

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

@ -466,6 +466,16 @@ ImageLayerOGL::RenderLayer(int,
MacIOSurfaceImageOGL *ioImage =
static_cast<MacIOSurfaceImageOGL*>(image.get());
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 = GetContainer()->GetCurrentImage();
gl()->MakeCurrent();
ioImage = static_cast<MacIOSurfaceImageOGL*>(image.get());
}
gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, ioImage->mTexture.GetTextureID());
ColorTextureLayerProgram *program =

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

@ -51,11 +51,16 @@ class THEBES_API MacIOSurfaceImageOGL : public MacIOSurfaceImage
public:
MacIOSurfaceImageOGL(LayerManagerOGL *aManager);
void SetCallback(UpdateSurfaceCallback aCallback, void* aObjectFrame);
void Update(ImageContainer* aContainer);
void SetData(const Data &aData);
GLTexture mTexture;
gfxIntSize mSize;
nsAutoPtr<nsIOSurface> mIOSurface;
void* mObjectFrame;
UpdateSurfaceCallback mCallback;
};
} /* layers */

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

@ -83,9 +83,24 @@ MacIOSurfaceImageOGL::SetData(const MacIOSurfaceImage::Data &aData)
mIOSurface->CGLTexImageIOSurface2D((CGLContextObj)[nsCtx CGLContextObj],
LOCAL_GL_RGBA, LOCAL_GL_BGRA,
LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV, 0);
gl->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
}
void
MacIOSurfaceImageOGL::SetCallback(UpdateSurfaceCallback aCallback, void* aObjectFrame)
{
mCallback = aCallback;
mObjectFrame = aObjectFrame;
}
void
MacIOSurfaceImageOGL::Update(ImageContainer* aContainer)
{
if (mCallback) {
mCallback(aContainer, mObjectFrame);
}
}
} /* layers */
} /* mozilla */

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

@ -1977,6 +1977,21 @@ nsPluginInstanceOwner::NotifyPaintWaiter(nsDisplayListBuilder* aBuilder)
}
}
static void DrawPlugin(ImageContainer* aContainer, void* aObjectFrame)
{
static_cast<nsObjectFrame*>(aObjectFrame)->UpdateImageLayer(aContainer, gfxRect(0,0,0,0));
}
void
nsObjectFrame::UpdateImageLayer(ImageContainer* aContainer, const gfxRect& aRect)
{
#ifdef XP_MACOSX
mInstanceOwner->DoCocoaEventDrawRect(aRect, nsnull);
#endif
mInstanceOwner->SetCurrentImage(aContainer);
}
PRBool
nsPluginInstanceOwner::SetCurrentImage(ImageContainer* aContainer)
{
@ -1985,6 +2000,12 @@ nsPluginInstanceOwner::SetCurrentImage(ImageContainer* aContainer)
nsRefPtr<Image> image;
inst->GetImage(aContainer, getter_AddRefs(image));
if (image) {
#ifdef XP_MACOSX
if (image->GetFormat() == Image::MAC_IO_SURFACE) {
MacIOSurfaceImage *oglImage = static_cast<MacIOSurfaceImage*>(image.get());
oglImage->SetCallback(&DrawPlugin, mObjectFrame);
}
#endif
aContainer->SetCurrentImage(image);
return PR_TRUE;
}
@ -2094,14 +2115,11 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
return nsnull;
}
#ifdef XP_MACOSX
// Until we get async plugins on mac we need to manually trigger the DrawRect event
mInstanceOwner->DoCocoaEventDrawRect(r, nsnull);
#endif
NS_ASSERTION(layer->GetType() == Layer::TYPE_IMAGE, "Bad layer type");
ImageLayer* imglayer = static_cast<ImageLayer*>(layer.get());
UpdateImageLayer(container, r);
imglayer->SetContainer(container);
imglayer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this));
@ -3491,7 +3509,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(NPRect *invalidRect)
#else
if (mozilla::FrameLayerBuilder::HasDedicatedLayer(mObjectFrame, nsDisplayItem::TYPE_PLUGIN)) {
mObjectFrame->InvalidateWithFlags(rect + mObjectFrame->GetUsedBorderAndPadding().TopLeft(),
nsIFrame::INVALIDATE_NO_THEBES_LAYERS);
nsIFrame::INVALIDATE_NO_UPDATE_LAYER_TREE);
} else {
mObjectFrame->Invalidate(rect + mObjectFrame->GetUsedBorderAndPadding().TopLeft());
}

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

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