Path clipping bug in marlin 0.8.1

97 views
Skip to first unread message

Botond Kósa

unread,
Sep 19, 2017, 11:42:09 AM9/19/17
to marlin-renderer
Hi Laurent,

I found a bug in the newest version of marlin. When drawing the boundary of a polygon, the last edge (connecting the last vertex back to the first one) is not painted if the first vertex is not in the clipped region. The bug appears regardless of the vertex count of the polygon, the orientation of the vertices (clockwise/counter-clockwise), or the first vertex's relative position to the clipping rectangle (left/top/right/bottom).

See the attached images. The vertex on the top is the first, the orientation is ccw.

Regards,
Botond
no_clip.png
clip_fail.png
clip_success.png

Botond Kósa

unread,
Sep 19, 2017, 11:44:39 AM9/19/17
to marlin-renderer
Correction: the orientation of the sample polygon is clockwise, not counter-clockwise.

Laurent Bourgès

unread,
Sep 19, 2017, 2:31:38 PM9/19/17
to marlin-...@googlegroups.com
Thanks for you report,
I will look at it as soon as I can (later).
You can disable clipping in this release by using the system property ...marlin.clip=false as a workaround.

Laurent

Le 19 sept. 2017 17:44, "Botond Kósa" <boton...@idata.hu> a écrit :
Correction: the orientation of the sample polygon is clockwise, not counter-clockwise.

--
You received this message because you are subscribed to the Google Groups "marlin-renderer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marlin-renderer+unsubscribe@googlegroups.com.
To post to this group, send email to marlin-renderer@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Laurent Bourgès

unread,
Sep 20, 2017, 2:34:57 PM9/20/17
to marlin-...@googlegroups.com
Hi Botond,

I reproduced your problem and fixed the bug = one liner !

I pushed in the openjdk-dev and will synch other branches asap.

Then I will make a new release 0.8.1.1.

Good catch and thank you for the bug report, it is rarely the case.

Laurent

Laurent Bourgès

unread,
Sep 20, 2017, 5:55:32 PM9/20/17
to marlin-...@googlegroups.com
Hi again,

Here is the Marlin release 0.8.1.1 fixing the Stroker's clipping bug:
https://github.com/bourgesl/marlin-renderer/releases/tag/v0.8.1.1

Enjoy Marlin,
Laurent

Olivier Brault

unread,
Oct 13, 2017, 5:29:57 AM10/13/17
to marlin-renderer
Hi,
First : congratulation for Marlin Renderer !
I have downloaded the latest version 0.8.1.1 and use it via marlin-graphics.
I still have a bug which doesn't happen in version 0.8.0

I draw a red square (via Path2D.Double)
Sometimes, at the bottom right corner of my JPanel, the square is cut and looks like a triangle. No problem in other corners.
See Attached image

Cordialement,
Olivier Brault
2017-10-13_11h17_57.png

Laurent Bourgès

unread,
Oct 13, 2017, 7:24:22 AM10/13/17
to marlin-...@googlegroups.com
Hi Olivier,

Thanks for your feedback.

Could you send me a test code that reproduces your problem ?

You could also use the ShapeDumperG2D class from the MapBench project to serialize your drawing commands in a binary file (.ser) that I then can use to reproduce and fix the bug.
See the sample:

Cheers,
Laurent

Olivier Brault

unread,
Oct 13, 2017, 8:06:02 AM10/13/17
to marlin-renderer
Hi
My app is quite complexe, so I wrote a small example to reproduce the issue.

Try this code.
You will see a red square.
Then, with your mouse, reduce the size of the window so that the bottom right corner of the square is out of view.
In that case, I see a triangle.

Olivier

package testmarlin0811;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.marlin.graphics.MarlinGraphics2D;

