On Fri, 3 Sep 2021 21:11:48 GMT, Kevin Rushforth <k...@openjdk.org> wrote:
>> I guess the assumption might be the other way around? Since the fill color >> was not transparent, there was no need to clear the area, when rendering the >> same solid rect at the new position? >> >> If you check this >> [comment](https://bugs.openjdk.java.net/browse/JDK-8090547?focusedCommentId=13808421&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13808421), >> there is already a mention that `WCPageBackBufferImpl::copyArea` doesn't >> care about the alpha channel. >> >> The proposed patch: >> >> texture.createGraphics().clearQuad(x+dx, y+dy, x+dx+w, y+dy+h); >> >> could work if we could apply it conditionally only for alpha == 0 (or maybe >> also for alpha < 1). >> >> My current approach with `clearRect` ultimately calls `clearQuad`, so both >> might be doing the same after all. > > I don't doubt that the area should be cleared. What I was questioning is > whether this was the best place to do it? I'd be OK with it if you document > it. The two options I see so far to clear the area are the one I've committed (change in `WCGraphicsPrismContext::setClip`) and the one I've mentioned above (`WCPageBackBufferImpl::copyArea`). After some more testing, I see that the latter doesn't work when there is full transparency, so I will discard it. Back to my original commit, it could be moved up to `WebPage::paint2GC`, before the call to `gc.setClip(rq.getClip());`, and that would also remove the need of passing down the opacity level to `WCGraphicsContext`. I also see now that the `clearRect()` call is required for full transparency only. This would be the change: WCRectangle clip = rq.getClip(); if (clip != null) { if (isBackgroundTransparent()) { // As backbuffer is enabled, new clips are drawn over the old rendered frames // regardless the alpha channel. While that works fine for alpha > 0, // for alpha == 0 we need to clear the old frame or it will still be visible. gc.clearRect((int) clip.getX(), (int) clip.getY(), (int) clip.getWidth(), (int) clip.getHeight()); } gc.setClip(clip); } ------------- PR: https://git.openjdk.java.net/jfx/pull/563