United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7172187 [macosx] JAWT native CALayer not positioned over Canvas
JDK-7172187 : [macosx] JAWT native CALayer not positioned over Canvas

Details
Type:
Bug
Submit Date:
2012-05-28
Status:
Resolved
Updated Date:
2013-04-16
Project Name:
JDK
Resolved Date:
2012-09-05
Component:
client-libs
OS:
os_x
Sub-Component:
java.awt
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

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
EVALUATION

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

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



Hardware and Software, Engineered to Work Together