Bug 1310064 - mark MediaEngineTabVideoSource draw target as uninitialized to avoid triggering assertion with Skia. r=lsalzman, jesup
authorvincentliu <vliu@mozilla.com>
Tue, 06 Dec 2016 21:52:02 -1000
changeset 325374 eef062272d1951b7c2e650b69cace6ba6f1023d0
parent 325337 f863d5050b3f71218c001804f97ca98474b2bae6
child 325375 3bb432e68db4e89ce6b5e11f022cfe3ca04fd751
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerslsalzman, jesup
bugs1310064
milestone53.0a1
Bug 1310064 - mark MediaEngineTabVideoSource draw target as uninitialized to avoid triggering assertion with Skia. r=lsalzman, jesup --- dom/media/webrtc/MediaEngineTabVideoSource.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
dom/media/webrtc/MediaEngineTabVideoSource.cpp
--- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp
@@ -324,39 +324,43 @@ MediaEngineTabVideoSource::Draw() {
       return;
     }
     presShell = presContext->PresShell();
   }
 
   RefPtr<layers::ImageContainer> container =
     layers::LayerManager::CreateImageContainer(layers::ImageContainer::ASYNCHRONOUS);
   RefPtr<DrawTarget> dt =
-    Factory::CreateDrawTargetForData(BackendType::CAIRO,
+    Factory::CreateDrawTargetForData(gfxPlatform::GetPlatform()->GetSoftwareBackend(),
                                      mData.get(),
                                      size,
                                      stride,
-                                     SurfaceFormat::B8G8R8X8);
+                                     SurfaceFormat::B8G8R8X8,
+                                     true);
   if (!dt || !dt->IsValid()) {
     return;
   }
-  RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
-  MOZ_ASSERT(context); // already checked the draw target above
-  context->SetMatrix(context->CurrentMatrix().Scale((((float) size.width)/mViewportWidth),
-                                                    (((float) size.height)/mViewportHeight)));
 
   if (mWindow) {
+    RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
+    MOZ_ASSERT(context); // already checked the draw target above
+    context->SetMatrix(context->CurrentMatrix().Scale((((float) size.width)/mViewportWidth),
+                                                      (((float) size.height)/mViewportHeight)));
+
     nscolor bgColor = NS_RGB(255, 255, 255);
     uint32_t renderDocFlags = mScrollWithPage? 0 :
       (nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING |
        nsIPresShell::RENDER_DOCUMENT_RELATIVE);
     nsRect r(nsPresContext::CSSPixelsToAppUnits((float)mViewportOffsetX),
              nsPresContext::CSSPixelsToAppUnits((float)mViewportOffsetY),
              nsPresContext::CSSPixelsToAppUnits((float)mViewportWidth),
              nsPresContext::CSSPixelsToAppUnits((float)mViewportHeight));
     NS_ENSURE_SUCCESS_VOID(presShell->RenderDocument(r, renderDocFlags, bgColor, context));
+  } else {
+    dt->ClearRect(Rect(0, 0, size.width, size.height));
   }
 
   RefPtr<SourceSurface> surface = dt->Snapshot();
   if (!surface) {
     return;
   }
 
   RefPtr<layers::SourceSurfaceImage> image = new layers::SourceSurfaceImage(size, surface);