Define shadow casting behavior within layers

bug:15860114

Savelayers and HW layers both now support shadow casting.

For save layers, the light source should always be correct, for HW
layers, the light source position is set when the layer is created,
and updated when it is resized.

Change-Id: Ie85567dd43c2bb0a0b08fd0bd4db41efa793ac2b
diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp
index 15bed58..054a164 100644
--- a/libs/hwui/DamageAccumulator.cpp
+++ b/libs/hwui/DamageAccumulator.cpp
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "DamageAccumulator"
-
 #include "DamageAccumulator.h"
 
 #include <cutils/log.h>
@@ -26,12 +24,6 @@
 namespace android {
 namespace uirenderer {
 
-NullDamageAccumulator NullDamageAccumulator::sInstance;
-
-NullDamageAccumulator* NullDamageAccumulator::instance() {
-    return &sInstance;
-}
-
 enum TransformType {
     TransformInvalid = 0,
     TransformRenderNode,
@@ -60,6 +52,30 @@
     mHead->type = TransformNone;
 }
 
+static void computeTransformImpl(const DirtyStack* currentFrame, Matrix4* outMatrix) {
+    if (currentFrame->prev != currentFrame) {
+        computeTransformImpl(currentFrame->prev, outMatrix);
+    }
+    switch (currentFrame->type) {
+    case TransformRenderNode:
+        currentFrame->renderNode->applyViewPropertyTransforms(*outMatrix);
+        break;
+    case TransformMatrix4:
+        outMatrix->multiply(*currentFrame->matrix4);
+        break;
+    case TransformNone:
+        // nothing to be done
+        break;
+    default:
+        LOG_ALWAYS_FATAL("Tried to compute transform with an invalid type: %d", currentFrame->type);
+    }
+}
+
+void DamageAccumulator::computeCurrentTransform(Matrix4* outMatrix) const {
+    outMatrix->loadIdentity();
+    computeTransformImpl(mHead, outMatrix);
+}
+
 void DamageAccumulator::pushCommon() {
     if (!mHead->next) {
         DirtyStack* nextFrame = (DirtyStack*) mAllocator.alloc(sizeof(DirtyStack));