From 27a38dedf1af3295a535c5f72e3e7443c07c1075 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 2 Jul 2018 09:52:04 -0700 Subject: [PATCH] Enable View flatening optimization by default Summary: This diff enables view flattening optimizations by default Reviewed By: wwjholmes, yungsters Differential Revision: D8699050 fbshipit-source-id: d37d06fe330e223c49a0788e85f6338fd056fd19 --- .../facebook/react/uimanager/ViewProps.java | 78 +++++++++---------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java index 0a353a6b0..58e67ccb7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java @@ -212,8 +212,6 @@ public class ViewProps { PADDING_START, PADDING_END)); - public static boolean sIsOptimizationsEnabled; - public static boolean isLayoutOnly(ReadableMap map, String prop) { if (LAYOUT_ONLY_PROPS.contains(prop)) { return true; @@ -222,47 +220,43 @@ public class ViewProps { return AUTO.equals(value) || BOX_NONE.equals(value); } - - if (sIsOptimizationsEnabled) { - switch (prop) { - case OPACITY: - // null opacity behaves like opacity = 1 - // Ignore if explicitly set to default opacity. - return map.isNull(OPACITY) || map.getDouble(OPACITY) == 1d; - case BORDER_RADIUS: // Without a background color or border width set, a border won't show. - if (map.hasKey(BACKGROUND_COLOR) && map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) { - return false; - } - if (map.hasKey(BORDER_WIDTH) - && !map.isNull(BORDER_WIDTH) - && map.getDouble(BORDER_WIDTH) != 0d) { - return false; - } - return true; - case BORDER_LEFT_COLOR: - return map.getInt(BORDER_LEFT_COLOR) == Color.TRANSPARENT; - case BORDER_RIGHT_COLOR: - return map.getInt(BORDER_RIGHT_COLOR) == Color.TRANSPARENT; - case BORDER_TOP_COLOR: - return map.getInt(BORDER_TOP_COLOR) == Color.TRANSPARENT; - case BORDER_BOTTOM_COLOR: - return map.getInt(BORDER_BOTTOM_COLOR) == Color.TRANSPARENT; - case BORDER_WIDTH: - return map.isNull(BORDER_WIDTH) || map.getDouble(BORDER_WIDTH) == 0d; - case BORDER_LEFT_WIDTH: - return map.isNull(BORDER_LEFT_WIDTH) || map.getDouble(BORDER_LEFT_WIDTH) == 0d; - case BORDER_TOP_WIDTH: - return map.isNull(BORDER_TOP_WIDTH) || map.getDouble(BORDER_TOP_WIDTH) == 0d; - case BORDER_RIGHT_WIDTH: - return map.isNull(BORDER_RIGHT_WIDTH) || map.getDouble(BORDER_RIGHT_WIDTH) == 0d; - case BORDER_BOTTOM_WIDTH: - return map.isNull(BORDER_BOTTOM_WIDTH) || map.getDouble(BORDER_BOTTOM_WIDTH) == 0d; - case OVERFLOW: - return map.isNull(OVERFLOW) || VISIBLE.equals(map.getString(OVERFLOW)); - default: + switch (prop) { + case OPACITY: + // null opacity behaves like opacity = 1 + // Ignore if explicitly set to default opacity. + return map.isNull(OPACITY) || map.getDouble(OPACITY) == 1d; + case BORDER_RADIUS: // Without a background color or border width set, a border won't show. + if (map.hasKey(BACKGROUND_COLOR) && map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) { return false; + } + if (map.hasKey(BORDER_WIDTH) + && !map.isNull(BORDER_WIDTH) + && map.getDouble(BORDER_WIDTH) != 0d) { + return false; + } + return true; + case BORDER_LEFT_COLOR: + return map.getInt(BORDER_LEFT_COLOR) == Color.TRANSPARENT; + case BORDER_RIGHT_COLOR: + return map.getInt(BORDER_RIGHT_COLOR) == Color.TRANSPARENT; + case BORDER_TOP_COLOR: + return map.getInt(BORDER_TOP_COLOR) == Color.TRANSPARENT; + case BORDER_BOTTOM_COLOR: + return map.getInt(BORDER_BOTTOM_COLOR) == Color.TRANSPARENT; + case BORDER_WIDTH: + return map.isNull(BORDER_WIDTH) || map.getDouble(BORDER_WIDTH) == 0d; + case BORDER_LEFT_WIDTH: + return map.isNull(BORDER_LEFT_WIDTH) || map.getDouble(BORDER_LEFT_WIDTH) == 0d; + case BORDER_TOP_WIDTH: + return map.isNull(BORDER_TOP_WIDTH) || map.getDouble(BORDER_TOP_WIDTH) == 0d; + case BORDER_RIGHT_WIDTH: + return map.isNull(BORDER_RIGHT_WIDTH) || map.getDouble(BORDER_RIGHT_WIDTH) == 0d; + case BORDER_BOTTOM_WIDTH: + return map.isNull(BORDER_BOTTOM_WIDTH) || map.getDouble(BORDER_BOTTOM_WIDTH) == 0d; + case OVERFLOW: + return map.isNull(OVERFLOW) || VISIBLE.equals(map.getString(OVERFLOW)); + default: + return false; } - } - return false; } }