SF: Remove setFinalCrop impl 2/2

setFinalCrop functionality is reimplemented by creating a new bounds layer
and applying a crop on this layer. see ag/4625718

Test: mmma frameworks/native/services/surfaceflinger/tests/ && \
mmma frameworks/native/libs/gui/tests/ && adb sync data && \
adb shell /data/nativetest64/libgui_test/libgui_test && \
adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest && \
adb shell /data/nativetest64/SurfaceFlinger_test/SurfaceFlinger_test && \
adb shell /data/nativetest64/SurfaceParcelable_test/SurfaceParcelable_test && \
adb shell /data/nativetest64/sffakehwc_test/sffakehwc_test && \
echo "ALL TESTS PASSED"

Change-Id: I9be511c07a3351a2947afb2beed10ce2a462b635
diff --git a/libs/gui/LayerDebugInfo.cpp b/libs/gui/LayerDebugInfo.cpp
index d3dc16d..ccde9e0 100644
--- a/libs/gui/LayerDebugInfo.cpp
+++ b/libs/gui/LayerDebugInfo.cpp
@@ -42,7 +42,6 @@
     RETURN_ON_ERROR(parcel->writeInt32(mWidth));
     RETURN_ON_ERROR(parcel->writeInt32(mHeight));
     RETURN_ON_ERROR(parcel->write(mCrop));
-    RETURN_ON_ERROR(parcel->write(mFinalCrop));
     RETURN_ON_ERROR(parcel->writeFloat(mColor.r));
     RETURN_ON_ERROR(parcel->writeFloat(mColor.g));
     RETURN_ON_ERROR(parcel->writeFloat(mColor.b));
@@ -81,7 +80,6 @@
     RETURN_ON_ERROR(parcel->readInt32(&mWidth));
     RETURN_ON_ERROR(parcel->readInt32(&mHeight));
     RETURN_ON_ERROR(parcel->read(mCrop));
-    RETURN_ON_ERROR(parcel->read(mFinalCrop));
     mColor.r = parcel->readFloat();
     RETURN_ON_ERROR(parcel->errorCheck());
     mColor.g = parcel->readFloat();
@@ -121,8 +119,7 @@
             info.mLayerStack, info.mZ, static_cast<double>(info.mX), static_cast<double>(info.mY),
             info.mWidth, info.mHeight);
 
-    result.appendFormat("crop=%s, finalCrop=%s, ",
-            to_string(info.mCrop).c_str(), to_string(info.mFinalCrop).c_str());
+    result.appendFormat("crop=%s, ", to_string(info.mCrop).c_str());
     result.appendFormat("isOpaque=%1d, invalidate=%1d, ", info.mIsOpaque, info.mContentDirty);
     result.appendFormat("dataspace=%s, ", dataspaceDetails(info.mDataSpace).c_str());
     result.appendFormat("pixelformat=%s, ", decodePixelFormat(info.mPixelFormat).c_str());
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 05c24c5..deb8ea8 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -38,7 +38,6 @@
     *reinterpret_cast<layer_state_t::matrix22_t *>(
             output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
     output.write(crop_legacy);
-    output.write(finalCrop_legacy);
     output.writeStrongBinder(barrierHandle_legacy);
     output.writeStrongBinder(reparentHandle);
     output.writeUint64(frameNumber_legacy);
@@ -99,7 +98,6 @@
         return BAD_VALUE;
     }
     input.read(crop_legacy);
-    input.read(finalCrop_legacy);
     barrierHandle_legacy = input.readStrongBinder();
     reparentHandle = input.readStrongBinder();
     frameNumber_legacy = input.readUint64();
@@ -248,10 +246,6 @@
         barrierGbp_legacy = other.barrierGbp_legacy;
         frameNumber_legacy = other.frameNumber_legacy;
     }
