Bug 535068 - [Dark Theme] CTabFolder Chevron looks bad
Summary: [Dark Theme] CTabFolder Chevron looks bad
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.10   Edit
Assignee: Matthias Becker CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
: 464230 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-05-24 08:42 EDT by Lars Vogel CLA
Modified: 2018-12-05 04:11 EST (History)
9 users (show)

See Also:


Attachments
Screenshot (12.54 KB, image/png)
2018-05-24 08:42 EDT, Lars Vogel CLA
no flags Details
chevron crisp on high resolution display (9.04 KB, image/png)
2018-08-31 11:03 EDT, Matthias Becker CLA
no flags Details
chevron crisp unchanged on normal resolution display (4.96 KB, image/png)
2018-08-31 11:04 EDT, Matthias Becker CLA
no flags Details
chevron not using transparency but the "correct" background (5.46 KB, image/png)
2018-09-04 04:39 EDT, Matthias Becker CLA
no flags Details
Chevron not using transparency (383 bytes, image/png)
2018-09-04 09:19 EDT, Wim Jongman CLA
no flags Details
wrong background color (41,41,41) on mac (5.89 KB, image/png)
2018-09-04 09:33 EDT, Matthias Becker CLA
no flags Details
screen recording showing toolbar item issue in CTabFolder (12.01 KB, image/png)
2018-09-04 09:49 EDT, Matthias Becker CLA
no flags Details
Fix in dark theme on mac (81.83 KB, image/png)
2018-09-05 04:06 EDT, Matthias Becker CLA
no flags Details
Fix in light theme on mac (80.51 KB, image/png)
2018-09-05 04:07 EDT, Matthias Becker CLA
no flags Details
Screenshot (22.60 KB, image/png)
2018-09-05 04:32 EDT, Lars Vogel CLA
no flags Details
with the fix on a retina display (134.06 KB, image/png)
2018-09-14 03:44 EDT, Matthias Becker CLA
no flags Details
with the fix on a normal resolution display (40.60 KB, image/png)
2018-09-14 03:45 EDT, Matthias Becker CLA
no flags Details
high resolution compared old (left) and new (right) (12.36 KB, image/png)
2018-09-18 03:26 EDT, Matthias Becker CLA
no flags Details
Windows 10 3480x2160 225% scaling (184.51 KB, image/png)
2018-09-18 05:26 EDT, Wim Jongman CLA
no flags Details
Current SWT Master Windows 10 3480x2160 225% scaling (3.96 KB, image/png)
2018-09-18 05:39 EDT, Wim Jongman CLA
no flags Details
Screen shots on Kubuntu with 200% scale (44.71 KB, image/png)
2018-09-18 06:12 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
screenshots with fedora 28 with gnome (17.30 KB, image/png)
2018-09-18 06:39 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2018-05-24 08:42:18 EDT
Created attachment 274175 [details]
Screenshot

