Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancing skia further #357

Merged
merged 26 commits into from
Aug 3, 2022
Merged

Enhancing skia further #357

merged 26 commits into from
Aug 3, 2022

Conversation

tushar5526
Copy link
Member

@tushar5526 tushar5526 commented Jul 14, 2022

Transform

  • rotate()
  • scale()
  • shearX()
  • shearY()
  • translate()
  • applyMatrix()
  • resetMatrix()

Settings

  • background()
  • clear()
  • fill()
  • noFill()
  • noStroke()
  • stroke()

Attributes

  • noSmooth()
  • strokeCap()
  • strokeJoin()
  • strokeWeight()
  • ellipseMode()
  • rectMode()

Vertex

  • beginContour()
  • beginShape()
  • bezierVertex()
  • curveVertex()
  • endContour()
  • enshape()
  • quadraticVertex()
  • vertex()

PS: apply_matrix has different structure than p5.js
- shear_x
- shear_y
- background currently works only for colors, not images
- reset styles and matrix after each frame back to default
- stroke_cap()
- stroke_join()
- Moved stroke_cap and stroke_join to style class
@tushar5526 tushar5526 marked this pull request as draft July 14, 2022 17:20
@tushar5526 tushar5526 marked this pull request as ready for review July 16, 2022 20:29
@tushar5526 tushar5526 requested a review from ziyaointl July 16, 2022 20:29
@tushar5526
Copy link
Member Author

Comparison of a few sketches. Skia followed by vispy, results look great and we are getting results similar to web canvas. Skia is really great.

skia_and_vispy.mp4

@tushar5526
Copy link
Member Author

tushar5526 commented Jul 16, 2022

Tried #298

particle_skia.mp4
particle_vispy.mp4

Copy link
Member

@ziyaointl ziyaointl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty python file?

p5/core/transforms.py Show resolved Hide resolved
p5/core/color.py Outdated Show resolved Hide resolved
p5/core/vertex.py Outdated Show resolved Hide resolved
@@ -309,8 +355,7 @@ def end_shape(mode=""):
:type mode: str

"""
global is_bezier, is_curve, is_quadratic, is_contour
assert not is_contour, "begin_contour called without calling end_contour"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reasoning behind removing this assert?

Copy link
Member Author

@tushar5526 tushar5526 Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion seems a bit wrong. The default value of is_contour is False so this assertion would raise an error even when no contour calls are made.

Also, is_contour indicates whether the current shape has a contour in it. So, we would have to use a different variable to indicate whether end_contour was called or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default value of False actually does not trigger this assert, since not is_contour would evaluate to True.
I think the original is_contour had the function of denoting whether begin_contour has been called without end_contour being called. Without calling end_contour, it doesn't make sense to call end_shape, hence the original assert.
Under what condition did this assert trigger for you?

Copy link
Member Author

@tushar5526 tushar5526 Jul 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yes, you are right. This is what really happenedend_contour resets the value to False after begin_contour in the old code. I have removed that in the current code because we need to know whether is_contour was called or not to be passed onto renderer.end_shape. So now the assert is_contour will throw an error because the value was not set to False in end_contour

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. I think the old is_contour is still useful as a variable that indicates whether we are in a contour, thus providing us a way to nudge users to not call end_shape without calling end_contour after every begin_contour. I think the use case you've mentioned sounds like that a new variable named has_contour might be more appropriate. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that sounds right. I have done that. Thanks!

p5/core/vertex.py Show resolved Hide resolved
p5/sketch/Skia2DRenderer/renderer2d.py Outdated Show resolved Hide resolved
p5/sketch/Skia2DRenderer/renderer2d.py Outdated Show resolved Hide resolved
p5/sketch/Skia2DRenderer/renderer2d.py Show resolved Hide resolved
@ziyaointl
Copy link
Member

Great work! I left some comments, but majority of them are requests for clarification.

@arihantparsoya
Copy link
Member

Looking great @tushar5526 . Have we done any performance comparison for this renderer? We can compare the FPS of skia renderer with old renderer and p5js as well.

I am sure this is great performance improvement. But it will be helpful for users to know these benchmarks.

@arihantparsoya
Copy link
Member

Does skia renderer solve Retina display issues? I remember this was a major issue for many Mac users. #131

@tushar5526
Copy link
Member Author

Does skia renderer solve Retina display issues? I remember this was a major issue for many Mac users. #131

Yes, I configured glfw to support retina displays as well. But, I was not able to test it locally because I don't have a MAC with me. Mark has probably tested it locally so I think the pixel Density issues is not there.

@tushar5526
Copy link
Member Author

tushar5526 commented Jul 28, 2022

Looking great @tushar5526 . Have we done any performance comparison for this renderer? We can compare the FPS of skia renderer with old renderer and p5js as well.

I am sure this is great performance improvement. But it will be helpful for users to know these benchmarks.

I can use the current profiling to show the improvements in the release notes. I am open to any other ideas as to how we could measure the performance.

@tushar5526
Copy link
Member Author

Hey @ziyaointl I am thinking of starting with the new text and image APIs only after getting this one merged, followed by a release.

I think it will take some time for me to get the access to make a release. So I would be glad if you could make the release on pypi

@ziyaointl
Copy link
Member

@parsoyaarihant I've been running vispy on a mac retina screen for a while now and it seems to work normally, so the issue probably has been fixed at some point in the past. I haven't been able to test skia on mac though due to a segfault. I'll probably have to install the skia library with debug symbols to find out what is causing that.

@tushar5526 Yes! Let me know when everything else in #360 has been finished, and I'll publish the 0.8.0 tag to pypi.

@tushar5526 tushar5526 force-pushed the enhancing-skia-2 branch 2 times, most recently from 2843477 to 99a4aa2 Compare August 1, 2022 05:57
@tushar5526
Copy link
Member Author

This PR is good to go. @ziyaointl you can review and merge it :)

p5/core/vertex.py Outdated Show resolved Hide resolved
p5/core/vertex.py Outdated Show resolved Hide resolved
p5/core/vertex.py Outdated Show resolved Hide resolved
p5/core/vertex.py Outdated Show resolved Hide resolved
@ziyaointl ziyaointl merged commit bc0046f into p5py:master Aug 3, 2022
@tushar5526 tushar5526 deleted the enhancing-skia-2 branch August 3, 2022 07:16
@tushar5526 tushar5526 restored the enhancing-skia-2 branch August 3, 2022 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants