Skip to content

Commit

Permalink
Merge pull request #218 from react-native-community/path-native-parser
Browse files Browse the repository at this point in the history
Path native parser
  • Loading branch information
magicismight authored Jan 8, 2017
2 parents a194ade + a325ac6 commit 7ed906d
Show file tree
Hide file tree
Showing 40 changed files with 1,543 additions and 775 deletions.
8 changes: 1 addition & 7 deletions android/src/main/java/com/horcrux/svg/CircleShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Shadow node for virtual RNSVGPath view
*/
public class CircleShadowNode extends PathShadowNode {
public class CircleShadowNode extends RenderableShadowNode {

private String mCx;
private String mCy;
Expand All @@ -43,12 +43,6 @@ public void setR(String r) {
markUpdated();
}

@Override
public void draw(Canvas canvas, Paint paint, float opacity) {
mPath = getPath(canvas, paint);
super.draw(canvas, paint, opacity);
}

@Override
protected Path getPath(Canvas canvas, Paint paint) {
Path path = new Path();
Expand Down
8 changes: 1 addition & 7 deletions android/src/main/java/com/horcrux/svg/EllipseShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Shadow node for virtual RNSVGPath view
*/
public class EllipseShadowNode extends PathShadowNode {
public class EllipseShadowNode extends RenderableShadowNode {

private String mCx;
private String mCy;
Expand Down Expand Up @@ -50,12 +50,6 @@ public void setRy(String ry) {
markUpdated();
}

@Override
public void draw(Canvas canvas, Paint paint, float opacity) {
mPath = getPath(canvas, paint);
super.draw(canvas, paint, opacity);
}

@Override
protected Path getPath(Canvas canvas, Paint paint) {
Path path = new Path();
Expand Down
8 changes: 4 additions & 4 deletions android/src/main/java/com/horcrux/svg/GroupShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Shadow node for virtual RNSVGGroup view
*/
public class GroupShadowNode extends PathShadowNode {
public class GroupShadowNode extends RenderableShadowNode {

public void draw(final Canvas canvas, final Paint paint, final float opacity) {
final SvgViewShadowNode svg = getSvgShadowNode();
Expand All @@ -38,7 +38,7 @@ public void draw(final Canvas canvas, final Paint paint, final float opacity) {
public boolean run(VirtualNode node) {
node.setupDimensions(canvas);

node.mergeProperties(self, mOwnedPropList, true);
node.mergeProperties(self, mAttributeList, true);
node.draw(canvas, paint, opacity * mOpacity);
node.markUpdateSeen();

Expand Down Expand Up @@ -109,10 +109,10 @@ public boolean run(VirtualNode node) {
}

@Override
public void mergeProperties(final VirtualNode target, final ReadableArray mergeList) {
public void mergeProperties(final VirtualNode target, final ReadableArray mergeList, final boolean inherited) {
traverseChildren(new NodeRunnable() {
public boolean run(VirtualNode node) {
node.mergeProperties(target, mergeList);
node.mergeProperties(target, mergeList, inherited);
return true;
}
});
Expand Down
12 changes: 9 additions & 3 deletions android/src/main/java/com/horcrux/svg/ImageShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/**
* Shadow node for virtual RNSVGPath view
*/
public class ImageShadowNode extends PathShadowNode {
public class ImageShadowNode extends RenderableShadowNode {

private String mX;
private String mY;
Expand Down Expand Up @@ -107,8 +107,7 @@ public void setMeetOrSlice(int meetOrSlice) {

@Override
public void draw(final Canvas canvas, final Paint paint, final float opacity) {
mPath = new Path();
mPath.addRect(new RectF(getRect()), Path.Direction.CW);
mPath = getPath(canvas, paint);

if (!mLoading.get()) {
final ImageRequest request = ImageRequestBuilder.newBuilderWithSource(mUri).build();
Expand All @@ -121,6 +120,13 @@ public void draw(final Canvas canvas, final Paint paint, final float opacity) {
}
}

@Override
protected Path getPath(Canvas canvas, Paint paint) {
Path path = new Path();
path.addRect(new RectF(getRect()), Path.Direction.CW);
return path;
}

private void loadBitmap(ImageRequest request, final Canvas canvas, final Paint paint) {
final DataSource<CloseableReference<CloseableImage>> dataSource
= Fresco.getImagePipeline().fetchDecodedImage(request, getThemedContext());
Expand Down
8 changes: 1 addition & 7 deletions android/src/main/java/com/horcrux/svg/LineShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Shadow node for virtual RNSVGPath view
*/
public class LineShadowNode extends PathShadowNode {
public class LineShadowNode extends RenderableShadowNode {

private String mX1;
private String mY1;
Expand Down Expand Up @@ -48,12 +48,6 @@ public void setY2(String y2) {
markUpdated();
}

@Override
public void draw(Canvas canvas, Paint paint, float opacity) {
mPath = getPath(canvas, paint);
super.draw(canvas, paint, opacity);
}

@Override
protected Path getPath(Canvas canvas, Paint paint) {
Path path = new Path();
Expand Down
Loading

0 comments on commit 7ed906d

Please sign in to comment.