Bug 569277 - [BugSur] Control#fillBackground() with background image results wrong pattern start location
Summary: [BugSur] Control#fillBackground() with background image results wrong pattern...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.18   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-30 02:11 EST by Jeeeyul Lee CLA
Modified: 2020-12-18 02:48 EST (History)
2 users (show)

See Also:


Attachments
wrong-pattern-offset (178.58 KB, image/png)
2020-11-30 02:11 EST, Jeeeyul Lee CLA
no flags Details
file to reproduce problem (1.55 KB, application/octet-stream)
2020-11-30 02:12 EST, Jeeeyul Lee CLA
no flags Details
Example code about the above comment (ABCDE thing) (1.96 KB, application/octet-stream)
2020-12-07 20:22 EST, Jeeeyul Lee CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeeeyul Lee CLA 2020-11-30 02:11:34 EST
Created attachment 284920 [details]
wrong-pattern-offset

[BugSur] Control#fillBackground() with background image results wrong pattern start location.

See the Attachment:
* Expected result: Red to Blue gradient.
* Actual Result: The pattern offset seems to be wrong.
Comment 1 Jeeeyul Lee CLA 2020-11-30 02:12:43 EST
Created attachment 284921 [details]
file to reproduce problem
Comment 2 Jeeeyul Lee CLA 2020-11-30 02:16:51 EST
Control#update(): 1324
context.setPatternPhase(phase);

seems not work properly for specific case.

I found these:
* This problem occurs when there are some SWT.BORDER flagged controls in the same shell.
* This problem also occurs when there are some NSScrollable controls in the same shell
Comment 3 Sravan Kumar Lakkimsetti CLA 2020-11-30 03:17:06 EST
Another related bug 569168. Looks like root cause same for both.
Comment 4 Jeeeyul Lee CLA 2020-11-30 03:33:52 EST
(In reply to Sravan Kumar Lakkimsetti from comment #3)
> Another related bug 569168. Looks like root cause same for both.

I agree. 

I have a theory about this, I will mention about it after more digging tomorrow.
Comment 5 Jeeeyul Lee CLA 2020-12-01 00:54:04 EST
Sorry, I have failed to find useful clues. The office will be closed for the time being due to covid 19, I can't pursuit this problem for while. Please somebody else pull this excalibur out instead.
Comment 6 Jeeeyul Lee CLA 2020-12-07 20:21:05 EST
I found these things:

Consider that situation:

Shell
 +- A
 +- B
 +- C (has an NSSCrollView due to SWT.X_SCROLL or SWT.BORDER)
 +- D
 +- E

1. Background patterns of D, E are rendered properly. (after scrollview)
2. Background patterns of A, B, C are rendered incorrectly. 
3. Painting A, B, C seems to use a not flipped coordinate system.

when I add below code on Control#fillBackground():1324

  phase.x -= tx;
  phase.y += ty;
  phase.y = controlView.bounds().height; // <- I've added this line
  context.setPatternPhase(phase);

These small change just ignore the coordinate system of the window content view. And it assumes that those view has it's own buffers and own drawing context.
Then interestingly A, B C are rendered properly. 

However NSView.isFlipped() always returns true.


And it is not just control's background problem. Painting image patterns using GC facing same problem. See GC.setPatternPhase()
Comment 7 Jeeeyul Lee CLA 2020-12-07 20:22:15 EST
Created attachment 284987 [details]
Example code about the above comment (ABCDE thing)
Comment 8 Jeeeyul Lee CLA 2020-12-07 20:29:09 EST
(In reply to Jeeeyul Lee from comment #6)
>   phase.y = controlView.bounds().height; // <- I've added this line

There was a typo, It was actually likes that:
 controlView.frame().height - imgHeight;
Comment 9 Sravan Kumar Lakkimsetti CLA 2020-12-15 01:26:48 EST
I will investigate this tomorrow after 4.18 release is almost complete
Comment 10 Sravan Kumar Lakkimsetti CLA 2020-12-18 02:48:28 EST
(In reply to Jeeeyul Lee from comment #8)
> (In reply to Jeeeyul Lee from comment #6)
> >   phase.y = controlView.bounds().height; // <- I've added this line
> 
> There was a typo, It was actually likes that:
>  controlView.frame().height - imgHeight;

When I tried this the problem moved from top three to bottom two.
Adding this line fixes A,B and C images but breaks D and E