public class TestMarlin0811 {

   
public static void main(String[] args) {
       
JFrame frame = new JFrame("JFrame Example");
       
JPanel panel = new MyPanel();
       
//panel.setBorder(new LineBorder(Color.BLUE));
        frame
.add(panel);
        frame
.setSize(300, 300);
        frame
.setLocationRelativeTo(null);
        frame
.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame
.setVisible(true);
   
}

   
static class MyPanel extends JPanel {
       
int decalX = 200;
       
int decalY = 200;

       
@Override
       
protected void paintComponent(Graphics g) {
           
super.paintComponent(g);

           
BufferedImage bi = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
           
Graphics2D g2d = new MarlinGraphics2D(bi);

           
Path2D.Double shape = new Path2D.Double();
            shape
.moveTo(0+decalX, 50+decalY);
            shape
.lineTo(0+decalX, 0+decalY);
            shape
.lineTo(50+decalX, 0+decalY);
            shape
.lineTo(50+decalX, 50+decalY);
            shape
.lineTo(0+decalX, 50+decalY);

            g2d
.setColor(Color.red);
            g2d
.fill(shape);
           
            g
.drawImage(bi, 0, 0, this);
       
}
   
}

}
Laurent

To unsubscribe from this group and stop receiving emails from it, send an email to marlin-render...@googlegroups.com.
To post to this group, send email to marlin-...@googlegroups.com.

Laurent Bourgès

unread,
Oct 13, 2017, 9:39:52 AM10/13/17
to marlin-...@googlegroups.com
Hi again,

It seems a bug in the PathClipFilter that only affects graphics.fill(Shape) which is new in Marlin 0.8.1: that's very interesting !

Laurent

Laurent Bourgès

unread,
Oct 14, 2017, 1:38:45 PM10/14/17
to marlin-...@googlegroups.com
Hi,

Thanks to your test, I already fixed the bug... will then run all my regression tests & benchmarks.

Will release Marlin 0.8.1.2 soon (at last, next week)

Laurent

To unsubscribe from this group and stop receiving emails from it, send an email to marlin-renderer+unsubscribe@googlegroups.com.
To post to this group, send email to marlin-renderer@googlegroups.com.

Laurent Bourgès

unread,
Oct 17, 2017, 4:12:57 PM10/17/17
to marlin-...@googlegroups.com
Hi Olivier,

I fixed your bugs and Marlin 0.8.1.2 is released:
https://github.com/bourgesl/marlin-renderer/releases/tag/v0.8.1.2

Laurent
--
--
Laurent Bourgès

Olivier Brault

unread,
Oct 18, 2017, 5:07:25 AM10/18/17
to marlin-renderer
nice job (and quite responsive) !
i will try it soon in my app !
Olivier
--
Laurent Bourgès

Olivier Brault

unread,
Nov 4, 2017, 5:46:35 AM11/4/17
to marlin-renderer
Hi again.
I'm sad to learn you stop developping new feature to Marlin, but I understand your point of view. It is a great job and you can be proud of yourself.

I still have the "triangle bug" with Marlin 8.1.2.
To see this bug, you just need to fill a square shape with all the corners out of the window (like a square on which you have made a deep zoom).
Then sometimes, the square appear like a triangle.

Olivier

Olivier Brault

unread,
Nov 4, 2017, 5:50:49 AM11/4/17
to marlin-renderer
Following my last post, here is a code than can reproduce the new triangle bug :
It is the same code than the last one i gave you, but with different coordinates.
To see the bug, run the code, and reduce the size of the window so that the low-right corner of the square is out of the window.
Olivier

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.marlin.graphics.MarlinGraphics2D;

