Bug 1245959 - Check plugin has non-zero dimensions before sending image to compositor. r?nical
MozReview-Commit-ID: KEd5IBUGlo6
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -217,22 +217,24 @@ nsPluginInstanceOwner::GetImageContainer
// NotifySize() causes Flash to do a bunch of stuff like ask for surfaces to render
// into, set y-flip flags, etc, so we do this at the beginning.
float resolution = mPluginFrame->PresContext()->PresShell()->GetCumulativeResolution();
ScreenSize screenSize = (r * LayoutDeviceToScreenScale(resolution)).Size();
mInstance->NotifySize(nsIntSize::Truncate(screenSize.width, screenSize.height));
container = LayerManager::CreateImageContainer();
- // Try to get it as an EGLImage first.
- RefPtr<Image> img;
- AttachToContainerAsSurfaceTexture(container, mInstance, r, &img);
-
- if (img) {
- container->SetCurrentImageInTransaction(img);
+ if (r.width && r.height) {
+ // Try to get it as an EGLImage first.
+ RefPtr<Image> img;
+ AttachToContainerAsSurfaceTexture(container, mInstance, r, &img);
+
+ if (img) {
+ container->SetCurrentImageInTransaction(img);
+ }
}
#else
if (NeedsScrollImageLayer()) {
// windowed plugin under e10s
#if defined(XP_WIN)
mInstance->GetScrollCaptureContainer(getter_AddRefs(container));
#endif
} else {
@@ -1573,21 +1575,23 @@ nsPluginInstanceOwner::GetVideos(nsTArra
mInstance->GetVideos(aVideos);
}
already_AddRefed<ImageContainer>
nsPluginInstanceOwner::GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInfo* aVideoInfo)
{
RefPtr<ImageContainer> container = LayerManager::CreateImageContainer();
- RefPtr<Image> img = new SurfaceTextureImage(
- aVideoInfo->mSurfaceTexture,
- gfx::IntSize::Truncate(aVideoInfo->mDimensions.width, aVideoInfo->mDimensions.height),
- gl::OriginPos::BottomLeft);
- container->SetCurrentImageInTransaction(img);
+ if (aVideoInfo->mDimensions.width && aVideoInfo->mDimensions.height) {
+ RefPtr<Image> img = new SurfaceTextureImage(
+ aVideoInfo->mSurfaceTexture,
+ gfx::IntSize::Truncate(aVideoInfo->mDimensions.width, aVideoInfo->mDimensions.height),
+ gl::OriginPos::BottomLeft);
+ container->SetCurrentImageInTransaction(img);
+ }
return container.forget();
}
void nsPluginInstanceOwner::Invalidate() {
NPRect rect;
rect.left = rect.top = 0;
rect.right = mPluginWindow->width;