Skip to content

Replace usages of new Image(device, width, height) #2178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ShahzaibIbrahim
Copy link
Contributor

The original commit was reverted in #2163 due to regression. With the test added, this PR again replaces the usage of Image(device, width, height) with Image(device, ImageGcDrawer).

Copy link
Contributor

Test Results

0 files   -    545  0 suites   - 545   0s ⏱️ - 29m 22s
0 tests  -  4 398  0 ✅  -  4 380  0 💤  -  18  0 ❌ ±0 
0 runs   - 16 719  0 ✅  - 16 578  0 💤  - 141  0 ❌ ±0 

Results for commit 20392c2. ± Comparison against base commit 9d3227d.

Copy link
Contributor

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on the coding style and unnecessary changes.

@akoch-yatta can you also please take a look? This PR solves the issue by instantiating gc again in line 1602 .

Comment on lines +1612 to +1621

if ((style & (SWT.NO_BACKGROUND | SWT.TRANSPARENT)) != 0) {
/* This code is intentionally commented because it may be slow to copy bits from the screen */
//newPaintGC.copyArea (image, ps.left, ps.top);
} else {
RECT rect = new RECT ();
OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
drawBackground (gc.handle, rect);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why duplicate this code?

Suggested change
if ((style & (SWT.NO_BACKGROUND | SWT.TRANSPARENT)) != 0) {
/* This code is intentionally commented because it may be slow to copy bits from the screen */
//newPaintGC.copyArea (image, ps.left, ps.top);
} else {
RECT rect = new RECT ();
OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
drawBackground (gc.handle, rect);
}

ImageGcDrawer drawer = new ImageGcDrawer() {
@Override
public void drawOn(GC gc, int iWidth, int iHeight) {
GCData gcData = gc.getGCData ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation looks wrong in Eclipse (not in GH though)

if (!isDisposed ()) {
paintGC.drawImage (image, DPIUtil.scaleDown(ps.left, zoom), DPIUtil.scaleDown(ps.top, zoom));
}
gc.dispose();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change, it's unnecessary now that you instantiated gc again and it only adds noise to the PR.

}
};
image = new Image (display, drawer, width, height);
gc = new GC(image, originalStyle & SWT.RIGHT_TO_LEFT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this works as expected? You now initialize the GC inside the ImageGcDrawer and then create a new one that is used throughout the rest of the method, which does not adhere to the settings inside ImageGcDrawer. At least, it would be my expectation that those two GCs behave completely independent. In my understanding, the code you move inside the ImageGcDrawer now equals to a no-op, doesn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants