Skip to content

Commit 54beee2

Browse files
Adam ComellaFacebook Github Bot
authored andcommitted
Android: Reduce overdraw layers by hiding cards when they are not visible
Summary: Cards which are not visible because another card is occluding them are still being rendered by Android resulting in overdraw. This results in wasted GPU time because some pixels are drawn multiple times. This change reduces overdraw by changing the opacity of occluded cards to 0. This bug was found using the tools described in Android's overdraw docs: https://developer.android.com/topic/performance/rendering/overdraw.html **Test plan (required)** This change is being used in my team's app. Adam Comella Microsoft Corp. Closes #10908 Differential Revision: D4175758 Pulled By: ericvicenti fbshipit-source-id: 4bfac7df16d2a7ea67db977659237a9aa6598f87
1 parent 16b2d5a commit 54beee2

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

Libraries/CustomComponents/NavigationExperimental/NavigationCardStackStyleInterpolator.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,21 @@ function forHorizontal(props: NavigationSceneRendererProps): Object {
8787
}
8888

8989
const index = scene.index;
90-
const inputRange = [index - 1, index, index + 1];
90+
const inputRange = [index - 1, index, index + 0.99, index + 1];
9191
const width = layout.initWidth;
9292
const outputRange = I18nManager.isRTL ?
93-
([-width, 0, 10]: Array<number>) :
94-
([width, 0, -10]: Array<number>);
93+
([-width, 0, 10, 10]: Array<number>) :
94+
([width, 0, -10, -10]: Array<number>);
9595

9696

9797
const opacity = position.interpolate({
9898
inputRange,
99-
outputRange: ([1, 1, 0.3]: Array<number>),
99+
outputRange: ([1, 1, 0.3, 0]: Array<number>),
100100
});
101101

102102
const scale = position.interpolate({
103103
inputRange,
104-
outputRange: ([1, 1, 0.95]: Array<number>),
104+
outputRange: ([1, 1, 0.95, 0.95]: Array<number>),
105105
});
106106

107107
const translateY = 0;
@@ -132,23 +132,23 @@ function forVertical(props: NavigationSceneRendererProps): Object {
132132
}
133133

134134
const index = scene.index;
135-
const inputRange = [index - 1, index, index + 1];
135+
const inputRange = [index - 1, index, index + 0.99, index + 1];
136136
const height = layout.initHeight;
137137

138138
const opacity = position.interpolate({
139139
inputRange,
140-
outputRange: ([1, 1, 0.3]: Array<number>),
140+
outputRange: ([1, 1, 0.3, 0]: Array<number>),
141141
});
142142

143143
const scale = position.interpolate({
144144
inputRange,
145-
outputRange: ([1, 1, 0.95]: Array<number>),
145+
outputRange: ([1, 1, 0.95, 0.95]: Array<number>),
146146
});
147147

148148
const translateX = 0;
149149
const translateY = position.interpolate({
150150
inputRange,
151-
outputRange: ([height, 0, -10]: Array<number>),
151+
outputRange: ([height, 0, -10, -10]: Array<number>),
152152
});
153153

154154
return {

0 commit comments

Comments
 (0)