From b860897cd5e5d48d804829d205c926ce9b9f553d Mon Sep 17 00:00:00 2001 From: Matthew Denner Date: Fri, 26 Feb 2016 00:41:25 -0800 Subject: [PATCH] Restore canvas once group has been drawn Summary:The implementation of ARTGroupShadowNode saved the canvas and then drew the child nodes but did not reset the canvas afterwards, unlike the behaviour of the other ART shadow nodes. Because of this the matrix operations were compounded for sibling nodes in the surface. As an example the following code should draw a green circle in the bottom right corner of the surface and a red circle in the top left, which it does on iOS; on Android you'll find that the red circle is drawn in the bottom right corner instead. ``` 'use strict'; import React, { AppRegistry, Component, StyleSheet, View, } from 'react-native'; const { Surface, Group, Shape } = React.ART; const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#808080', }, surface: { backgroundColor: '#ffffff' }, }); class ARTGroupBug extends Component { render() { return ( < Closes https://github.com/facebook/react-native/pull/5619 Differential Revision: D2981865 Pulled By: spicyj fb-gh-sync-id: 95ca701354fe728ed6ee78f8c02d1e1eb70c181e shipit-source-id: 95ca701354fe728ed6ee78f8c02d1e1eb70c181e --- .../java/com/facebook/react/views/art/ARTGroupShadowNode.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTGroupShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTGroupShadowNode.java index 9586a7b0f88..f01ca1ccf97 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTGroupShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTGroupShadowNode.java @@ -32,6 +32,8 @@ public class ARTGroupShadowNode extends ARTVirtualNode { child.draw(canvas, paint, opacity); child.markUpdateSeen(); } + + restoreCanvas(canvas); } } }