Merge latest green fx-team changeset and mozilla-central
authorEd Morley <emorley@mozilla.com>
Wed, 07 Aug 2013 16:17:05 -0700
changeset 154579 45128af1773980dc890cd698bed16678f9413547
parent 154578 4e2e139c6b83a028c92820e3a8d705bfcf1cd0e2 (current diff)
parent 154560 74258a163eb07e11c4c5c84a5e36753a3f4bef30 (diff)
child 154584 08e15a158e83b9854854674f27b5e356132acd0a
child 154652 56912957f3e96b7a549202dab4e96cd321da3daa
child 154676 d2c0f6d0fea58462baaa75f0cf61ba2fb0965397
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge latest green fx-team changeset and mozilla-central
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,4 +1,4 @@
 {
-    "revision": "ca81894022ba9094e24f6f1d233ef0ebb1b59bba", 
+    "revision": "acd53f668718d06090805303ed85e36dddf61853", 
     "repo_path": "/integration/gaia-central"
 }
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -1253,68 +1253,60 @@ private:
 
     return true;
   }
 };
 
 class PrepareAdapterRunnable : public nsRunnable
 {
 public:
+  PrepareAdapterRunnable(const nsAString& aAdapterPath)
+    : mAdapterPath(aAdapterPath)
+  { }
+
   NS_IMETHOD Run()
   {
     static const dbus_uint32_t sServices[] = {
       BluetoothServiceClass::HANDSFREE_AG,
       BluetoothServiceClass::HEADSET_AG,
       BluetoothServiceClass::OBJECT_PUSH
     };
 
-    MOZ_ASSERT(!NS_IsMainThread());
-
-    nsRefPtr<DBusReplyHandler> handler = new AddReservedServiceRecordsReplyHandler();
-    MOZ_ASSERT(handler.get());
+    MOZ_ASSERT(NS_IsMainThread());
+
+    nsRefPtr<RawDBusConnection> threadConnection = gThreadConnection;
+
+    if (!threadConnection.get()) {
+      BT_WARNING("%s: DBus connection has been closed.", __FUNCTION__);
+      return false;
+    }
+
+    sAdapterPath = mAdapterPath;
+
+    nsRefPtr<DBusReplyHandler> handler =
+      new AddReservedServiceRecordsReplyHandler();
 
     const dbus_uint32_t* services = sServices;
 
-    bool success = dbus_func_args_async(gThreadConnection->GetConnection(), -1,
+    bool success = dbus_func_args_async(threadConnection->GetConnection(), -1,
                                         DBusReplyHandler::Callback, handler.get(),
                                         NS_ConvertUTF16toUTF8(sAdapterPath).get(),
                                         DBUS_ADAPTER_IFACE, "AddReservedServiceRecords",
                                         DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
                                         &services, NS_ARRAY_LENGTH(sServices),
                                         DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE(success, NS_ERROR_FAILURE);
 
     handler.forget();
 
     return NS_OK;
   }
-};
-
-class PrepareAdapterTask : public nsRunnable
-{
-public:
-  PrepareAdapterTask(const nsAString& aPath)
-    : mPath(aPath)
-  {
-  }
-
-  nsresult Run()
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    BluetoothService* bs = BluetoothService::Get();
-    NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
-    sAdapterPath = mPath;
-    nsRefPtr<nsRunnable> func(new PrepareAdapterRunnable());
-    bs->DispatchToCommandThread(func);
-    return NS_OK;
-  }
 
 private:
-  nsString mPath;
+  nsString mAdapterPath;
 };
 
 class SendPlayStatusTask : public nsRunnable
 {
 public:
   SendPlayStatusTask()
   {
     MOZ_ASSERT(!NS_IsMainThread());
@@ -1512,17 +1504,17 @@ EventFilter(DBusConnection* aConn, DBusM
     const char* str;
     if (!dbus_message_get_args(aMsg, &err,
                                DBUS_TYPE_OBJECT_PATH, &str,
                                DBUS_TYPE_INVALID)) {
       LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, aMsg);
       errorStr.AssignLiteral("Cannot parse manager path!");
     } else {
       v = NS_ConvertUTF8toUTF16(str);
-      NS_DispatchToMainThread(new PrepareAdapterTask(v.get_nsString()));
+      NS_DispatchToMainThread(new PrepareAdapterRunnable(v.get_nsString()));
     }
   } else if (dbus_message_is_signal(aMsg, DBUS_MANAGER_IFACE,
                                     "PropertyChanged")) {
     ParsePropertyChange(aMsg,
                         v,
                         errorStr,
                         sManagerProperties,
                         ArrayLength(sManagerProperties));
@@ -1666,20 +1658,20 @@ BluetoothDBusService::StartInternal()
   if (!sAuthorizeReqTable.IsInitialized()) {
     sAuthorizeReqTable.Init();
   }
 
   BluetoothValue v;
   nsAutoString replyError;
   if (!GetDefaultAdapterPath(v, replyError)) {
     // Adapter path is not ready yet
-    // Let's do PrepareAdapterTask when we receive signal 'AdapterAdded'
+    // Let's do PrepareAdapterRunnable when we receive signal 'AdapterAdded'
   } else {
-    // Adapter path has been ready. let's do PrepareAdapterTask now
-    nsRefPtr<PrepareAdapterTask> b = new PrepareAdapterTask(v.get_nsString());
+    // Adapter path has been ready. let's do PrepareAdapterRunnable now
+    nsRefPtr<PrepareAdapterRunnable> b = new PrepareAdapterRunnable(v.get_nsString());
     if (NS_FAILED(NS_DispatchToMainThread(b))) {
       NS_WARNING("Failed to dispatch to main thread!");
     }
   }
 
   return NS_OK;
 }
 
--- a/gfx/layers/composite/APZCTreeManager.cpp
+++ b/gfx/layers/composite/APZCTreeManager.cpp
@@ -62,35 +62,39 @@ APZCTreeManager::UpdatePanZoomController
   Collect(mRootApzc, &apzcsToDestroy);
   mRootApzc = nullptr;
 
   if (aRoot) {
     UpdatePanZoomControllerTree(aCompositor,
                                 aRoot,
                                 // aCompositor is null in gtest scenarios
                                 aCompositor ? aCompositor->RootLayerTreeId() : 0,
-                                nullptr, nullptr,
+                                gfx3DMatrix(), nullptr, nullptr,
                                 aIsFirstPaint, aFirstPaintLayersId,
                                 &apzcsToDestroy);
   }
 
   for (int i = apzcsToDestroy.Length() - 1; i >= 0; i--) {
     APZC_LOG("Destroying APZC at %p\n", apzcsToDestroy[i].get());
     apzcsToDestroy[i]->Destroy();
   }
 }
 
 AsyncPanZoomController*
 APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
                                              Layer* aLayer, uint64_t aLayersId,
+                                             gfx3DMatrix aTransform,
                                              AsyncPanZoomController* aParent,
                                              AsyncPanZoomController* aNextSibling,
                                              bool aIsFirstPaint, uint64_t aFirstPaintLayersId,
                                              nsTArray< nsRefPtr<AsyncPanZoomController> >* aApzcsToDestroy)
 {
+  // Accumulate the CSS transform between layers that have an APZC
+  aTransform = aTransform * aLayer->GetTransform();
+
   ContainerLayer* container = aLayer->AsContainerLayer();
   AsyncPanZoomController* controller = nullptr;
   if (container) {
     if (container->GetFrameMetrics().IsScrollable()) {
       const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aLayersId);
       if (state && state->mController.get()) {
         // If we get here, aLayer is a scrollable container layer and somebody
         // has registered a GeckoContentController for it, so we need to ensure
@@ -111,23 +115,23 @@ APZCTreeManager::UpdatePanZoomController
           controller->SetPrevSibling(nullptr);
           controller->SetLastChild(nullptr);
         }
         APZC_LOG("Using APZC %p for layer %p with identifiers %lld %lld\n", controller, aLayer, aLayersId, container->GetFrameMetrics().mScrollId);
 
         controller->NotifyLayersUpdated(container->GetFrameMetrics(),
                                         aIsFirstPaint && (aLayersId == aFirstPaintLayersId));
 
-        gfx3DMatrix transform = container->GetEffectiveTransform();
         LayerRect visible = container->GetFrameMetrics().mViewport * container->GetFrameMetrics().LayersPixelsPerCSSPixel();
-        gfxRect transformed = transform.TransformBounds(gfxRect(visible.x, visible.y, visible.width, visible.height));
-        controller->SetVisibleRegion(transformed);
-        APZC_LOG("Setting rect(%f %f %f %f) as visible region for %p\n", transformed.x, transformed.y,
-                                                                         transformed.width, transformed.height,
-                                                                         controller);
+        controller->SetLayerHitTestData(visible, aTransform);
+        // Reset the accumulated transform once we hit a layer with an APZC
+        aTransform = gfx3DMatrix();
+        APZC_LOG("Setting rect(%f %f %f %f) as visible region for APZC %p\n", visible.x, visible.y,
+                                                                              visible.width, visible.height,
+                                                                              controller);
 
         // Bind the APZC instance into the tree of APZCs
         if (aNextSibling) {
           aNextSibling->SetPrevSibling(controller);
         } else if (aParent) {
           aParent->SetLastChild(controller);
         } else {
           mRootApzc = controller;
@@ -139,17 +143,17 @@ APZCTreeManager::UpdatePanZoomController
     }
 
     container->SetAsyncPanZoomController(controller);
   }
 
   uint64_t childLayersId = (aLayer->AsRefLayer() ? aLayer->AsRefLayer()->GetReferentId() : aLayersId);
   AsyncPanZoomController* next = nullptr;
   for (Layer* child = aLayer->GetLastChild(); child; child = child->GetPrevSibling()) {
-    next = UpdatePanZoomControllerTree(aCompositor, child, childLayersId, aParent, next,
+    next = UpdatePanZoomControllerTree(aCompositor, child, childLayersId, aTransform, aParent, next,
                                        aIsFirstPaint, aFirstPaintLayersId, aApzcsToDestroy);
   }
 
   // Return the APZC that should be the sibling of other APZCs as we continue
   // moving towards the first child at this depth in the layer tree.
   // If this layer doesn't have a controller, we promote any APZCs in the subtree
   // upwards. Otherwise we fall back to the aNextSibling that was passed in.
   if (controller) {
@@ -361,26 +365,30 @@ APZCTreeManager::FindTargetAPZC(AsyncPan
     return aApzc;
   }
   return nullptr;
 }
 
 AsyncPanZoomController*
 APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc, gfxPoint aHitTestPoint)
 {
+  gfx3DMatrix transform = gfx3DMatrix(aApzc->GetCurrentAsyncTransform()) * aApzc->GetCSSTransform();
+  gfx3DMatrix untransform = transform.Inverse();
+  gfxPoint untransformed = untransform.ProjectPoint(aHitTestPoint);
+  APZC_LOG("Untransformed %f %f to %f %f for APZC %p\n", aHitTestPoint.x, aHitTestPoint.y, untransformed.x, untransformed.y, aApzc);
+
   // This walks the tree in depth-first, reverse order, so that it encounters
   // APZCs front-to-back on the screen.
-  ViewTransform apzcTransform = aApzc->GetCurrentAsyncTransform();
-  gfxPoint untransformed = gfx3DMatrix(apzcTransform).Inverse().ProjectPoint(aHitTestPoint);
   for (AsyncPanZoomController* child = aApzc->GetLastChild(); child; child = child->GetPrevSibling()) {
     AsyncPanZoomController* match = GetAPZCAtPoint(child, untransformed);
     if (match) {
       return match;
     }
   }
-  if (aApzc->VisibleRegionContains(untransformed)) {
+  if (aApzc->VisibleRegionContains(LayerPoint(untransformed.x, untransformed.y))) {
+    APZC_LOG("Successfully matched untransformed point %f %f to visible region for APZC %p\n", untransformed.x, untransformed.y, aApzc);
     return aApzc;
   }
   return nullptr;
 }
 
 }
 }
--- a/gfx/layers/composite/APZCTreeManager.h
+++ b/gfx/layers/composite/APZCTreeManager.h
@@ -248,16 +248,17 @@ private:
    * Note that this means APZCs corresponding to layers at different depths in the tree
    * may end up becoming siblings. It also means that the "root" APZC may have siblings.
    * This function walks the layer tree backwards through siblings and constructs the APZC
    * tree also as a last-child-prev-sibling tree because that simplifies the hit detection
    * code.
    */
   AsyncPanZoomController* UpdatePanZoomControllerTree(CompositorParent* aCompositor,
                                                       Layer* aLayer, uint64_t aLayersId,
+                                                      gfx3DMatrix aTransform,
                                                       AsyncPanZoomController* aParent,
                                                       AsyncPanZoomController* aNextSibling,
                                                       bool aIsFirstPaint,
                                                       uint64_t aFirstPaintLayersId,
                                                       nsTArray< nsRefPtr<AsyncPanZoomController> >* aApzcsToDestroy);
 
 private:
   /* Whenever walking or mutating the tree rooted at mRootApzc, mTreeLock must be held.
--- a/gfx/layers/ipc/AsyncPanZoomController.h
+++ b/gfx/layers/ipc/AsyncPanZoomController.h
@@ -11,16 +11,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/RefPtr.h"
 #include "InputData.h"
 #include "Axis.h"
 #include "TaskThrottler.h"
 #include "mozilla/layers/APZCTreeManager.h"
+#include "gfx3DMatrix.h"
 
 #include "base/message_loop.h"
 
 namespace mozilla {
 namespace layers {
 
 struct ScrollableLayerGuid;
 class CompositorParent;
@@ -636,25 +637,36 @@ private:
   nsRefPtr<AsyncPanZoomController> mLastChild;
   nsRefPtr<AsyncPanZoomController> mPrevSibling;
 
   /* The functions and members in this section are used to maintain the
    * area that this APZC instance is responsible for. This is used when
    * hit-testing to see which APZC instance should handle touch events.
    */
 public:
