From 79be10428b589bd6dc75644705b71b10d9405ba9 Mon Sep 17 00:00:00 2001 From: Denis Koroskin Date: Sun, 20 Dec 2015 19:36:23 -0800 Subject: [PATCH] Add support for ViewProps.NEEDS_OFFSCREEN_ALPHA_COMPOSITING to RCTView Summary: Copied from ReactViewManager. Should provide performance improvements. Reviewed By: ahmedre Differential Revision: D2772832 --- .../com/facebook/react/flat/FlatViewGroup.java | 17 +++++++++++++++++ .../com/facebook/react/flat/RCTViewManager.java | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java index 27e4e2896a6..d369f1e21c5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java @@ -57,6 +57,7 @@ import com.facebook.react.uimanager.ReactCompoundView; private int mDrawChildIndex = 0; private boolean mIsAttached = false; private boolean mIsLayoutRequested = false; + private boolean mNeedsOffscreenAlphaCompositing = false; private Drawable mHotspot; /* package */ FlatViewGroup(Context context) { @@ -179,6 +180,22 @@ import com.facebook.react.uimanager.ReactCompoundView; } } + /** + * We override this to allow developers to determine whether they need offscreen alpha compositing + * or not. See the documentation of needsOffscreenAlphaCompositing in View.js. + */ + @Override + public boolean hasOverlappingRendering() { + return mNeedsOffscreenAlphaCompositing; + } + + /** + * See the documentation of needsOffscreenAlphaCompositing in View.js. + */ + /* package */ void setNeedsOffscreenAlphaCompositing(boolean needsOffscreenAlphaCompositing) { + mNeedsOffscreenAlphaCompositing = needsOffscreenAlphaCompositing; + } + /* package */ void setHotspot(Drawable hotspot) { if (mHotspot != null) { mHotspot.setCallback(null); diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewManager.java index aa57fa51b25..2b29b4f457c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewManager.java @@ -90,4 +90,11 @@ import com.facebook.react.views.view.ReactDrawableHelper; } } } + + @ReactProp(name = ViewProps.NEEDS_OFFSCREEN_ALPHA_COMPOSITING) + public void setNeedsOffscreenAlphaCompositing( + FlatViewGroup view, + boolean needsOffscreenAlphaCompositing) { + view.setNeedsOffscreenAlphaCompositing(needsOffscreenAlphaCompositing); + } }