Skip to content

Commit a9115bc

Browse files
committed
[ReactNative][SyncDiff] Add parameter to allow turning on/off off screen rendering for alpha compositing
1 parent 7bf157c commit a9115bc

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Libraries/Components/View/View.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,29 @@ var View = React.createClass({
274274
* @platform android
275275
*/
276276
collapsable: PropTypes.bool,
277+
278+
/**
279+
* Whether this view needs to rendered offscreen and composited with an alpha
280+
* in order to preserve 100% correct colors and blending behavior. The default
281+
* (false) falls back to drawing the component and its children with an alpha
282+
* applied to the paint used to draw each element instead of rendering the full
283+
* component offscreen and compositing it back with an alpha value. This default
284+
* may be noticeable and undesired in the case where the View you are setting
285+
* an opacity on has multiple overlapping elements (e.g. multiple overlapping
286+
* Views, or text and a background).
287+
*
288+
* Rendering offscreen to preserve correct alpha behavior is extremely
289+
* expensive and hard to debug for non-native developers, which is why it is
290+
* not turned on by default. If you do need to enable this property for an
291+
* animation, consider combining it with renderToHardwareTextureAndroid if the
292+
* view **contents** are static (i.e. it doesn't need to be redrawn each frame).
293+
* If that property is enabled, this View will be rendered off-screen once,
294+
* saved in a hardware texture, and then composited onto the screen with an alpha
295+
* each frame without having to switch rendering targets on the GPU.
296+
*
297+
* @platform android
298+
*/
299+
needsOffscreenAlphaCompositing: PropTypes.bool,
277300
},
278301

279302
render: function() {

Libraries/ReactNative/ReactNativeViewAttributes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ ReactNativeViewAttributes.UIView = {
3030
onAccessibilityTap: true,
3131
onMagicTap: true,
3232
collapsable: true,
33+
needsOffscreenAlphaCompositing: true,
3334
};
3435

3536
ReactNativeViewAttributes.RCTView = merge(

0 commit comments

Comments
 (0)