react-native/Libraries
Valentin Shergin 8c8944c10f Removing `inherited background color` optimization from RCTText
Summary:
This is a long story. Awhile ago awesome Nick Lockwood (Hey Nick!) introduced a special optimization for ReactNative rendering layer called "inherited background color".
He described this idea in D2811031:
>>>
Blending semitransparent pixels against their background is fairly a fairly expensive operation on mobile GPUs. To reduce blending, React Native has a system called "background color propagation", where the background color of parent views is automatically inherited by child views unless explicitly overridden. This means that translucent pixels can be blended directly against a known background color, avoiding the need to do this dynamically on the GPU.
In practice, this is only useful for views that do their own drawing, which is basically just <Image/> and <Text/> components, and for image components it only really matters when the image has an alpha component.
The automatic background propagation is a bit of a hack, and often does the wrong thing - for example if a view overflows its bounds, or if it overlaps a sibling, the background color will often be incorrect and need to be manually disabled. Because the only place that it provides a significant performance benefit is for text, this diff disables the behavior for everything except <Text/> nodes. It might still be useful for <Image/> nodes too, but looking through the examples in UIExplorer, the number of places where it does the wrong thing for images outnumbers the cases where it provides significant reduction in blending.

However. I think it is time to remove it. Why? There are several reasons:

* It drastically complicates rendering layer. DRASTICALLY. In many many unrelated places (try search for "backgroundColor"!);
* This mechanism is totally non-conceptual to RN and it prevents us to implement some new possible render optimization that we plan to do;
* This adopted only by two components now: Text and ART;
* This is not a significant performance drain anymore; from iOS 6 even UILabel has clear background color by default.
* I doubt that it even works now because `drawRect:` in Text component does not call super method.

So, this diff just turns this feature off for Text. If all performance metrics are neutral, I will delete this mechanism.
Peace.

Reviewed By: sahrens

Differential Revision: D6564199

fbshipit-source-id: 70524fdd955ca32bbf86d2d1ff5e73316b791219
2017-12-15 12:31:58 -08:00
..
ART Fix format warnings for clang 5.0 2017-09-25 10:30:53 -07:00
ActionSheetIOS Flow Type ActionSheetIOS 2017-12-13 16:19:21 -08:00
Alert Migrate additional docs to the new format 2017-11-20 13:16:12 -08:00
Animated Allow extending props supported by native animations 2017-12-13 13:53:07 -08:00
AppState Migrate additional docs to the new format 2017-11-20 13:16:12 -08:00
BatchedBridge Make the __DEV__ argument check more robust 2017-12-14 11:17:39 -08:00
Blob Upgrade to 1.9.1 2017-12-06 17:34:26 -08:00
BugReporting Add extra data view to RN RedBox 2017-12-14 10:50:24 -08:00
CameraRoll Fix some flow errors that appear 2017-12-07 08:31:37 -08:00
Components Fix backgroundColor with TouchableHighlight 2017-12-14 21:20:17 -08:00
Core Fix sections that come from React Fiber 2017-11-09 13:05:07 -08:00
EventEmitter RN: Improve NativeEventEmitter Flow Types 2017-10-13 08:04:17 -07:00
Experimental AMA changes to support disk cache 2017-11-12 13:03:41 -08:00
Geolocation @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
Image Providing an API to load assets from a different directory 2017-12-08 15:01:40 -08:00
Inspector Improve types for React Native styles. 2017-11-14 13:18:33 -08:00
Interaction Adding @email tags to most of the tests 2017-11-02 06:25:03 -07:00
JSInspector Add Network agent 2016-11-02 12:29:15 -07:00
LayoutAnimation @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
Linking fix flow warning and typo 2017-09-08 14:46:14 -07:00
LinkingIOS Standardize project indentation settings on 2 spaces 2017-07-31 05:20:03 -07:00
Lists Upgrade to 1.9.1 2017-12-06 17:34:26 -08:00
Modal Add onDismiss to Modal.js 2017-09-21 15:01:52 -07:00
NativeAnimation Renaming uiManagerWillFlushUIBlocks -> uiManagerWillPerformMounting 2017-12-11 17:10:48 -08:00
Network Add RCTLibraryPathForURL in RCTUtil 2017-12-14 14:31:50 -08:00
Performance Don't set global.performance to undefined if it was initialized already 2017-12-01 02:46:18 -08:00
PermissionsAndroid Update documentation for PermissionsAndroid 2017-08-16 15:01:51 -07:00
PushNotificationIOS Fix flowtype errors for PushNotificationIOS 2017-08-14 12:03:18 -07:00
RCTTest Report all errors from running tests 2017-12-08 16:46:55 -08:00
ReactNative Upgrade to 1.9.1 2017-12-06 17:34:26 -08:00
Renderer Temporarily patched Map/Set non-extensible check into RN dev renderer 2017-12-05 12:27:12 -08:00
Sample Standardize project indentation settings on 2 spaces 2017-07-31 05:20:03 -07:00
Settings Fix infinite recursion in RCTSettingsManager init 2017-08-09 09:39:40 -07:00
Share Flow 0.59 xplat/js deploy 2017-11-10 21:15:48 -08:00
Storage Migrate additional docs to the new format 2017-11-20 13:16:12 -08:00
StyleSheet Some TouchableHighlight cleanup 2017-12-13 17:31:24 -08:00
SurfaceBackedComponent RCTSurface: Couple helper functions for Stage 2017-12-03 20:16:35 -08:00
SurfaceHostingComponent Introducing RCTSurfaceHostingComponent 2017-11-11 21:25:47 -08:00
Text Removing `inherited background color` optimization from RCTText 2017-12-15 12:31:58 -08:00
Types add CoreEventTypes with LayoutEvent 2017-12-13 12:02:32 -08:00
Utilities metro-buck: check validity of segments 2017-12-14 09:49:37 -08:00
Vibration Run eslint --fix 2017-10-09 17:46:44 -07:00
WebSocket Avoid memory leak in RCTWebSocketModule 2017-12-04 09:34:19 -08:00
Wrapper Opensourcing RCTWrapper 2017-10-09 17:22:35 -07:00
fishhook Merge fishhook.xcodeproj in RCTWebSocket 2017-08-09 07:48:09 -07:00
polyfills Use proper script way to clone Emoji files from www 2017-08-21 16:29:39 -07:00
react-native Switch to `declare module.exports` syntax 2017-12-14 16:31:14 -08:00
vendor @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
.eslintrc Disallow trailing commas in react-native-github 2017-08-17 16:20:04 -07:00
Promise.js @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
promiseRejectionIsError.js @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00