mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-02 06:45:02 +08:00
Accept transforms list instead of matrix for transform view parameter.
Summary: In #7916 I moved transform matrix decomposition logic from JS to java. The next step is to accept list of transforms instead oftransform matrix as a transform ReactProp. This way there is no extra processing required on JS side for the transform param (at least for android now) and this on the other hand allow us to execute transform updates (through offloaded animation) solely on the UI thread. After this change there is a whole bunch of stuff from `Libraries/Utilities/MatrixMath.js` that can be deleted (methods like: determinant, inverse, transpose). Although astreet mentioned under one of my previous commits that the code is still being referenced internally at fb, so I decided not to delete it here. **Test plan (required)** Run UIExplorer Transform example before and after - compare the results Run android unit test: com.facebook.react.uimanager.MatrixMathHelperTest Closes https://github.com/facebook/react-native/pull/8892 Differential Revision: D3676017 Pulled By: astreet fbshipit-source-id: 5275e30805a85c12c89bea44e8b3a2b2ec7b33fa
This commit is contained in:
committed by
Facebook Github Bot
parent
eba6c379c3
commit
68b9a36858
@@ -8,7 +8,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
|
||||
/**
|
||||
@@ -53,9 +52,9 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
@ReactProp(name = PROP_TRANSFORM)
|
||||
public void setTransform(T view, ReadableArray matrix) {
|
||||
if (matrix == null) {
|
||||
resetTransformMatrix(view);
|
||||
resetTransformProperty(view);
|
||||
} else {
|
||||
setTransformMatrix(view, matrix);
|
||||
setTransformProperty(view, matrix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,10 +153,8 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
}
|
||||
|
||||
private static void setTransformMatrix(View view, ReadableArray matrix) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
sTransformDecompositionArray[i] = matrix.getDouble(i);
|
||||
}
|
||||
private static void setTransformProperty(View view, ReadableArray transforms) {
|
||||
TransformHelper.processTransform(transforms, sTransformDecompositionArray);
|
||||
MatrixMathHelper.decomposeMatrix(sTransformDecompositionArray, sMatrixDecompositionContext);
|
||||
view.setTranslationX(
|
||||
PixelUtil.toPixelFromDIP((float) sMatrixDecompositionContext.translation[0]));
|
||||
@@ -170,7 +167,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
view.setScaleY((float) sMatrixDecompositionContext.scale[1]);
|
||||
}
|
||||
|
||||
private static void resetTransformMatrix(View view) {
|
||||
private static void resetTransformProperty(View view) {
|
||||
view.setTranslationX(PixelUtil.toPixelFromDIP(0));
|
||||
view.setTranslationY(PixelUtil.toPixelFromDIP(0));
|
||||
view.setRotation(0);
|
||||
|
||||
Reference in New Issue
Block a user