Bug 1245959 - Check plugin has non-zero dimensions before sending image to compositor. r?nical draft
authorJamie Nicol <jnicol@mozilla.com>
Mon, 19 Sep 2016 13:28:05 +0100
changeset 415422 b268ff72101e8ac7423e27a3482dd494f7bcf2c2
parent 415108 fd0564234eca242b7fb753a110312679020f8059
child 415423 7ba4791da0afef1d0a382eaf8ffdd31b26898320
push id29866
push userbmo:jnicol@mozilla.com
push dateTue, 20 Sep 2016 09:24:28 +0000
reviewersnical
bugs1245959
milestone52.0a1
Bug 1245959 - Check plugin has non-zero dimensions before sending image to compositor. r?nical MozReview-Commit-ID: KEd5IBUGlo6
dom/plugins/base/nsPluginInstanceOwner.cpp
--- 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;