Add sticky transform to surfaceflinger.

Bug: 15116722

- Adds a sticky transform field that can be set from a
  SurfaceFlinger client Surface.  This transform is
  added to any transform applied to the Surface.

Change-Id: Idaa4311dfd027b2d2b8ea5e2c6cba2da5779d753
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 63bc257..4861e34 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -624,6 +624,17 @@
     engine.disableBlending();
 }
 
+uint32_t Layer::getProducerStickyTransform() const {
+    int producerStickyTransform = 0;
+    int ret = mProducer->query(NATIVE_WINDOW_STICKY_TRANSFORM, &producerStickyTransform);
+    if (ret != OK) {
+        ALOGW("%s: Error %s (%d) while querying window sticky transform.", __FUNCTION__,
+                strerror(-ret), ret);
+        return 0;
+    }
+    return static_cast<uint32_t>(producerStickyTransform);
+}
+
 void Layer::setFiltering(bool filtering) {
     mFiltering = filtering;
 }
@@ -992,10 +1003,12 @@
             Layer::State& front;
             Layer::State& current;
             bool& recomputeVisibleRegions;
+            bool stickyTransformSet;
             Reject(Layer::State& front, Layer::State& current,
-                    bool& recomputeVisibleRegions)
+                    bool& recomputeVisibleRegions, bool stickySet)
                 : front(front), current(current),
-                  recomputeVisibleRegions(recomputeVisibleRegions) {
+                  recomputeVisibleRegions(recomputeVisibleRegions),
+                  stickyTransformSet(stickySet) {
             }
 
             virtual bool reject(const sp<GraphicBuffer>& buf,
@@ -1058,12 +1071,12 @@
                             front.requested.crop.getHeight());
                 }
 
-                if (!isFixedSize) {
+                if (!isFixedSize && !stickyTransformSet) {
                     if (front.active.w != bufWidth ||
                         front.active.h != bufHeight) {
                         // reject this buffer
-                        //ALOGD("rejecting buffer: bufWidth=%d, bufHeight=%d, front.active.{w=%d, h=%d}",
-                        //        bufWidth, bufHeight, front.active.w, front.active.h);
+                        ALOGE("rejecting buffer: bufWidth=%d, bufHeight=%d, front.active.{w=%d, h=%d}",
+                                bufWidth, bufHeight, front.active.w, front.active.h);
                         return true;
                     }
                 }
@@ -1092,8 +1105,8 @@
             }
         };
 
-
-        Reject r(mDrawingState, getCurrentState(), recomputeVisibleRegions);
+        Reject r(mDrawingState, getCurrentState(), recomputeVisibleRegions,
+                getProducerStickyTransform() != 0);
 
         status_t updateResult = mSurfaceFlingerConsumer->updateTexImage(&r,
                 mFlinger->mPrimaryDispSync);
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index ee9f8a0..2d8084d 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -339,6 +339,9 @@
     void drawWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip,
             bool useIdentityTransform) const;
 
+    // Temporary - Used only for LEGACY camera mode.
+    uint32_t getProducerStickyTransform() const;
+
 
     // -----------------------------------------------------------------------