wei-spring / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

Artefact when filling a Shape on iOS using new pipeline. #1156

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This issue relates to the new graphics pipeline implementation on iOS.
The issue shows on my (non-retina) iPad Mini, running iOS 7.1.2

What steps will reproduce the problem?

1. Draw a (orange) colour background.
2. Create a Shape using a GeneralPath.
3. draw the shape in a colour (blue) using the Graphics.fillShape() method.

What is the expected output? What do you see instead?
Expected to see only the blue Shape on the orange background. However, a white 
line appears at the "right hand" edge of the Shape.

What version of the product are you using? On what operating system?

Up to date library (checked!). Artefact shows on non-retina iPad Mini running 
iOS 7.1.2

Please provide any additional information below.

Android hardware and the simulator do not share the issue.
Drawing a blue outline using Graphics.drawShape() does not remove the white 
line (which suggests it is outside the Shape).

Original issue reported on code.google.com by timo.van...@gmail.com on 18 Jul 2014 at 8:02

GoogleCodeExporter commented 9 years ago
Can you post code and send a screenshot?  I can't seem to reproduce.  Here is 
the code I tried.

 public void paint(Graphics g) {
        super.paint(g); //To change body of generated methods, choose Tools | Templates.

        int x = getX();
        int y = getY();
        int w = getWidth();
        int h = getHeight();

        g.setColor(0xff4500);
        g.fillRect(x, y, 500, 500);

        GeneralPath p = new GeneralPath();
        p.moveTo(x+10, y+10);
        p.quadTo(x+100, y+20, x+150, y+100);
        p.quadTo(x+50, y+150, x+20, y+200);
        p.closePath();

        g.setColor(0x0000ff);
        g.fillShape(p);
}

And screenshot attached.

Original comment by st...@weblite.ca on 18 Jul 2014 at 4:51

Attachments:

GoogleCodeExporter commented 9 years ago
Note that the problem only occurs on iOS hardware, and not in the simulator.

The only difference appears to be that I use lineTo() instead of quadTo() to 
build the shape. This is how I build the shape from a list of points:

private Shape buildShape(List<Point> points) {
    GeneralPath shape = new GeneralPath();
    boolean first = true;
    for (Point p : points) {
        if (first)
            shape.moveTo(p.getX(), p.getY());
        else
            shape.lineTo(p.getX(), p.getY());
        first = false;
    }
    return shape;
}

Attached you find a picture of the output on iOS.

(The blue area is drawn as a pie shape in clockwise direction on top of the 
existing orange disc.)

Original comment by timo.van...@gmail.com on 21 Jul 2014 at 8:00

Attachments:

GoogleCodeExporter commented 9 years ago
Another difference was that I did not explicitly close the path of the shape.

Adding this call, however, makes no difference to the output.

Original comment by timo.van...@gmail.com on 21 Jul 2014 at 9:02

GoogleCodeExporter commented 9 years ago
Can you provide a full minimal working example.  That is just a generic shape 
builder function, and that is working fine for me with the shapes that I am 
putting in.  When you say it doesn't happen on the Simulator, do you mean the 
codename one simulator, or the iOS simulator that is part of X-Code.  I was 
using the iOS simulator in Xcode, not the codename one simulator.

Original comment by st...@weblite.ca on 21 Jul 2014 at 2:52

GoogleCodeExporter commented 9 years ago
I was referring to the CN1 simulator.

(The attached image was taken from the screen of my iPad mini.)

Original comment by timo.van...@gmail.com on 21 Jul 2014 at 2:56

GoogleCodeExporter commented 9 years ago
The code below creates a nice white line when run on my iPad mini under iOS 
7.1.2.
Interestingly, the (build time) screen shot that is displayed at startup does 
not include the white line!

Place this component in the center of a border layout form:

public class Canvas extends Component {
    @Override
    public void paint(Graphics g) {
        int x = getX();
        int y = getY();

        g.setColor(0x0FF9500);
        g.fillRect(x, y, 500, 500);

        GeneralPath p = new GeneralPath();
        p.moveTo(x + 10, y + 10);
        p.lineTo(x + 200, y + 100);
        p.lineTo(x + 50, y + 150);
        p.closePath();

        g.setColor(0x0F7AFD);
        g.fillShape(p);
    }
}

Original comment by timo.van...@gmail.com on 21 Jul 2014 at 6:09

GoogleCodeExporter commented 9 years ago
Any news on the solution of this issue?

The current version still has this very same problem, and is blocking my 
progress on another app...

Worse still, using drawShape() to draw a straight line between two points with 
a (very) wide stroke demonstrated a bizarre width reduction when the line is 
either horizontal or vertical. (Horizontal / vertical lines as part of a larger 
shape appear to not have this problem.)

Is anybody using this code in production?

Original comment by timo.van...@gmail.com on 5 Jan 2015 at 1:33

GoogleCodeExporter commented 9 years ago
Steve, do you have an idea on this?

Original comment by shai.almog on 5 Jan 2015 at 3:35

GoogleCodeExporter commented 9 years ago
I have now reproduced this and fixed it locally.  I need to run some tests to 
make sure it doesn't introduce any regressions, but I'll have this in SVN 
within the next couple of hours.

Original comment by steve.ha...@codenameone.com on 5 Jan 2015 at 11:47

GoogleCodeExporter commented 9 years ago
Fixed.  Attached is a screenshot of the example posted running in Xcode's iOS 
simulator.

Original comment by steve.ha...@codenameone.com on 6 Jan 2015 at 12:04

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Steve,

Thank you for fixing this issue; you just made my day!  :-)

Did you also look into (or fix) the mentioned problem with drawShape() of a 
single straight hoizontal/vertical line and a (very) broad stroke on iOS? - It 
looks as if the stroke algorithm fails when crossing the horizonal/vertical 
axis.

Original comment by timo.van...@gmail.com on 6 Jan 2015 at 8:41

GoogleCodeExporter commented 9 years ago
Can you post a test case?

Original comment by steve.ha...@codenameone.com on 6 Jan 2015 at 4:10

GoogleCodeExporter commented 9 years ago
Hi Steve,

I submitted a new issue #1260 for this, which includes sample source code and a 
screen photo from my iPad mini of its screen output.

Original comment by timo.van...@gmail.com on 6 Jan 2015 at 5:25

GoogleCodeExporter commented 9 years ago
I see.  No this bug is probably not fixed yet but I think I know what is going 
on.  I should have a fix soon.

Original comment by steve.ha...@codenameone.com on 6 Jan 2015 at 5:46