-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8357299: Graphics copyArea doesn't copy any pixels when there is overflow #25340
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
Conversation
|
👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into |
|
@prsadhuk This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 614 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
|
||
| srcInfo.bounds.x1 = srcx; | ||
| srcInfo.bounds.y1 = srcy; | ||
| if (UNSAFE_TO_ADD(srcx, width) || |
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.
isn't the MaskBlit_MaskBlit use the same pattern?
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.
But that doesn't cause any issue to the testcase given and existing testcase..Do you have any testcase which doesnt work because of MaskBlit pattern?
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.
I have not tried to create a test for MaskBlit, only for a simple Blit. I will take a look at the possibility of reproducing it.
alisenchung
left a comment
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.
Tested locally on macOS and test fails before the change and passes after the change.
azuev-java
left a comment
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.
Looks good.
| dstInfo.bounds.y2 = dsty + height; | ||
| dstInfo.bounds.x2 = UNSAFE_TO_ADD(dstx, width) | ||
| ? clipInfo.bounds.x2 : (dstx + width); | ||
| dstInfo.bounds.y2 = UNSAFE_TO_ADD(dsty, 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.
why wouldn't you always want to limit it to the clip ?
I mean shouldn't it be like this ?
dstInfo.bounds.x2 = UNSAFE_TO_ADD(dstx, width) ? clipInfo.bounds.x2 : (((dstx + width) > clipInfo.bounds.x2) ? clipInfo.bounds.x2 : (dstx + width));
or maybe a bit more readable as
dstInfo.bounds.x2 = ((UNSAFE_TO_ADD(dstx, width) || ((dstx + width) > clipInfo.bounds.x2)) ? clipInfo.bounds.x2 : (dstx + width);
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.
That is because down below it anyway calls
SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);
so it should clip to clipInfo.bounds there.
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.
@prrace Since it is going to clip dstInfo.bounds to clipInfo.bounds in SurfaceData_IntersectBounds, I believe is not necessary to do the duplicate clip here.
Let me know if you think otherwise..
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.
ok
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.
That is because down below it anyway calls SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);
so it should clip to clipInfo.bounds there.
In addition to intersecting dst with clip, you're also intersecting src with clip, which seems incorrect. A better approach might be to compute the drawable width based on the non-overflowing range for both src and dst, and then proceed with the original logic.
BTW I have not checked MaskBlit_MaskBlit yet it might require a similar update.
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.
We have not found any problem with that part of code so far..We have addressed the issue that was raised.
MaskBlit might require similar update but since it was not proven to be problematic (we waited for your feedback) and since RDP1 is approaching, we will integrate this and you can come back with POC for us to check..
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.
We have not found any problem with that part of code so far..
This is incorrect because the clip bounds are relative to the destination (dst), so you cannot intersect them directly with the source (src) surface. The usage of UNSAFE_TO_SUB below is also wrong, we cannot just exists.
filed https://bugs.openjdk.org/browse/JDK-8358103 and https://bugs.openjdk.org/browse/JDK-8358107
| dstInfo.bounds.y2 = dsty + height; | ||
| dstInfo.bounds.x2 = UNSAFE_TO_ADD(dstx, width) | ||
| ? clipInfo.bounds.x2 : (dstx + width); | ||
| dstInfo.bounds.y2 = UNSAFE_TO_ADD(dsty, 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.
That is because down below it anyway calls SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);
so it should clip to clipInfo.bounds there.
In addition to intersecting dst with clip, you're also intersecting src with clip, which seems incorrect. A better approach might be to compute the drawable width based on the non-overflowing range for both src and dst, and then proceed with the original logic.
BTW I have not checked MaskBlit_MaskBlit yet it might require a similar update.
| dstInfo.bounds.y2 = UNSAFE_TO_ADD(dsty, height) | ||
| ? clipInfo.bounds.y2 : (dsty + height); | ||
| if (UNSAFE_TO_SUB(srcx, dstx) || | ||
| UNSAFE_TO_SUB(srcy, dsty)) { |
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.
we also should check this part of the code, is it correct to simply exit here, or should we instead calculate and use the maximum distance we can handle?
|
/integrate |
|
Going to push as commit 64503c7.
Your commit was automatically rebased without conflicts. |
Graphics copyArea overflow check bails out of copying pixels if there is overflow.
The spec says ""If a portion of the source rectangle lies outside the bounds of the component, or is obscured by another window or component, {@code copyArea} will be unable to copy the associated pixels"
which suggests that we should always copy the parts inside the bounds and never the parts outside the bounds
but it seems currently, in the case of overflow it no longer copies any pixels, including the parts that are inside.
So, the fix clips the copyarea region to clip bounds so it will only affect pixels within the valid bounds, and any pixels outside will be ignored.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25340/head:pull/25340$ git checkout pull/25340Update a local copy of the PR:
$ git checkout pull/25340$ git pull https://git.openjdk.org/jdk.git pull/25340/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25340View PR using the GUI difftool:
$ git pr show -t 25340Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25340.diff
Using Webrev
Link to Webrev Comment