-    if (other.what & eFinalCropChanged_legacy) {
-        what |= eFinalCropChanged_legacy;
-        finalCrop_legacy = other.finalCrop_legacy;
-    }
     if (other.what & eOverrideScalingModeChanged) {
         what |= eOverrideScalingModeChanged;
         overrideScalingMode = other.overrideScalingMode;
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index b8465e3..f913977 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -353,18 +353,6 @@
     return *this;
 }
 
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFinalCrop_legacy(
-        const sp<SurfaceControl>& sc, const Rect& crop) {
-    layer_state_t* s = getLayerState(sc);
-    if (!s) {
-        mStatus = BAD_INDEX;
-        return *this;
-    }
-    s->what |= layer_state_t::eFinalCropChanged_legacy;
-    s->finalCrop_legacy = crop;
-    return *this;
-}
-
 SurfaceComposerClient::Transaction&
 SurfaceComposerClient::Transaction::deferTransactionUntil_legacy(const sp<SurfaceControl>& sc,
                                                                  const sp<IBinder>& handle,
diff --git a/libs/gui/include/gui/LayerDebugInfo.h b/libs/gui/include/gui/LayerDebugInfo.h
index 92bd8c5..66a7b4d 100644
--- a/libs/gui/include/gui/LayerDebugInfo.h
+++ b/libs/gui/include/gui/LayerDebugInfo.h
@@ -52,7 +52,6 @@
     int32_t mWidth = -1;
     int32_t mHeight = -1;
     Rect mCrop = Rect::INVALID_RECT;
-    Rect mFinalCrop = Rect::INVALID_RECT;
     half4 mColor = half4(1.0_hf, 1.0_hf, 1.0_hf, 0.0_hf);
     uint32_t mFlags = 0;
     PixelFormat mPixelFormat = PIXEL_FORMAT_NONE;
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 0981798..0859aff 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -54,25 +54,24 @@
         eLayerStackChanged = 0x00000080,
         eCropChanged_legacy = 0x00000100,
         eDeferTransaction_legacy = 0x00000200,
-        eFinalCropChanged_legacy = 0x00000400,
-        eOverrideScalingModeChanged = 0x00000800,
-        eGeometryAppliesWithResize = 0x00001000,
-        eReparentChildren = 0x00002000,
-        eDetachChildren = 0x00004000,
-        eRelativeLayerChanged = 0x00008000,
-        eReparent = 0x00010000,
-        eColorChanged = 0x00020000,
-        eDestroySurface = 0x00040000,
-        eTransformChanged = 0x00100000,
-        eTransformToDisplayInverseChanged = 0x00200000,
-        eCropChanged = 0x00400000,
-        eBufferChanged = 0x00800000,
-        eAcquireFenceChanged = 0x01000000,
-        eDataspaceChanged = 0x02000000,
-        eHdrMetadataChanged = 0x04000000,
-        eSurfaceDamageRegionChanged = 0x08000000,
-        eApiChanged = 0x10000000,
-        eSidebandStreamChanged = 0x20000000,
+        eOverrideScalingModeChanged = 0x00000400,
+        eGeometryAppliesWithResize = 0x00000800,
+        eReparentChildren = 0x00001000,
+        eDetachChildren = 0x00002000,
+        eRelativeLayerChanged = 0x00004000,
+        eReparent = 0x00008000,
+        eColorChanged = 0x00010000,
+        eDestroySurface = 0x00020000,
+        eTransformChanged = 0x00040000,
+        eTransformToDisplayInverseChanged = 0x00080000,
+        eCropChanged = 0x00100000,
+        eBufferChanged = 0x00200000,
+        eAcquireFenceChanged = 0x00400000,
+        eDataspaceChanged = 0x00800000,
+        eHdrMetadataChanged = 0x01000000,
+        eSurfaceDamageRegionChanged = 0x02000000,
+        eApiChanged = 0x04000000,
+        eSidebandStreamChanged = 0x08000000,
     };
 
     layer_state_t()
@@ -88,7 +87,6 @@
             mask(0),
             reserved(0),
             crop_legacy(Rect::INVALID_RECT),
-            finalCrop_legacy(Rect::INVALID_RECT),
             frameNumber_legacy(0),
             overrideScalingMode(-1),
             transform(0),
@@ -126,7 +124,6 @@
     uint8_t reserved;
     matrix22_t matrix;
     Rect crop_legacy;
-    Rect finalCrop_legacy;
     sp<IBinder> barrierHandle_legacy;
     sp<IBinder> reparentHandle;
     uint64_t frameNumber_legacy;
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 9bd1131..539e46c 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -204,7 +204,6 @@
         Transaction& setMatrix(const sp<SurfaceControl>& sc,
                 float dsdx, float dtdx, float dtdy, float dsdy);
         Transaction& setCrop_legacy(const sp<SurfaceControl>& sc, const Rect& crop);
-        Transaction& setFinalCrop_legacy(const sp<SurfaceControl>& sc, const Rect& crop);
         Transaction& setLayerStack(const sp<SurfaceControl>& sc, uint32_t layerStack);
         // Defers applying any changes made in this transaction until the Layer
         // identified by handle reaches the given frameNumber. If the Layer identified