-
Notifications
You must be signed in to change notification settings - Fork 183
Cache the last created temporary handles at a requested size #2601
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
base: master
Are you sure you want to change the base?
Cache the last created temporary handles at a requested size #2601
Conversation
Cache the most recently created temporary handle. When a handle of a different size is requested, dispose of the previous one and replace it with the new handle. The last cached handle is also destroyed when the image is disposed.
d897312
to
ac8d6ec
Compare
imageHandle.destroy(); | ||
} | ||
} | ||
lastRequestedHandle.destroy(); |
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.
This doesn't belong here, the method accepts a filter. Put it in destroyHandles()
and, if necessary, in destroyHandlesExcept(Set<Integer>)
too.
} | ||
}; | ||
|
||
CachedHandle lastRequestedHandle = new CachedHandle(null, SWT.DEFAULT, SWT.DEFAULT, SWT.DEFAULT, SWT.DEFAULT); |
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.
Move it above the type-declaration (together with other fields), make it private
and pass -1
instead of SWT.DEFAULT
as parameters. There is no "default" in this context, only "uninitialized".
imageData.height); | ||
} | ||
handleAtSizeConsumer.accept(lastRequestedHandle.getHandle(), | ||
new Point(lastRequestedHandle.handleWidth, lastRequestedHandle.handleHeight)); |
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.
new Point(lastRequestedHandle.handleWidth, lastRequestedHandle.handleHeight)); | |
new Point(lastRequestedHandle.handleWidth(), lastRequestedHandle.handleHeight())); |
When rendering images at a specific targetSize, the most recently created temporary handle is cached. If a handle of a different size is needed, the previous handle is disposed of and replaced with the new one. The last cached handle is also disposed of when the image itself is destroyed.
This change does not affect the visual appearance and is purely an optimization. It is especially useful when a user scrolls through a diagram, as the same-size image may be redrawn multiple times. Without handle caching, new image handles would need to be created repeatedly whenever the image is redrawn. More details can be found at vi-eclipse/Eclipse-Platform#326 (comment)