diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 5ba250dea..244ea90ea 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -225,8 +225,28 @@ var View = React.createClass({ * different parameters. The downside is that this can use up limited video * memory, so this prop should be set back to false at the end of the * interaction/animation. + * @platform android */ renderToHardwareTextureAndroid: PropTypes.bool, + + /** + * Whether this view should be rendered as a bitmap before compositing. + * + * On iOS, this is useful for animations and interactions that do not + * modify this component's dimensions nor its children; for example, when + * translating the position of a static view, rasterization allows the + * renderer to reuse a cached bitmap of a static view and quickly composite + * it during each frame. + * + * Rasterization incurs an off-screen drawing pass and the bitmap consumes + * memory. Test and measure when using this property. + * @platform ios + */ + shouldRasterizeIOS: PropTypes.bool, + + /** + * @platform android + */ collapsable: PropTypes.bool, }, diff --git a/Libraries/ReactNative/ReactNativeViewAttributes.js b/Libraries/ReactNative/ReactNativeViewAttributes.js index c9d715433..b8ad5761c 100644 --- a/Libraries/ReactNative/ReactNativeViewAttributes.js +++ b/Libraries/ReactNative/ReactNativeViewAttributes.js @@ -23,6 +23,7 @@ ReactNativeViewAttributes.UIView = { accessibilityLiveRegion: true, accessibilityTraits: true, testID: true, + shouldRasterizeIOS: true, onLayout: true, onAccessibilityTap: true, onMagicTap: true, diff --git a/React/Views/RCTViewManager.m b/React/Views/RCTViewManager.m index 4d8583042..a892c4d8d 100644 --- a/React/Views/RCTViewManager.m +++ b/React/Views/RCTViewManager.m @@ -112,6 +112,11 @@ RCT_REMAP_VIEW_PROPERTY(shadowOffset, layer.shadowOffset, CGSize); RCT_REMAP_VIEW_PROPERTY(shadowOpacity, layer.shadowOpacity, float) RCT_REMAP_VIEW_PROPERTY(shadowRadius, layer.shadowRadius, CGFloat) RCT_REMAP_VIEW_PROPERTY(overflow, clipsToBounds, css_clip_t) +RCT_CUSTOM_VIEW_PROPERTY(shouldRasterizeIOS, BOOL, RCTView) +{ + view.layer.shouldRasterize = json ? [RCTConvert BOOL:json] : defaultView.layer.shouldRasterize; + view.layer.rasterizationScale = view.layer.shouldRasterize ? view.window.screen.scale : defaultView.layer.rasterizationScale; +} RCT_CUSTOM_VIEW_PROPERTY(transformMatrix, CATransform3D, RCTView) { view.layer.transform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.transform;