This chevron is custom drawn. Maybe this drawing can be improved so that is looks also good in the dark theme.
Comment 1 Lars Vogel CLA 2018-05-24 08:44:10 EDT
Wim, you are a custom widget/ gc expert. Could you help in improving the drawing for both the light and the dark theme?
Comment 2 Wim Jongman CLA 2018-05-30 17:28:16 EDT
(In reply to Lars Vogel from comment #1)
> Wim, you are a custom widget/ gc expert. Could you help in improving the
> drawing for both the light and the dark theme?

Thanks for the promotion. I think this is not SWT but must be some stack renderer addon no? WDYT?
Comment 3 Wim Jongman CLA 2018-05-30 17:50:04 EDT
Never mind, I think I found it in CTabFolderRenderer#drawChevron
Comment 4 Lars Vogel CLA 2018-06-13 05:31:04 EDT
(In reply to Wim Jongman from comment #3)
> Never mind, I think I found it in CTabFolderRenderer#drawChevron

Master Wim, can you have a look at this? I believe for you it will be trivial and it really affects my dark theme experience.
Comment 5 Lakshmi P Shanmugam CLA 2018-08-28 04:38:51 EDT
Resetting target, please re-target as required.
Comment 6 Matthias Becker CLA 2018-08-31 06:51:03 EDT
during the analysis of this bug I found another one. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=538456.
I also proposed a solution for that bug there.
Comment 7 Eclipse Genie CLA 2018-08-31 11:00:02 EDT
New Gerrit change created: https://git.eclipse.org/r/128454
Comment 8 Eclipse Genie CLA 2018-08-31 11:00:17 EDT
New Gerrit change created: https://git.eclipse.org/r/128455
Comment 9 Matthias Becker CLA 2018-08-31 11:02:25 EDT
my two gerrits are a proof of concept.
I know that the SWT change breaks API (therefore I needed to adapt code in platform.ui)  - I just want got get feedback if the general approach is going into the right direction.

The chevron does not look better on "normal" res displays (actually it's unchanged there). But is sharp and crisp on high resolution displays.
Comment 10 Matthias Becker CLA 2018-08-31 11:03:47 EDT
Created attachment 275630 [details]
chevron crisp on high resolution display
Comment 11 Matthias Becker CLA 2018-08-31 11:04:26 EDT
Created attachment 275631 [details]
chevron crisp unchanged on normal resolution display
Comment 12 Matthias Becker CLA 2018-08-31 11:05:57 EDT
(In reply to Matthias Becker from comment #11)
> Created attachment 275631 [details]
> chevron crisp unchanged on normal resolution display

The "white" ugly border comes from the interpolation between the foreground color and the transparent background color. They are still there on the high resolution version but there are much smaller there (because of the higher resolution)
Comment 13 Matthias Becker CLA 2018-09-04 04:38:58 EDT
(In reply to Matthias Becker from comment #12)
> (In reply to Matthias Becker from comment #11)
> > Created attachment 275631 [details]
> > chevron crisp unchanged on normal resolution display
> 
> The "white" ugly border comes from the interpolation between the foreground
> color and the transparent background color. They are still there on the high
> resolution version but there are much smaller there (because of the higher
> resolution)

I had again a look at this. The code that causes this is marked with a "<<<":

 Image image = new Image (display, size.x - trim.width, size.y - trim.height);
 GC gc = new GC (image);
 RGB transparent;
 if (button == CTabFolderRenderer.PART_CHEVRON_BUTTON) { 
  transparent = new RGB(0xFF, 0xFF, 0xFF);
 } else {
  transparent = new RGB(0xF7, 0, 0);
 }
 Color transColor = new Color(display, transparent);
 gc.setBackground(transColor);
 gc.fillRectangle(image.getBounds());
 "drawing code goes here
 final ImageData imageData = image.getImageData (DPIUtil.getDeviceZoom ());
 imageData.transparentPixel = imageData.palette.getPixel(transparent); "<<<

Here an image is created and the background is set to white. After the the chevron is drawn (on the gc on that image) the image data is retrieved and the transparentPixel field is set to the "white" background. This is saying: "All white pixels are transparent". But not all pixels are either "white" or the chevrons foreground color. Due to the interpolation there are pixels that are "almost white". And these are not rendered as transparent and this creates this bade white border around the drawing.

For testing purposes I change the code to (chagned are marked with "<<<):

 Image image = new Image (display, size.x - trim.width, size.y - trim.height);
 GC gc = new GC (image);
 RGB transparent;
 if (button == CTabFolderRenderer.PART_CHEVRON_BUTTON) {
  transparent = new RGB(67,67,70); "<<<
 } else {
  transparent = new RGB(0xF7, 0, 0);
 }
 Color transColor = new Color(display, transparent);
 gc.setBackground(transColor);
 gc.fillRectangle(image.getBounds());
 "drawing code goes here
 final ImageData imageData = image.getImageData (DPIUtil.getDeviceZoom ());
 //imageData.transparentPixel = imageData.palette.getPixel(transparent); "<<<

I set the color of the created image to the background of control it is drawn on and do not use transparency at all. I will upload the result as a screenshot in a view moments. The result looks really nice. The white border is gone.

But this is just a proof of concept. I got the new RGB(67,67,70) by using a color-picker tool to grab the actual background in the running eclipse. I did not find a way to get that color via code. I also used the CSS-Spy by inspecting the control hierarchy to get the background color but for  all the controls (the MPlacHolder, the MArea, the CTabFolder, the toolbar, ...) I get something like RGB(81,86,88). Where can I get the correct background color from? Can somebody pls. give me a hint?
Comment 14 Matthias Becker CLA 2018-09-04 04:39:43 EDT
Created attachment 275671 [details]
chevron not using transparency but the "correct" background
Comment 15 Wim Jongman CLA 2018-09-04 07:42:47 EDT
(In reply to Matthias Becker from comment #13)

> color from? Can somebody pls. give me a hint?

Pretty cool Matthias. I assume the code is in the Gerrit right? I do not see enough of it here to make a good suggestion. I will take a look at it.
Comment 16 Matthias Becker CLA 2018-09-04 07:53:47 EDT
(In reply to Wim Jongman from comment #15)
> (In reply to Matthias Becker from comment #13)
> 
> > color from? Can somebody pls. give me a hint?
> 
> Pretty cool Matthias. I assume the code is in the Gerrit right? I do not see
> enough of it here to make a good suggestion. I will take a look at it.

No the code is not in Gerrit (yet). 
The attached Gerrits are a prove of concept for enabling drawing in high resolution.
But this transparency issue is independent from the other. So I will create an independent gerrit change for this (with my demo-code outlined below).
Comment 17 Eclipse Genie CLA 2018-09-04 08:05:09 EDT
New Gerrit change created: https://git.eclipse.org/r/128632
Comment 18 Matthias Becker CLA 2018-09-04 08:08:38 EDT
(In reply to Matthias Becker from comment #16)
> No the code is not in Gerrit (yet). 

Now it is ;-)
Comment 19 Matthias Becker CLA 2018-09-04 08:09:27 EDT
(In reply to Wim Jongman from comment #15)
> (In reply to Matthias Becker from comment #13)
> 
> > color from? Can somebody pls. give me a hint?
> 
> Pretty cool Matthias. I assume the code is in the Gerrit right? I do not see
> enough of it here to make a good suggestion. I will take a look at it.

I added you as a reviewer in gerrit.
Comment 20 Eclipse Genie CLA 2018-09-04 08:10:24 EDT
New Gerrit change created: https://git.eclipse.org/r/128633
Comment 21 Wim Jongman CLA 2018-09-04 08:44:08 EDT
(In reply to Matthias Becker from comment #18)

Ok, I got it. How about:

Line 729

RGB transparent;

if(button == CTabFolderRenderer.PART_CHEVRON_BUTTON){
  transparent = chevronItem.getControl().getBackground().getRGB();
} else {
  transparent = new RGB(0xF7, 0, 0);
}
Comment 22 Matthias Becker CLA 2018-09-04 08:58:32 EDT
(In reply to Wim Jongman from comment #21)
> (In reply to Matthias Becker from comment #18)
> 
> Ok, I got it. How about:
> 
> Line 729
> 
> RGB transparent;
> 
> if(button == CTabFolderRenderer.PART_CHEVRON_BUTTON){
>   transparent = chevronItem.getControl().getBackground().getRGB();
> } else {
>   transparent = new RGB(0xF7, 0, 0);
> }

this causes NPEs. ChevronItem may be null, "getControl()" may return null..

If also would like to get rid of that 
  if(button == CTabFolderRenderer.PART_CHEVRON_BUTTON)
and would also use the same approach (without ransparency) for all the button images here.
Comment 23 Wim Jongman CLA 2018-09-04 09:07:43 EDT

> this causes NPEs. ChevronItem may be null, "getControl()" may return null..

Yes. It was a first glance before I could actually prepare my workspace and run. I figured that you would have seen that.

> 
> If also would like to get rid of that 
>   if(button == CTabFolderRenderer.PART_CHEVRON_BUTTON)
> and would also use the same approach (without ransparency) for all the
> button images here.

Yes but it means we must pass the background color to the method. Which, like you said, requires us to find it in some way from where we are.

Did you follow chevronItem.setImage(chevronImage); on line 2573?
Comment 24 Matthias Becker CLA 2018-09-04 09:14:37 EDT
(In reply to Wim Jongman from comment #23)
> 
> > this causes NPEs. ChevronItem may be null, "getControl()" may return null..
> 
> Yes. It was a first glance before I could actually prepare my workspace and
> run. I figured that you would have seen that.
> 
> > 
> > If also would like to get rid of that 
> >   if(button == CTabFolderRenderer.PART_CHEVRON_BUTTON)
> > and would also use the same approach (without ransparency) for all the
> > button images here.
> 
> Yes but it means we must pass the background color to the method. Which,
> like you said, requires us to find it in some way from where we are.
> 
> Did you follow chevronItem.setImage(chevronImage); on line 2573?

Even at this call "getControl" returns null. The JavaDoc of ToolItem#getControl
says: "Returns the control that is used to fill the bounds of the item when the item is a SEPARATOR".
So this does not help. Maybe you can checkout my gerrit change an play with the code by yourself.
Comment 25 Wim Jongman CLA 2018-09-04 09:19:33 EDT
Created attachment 275678 [details]
Chevron not using transparency

(In reply to Matthias Becker from comment #24)

> So this does not help. Maybe you can checkout my gerrit change an play with
> the code by yourself.

Yes, I am playing with it. I found that

background = chevronItem.getParent().getBackground().getRGB();

works. 

I think that we need to pass the background color to this method. In case of null the old code kicks in.
Comment 26 Matthias Becker CLA 2018-09-04 09:33:01 EDT
(In reply to Wim Jongman from comment #25)
> Created attachment 275678 [details]
> Chevron not using transparency
> 
> (In reply to Matthias Becker from comment #24)
> 
> > So this does not help. Maybe you can checkout my gerrit change an play with
> > the code by yourself.
> 
> Yes, I am playing with it. I found that
> 
> background = chevronItem.getParent().getBackground().getRGB();
> 
> works. 
Not for me. In mac it returns (41,41,41) which is too dark - see screenshot
Comment 27 Matthias Becker CLA 2018-09-04 09:33:26 EDT
Created attachment 275680 [details]
wrong background color (41,41,41) on mac
Comment 28 Matthias Becker CLA 2018-09-04 09:49:26 EDT
Created attachment 275682 [details]
screen recording showing toolbar item issue in CTabFolder

(In reply to Matthias Becker from comment #27)
> Created attachment 275680 [details]
> wrong background color (41,41,41) on mac

The correct color in macOS dark theme is (70,70,73).
And this comes from this dark theme stylesheet.

ColorDefinition#org-eclipse-ui-workbench-INACTIVE_UNSELECTED_TABS_COLOR_END {
	color: #464649;
	category: '#org-eclipse-ui-presentation-default';
	label: url('platform:/plugin/org.eclipse.ui.themes?message=INACTIVE_UNSELECTED_TABS_COLOR_END');
}

You can configure this in the preferences. I did change that color to a red color for that screenshot. The screenshot was made with the original code (that still has the transparency issue). As you see in the lower part of the picture we already have an issue with "normal" toolbar items in that area. They have the wrong background color.
Comment 29 Wim Jongman CLA 2018-09-04 11:09:57 EDT
Matthias I have troubles adding to the same change set. 

This works on windows. Can you try on mac?

Image createButtonImage(Display display, int button) {
	GC tempGC = new GC (this);
	Point size = renderer.computeSize(button, SWT.NONE, tempGC, SWT.DEFAULT, SWT.DEFAULT);
	tempGC.dispose();
	Rectangle trim = renderer.computeTrim(button, SWT.NONE, 0, 0, 0, 0);
	Image image = new Image (display, size.x - trim.width, size.y - trim.height);
	GC gc = new GC (image);
	Color transColor = renderer.parent.getBackground();
	gc.setBackground(transColor);
	RGB transparent = transColor.getRGB();
	gc.setBackground(transColor);
	gc.fillRectangle(image.getBounds());
	renderer.draw(button, SWT.NONE, new Rectangle(trim.x, trim.y, size.x, size.y), gc);
	gc.dispose ();
	final ImageData imageData = image.getImageData (DPIUtil.getDeviceZoom ());
	imageData.transparentPixel = imageData.palette.getPixel(transparent);
	image.dispose();
	image = new Image(display, new AutoScaleImageDataProvider(display, imageData, DPIUtil.getDeviceZoom()));
	return image;
}
Comment 30 Matthias Becker CLA 2018-09-05 03:14:46 EDT
(In reply to Wim Jongman from comment #29)
> Matthias I have troubles adding to the same change set. 
> 
> This works on windows. Can you try on mac?
> 
> Image createButtonImage(Display display, int button) {
> 	GC tempGC = new GC (this);
> 	Point size = renderer.computeSize(button, SWT.NONE, tempGC, SWT.DEFAULT,
> SWT.DEFAULT);
> 	tempGC.dispose();
> 	Rectangle trim = renderer.computeTrim(button, SWT.NONE, 0, 0, 0, 0);
> 	Image image = new Image (display, size.x - trim.width, size.y -
> trim.height);
> 	GC gc = new GC (image);
> 	Color transColor = renderer.parent.getBackground();
> 	gc.setBackground(transColor);
> 	RGB transparent = transColor.getRGB();
> 	gc.setBackground(transColor);
> 	gc.fillRectangle(image.getBounds());
> 	renderer.draw(button, SWT.NONE, new Rectangle(trim.x, trim.y, size.x,
> size.y), gc);
> 	gc.dispose ();
> 	final ImageData imageData = image.getImageData (DPIUtil.getDeviceZoom ());
> 	imageData.transparentPixel = imageData.palette.getPixel(transparent);
> 	image.dispose();
> 	image = new Image(display, new AutoScaleImageDataProvider(display,
> imageData, DPIUtil.getDeviceZoom()));
> 	return image;
> }

I first didn't understand why this looks better as still transparency is used. But now I got it. The artifacts are still there but not less visible in the dark theme because they are also dark. I updated the gerrit patch by removing the testing-code and by adding a detailed commit message. So from my side it's finished.

This is working fine on macOS. I tested with all available themes (also the [Windows] and [Linux] once). Can somebody test it on Linux? If it's also working nice there I would like to get it merged early for 4.10.
Comment 31 Lars Vogel CLA 2018-09-05 03:50:47 EDT
(In reply to Matthias Becker from comment #30)

> This is working fine on macOS. I tested with all available themes (also the
> [Windows] and [Linux] once). Can somebody test it on Linux? 

Looks beautiful under Linux. +1 for early merge.
Comment 32 Matthias Becker CLA 2018-09-05 04:06:50 EDT
Created attachment 275693 [details]
Fix in dark theme on mac
Comment 33 Matthias Becker CLA 2018-09-05 04:07:08 EDT
Created attachment 275694 [details]
Fix in light theme on mac
Comment 34 Lars Vogel CLA 2018-09-05 04:32:52 EDT
Created attachment 275696 [details]
Screenshot
Comment 36 Lars Vogel CLA 2018-09-06 03:08:13 EDT
Service segment update in MANIFEST.MF will be done via https://git.eclipse.org/r/128807 See https://wiki.eclipse.org/Version_Numbering for details.
Comment 37 Matthias Becker CLA 2018-09-06 03:51:29 EDT
(In reply to Eclipse Genie from comment #35)
> Gerrit change https://git.eclipse.org/r/128632 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=0dd8e12c56f609aa47708bdca09e29969d9fa44e

The transparency artefacts are fixed with that change. But the chevron is sitll blurry on high resolution displays. 
My change https://git.eclipse.org/r/#/c/128454/ shows how this can be fixed.
Unfortunately that change breaks API (see https://git.eclipse.org/r/#/c/128455/ what breaks in platform due to this change).

When I understand it correctly it is by intention that CTabFolderRenderer can be subclassed to customize the rendering.

I tried adding a new methods:
  protected void draw (int part, int state, Rectangle bounds, GC gc, int zoom)
  void drawChevron(GC gc, Rectangle chevronRect, int chevronImageState, int zoom)
next to 
  protected void draw (int part, int state, Rectangle bounds, GC gc)
  void drawChevron(GC gc, Rectangle chevronRect, int chevronImageState)

So that e.g. CTabRendering in platform.ui does not break. From a compile point of view this works but I get some strange NPE when starting this.

Any idea how I should proceed here? Is an incompatible change an option? If yes, what's the correct way of doing it? If not,
how could a compatible change look like?
Comment 38 Eclipse Genie CLA 2018-09-06 03:52:17 EDT
New Gerrit change created: https://git.eclipse.org/r/128813
Comment 39 Matthias Becker CLA 2018-09-06 03:54:12 EDT
(In reply to Eclipse Genie from comment #38)
> New Gerrit change created: https://git.eclipse.org/r/128813

This are my changes I talked about in comment 37. I don't have a clue why this causes NPEs. Can somebody pls. have a look at it - maybe I am simply blind.
Comment 40 Matthias Becker CLA 2018-09-11 02:28:52 EDT
(In reply to Matthias Becker from comment #39)
> (In reply to Eclipse Genie from comment #38)
> > New Gerrit change created: https://git.eclipse.org/r/128813
> 
> This are my changes I talked about in comment 37. I don't have a clue why
> this causes NPEs. Can somebody pls. have a look at it - maybe I am simply
> blind.

I don't see the NPEs any more - must have been an artefact locally. I will look into this further.
Comment 41 Till Brychcy CLA 2018-09-12 14:17:54 EDT
(In reply to Matthias Becker from comment #37)
> Any idea how I should proceed here? Is an incompatible change an option? If
> yes, what's the correct way of doing it? If not,
> how could a compatible change look like?

I think you could add a draw() method that takes and additional zoom parameter and assigns it to a field (which is used where now parameters are passed to) and at the end restores the previous zoom value.
Comment 42 Till Brychcy CLA 2018-09-13 16:32:29 EDT
(In reply to Till Brychcy from comment #41)
> (In reply to Matthias Becker from comment #37)
> > Any idea how I should proceed here? Is an incompatible change an option? If
> > yes, what's the correct way of doing it? If not,
> > how could a compatible change look like?
> 
> I think you could add a draw() method that takes and additional zoom
> parameter and assigns it to a field (which is used where now parameters are
> passed to) and at the end restores the previous zoom value.

In https://git.eclipse.org/r/#/c/128454/ patch set #5 I've implemented that idea.
(In patch set #4 I had some unwanted changes as rebasing was slightly tricky).
Comment 43 Till Brychcy CLA 2018-09-13 16:40:25 EDT
(In reply to Till Brychcy from comment #42)
> In https://git.eclipse.org/r/#/c/128454/ patch set #5 I've implemented that
> idea.
> (In patch set #4 I had some unwanted changes as rebasing was slightly
> tricky).

I think the vertical positioning needs some tuning, the number of tags in the chevron is slightly cut off at the bottom.
Matthias, you understand that code better, can you take over again?
Comment 44 Matthias Becker CLA 2018-09-14 03:43:08 EDT
(In reply to Till Brychcy from comment #42)
> (In reply to Till Brychcy from comment #41)
> > (In reply to Matthias Becker from comment #37)
> > > Any idea how I should proceed here? Is an incompatible change an option? If
> > > yes, what's the correct way of doing it? If not,
> > > how could a compatible change look like?
> > 
> > I think you could add a draw() method that takes and additional zoom
> > parameter and assigns it to a field (which is used where now parameters are
> > passed to) and at the end restores the previous zoom value.
> 
> In https://git.eclipse.org/r/#/c/128454/ patch set #5 I've implemented that
> idea.
> (In patch set #4 I had some unwanted changes as rebasing was slightly
> tricky).

Thank you Till. I had a similar version of that locally.
Comment 45 Matthias Becker CLA 2018-09-14 03:44:00 EDT
(In reply to Till Brychcy from comment #43)
> (In reply to Till Brychcy from comment #42)
> > In https://git.eclipse.org/r/#/c/128454/ patch set #5 I've implemented that
> > idea.
> > (In patch set #4 I had some unwanted changes as rebasing was slightly
> > tricky).
> 
> I think the vertical positioning needs some tuning, the number of tags in
> the chevron is slightly cut off at the bottom.
> Matthias, you understand that code better, can you take over again?

I fix the vertical position. Now I really really looks nice on high resolution displays.
Comment 46 Matthias Becker CLA 2018-09-14 03:44:28 EDT
Created attachment 275813 [details]
with the fix on a retina display
Comment 47 Matthias Becker CLA 2018-09-14 03:45:37 EDT
Created attachment 275814 [details]
with the fix on a normal resolution display

on a normal resolution display it doesn't get more crisp - I just is the same as before.
Comment 48 Eclipse Genie CLA 2018-09-14 04:37:10 EDT
New Gerrit change created: https://git.eclipse.org/r/129411
Comment 49 Matthias Becker CLA 2018-09-14 04:44:37 EDT
@Till: Can you please review my change?
@Linux / windows users: Does it also look good on your OS?
Comment 50 Wim Jongman CLA 2018-09-14 07:43:27 EDT
(In reply to Lars Vogel from comment #36)
> Service segment update in MANIFEST.MF will be done via
> https://git.eclipse.org/r/128807 See
> https://wiki.eclipse.org/Version_Numbering for details.

Next time we'd better create a new bug, no? This bug was solved with this comment.
Comment 51 Matthias Becker CLA 2018-09-14 08:40:33 EDT
(In reply to Wim Jongman from comment #50)
> (In reply to Lars Vogel from comment #36)
> > Service segment update in MANIFEST.MF will be done via
> > https://git.eclipse.org/r/128807 See
> > https://wiki.eclipse.org/Version_Numbering for details.
> 
> Next time we'd better create a new bug, no? This bug was solved with this
> comment.

yes. the version of the swt bundle was already increased.
Comment 52 Matthias Becker CLA 2018-09-18 03:26:20 EDT
Created attachment 275850 [details]
high resolution compared old (left) and new (right)

Screenshot shows old and new next to each other. I don't see any alignment differences.

I would say this is save to merge. 
Anyway it would be great if somebody with a linux or windows computer with a high resolution display could test this change.
Comment 53 Lars Vogel CLA 2018-09-18 04:01:01 EDT
(In reply to Matthias Becker from comment #52)
> Created attachment 275850 [details]
> high resolution compared old (left) and new (right)
> 
> Screenshot shows old and new next to each other. I don't see any alignment
> differences.
> 
> I would say this is save to merge. 
> Anyway it would be great if somebody with a linux or windows computer with a
> high resolution display could test this change.

I'm not aware of a team member with HDPI screen on Linux or Windows. I suggest to go ahead with the merge.
Comment 54 Till Brychcy CLA 2018-09-18 04:22:21 EDT
(In reply to Lars Vogel from comment #53)
> (In reply to Matthias Becker from comment #52)
> I'm not aware of a team member with HDPI screen on Linux or Windows. I
> suggest to go ahead with the merge.

As the patch replaced some code that I suspected ( as written in the gerrit) was there for HiDPI screens, I think that merging this without testing is a bad idea.
Comment 55 Lars Vogel CLA 2018-09-18 04:28:35 EDT
(In reply to Till Brychcy from comment #54)
> (In reply to Lars Vogel from comment #53)
> > (In reply to Matthias Becker from comment #52)
> > I'm not aware of a team member with HDPI screen on Linux or Windows. I
> > suggest to go ahead with the merge.
> 
> As the patch replaced some code that I suspected ( as written in the gerrit)
> was there for HiDPI screens, I think that merging this without testing is a
> bad idea.

I agree but I'm not aware of anyone with HDPI. Do we have developers with HDPI on Windows or Linux?
Comment 56 Till Brychcy CLA 2018-09-18 04:30:55 EDT
If nobody else can do it, I can do it at least on windows, which should be enough.

I have an old eclipse workspace on my bootcamp (= windows on mac) partition, but as I'd first have to update everything, this would probably a few days.
Comment 57 Lars Vogel CLA 2018-09-18 04:33:05 EDT
(In reply to Till Brychcy from comment #56)
> If nobody else can do it, I can do it at least on windows, which should be
> enough.

Thanks!
Comment 58 Matthias Becker CLA 2018-09-18 04:37:48 EDT
(In reply to Till Brychcy from comment #56)
> If nobody else can do it, I can do it at least on windows, which should be
> enough.
> 
> I have an old eclipse workspace on my bootcamp (= windows on mac) partition,
> but as I'd first have to update everything, this would probably a few days.

I have a co-worker that has a windows laptop with a 4k display. I will test with him together and report back.
Comment 59 Sravan Kumar Lakkimsetti CLA 2018-09-18 05:04:45 EDT
I am checking this on fedora28 with gnome
Comment 60 Wim Jongman CLA 2018-09-18 05:08:07 EDT
(In reply to Lars Vogel from comment #53)


I have a HiDPI screen and I am on Windows 10. I will check the patch now.
Comment 61 Lars Vogel CLA 2018-09-18 05:11:27 EDT
Seems like EVERYBODY has HDPI screens these days... ;-) I should update my hardware.
Comment 62 Wim Jongman CLA 2018-09-18 05:15:07 EDT
(In reply to Wim Jongman from comment #60)
> (In reply to Lars Vogel from comment #53)
> 
> 
> I have a HiDPI screen and I am on Windows 10. I will check the patch now.

I'm confused. Which patch set do I need to test? 128454?
Comment 63 Wim Jongman CLA 2018-09-18 05:18:49 EDT
(In reply to Lars Vogel from comment #61)
> Seems like EVERYBODY has HDPI screens these days... ;-) I should update my
> hardware.

It is overhyped. I am in 1920 mode most of the time.
Comment 64 Matthias Becker CLA 2018-09-18 05:18:58 EDT
(In reply to Wim Jongman from comment #62)
> (In reply to Wim Jongman from comment #60)
> > (In reply to Lars Vogel from comment #53)
> > 
> > 
> > I have a HiDPI screen and I am on Windows 10. I will check the patch now.
> 
> I'm confused. Which patch set do I need to test? 128454?

didn't you just update your monitor? ;-)
Comment 65 Matthias Becker CLA 2018-09-18 05:23:20 EDT
(In reply to Wim Jongman from comment #62)
> (In reply to Wim Jongman from comment #60)
> > (In reply to Lars Vogel from comment #53)
> > 
> > 
> > I have a HiDPI screen and I am on Windows 10. I will check the patch now.
> 
> I'm confused. Which patch set do I need to test? 128454?

https://git.eclipse.org/r/#/c/128454/
Comment 66 Wim Jongman CLA 2018-09-18 05:26:07 EDT
Created attachment 275855 [details]
Windows 10 3480x2160 225% scaling

It looks a little weird.
Comment 67 Matthias Becker CLA 2018-09-18 05:28:24 EDT
(In reply to Wim Jongman from comment #66)
> Created attachment 275855 [details]
> Windows 10 3480x2160 225% scaling
> 
> It looks a little weird.

how does it look like without my patch?
Comment 68 Lars Vogel CLA 2018-09-18 05:34:19 EDT
(In reply to Matthias Becker from comment #64
> didn't you just update your monitor? ;-)

Co-worker "stole" it while I was in Walldorf. Second one ordered now.
Comment 69 Wim Jongman CLA 2018-09-18 05:39:51 EDT
Created attachment 275856 [details]
Current SWT Master Windows 10 3480x2160 225% scaling

This is the SWT from master.
Comment 70 Wim Jongman CLA 2018-09-18 05:40:55 EDT
(In reply to Wim Jongman from comment #69)
> Created attachment 275856 [details]
> Current SWT Master Windows 10 3480x2160 225% scaling
> 
> This is the SWT from master.

It looks fine IMHO. Is it worth the effort to push to perfection?
Comment 71 Sravan Kumar Lakkimsetti CLA 2018-09-18 06:12:38 EDT
Created attachment 275858 [details]
Screen shots on Kubuntu with 200% scale

I am seeing weird behavior. There is a change in the layout with the patch and the number is larger. I think that is not correct.
Comment 72 Sravan Kumar Lakkimsetti CLA 2018-09-18 06:39:22 EDT
Created attachment 275859 [details]
screenshots with fedora 28 with gnome
Comment 73 Matthias Becker CLA 2018-09-18 08:27:16 EDT
thanks for testing.
Really really strange what happens on Linux and Windows.
I will look into it.
Comment 74 Matthias Becker CLA 2018-09-19 02:14:51 EDT
Dear Wim and Sravan,

I just uploaded a new patchset that includes some debugging output. Could you re-do your test and paste the console output to this bug? 
I hope this helps to understand why this behaves so differently on linux and windows.
Comment 75 Matthias Becker CLA 2018-09-19 02:15:58 EDT
(In reply to Wim Jongman from comment #70)
> (In reply to Wim Jongman from comment #69)
> > Created attachment 275856 [details]
> > Current SWT Master Windows 10 3480x2160 225% scaling
> > 
> > This is the SWT from master.
> 
> It looks fine IMHO. Is it worth the effort to push to perfection?

it interestingly locks not that bad on windows. But compare with my screenshots how it looks on mac - it's really bad there.
Comment 76 Wim Jongman CLA 2018-09-19 04:15:37 EDT
(In reply to Matthias Becker from comment #75)

I had to rebase your patch with master in order to be synced with the latest binaries.

When I resize my editor initially this appeared. 

createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE

Then I resized some more and this appeared:

createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
getChevronFont zoom: 100 FontData: 1|Segoe UI|6.0|0|WINDOWS|1|-27|0|0|0|0|0|0|0|1|0|0|0|0|Segoe UI
createButtonImage zoom:200 size: Point {48, 32}
getChevronFont zoom: 200 FontData: 1|Segoe UI|12.0|0|WINDOWS|1|-27|0|0|0|0|0|0|0|1|0|0|0|0|Segoe UI
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {48, 32}
drawChevron chevronImageState: NONE
Comment 77 Sravan Kumar Lakkimsetti CLA 2018-09-19 08:29:52 EDT
(In reply to Matthias Becker from comment #74)
> Dear Wim and Sravan,
> 
> I just uploaded a new patchset that includes some debugging output. Could
> you re-do your test and paste the console output to this bug? 
> I hope this helps to understand why this behaves so differently on linux and
> windows.

This is the output I get 
getChevronFont zoom: 100 FontData: 1|Noto Sans|7.0|0|GTK|1|
createButtonImage zoom:200 size: Point {54, 36}
getChevronFont zoom: 200 FontData: 1|Noto Sans|14.0|0|GTK|1|
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {54, 36}
drawChevron chevronImageState: NONE

after resize I get 
createButtonImage zoom:200 size: Point {54, 36}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {54, 36}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {54, 36}
drawChevron chevronImageState: NONE
Comment 78 Matthias Becker CLA 2018-09-20 04:24:10 EDT
on macOS it's:

getChevronFont zoom: 100 FontData: 1|.SF NS Text|10.0|0|COCOA|1|.SFNSText
createButtonImage zoom:100 size: Point {28, 16}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {56, 32}
getChevronFont zoom: 200 FontData: 1|.SF NS Text|20.0|0|COCOA|1|.SFNSText
drawChevron chevronImageState: NONE
createButtonImage zoom:100 size: Point {28, 16}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {56, 32}
drawChevron chevronImageState: NONE
createButtonImage zoom:100 size: Point {28, 16}
drawChevron chevronImageState: NONE
createButtonImage zoom:200 size: Point {56, 32}
drawChevron chevronImageState: NONE
Comment 79 Matthias Becker CLA 2018-09-20 07:38:57 EDT
when I strip out the duplicated lines it boils down to:

macOS

getChevronFont zoom: 100 FontData: 1|.SF NS Text|10.0
getChevronFont zoom: 200 FontData: 1|.SF NS Text|20.0
createButtonImage zoom:100 size: Point {28, 16}
createButtonImage zoom:200 size: Point {56, 32}


Linux:

getChevronFont zoom: 100 FontData: 1|Noto Sans|7.0 
getChevronFont zoom: 200 FontData: 1|Noto Sans|14.0
createButtonImage zoom:200 size: Point {54, 36}


Windows:

getChevronFont zoom: 100 FontData: 1|Segoe UI|6.0 
getChevronFont zoom: 200 FontData: 1|Segoe UI|12.0
createButtonImage zoom:200 size: Point {48, 32}

The font sizes look right to me. The sizes given in createButtonImage are the one *after* scaling. The values for the 200 version are also very similar.
For mac both buttom image are created for linux and window only the 200 version is created. But this seems to be an implementation detail.

I don't have a clue how does wrong here? I thought that the image data provider simply return the image based on the zoom level and SWT / OS then takes care to display the correct one. I looks like as on windows and linux the image is twice as big as it should be.
Also I don't understand Wim's screenshot https://bugs.eclipse.org/bugs/attachment.cgi?id=275856 form the state without my patch. Why is the chevron and the number next to is sharp and crisp compare to the situation on macOS https://bugs.eclipse.org/bugs/attachment.cgi?id=275850.
I thought that as the image is drawn on 100% it is then auto-scaled up by SWT / OS on all platforms and therefore does get blurry due to that scaling.

Can some of the SWT-Experts help understanding this?
Comment 80 Sravan Kumar Lakkimsetti CLA 2018-09-21 08:14:33 EDT
(In reply to Matthias Becker from comment #79)
> when I strip out the duplicated lines it boils down to:
> 
> macOS
> 
> getChevronFont zoom: 100 FontData: 1|.SF NS Text|10.0
> getChevronFont zoom: 200 FontData: 1|.SF NS Text|20.0
> createButtonImage zoom:100 size: Point {28, 16}
> createButtonImage zoom:200 size: Point {56, 32}
> 
> 
> Linux:
> 
> getChevronFont zoom: 100 FontData: 1|Noto Sans|7.0 
> getChevronFont zoom: 200 FontData: 1|Noto Sans|14.0
> createButtonImage zoom:200 size: Point {54, 36}
> 
> 
> Windows:
> 
> getChevronFont zoom: 100 FontData: 1|Segoe UI|6.0 
> getChevronFont zoom: 200 FontData: 1|Segoe UI|12.0
> createButtonImage zoom:200 size: Point {48, 32}
> 
> The font sizes look right to me. The sizes given in createButtonImage are
> the one *after* scaling. The values for the 200 version are also very
> similar.
> For mac both buttom image are created for linux and window only the 200
> version is created. But this seems to be an implementation detail.
> 
> I don't have a clue how does wrong here? I thought that the image data
> provider simply return the image based on the zoom level and SWT / OS then
> takes care to display the correct one. I looks like as on windows and linux
> the image is twice as big as it should be.
> Also I don't understand Wim's screenshot
> https://bugs.eclipse.org/bugs/attachment.cgi?id=275856 form the state
> without my patch. Why is the chevron and the number next to is sharp and
> crisp compare to the situation on macOS
> https://bugs.eclipse.org/bugs/attachment.cgi?id=275850.
> I thought that as the image is drawn on 100% it is then auto-scaled up by
> SWT / OS on all platforms and therefore does get blurry due to that scaling.
> 
> Can some of the SWT-Experts help understanding this?

I will do a review on Monday
Comment 81 Sravan Kumar Lakkimsetti CLA 2018-09-24 02:33:46 EDT
After reviewing here are my observations for creating the chevron.

1. Create a GC
2. Draw chevron scaledup(zoomed up) dimensions. 
 - lines drawn with zoom *coordinates
 - font size scaled up

The issue here is the way we create GC and draw on GC in hidpi mode.

On Windows and Linux KDE we do the following
1. Create GC with scaled up surface.
2. All GC operations are scaled up using dpiutil methods. So the image is drawn using scaled up coordinates.

On Linux Gnome.
1. Create cairo surface with scaled up size but set the device_scale parameter to the surface to zoom.
2. All GC operations are cairo drawing operations. These are scaled up by cairo automatically

On Mac
1. We create GC with 100% representation (ideally we should create a new blank representation with the current zoom level)
2. Draw using the GC methods. 

With this we get a 100% representation drawn properly and that representation is used for display by scaling up. This causes blurriness in the final display.

I hope this helps
Comment 82 Matthias Becker CLA 2018-09-24 05:23:13 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #81)
> After reviewing here are my observations for creating the chevron.
> 
> 1. Create a GC
> 2. Draw chevron scaledup(zoomed up) dimensions. 
>  - lines drawn with zoom *coordinates
>  - font size scaled up
> 
> The issue here is the way we create GC and draw on GC in hidpi mode.
> 
> On Windows and Linux KDE we do the following
> 1. Create GC with scaled up surface.
> 2. All GC operations are scaled up using dpiutil methods. So the image is
> drawn using scaled up coordinates.
> 
> On Linux Gnome.
> 1. Create cairo surface with scaled up size but set the device_scale
> parameter to the surface to zoom.
> 2. All GC operations are cairo drawing operations. These are scaled up by
> cairo automatically
> 
> On Mac
> 1. We create GC with 100% representation (ideally we should create a new
> blank representation with the current zoom level)
> 2. Draw using the GC methods. 
> 
> With this we get a 100% representation drawn properly and that
> representation is used for display by scaling up. This causes blurriness in
> the final display.
> 
> I hope this helps

Sravan, thank you for the review and explaining. Is this GC-creation stuff you talk about  valid everywhere or just for this place?
If it's valid everywhere: Does this mean the GC behaves differently on the different platforms? Shouldn't SWT shield the client code from such differences?

What's your proposal to fix this issue?
Comment 83 Sravan Kumar Lakkimsetti CLA 2018-09-24 06:33:33 EDT
(In reply to Matthias Becker from comment #82)
> (In reply to Sravan Kumar Lakkimsetti from comment #81)
> > After reviewing here are my observations for creating the chevron.
> > 
> > 1. Create a GC
> > 2. Draw chevron scaledup(zoomed up) dimensions. 
> >  - lines drawn with zoom *coordinates
> >  - font size scaled up
> > 
> > The issue here is the way we create GC and draw on GC in hidpi mode.
> > 
> > On Windows and Linux KDE we do the following
> > 1. Create GC with scaled up surface.
> > 2. All GC operations are scaled up using dpiutil methods. So the image is
> > drawn using scaled up coordinates.
> > 
> > On Linux Gnome.
> > 1. Create cairo surface with scaled up size but set the device_scale
> > parameter to the surface to zoom.
> > 2. All GC operations are cairo drawing operations. These are scaled up by
> > cairo automatically
> > 
> > On Mac
> > 1. We create GC with 100% representation (ideally we should create a new
> > blank representation with the current zoom level)
> > 2. Draw using the GC methods. 
> > 
> > With this we get a 100% representation drawn properly and that
> > representation is used for display by scaling up. This causes blurriness in
> > the final display.
> > 
> > I hope this helps
> 
> Sravan, thank you for the review and explaining. Is this GC-creation stuff
> you talk about  valid everywhere or just for this place?
> If it's valid everywhere: Does this mean the GC behaves differently on the
> different platforms? Shouldn't SWT shield the client code from such
> differences?
> 
> What's your proposal to fix this issue?

Unfortunately this is valid everywhere. I am currently working on fixing this issue on Mac. other platforms we do shield this from the end users.
Comment 84 Matthias Becker CLA 2018-09-24 06:41:49 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #83)
> Unfortunately this is valid everywhere. I am currently working on fixing
> this issue on Mac. other platforms we do shield this from the end users.
So would that mean that my fix is no longer needed after you fix?
Pls. keep me updated on your fix.
Comment 85 Sravan Kumar Lakkimsetti CLA 2018-09-24 07:01:07 EDT
(In reply to Matthias Becker from comment #84)
> (In reply to Sravan Kumar Lakkimsetti from comment #83)
> > Unfortunately this is valid everywhere. I am currently working on fixing
> > this issue on Mac. other platforms we do shield this from the end users.
> So would that mean that my fix is no longer needed after you fix?
> Pls. keep me updated on your fix.

Most likely it may not be required. GC related effort is being tracked in Bug 489451
Comment 88 Lars Vogel CLA 2018-11-30 12:37:43 EST
*** Bug 464230 has been marked as a duplicate of this bug. ***
Comment 89 Lakshmi P Shanmugam CLA 2018-12-03 03:20:14 EST
Matthias,
Can you please resolve this bug (as some changes went in for 4.10) and open a new one for the remaining issue?
Comment 90 Dani Megert CLA 2018-12-05 04:11:06 EST
(In reply to Lakshmi Shanmugam from comment #89)
> Matthias,
> Can you please resolve this bug (as some changes went in for 4.10) and open
> a new one for the remaining issue?

I'm marking this as fixed. Please open new bugs as mentioned by Lars.