Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 494717

Summary: [HiDPI][GTK] Path cubic curves are not auto-scaled correctly with HiDPI settings
Product: [Eclipse Project] Platform Reporter: Peter Severin <peter>
Component: SWTAssignee: Sravan Kumar Lakkimsetti <sravankumarl>
Status: VERIFIED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: arunkumar.thondapu, daniel_megert, lshanmug, lufimtse, markus.kell.r, niraj.modi, sravankumarl
Version: 4.6Flags: markus.kell.r: review+
lshanmug: review+
niraj.modi: review+
Target Milestone: 4.6 RC4   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/73902
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ed5e45664229e6b5ca67a044b19e5e7f6c9faa0d
Whiteboard:
Bug Depends on:    
Bug Blocks: 479614    
Attachments:
Description Flags
Test case for reproducing cubic curve scaling problem
none
Cubic curve no scaling
none
Cubic curve x2 scaling
none
Snippet10 no scaling
none
Snippet10 x2 scaling
none
Win7: Output of Snippet10 and TestSnippet at 200% Zoom none

Description Peter Severin CLA 2016-05-27 04:08:59 EDT
Created attachment 262044 [details]
Test case for reproducing cubic curve scaling problem

I am testing HiDPI auto scaling and comparing results of no-scaling and x2 scaling, and I see some scaling problems with SWT Paths. Specifically, it looks like cubic curves are not scaled correctly, but perhaps the bug is present in quad curves too. Moveto and Lineto operations seems to be scaled correctly.

I've attached a snippet that shows the curve drawing differences between 2 scaling settings.

I've also noticed differences when running SWT Snippet10 (draw using transformations, paths and alpha blending). I'm not sure if it's the same but, but I've attached images for this test too.

I'm testing with the latest integration build I20160525-2000.

I'm testing with Debian, but I believe that the bug is not platform specific.
Comment 1 Peter Severin CLA 2016-05-27 04:09:35 EDT
Created attachment 262045 [details]
Cubic curve no scaling
Comment 2 Peter Severin CLA 2016-05-27 04:09:51 EDT
Created attachment 262046 [details]
Cubic curve x2 scaling
Comment 3 Peter Severin CLA 2016-05-27 04:10:06 EDT
Created attachment 262047 [details]
Snippet10 no scaling
Comment 4 Peter Severin CLA 2016-05-27 04:10:23 EDT
Created attachment 262048 [details]
Snippet10 x2 scaling
Comment 5 Niraj Modi CLA 2016-05-27 08:28:24 EDT
Created attachment 262067 [details]
Win7: Output of Snippet10 and TestSnippet at 200% Zoom

Works fine on Win7 200%Zoom.
Comment 6 Peter Severin CLA 2016-05-27 08:57:41 EDT
It looks like the x, y arguments in Path#cubicTo are not scaled on cairo graphics.

Here's the windows version:

public void cubicTo (float cx1, float cy1, float cx2, float cy2, float x, float y) {
	cx1 = DPIUtil.autoScaleUp(cx1);
	cy1 = DPIUtil.autoScaleUp(cy1);
	cx2 = DPIUtil.autoScaleUp(cx2);
	cy2 = DPIUtil.autoScaleUp(cy2);
	x = DPIUtil.autoScaleUp(x);
	y = DPIUtil.autoScaleUp(y);
	cubicToInPixels(cx1, cy1, cx2, cy2, x, y);
}

Here's cairo version:

public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) {
	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
	cx1 = DPIUtil.autoScaleUp(cx1);
	cy1 = DPIUtil.autoScaleUp(cy1);
	cx2 = DPIUtil.autoScaleUp(cx2);
	cy2 = DPIUtil.autoScaleUp(cy2);
	cubicToInPixels(cx1, cy1, cx2, cy2, x, y);
}

quadTo on cairo has the same problem.
Comment 7 Sravan Kumar Lakkimsetti CLA 2016-05-30 04:13:56 EDT
(In reply to Peter Severin from comment #6)
> It looks like the x, y arguments in Path#cubicTo are not scaled on cairo
> graphics.
> 
> Here's the windows version:
> 
> public void cubicTo (float cx1, float cy1, float cx2, float cy2, float x,
> float y) {
> 	cx1 = DPIUtil.autoScaleUp(cx1);
> 	cy1 = DPIUtil.autoScaleUp(cy1);
> 	cx2 = DPIUtil.autoScaleUp(cx2);
> 	cy2 = DPIUtil.autoScaleUp(cy2);
> 	x = DPIUtil.autoScaleUp(x);
> 	y = DPIUtil.autoScaleUp(y);
> 	cubicToInPixels(cx1, cy1, cx2, cy2, x, y);
> }
> 
> Here's cairo version:
> 
> public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x,
> float y) {
> 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
> 	cx1 = DPIUtil.autoScaleUp(cx1);
> 	cy1 = DPIUtil.autoScaleUp(cy1);
> 	cx2 = DPIUtil.autoScaleUp(cx2);
> 	cy2 = DPIUtil.autoScaleUp(cy2);
> 	cubicToInPixels(cx1, cy1, cx2, cy2, x, y);
> }
> 
> quadTo on cairo has the same problem.

Hi,

Thank you for the analysis. Can you please let us know if this problem is affecting any products or epp packages? if so can you please point us to the bug associated.

Thanks
Sravan
Comment 8 Peter Severin CLA 2016-05-30 04:19:59 EDT
I am not in position to provide this information. I'm reproducing this bug with my own product (WireframeSketcher plugin) that I am testing with Eclipse 4.6. WireframeSketcher is unusable in the presence of this bug.
Comment 9 Eclipse Genie CLA 2016-05-30 04:57:01 EDT
New Gerrit change created: https://git.eclipse.org/r/73902
Comment 10 Sravan Kumar Lakkimsetti CLA 2016-05-30 05:23:25 EDT
This bug affects the drawing of curves. I believe this will impact graphics packages like GEF, GMF etc. In my opinion this should be fixed for 4.6. 

The code change is quite simple. There are couple of places I missed to scaleup the coordinates. one for cubic curve and another for font. This doesnot affect Windows as these changes are already there is Windows.

I have tested this using graphics example available in swt examples. 

Once all the approvals are in place we would like to push this to RC4.
Comment 11 Markus Keller CLA 2016-05-30 15:29:54 EDT
Risk assessment: low.

Affected clients: Only GTK code that uses org.eclipse.swt.graphics.Path.
The Path class is not used in SDK, which explains (but doesn't excuse) why this was not detected earlier.

The code changes are small, local, and easy to understand.
Comment 13 Sravan Kumar Lakkimsetti CLA 2016-05-31 04:13:19 EDT
Verified in build 4.6.0.I20160530-2000 on Ubuntu 15.10