-  void SetVisibleRegion(gfxRect rect) { mVisibleRegion = rect; }
+  void SetLayerHitTestData(const LayerRect& aRect, const gfx3DMatrix& aTransform) {
+    mVisibleRect = aRect;
+    mCSSTransform = aTransform;
+  }
 
-  bool VisibleRegionContains(const gfxPoint& aPoint) const {
-    return mVisibleRegion.Contains(aPoint.x, aPoint.y);
+  gfx3DMatrix GetCSSTransform() const {
+    return mCSSTransform;
+  }
+
+  bool VisibleRegionContains(const LayerPoint& aPoint) const {
+    return mVisibleRect.Contains(aPoint);
   }
 
 private:
-  /* This is the viewport of the layer that this APZC corresponds to, but
-   * post-transform. In other words, it is in the coordinate space of its
-   * parent layer. */
-  gfxRect mVisibleRegion;
+  /* This is the viewport of the layer that this APZC corresponds to, in
+   * layer pixels. It position here does not account for any transformations
+   * applied to any layers, whether they are CSS transforms or async
+   * transforms. */
+  LayerRect mVisibleRect;
+  /* This is the cumulative layer transform from the parent APZC down to this
+   * one. */
+  gfx3DMatrix mCSSTransform;
 };
 
 }
 }
 
 #endif // mozilla_layers_PanZoomController_h
--- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp
+++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp
@@ -416,30 +416,30 @@ TEST(APZCTreeManager, GetAPZCAtPoint) {
   EXPECT_EQ(nullAPZC, hit.get());
   hit = manager->GetTargetAPZC(ScreenPoint(-1000, 10));
   EXPECT_EQ(nullAPZC, hit.get());
 
   // Test layer transform
   gfx3DMatrix transform;
   transform.ScalePost(0.1, 0.1, 1);
   root->SetBaseTransform(transform);
-  root->ComputeEffectiveTransforms(gfx3DMatrix());
   manager->UpdatePanZoomControllerTree(nullptr, root, 0, false);
   hit = manager->GetTargetAPZC(ScreenPoint(50, 50)); // This point is now outside the root layer
   EXPECT_EQ(nullAPZC, hit.get());
 
+  // This hit test will hit both layers[3] and layers[4]; layers[4] is later in the tree so
+  // it is a better match
   hit = manager->GetTargetAPZC(ScreenPoint(2, 2));
-  EXPECT_EQ(layers[3]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
+  EXPECT_EQ(layers[4]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
   // expect hit point at LayerPoint(20, 20)
 
   // Scale layer[4] outside the range
   layers[4]->SetBaseTransform(transform);
   // layer 4 effective visible screenrect: (0.05, 0.05, 0.2, 0.2)
   // Does not contain (2, 2)
-  root->ComputeEffectiveTransforms(gfx3DMatrix());
   manager->UpdatePanZoomControllerTree(nullptr, root, 0, false);
   hit = manager->GetTargetAPZC(ScreenPoint(2, 2));
   EXPECT_EQ(layers[3]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
   // expect hit point at LayerPoint(20, 20)
 
   // Transformation chain to layer 7
   SetScrollableFrameMetrics(layers[7], FrameMetrics::START_SCROLL_ID + 2, mcc);
 
@@ -450,17 +450,16 @@ TEST(APZCTreeManager, GetAPZCAtPoint) {
   gfx3DMatrix translateTransform2;
   translateTransform2.Translate(gfxPoint3D(-20, 0, 0));
   layers[6]->SetBaseTransform(translateTransform2);
 
   gfx3DMatrix translateTransform3;
   translateTransform3.ScalePost(1,15,1);
   layers[7]->SetBaseTransform(translateTransform3);
 
-  root->ComputeEffectiveTransforms(gfx3DMatrix());
   manager->UpdatePanZoomControllerTree(nullptr, root, 0, false);
   // layer 7 effective visible screenrect (0,16,4,60) but clipped by parent layers
   hit = manager->GetTargetAPZC(ScreenPoint(1, 45));
   EXPECT_EQ(layers[7]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
   // expect hit point at LayerPoint(20, 29)
 
   manager->ClearTree();
 }
--- a/widget/gonk/libdisplay/BootAnimation.cpp
+++ b/widget/gonk/libdisplay/BootAnimation.cpp
@@ -519,18 +519,37 @@ AnimationThread(void *)
                                    GRALLOC_USAGE_SW_READ_NEVER |
                                    GRALLOC_USAGE_SW_WRITE_OFTEN |
                                    GRALLOC_USAGE_HW_FB,
                                    0, 0, width, height, &vaddr)) {
                     LOGW("Failed to lock buffer_handle_t");
                     display->QueueBuffer(buf);
                     break;
                 }
-                memcpy(vaddr, frame.buf,
-                       frame.width * frame.height * frame.bytepp);
+
+                if (buf->height == frame.height && buf->width == frame.width) {
+                    memcpy(vaddr, frame.buf,
+                           frame.width * frame.height * frame.bytepp);
+                } else if (buf->height >= frame.height &&
+                           buf->width >= frame.width) {
+                    int startx = (buf->width - frame.width) / 2;
+                    int starty = (buf->height - frame.height) / 2;
+
+                    int src_stride = frame.width * frame.bytepp;
+                    int dst_stride = buf->stride * frame.bytepp;
+
+                    char *src = frame.buf;
+                    char *dst = (char *) vaddr + starty * dst_stride + startx * frame.bytepp;
+
+                    for (int i = 0; i < frame.height; i++) {
+                        memcpy(dst, src, src_stride);
+                        src += src_stride;
+                        dst += dst_stride;
+                    }
+                }
                 grmodule->unlock(grmodule, buf->handle);
 
                 gettimeofday(&tv2, nullptr);
 
                 timersub(&tv2, &tv1, &tv2);
 
                 if (tv2.tv_usec < frameDelayUs) {
                     usleep(frameDelayUs - tv2.tv_usec);