-
Notifications
You must be signed in to change notification settings - Fork 4
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
Initial custom Group widget implementation #120
base: master
Are you sure you want to change the base?
Conversation
Test Results 136 files - 202 136 suites - 202 1m 11s ⏱️ - 1m 18s Results for commit 6b16d26. ± Comparison against base commit fb29be9. This pull request removes 19 tests.
This pull request skips 41 tests.
♻️ This comment has been updated with latest results. |
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
private String text = ""; | ||
static final int CLIENT_INSET = 3; | ||
private Listener listener; | ||
private boolean enabled = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The enabled state should not be tracked here, but instead isEnabled() should be used, because it should be drawn disabled even if it is set enabled, but a parent is disabled.
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
void enableWidget(boolean enabled) { | ||
this.enabled = enabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remember here.
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Group.java
Outdated
Show resolved
Hide resolved
I see a performance issue in this branch when running Additionally, the JMC performance tool highlights the following method as a concern, and I also noticed a heap space issue, as shown in the attached image. Is it known issue or should there be some issue in my code ? Method Profiling The most sampled method was void org.eclipse.swt.graphics.ImageData.blit(byte[], int, int, int, int, int, int, int, int, byte[], int, int, int, int, int, int, int, int, boolean, boolean), with 3.45 % of the maximum possible samples for 3/4/2025, 6:03:42.000 PM – 6:04:12 PM, and 64.8 % of the actual samples. The methods that used the most CPU are: The most common stack trace was: at |
Yes, it is not a suprise, that the SkijaGC.commit call requires a lot of performance. We want to get rid of all these image conversion calls in the future either with OpenGL or the direct use of windows GDI. See issue #107 |
a9f24e5
to
d2109d6
Compare
160668a
to
da3d99d
Compare
Test Snippet Review points fix Review points fixed
da3d99d
to
6b16d26
Compare
} | ||
|
||
private void drawGroup(GC gc) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this empty line.
checkWidget(); | ||
Point size = DPIUtil.autoScaleUp(super.computeSize(wHint, hHint, changed)); | ||
|
||
if (!changed && new Point(wHint, hHint).equals(size)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating a new Point, why not just compare the x and y values?
return size; | ||
} | ||
Layout layout = getLayout(); | ||
Point layoutSize = (layout != null) ? layout.computeSize(this, wHint, hHint, changed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, the above super.computeSize() already invokes the layout manager. Why here again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this finding . I was able to fix other scaling issue as well while fixing this
} | ||
|
||
@Override | ||
void enableWidget(boolean enabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that method necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be necessary since I do not have any additional implementation compared to the parent (Control
), and it is called solely by the parent (Control
) in the setEnabled
method in SWT. I retained this method as it was in the original Group
widget implementation. I will remove it.
checkWidget(); | ||
Rectangle rect = super.getClientArea(); | ||
if (rect.isEmpty()) | ||
return rect; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please surround the return statement with {}.
boolean mnemonicMatch(char key) { | ||
char mnemonic = findMnemonic(getText()); | ||
if (mnemonic == '\0') | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
private void drawGroup(GC gc) { | ||
|
||
int width = getBounds().width; | ||
int height = getBounds().height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't invoke getBounds()
two times, but rather cache the result.
int width = getBounds().width; | ||
int height = getBounds().height; | ||
int titleWidth = textExtent.x; | ||
int titleHeight = textExtent.y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure, the textExtent is alway set correctly here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
textExtent
is calculated whenever text/group title is changed using setText(String text)
. Do you find any loophole here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the font or the font size changes.
But basically it is right to cache these information and use them directly in the drawing, instead of doing all these calculations in the drawing.
In the end the efficiency of the drawing method defines the speed of the widget toolkit, because the drawings of controls cluster in the redraw.
It is more the question, how can we make sure these calculations are always up to date without recalculate them all the time (general question... :-) ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caching is fine, but if a method is using the cached values, you need to ensure that they are valid at this point. BTW, better indicate cached values in their variable names and before using them, check whether these values are valid.
int textX = inset + groupInset; | ||
int textY = titleHeight; | ||
int newWidth = width - (inset * 2); | ||
int newHeight = height - (inset * 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use better variable name, e.g. borderWidth/Height.
The more i think about this: -> first drawing the group widget with SkijaGC + commit and this happens at each redraw() and these "SkijaGC + commit" of parent and child are separated calls. Of course the bigger our widgets become, the more lag the SkijaGC + commit causes. Generally: |
I had unnecessarily scaled up some dimensions in the implementation. After fixing it, I was able to launch |
Known Issues :
controlExample
when scaled to 175% because the control example does not fit within the screen.PrintWidget
not yet worked on.Any suggestions are welcome.