JDK-7172187 : [macosx] JAWT native CALayer not positioned over Canvas
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2012-05-28
  • Updated: 2013-09-12
  • Resolved: 2012-09-05
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 7 JDK 8
7u40Fixed 8 b55Fixed
Description
FULL PRODUCT VERSION :
java version "1.7.0_06-ea"
Java(TM) SE Runtime Environment (build 1.7.0_06-ea-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
10.7.4

A DESCRIPTION OF THE PROBLEM :
When a CALayer is attached to an AWT Canvas via

id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>) dsi->platformInfo;
CALayer *layer = [[CALayer alloc] init];
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB ();
CGFloat rgba[4] = {1.0, 0.0, 0.0, 0.5};
CGColorRef color = CGColorCreate (colorspace, rgba);
layer.backgroundColor = color;
surfaceLayers.layer = layer;

That CALayer is not positioned over the Canvas.  It is instead positioned in the lower-left corner of the window.  With the layer created in the above code fragment, we will see a red semi-transparent rectangle the size of the Canvas but positioned in the lower-left corner of the window.  With Apple's Java 6, we see a red semi-transparent rectangle both the size of the canvas and positioned over the Canvas.

REGRESSION.  Last worked in version 6u31

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attach a CALayer to a Canvas using the code fragment given in the description.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A red semi-transparent rectangle the size of the canvas rendered over the Canvas in the window.
ACTUAL -
A red semi-transparent rectangle the size of the canvas rendered in the lower-left corner of the window.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
This modified version of Apple's JAWT example code demonstrates the issue:
http://www.jeffsplace.net/JAWTExample.tar.gz

  To build, run build.sh.
  To run on Java 6, run run-java6.sh, for Java 7, run-java7.sh

JAVA_HOME may need modification in build.sh and run-java7.sh to point to the appropriate Java 7 home.
---------- END SOURCE ----------

Comments
AWT_NativeDrawing/Automated/JAWTCALayerTest
16-08-2013

Verified b102!
15-08-2013

EVALUATION -layer.bounds should be replaced by layer.frame -Wrong position inversion should be removed.
15-08-2012

SUGGESTED FIX http://hg.openjdk.java.net/jdk8/awt/jdk/rev/65d874d16d59
15-08-2012