JDK-6797587 : Need better control over shapes cut out by hw/lw mixing
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u14
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-01-26
  • Updated: 2017-05-16
  • Resolved: 2009-05-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u14 b02Fixed 7Resolved
Related Reports
Relates :  
Relates :  
Relates :  
Description
The fix 6776743 introduces the "boolean" API for controling how the hw/lw mixing code cuts out shapes of lw component from hw components. The API (the com.sun.awt.AWTUtilities class) is as follows:

setComponentNonOpaqueForMixing(Component component, boolean nonOpaque);

Making a component 'non-opaque-for-mixing' tells the mixing code to not cut out the shape of this component (but still cut out the shapes of its children).

However this API seems too limited: the new L&Fs which use non-opaque components to render rounded corners will work OK, but the rounded corners themselves will produce some kind of "unrendered pieces". To eliminate this limitation we need to remove the newly introduced API (it is introduced in 6u14b01, nobody uses it for now, it is not an "official" API), and replace it with the following API in 6u14b02:

setComponentMixingCutoutShape(Component component, Shape shape);

By default a component will have a null cutout shape, meaning the component should be considered opaque rectangle by the hw/lw mixing code. Setting an empty non-null shape means the component should be treated as a non-opaque entity (only the shapes of its children should be cut out by the mixing code). Finally, if one sets a non-null, non-empty shape to the component, exactly this shape will be cut out from hw components.

Comments
EVALUATION The following method is added to the com.sun.awt.AWTUtilities class: /** * Sets a 'mixing-cutout' shape for the given component. * * By default a lightweight component is treated as an opaque rectangle for * the purposes of the Heavyweight/Lightweight Components Mixing feature. * This method enables developers to set an arbitrary shape to be cut out * from heavyweight components positioned underneath the lightweight * component in the z-order. * <p> * The {@code shape} argument may have the following values: * <ul> * <li>{@code null} - reverts the default cutout shape (the rectangle equal * to the component's {@code getBounds()}) * <li><i>empty-shape</i> - does not cut out anything from heavyweight * components. This makes the given lightweight component effectively * transparent. Note that descendants of the lightweight component still * affect the shapes of heavyweight components. An example of an * <i>empty-shape</i> is {@code new Rectangle()}. * <li><i>non-empty-shape</i> - the given shape will be cut out from * heavyweight components. * </ul> * <p> * The most common example when the 'mixing-cutout' shape is needed is a * glass pane component. The {@link JRootPane#setGlassPane()} method * automatically sets the <i>empty-shape</i> as the 'mixing-cutout' shape * for the given glass pane component. If a developer needs some other * 'mixing-cutout' shape for the glass pane (which is rare), this must be * changed manually after installing the glass pane to the root pane. * <p> * Note that the 'mixing-cutout' shape neither affects painting, nor the * mouse events handling for the given component. It is used exclusively * for the purposes of the Heavyweight/Lightweight Components Mixing * feature. * * @param component the component that needs non-default * 'mixing-cutout' shape * @param shape the new 'mixing-cutout' shape * @throws NullPointerException if the component argument is {@code null} */ public static void setComponentMixingCutoutShape(Component component, Shape shape);
26-01-2009