Bug 1112345 - Tab streaming should scroll stream with layers and not offsets. r=snorp, a=sledru
authorBrad Lassey <blassey@mozilla.com>
Tue, 16 Dec 2014 17:43:23 -0500
changeset 242834 3956d52ad3f0
parent 242833 3b4908a629e8
child 242835 cdd335426a39
push id4319
push userryanvm@gmail.com
push date2015-01-14 14:36 +0000
treeherdermozilla-beta@f6d5f2303fea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, sledru
bugs1112345
milestone36.0
Bug 1112345 - Tab streaming should scroll stream with layers and not offsets. r=snorp, a=sledru
dom/media/webrtc/MediaEngineTabVideoSource.cpp
--- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp
@@ -211,17 +211,16 @@ MediaEngineTabVideoSource::NotifyPull(Me
 }
 
 void
 MediaEngineTabVideoSource::Draw() {
 
   IntSize size(mBufW, mBufH);
 
   nsresult rv;
-  float scale = 1.0;
 
   nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(mWindow);
 
   if (!win) {
     return;
   }
 
   // take a screenshot, as wide as possible, proportional to the destination size
@@ -232,35 +231,24 @@ MediaEngineTabVideoSource::Draw() {
 
   nsCOMPtr<nsIDOMClientRect> rect;
   rv = utils->GetRootBounds(getter_AddRefs(rect));
   NS_ENSURE_SUCCESS_VOID(rv);
   if (!rect) {
     return;
   }
 
-  float left, top, width, height;
-  rect->GetLeft(&left);
-  rect->GetTop(&top);
+  float width, height;
   rect->GetWidth(&width);
   rect->GetHeight(&height);
 
-  if (mScrollWithPage) {
-    nsPoint point;
-    utils->GetScrollXY(false, &point.x, &point.y);
-    left += point.x;
-    top += point.y;
-  }
-
   if (width == 0 || height == 0) {
     return;
   }
 
-  int32_t srcX = left;
-  int32_t srcY = top;
   int32_t srcW;
   int32_t srcH;
 
   float aspectRatio = ((float) size.width) / size.height;
   if (width / aspectRatio < height) {
     srcW = width;
     srcH = width / aspectRatio;
   } else {
@@ -271,42 +259,43 @@ MediaEngineTabVideoSource::Draw() {
   nsRefPtr<nsPresContext> presContext;
   nsIDocShell* docshell = win->GetDocShell();
   if (docshell) {
     docshell->GetPresContext(getter_AddRefs(presContext));
   }
   if (!presContext) {
     return;
   }
+
   nscolor bgColor = NS_RGB(255, 255, 255);
   nsCOMPtr<nsIPresShell> presShell = presContext->PresShell();
-  uint32_t renderDocFlags = (nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING |
-                             nsIPresShell::RENDER_DOCUMENT_RELATIVE);
-  nsRect r(nsPresContext::CSSPixelsToAppUnits(srcX / scale),
-           nsPresContext::CSSPixelsToAppUnits(srcY / scale),
-           nsPresContext::CSSPixelsToAppUnits(srcW / scale),
-           nsPresContext::CSSPixelsToAppUnits(srcH / scale));
+  uint32_t renderDocFlags = nsIPresShell::RENDER_DOCUMENT_RELATIVE;
+  if (!mScrollWithPage) {
+    renderDocFlags |= nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING;
+  }
+  nsRect r(0, 0, nsPresContext::CSSPixelsToAppUnits((float)srcW),
+           nsPresContext::CSSPixelsToAppUnits((float)srcH));
 
   gfxImageFormat format = gfxImageFormat::RGB24;
   uint32_t stride = gfxASurface::FormatStrideForWidth(format, size.width);
 
   nsRefPtr<layers::ImageContainer> container = layers::LayerManager::CreateImageContainer();
   RefPtr<DrawTarget> dt =
     Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                      mData.rwget(),
                                      size,
                                      stride,
                                      SurfaceFormat::B8G8R8X8);
   if (!dt) {
     return;
   }
   nsRefPtr<gfxContext> context = new gfxContext(dt);
-  context->SetMatrix(
-    context->CurrentMatrix().Scale(scale * size.width / srcW,
-                                   scale * size.height / srcH));
+  context->SetMatrix(context->CurrentMatrix().Scale((float)size.width/srcW,
+                                                    (float)size.height/srcH));
+
   rv = presShell->RenderDocument(r, renderDocFlags, bgColor, context);
 
   NS_ENSURE_SUCCESS_VOID(rv);
 
   RefPtr<SourceSurface> surface = dt->Snapshot();
   if (!surface) {
     return;
   }