public class TestMarlin0812 {


   
public static void main(String[] args) {
       
JFrame frame = new JFrame("JFrame Example");
       
JPanel panel = new MyPanel();

        frame
.add(panel);
        frame
.setSize(300, 300);
        frame
.setLocationRelativeTo(null);
        frame
.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame
.setVisible(true);
   
}

   
static class MyPanel extends JPanel {

       
int decalX = -100;
       
int decalY = -100;


       
@Override
       
protected void paintComponent(Graphics g) {
           
super.paintComponent(g);

           
BufferedImage bi = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
           
Graphics2D g2d = new MarlinGraphics2D(bi);

           
Path2D.Double shape = new Path2D.Double();

            shape
.moveTo(0+decalX, 300+decalY);
            shape
.lineTo(0+decalX, 0+decalY);
            shape
.lineTo(300+decalX, 0+decalY);
            shape
.lineTo(300+decalX, 300+decalY);
            shape
.lineTo(0+decalX, 300+decalY);

Laurent Bourgès

unread,
Nov 4, 2017, 7:21:11 AM11/4/17
to marlin-...@googlegroups.com
Hi Olivier,

Hi again.
I'm sad to learn you stop developping new feature to Marlin, but I understand your point of view. It is a great job and you can be proud of yourself.

Thanks, I am still improving my lovely Marlin... let's be happy coding, but as free as possible.

 I am disappointed as I worked hard & had a talk at JavaOne to attract other dev contributors or at least get feedback, bug reports or get some sponsoring (few $$ from large companies like O...) without success so far. 
Even after my last call for FOSS support !

Thank you very much for giving your feedback: optimizing Math.cbrt() and other ops seems a very good idea, but I must write my own Fast version to avoid any license issue (GPL v2 + OCLA).


I still have the "triangle bug" with Marlin 8.1.2.
To see this bug, you just need to fill a square shape with all the corners out of the window (like a square on which you have made a deep zoom).
Then sometimes, the square appear like a triangle.

I started coding an automated artefact finder test and I confirm that filler bug. I may work on a fix soon...

Laurent

Laurent Bourgès

unread,
Nov 4, 2017, 7:14:50 PM11/4/17
to marlin-...@googlegroups.com
Hi Olivier,

Here is the Marlin release 0.8.2 that fixes your problem and few other corner cases in the PathClipFilter (fill):
https://github.com/bourgesl/marlin-renderer/releases/tag/v0.8.2

I tested all possible cases in either Stroker or Filler rendering so I expect it is very stable !
The new path clipper gives some interesting performance improvements when path elements are out of the clip.

Changes:

  • Fixed 2 bugs in PathClipFilter for polygons whose initial or last point are outside the clip (corners): it only affects fill operations.
  • Support either the Non Zero or the Even Odd winding rules in the Filler
  • Tested automatically by the MapBench.ClipShapeTests for Stroker (all stroke combinations of cap / joins) and Filler (closed, winding rules EO / NZ) with random paths (10 000 per test case)
Please give us your your feedback, as usual !

Enjoy Marlin,
Laurent

Laurent Bourgès

unread,
Nov 7, 2017, 3:36:16 AM11/7/17
to marlin-...@googlegroups.com
Dear Marlin users,

Could you please give me your feedback on latest Marlin 0.8.2 release ?
Did you try it ?
Which JDK ? JVM settings ?
Which application (desktop or server-side) ?
Any performance gain or loss ?

Do you need help for tuning the Marlin renderer (lots of settings) or improving your application (rendering & graphics) ?

Would you accept to support my work ?

I need help on unit testing, benchmarking (machines, blog or wiki updates), updating the documentation (manual, recent results) and of course, coding improvements (texture paint, gamma correction, pixel coverage estimation like AGG).

Any funding proposal ?
I wonder if I should adopt the FOSS kickstarter approach:
- create a new campaign 'Marlin renderer Enhancement & Support' with low funding levels ~ 1000 €
- If the campaign is successful, then I can release the new Marlin renderer publicly on github

FYI I had a lot of expenses at home in October and my JavaOne trip costed ~ 4500€ (hotel + flight + food...) so my bank account is in negative (exhausted budget).


Please at least give me your comments by answering this email on the mailing list or privately at bourges.laurent (gmail).

Cheers,
Laurent

Chris Newland

unread,
Nov 9, 2017, 3:18:58 AM11/9/17
to marlin-renderer
Hi Laurent,

Thanks for your continued work on Marlin.

I can offer some support in benchmarking the changes as they reach JavaFX. I don't fully understand how Marlin changes get pushed into MarlinFX but I have a public JavaFX build server and would be happy to work with you to produce early access JDK builds that include the latest MarlinFX changes.

I can also develop some specific effects in my DemoFX system for benchmarking MarlinFX changes.

Cheers,

Chris
--
@chriswhocodes

Laurent Bourgès

unread,
Nov 9, 2017, 7:54:54 AM11/9/17
to marlin-...@googlegroups.com
Chris,

Thank you for your feedback, you're the single person answering my 'survey' and call for contributions.

Thanks for your continued work on Marlin.

Thx.
 
I can offer some support in benchmarking the changes as they reach JavaFX. I don't fully understand how Marlin changes get pushed into MarlinFX but I have a public JavaFX build server and would be happy to work with you to produce early access JDK builds that include the latest MarlinFX changes.

I currently deal with several projects on github & multiple OpenJDK forrests:
  • marlin-renderer project has 3 active branches:
  • unsafe: Main Marlin-renderer branch for github releases = compatible with JDK 1.6 to 1.8 + marlin-graphics (Graphics2D wrapper)
  • openJDK: in sync with OpenJDK8/9 ( => jdk9/client)
  • openJDK_dev: experimental to be updated for OpenJDK 10 (JDK.Next => jdk/client)
  • marlin-fx project has 2 active branches:
    • master: MarlinFX for JDK8 (JavaFX 8) - in sync with Marlin - Unsafe branch
    • openjdk: in sync with OpenJFX 10 (openjfx10)
So I manually merge / synchronize those branches on my laptop:
- build & test on github projects => Marlin-renderer releases
- build & test OpenJDK / OpenJFX 10 => patches on 2d or jfx forrests

I want to provide new Marlin & MarlinFX releases for Java 9 as system module patches soon.
I will certainly add new branches on github and update the maven pom.xml to produce such java9 patches.
I asked for help on that java 9 build (maybe Nicolas Parlog could tell me how to make it ?)

Could you present me your JavaFX build server ?
Which JavaFX version do you support (8, 9, 10) ?
 
I can also develop some specific effects in my DemoFX system for benchmarking MarlinFX changes.

As announced last month on tweeter, I made (thanks to FXGraphics2D Canvas) the new MapBenchFX tool that works on JavaFX 8, 9, 10... so we reuse some MapBench scene or write few specific shape rendering tasks to benchmark MarlinFX.

Thank you very much for your help,
Laurent

Chris Newland

unread,
Nov 10, 2017, 3:55:24 AM11/10/17
to marlin-renderer
I'm going to raise this with the AdoptOpenJDK project. They have better build farms than me and also some experience in module patching.

Cheers,

Chris

Laurent Bourgès

unread,
Nov 10, 2017, 4:19:16 AM11/10/17
to marlin-...@googlegroups.com
I asked Martin and their build farm does not build openjfx for now but it will in the future.

Could you ask if it would be possible to run benchmarks (head less) on such various machines ?

That would be AWESOME.

bye,
Laurent

--
You received this message because you are subscribed to the Google Groups "marlin-renderer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marlin-renderer+unsubscribe@googlegroups.com.
To post to this group, send email to marlin-renderer@googlegroups.com.

Olivier Brault

unread,
Nov 10, 2017, 11:59:34 AM11/10/17
to marlin-renderer
I tried Marlin 0.8.2  with Oracle JDK 1.8.0_102 (very old, I know ...)
With 4GB heap size allocated.
Desktop application

It work fine, now, no triangle bug anymore !
I have not seen performance gain since older 0.8 versions, but I don't make fine benchmark, only printing full drawing time in console.

Concerning support, I admit not having much time nor money for now.
But I am really interested in computer graphism, so I hope having more time to participate, maybe later ...

Concerning big company or stucture (notably Oracle), I am very surprised you couldn't have any support or consideration for your wonderful work. It is really pitiful.

Olivier

Laurent Bourgès

unread,
Dec 2, 2017, 8:05:26 AM12/2/17
to marlin-...@googlegroups.com
Chris,
I updated marlin-fx (master branch) to 0.8.2 on github.

Will work soon on making the jdk10 module patch (openjdk branch)... so you will be able to test it.

Laurent

--
You received this message because you are subscribed to the Google Groups "marlin-renderer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marlin-renderer+unsubscribe@googlegroups.com.
To post to this group, send email to marlin-renderer@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages