Community
Participate
Working Groups
SWT-win32, v3231 When the advanced graphics mode is used, a call to GC.fillPolygon in some cases results in the polygon being painted at coordinates that are different from those seen in normal mode. Some of these coordinates may lie slightly outside the region specified by the point array. This seems wrong, or is it expected for some reason? --- import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class PolygonTest { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { int[] pts = { 75, 100, 100, 75, 125, 100, 100, 125}; e.gc.drawLine(0, 100, 199, 100); e.gc.drawLine(100, 0, 100, 199); e.gc.drawRectangle(75, 75, 50, 50); e.gc.setAdvanced(true); e.gc.setBackground(e.gc.getDevice().getSystemColor(SWT.COLOR_RED)); e.gc.setForeground(e.gc.getDevice().getSystemColor(SWT.COLOR_BLUE)); e.gc.fillPolygon(pts); e.gc.drawPolygon(pts); } }); Rectangle rect = shell.computeTrim(0, 0, 200, 200); shell.setSize(rect.width, rect.height); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
Created attachment 40083 [details] Screenshot (magnified) fillPolygon and drawPolygon called with the same coordinates Left: Normal mode Right: Advanced mode
New Gerrit change created: https://git.eclipse.org/r/136209
(In reply to Eclipse Genie from comment #2) > New Gerrit change created: https://git.eclipse.org/r/136209 Able to reproduce the problem, am looking into this patch.
(In reply to Eclipse Genie from comment #2) > New Gerrit change created: https://git.eclipse.org/r/136209 Above patch works, but seems like a hack. Similar problem is solved in other GC functions, am working on an alternate patch.
New Gerrit change created: https://git.eclipse.org/r/136237
(In reply to Eclipse Genie from comment #5) > New Gerrit change created: https://git.eclipse.org/r/136237 Hi Mike, Please test the updated patch set 3.
Further tested https://git.eclipse.org/r/#/c/136237/ patch set 3. Found one breaking scenario(snippet modified from comment 0). Sharing my observations: 1. Apart from data.gdipXOffset correction we also need correction for data.gdipYOffset 2. Also the offsetCorrection value of 0.5f(instead of 1 pixel as suggested in patch set 3 above) is also sufficient for fixing this issue. Will share an updated patch shortly ------------------------------------------------------------------------------- import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class PolygonTest { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { int[] pts = { 77, 100, 100, 77, 125, 100, 100, 125}; e.gc.drawLine(0, 100, 199, 100); e.gc.drawLine(100, 0, 100, 199); e.gc.drawRectangle(75, 75, 50, 50); e.gc.setAdvanced(true); e.gc.setBackground(e.gc.getDevice().getSystemColor(SWT.COLOR_RED)); e.gc.setForeground(e.gc.getDevice().getSystemColor(SWT.COLOR_BLUE)); e.gc.fillPolygon(pts); e.gc.drawPolygon(pts); } }); Rectangle rect = shell.computeTrim(0, 0, 200, 200); shell.setSize(rect.width, rect.height); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
Gerrit change https://git.eclipse.org/r/136237 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=796a41a7ac80115a4a90c80b42d2989134aed2ef
(In reply to Eclipse Genie from comment #8) > Gerrit change https://git.eclipse.org/r/136237 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=796a41a7ac80115a4a90c80b42d2989134aed2ef Changes merged to master, resolving now.
Thanks Mike for your quick reviews and inputs!
(In reply to Niraj Modi from comment #10) > Thanks Mike for your quick reviews and inputs! Glad to help, thank you Niraj!
Thanks Mike and Niraj this will significantly improve the dark theme on windows.
New Gerrit change created: https://git.eclipse.org/r/136342
Gerrit change https://git.eclipse.org/r/136342 was merged to [master]. Commit: http://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=7ded2020116b1677fdc7947ecf3541a2b2450f91
Verified the fix in SWT and Eclipse in IBuild id: I20190218-1800 @Win7
I had to create a bug ticket because of the bugfix: https://bugs.eclipse.org/bugs/show_bug.cgi?id=546898 -> look at: https://bugs.eclipse.org/bugs/attachment.cgi?id=278457