RFR: 8090547: Allow for transparent backgrounds in WebView [v4]

Kevin Rushforth kcr at openjdk.java.net
Wed Sep 8 13:12:12 UTC 2021

On Mon, 6 Sep 2021 11:05:42 GMT, Jose Pereda <jpereda at openjdk.org> wrote:

>> 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);
>                 }

This seems like the best approach to me in that it moves the clear to a drawing method rather than as a side effect of setting the clip.


PR: https://git.openjdk.java.net/jfx/pull/563

More information about the openjfx-dev mailing list