提交 96f517f4 编写于 作者: A andrew

Merge

/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -48,8 +48,9 @@ public abstract class CGLSurfaceData extends OGLSurfaceData { ...@@ -48,8 +48,9 @@ public abstract class CGLSurfaceData extends OGLSurfaceData {
native void validate(int xoff, int yoff, int width, int height, boolean isOpaque); native void validate(int xoff, int yoff, int width, int height, boolean isOpaque);
private native void initOps(long pConfigInfo, long pPeerData, long layerPtr, private native void initOps(OGLGraphicsConfig gc, long pConfigInfo,
int xoff, int yoff, boolean isOpaque); long pPeerData, long layerPtr, int xoff,
int yoff, boolean isOpaque);
protected native boolean initPbuffer(long pData, long pConfigInfo, protected native boolean initPbuffer(long pData, long pConfigInfo,
boolean isOpaque, int width, int height); boolean isOpaque, int width, int height);
...@@ -77,7 +78,7 @@ public abstract class CGLSurfaceData extends OGLSurfaceData { ...@@ -77,7 +78,7 @@ public abstract class CGLSurfaceData extends OGLSurfaceData {
pPeerData = pView.getAWTView(); pPeerData = pView.getAWTView();
isOpaque = pView.isOpaque(); isOpaque = pView.isOpaque();
} }
initOps(pConfigInfo, pPeerData, 0, 0, 0, isOpaque); initOps(gc, pConfigInfo, pPeerData, 0, 0, 0, isOpaque);
} }
protected CGLSurfaceData(CGLLayer layer, CGLGraphicsConfig gc, protected CGLSurfaceData(CGLLayer layer, CGLGraphicsConfig gc,
...@@ -93,7 +94,7 @@ public abstract class CGLSurfaceData extends OGLSurfaceData { ...@@ -93,7 +94,7 @@ public abstract class CGLSurfaceData extends OGLSurfaceData {
layerPtr = layer.getPointer(); layerPtr = layer.getPointer();
isOpaque = layer.isOpaque(); isOpaque = layer.isOpaque();
} }
initOps(pConfigInfo, 0, layerPtr, 0, 0, isOpaque); initOps(gc, pConfigInfo, 0, layerPtr, 0, 0, isOpaque);
} }
@Override //SurfaceData @Override //SurfaceData
......
...@@ -144,31 +144,6 @@ JNF_COCOA_ENTER(env); ...@@ -144,31 +144,6 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
/**
* Returns a pointer (as a jlong) to the native CGLGraphicsConfigInfo
* associated with the given OGLSDOps. This method can be called from
* shared code to retrieve the native GraphicsConfig data in a platform-
* independent manner.
*/
jlong
OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
{
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_GetNativeConfigInfo");
if (oglsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: ops are null");
return 0L;
}
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
if (cglsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_GetNativeConfigInfo: cgl ops are null");
return 0L;
}
return ptr_to_jlong(cglsdo->configInfo);
}
/** /**
* Makes the given GraphicsConfig's context current to its associated * Makes the given GraphicsConfig's context current to its associated
* "scratch" surface. If there is a problem making the context current, * "scratch" surface. If there is a problem making the context current,
...@@ -411,7 +386,7 @@ extern DisposeFunc OGLSD_Dispose; ...@@ -411,7 +386,7 @@ extern DisposeFunc OGLSD_Dispose;
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_java2d_opengl_CGLSurfaceData_initOps Java_sun_java2d_opengl_CGLSurfaceData_initOps
(JNIEnv *env, jobject cglsd, (JNIEnv *env, jobject cglsd, jobject gc,
jlong pConfigInfo, jlong pPeerData, jlong layerPtr, jlong pConfigInfo, jlong pPeerData, jlong layerPtr,
jint xoff, jint yoff, jboolean isOpaque) jint xoff, jint yoff, jboolean isOpaque)
{ {
...@@ -419,8 +394,22 @@ Java_sun_java2d_opengl_CGLSurfaceData_initOps ...@@ -419,8 +394,22 @@ Java_sun_java2d_opengl_CGLSurfaceData_initOps
J2dTraceLn1(J2D_TRACE_INFO, " pPeerData=%p", jlong_to_ptr(pPeerData)); J2dTraceLn1(J2D_TRACE_INFO, " pPeerData=%p", jlong_to_ptr(pPeerData));
J2dTraceLn2(J2D_TRACE_INFO, " xoff=%d, yoff=%d", (int)xoff, (int)yoff); J2dTraceLn2(J2D_TRACE_INFO, " xoff=%d, yoff=%d", (int)xoff, (int)yoff);
gc = (*env)->NewGlobalRef(env, gc);
if (gc == NULL) {
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
return;
}
OGLSDOps *oglsdo = (OGLSDOps *) OGLSDOps *oglsdo = (OGLSDOps *)
SurfaceData_InitOps(env, cglsd, sizeof(OGLSDOps)); SurfaceData_InitOps(env, cglsd, sizeof(OGLSDOps));
if (oglsdo == NULL) {
(*env)->DeleteGlobalRef(env, gc);
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
return;
}
// later the graphicsConfig will be used for deallocation of oglsdo
oglsdo->graphicsConfig = gc;
CGLSDOps *cglsdo = (CGLSDOps *)malloc(sizeof(CGLSDOps)); CGLSDOps *cglsdo = (CGLSDOps *)malloc(sizeof(CGLSDOps));
if (cglsdo == NULL) { if (cglsdo == NULL) {
JNU_ThrowOutOfMemoryError(env, "creating native cgl ops"); JNU_ThrowOutOfMemoryError(env, "creating native cgl ops");
......
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015 Red Hat, Inc. * Copyright (c) 2015 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
...@@ -62,14 +62,16 @@ final class GHASH { ...@@ -62,14 +62,16 @@ final class GHASH {
private static final int AES_BLOCK_SIZE = 16; private static final int AES_BLOCK_SIZE = 16;
// Multiplies state0, state1 by V0, V1. // Multiplies state[0], state[1] by subkeyH[0], subkeyH[1].
private void blockMult(long V0, long V1) { private static void blockMult(long[] st, long[] subH) {
long Z0 = 0; long Z0 = 0;
long Z1 = 0; long Z1 = 0;
long V0 = subH[0];
long V1 = subH[1];
long X; long X;
// Separate loops for processing state0 and state1. // Separate loops for processing state[0] and state[1].
X = state0; X = st[0];
for (int i = 0; i < 64; i++) { for (int i = 0; i < 64; i++) {
// Zi+1 = Zi if bit i of x is 0 // Zi+1 = Zi if bit i of x is 0
long mask = X >> 63; long mask = X >> 63;
...@@ -89,7 +91,7 @@ final class GHASH { ...@@ -89,7 +91,7 @@ final class GHASH {
X <<= 1; X <<= 1;
} }
X = state1; X = st[1];
for (int i = 64; i < 127; i++) { for (int i = 64; i < 127; i++) {
// Zi+1 = Zi if bit i of x is 0 // Zi+1 = Zi if bit i of x is 0
long mask = X >> 63; long mask = X >> 63;
...@@ -115,15 +117,18 @@ final class GHASH { ...@@ -115,15 +117,18 @@ final class GHASH {
Z1 ^= V1 & mask; Z1 ^= V1 & mask;
// Save result. // Save result.
state0 = Z0; st[0] = Z0;
state1 = Z1; st[1] = Z1;
} }
/* subkeyH and state are stored in long[] for GHASH intrinsic use */
// hash subkey H; should not change after the object has been constructed // hash subkey H; should not change after the object has been constructed
private final long subkeyH0, subkeyH1; private final long[] subkeyH;
// buffer for storing hash // buffer for storing hash
private long state0, state1; private final long[] state;
// variables for save/restore calls // variables for save/restore calls
private long stateSave0, stateSave1; private long stateSave0, stateSave1;
...@@ -141,8 +146,10 @@ final class GHASH { ...@@ -141,8 +146,10 @@ final class GHASH {
if ((subkeyH == null) || subkeyH.length != AES_BLOCK_SIZE) { if ((subkeyH == null) || subkeyH.length != AES_BLOCK_SIZE) {
throw new ProviderException("Internal error"); throw new ProviderException("Internal error");
} }
this.subkeyH0 = getLong(subkeyH, 0); state = new long[2];
this.subkeyH1 = getLong(subkeyH, 8); this.subkeyH = new long[2];
this.subkeyH[0] = getLong(subkeyH, 0);
this.subkeyH[1] = getLong(subkeyH, 8);
} }
/** /**
...@@ -151,33 +158,30 @@ final class GHASH { ...@@ -151,33 +158,30 @@ final class GHASH {
* this object for different data w/ the same H. * this object for different data w/ the same H.
*/ */
void reset() { void reset() {
state0 = 0; state[0] = 0;
state1 = 0; state[1] = 0;
} }
/** /**
* Save the current snapshot of this GHASH object. * Save the current snapshot of this GHASH object.
*/ */
void save() { void save() {
stateSave0 = state0; stateSave0 = state[0];
stateSave1 = state1; stateSave1 = state[1];
} }
/** /**
* Restores this object using the saved snapshot. * Restores this object using the saved snapshot.
*/ */
void restore() { void restore() {
state0 = stateSave0; state[0] = stateSave0;
state1 = stateSave1; state[1] = stateSave1;
} }
private void processBlock(byte[] data, int ofs) { private static void processBlock(byte[] data, int ofs, long[] st, long[] subH) {
if (data.length - ofs < AES_BLOCK_SIZE) { st[0] ^= getLong(data, ofs);
throw new RuntimeException("need complete block"); st[1] ^= getLong(data, ofs + 8);
} blockMult(st, subH);
state0 ^= getLong(data, ofs);
state1 ^= getLong(data, ofs + 8);
blockMult(subkeyH0, subkeyH1);
} }
void update(byte[] in) { void update(byte[] in) {
...@@ -185,22 +189,57 @@ final class GHASH { ...@@ -185,22 +189,57 @@ final class GHASH {
} }
void update(byte[] in, int inOfs, int inLen) { void update(byte[] in, int inOfs, int inLen) {
if (inLen - inOfs > in.length) { if (inLen == 0) {
throw new RuntimeException("input length out of bound"); return;
}
ghashRangeCheck(in, inOfs, inLen, state, subkeyH);
processBlocks(in, inOfs, inLen/AES_BLOCK_SIZE, state, subkeyH);
}
private static void ghashRangeCheck(byte[] in, int inOfs, int inLen, long[] st, long[] subH) {
if (inLen < 0) {
throw new RuntimeException("invalid input length: " + inLen);
}
if (inOfs < 0) {
throw new RuntimeException("invalid offset: " + inOfs);
}
if (inLen > in.length - inOfs) {
throw new RuntimeException("input length out of bound: " +
inLen + " > " + (in.length - inOfs));
} }
if (inLen % AES_BLOCK_SIZE != 0) { if (inLen % AES_BLOCK_SIZE != 0) {
throw new RuntimeException("input length unsupported"); throw new RuntimeException("input length/block size mismatch: " +
inLen);
} }
for (int i = inOfs; i < (inOfs + inLen); i += AES_BLOCK_SIZE) { // These two checks are for C2 checking
processBlock(in, i); if (st.length != 2) {
throw new RuntimeException("internal state has invalid length: " +
st.length);
}
if (subH.length != 2) {
throw new RuntimeException("internal subkeyH has invalid length: " +
subH.length);
}
}
/*
* This is an intrinsified method. The method's argument list must match
* the hotspot signature. This method and methods called by it, cannot
* throw exceptions or allocate arrays as it will breaking intrinsics
*/
private static void processBlocks(byte[] data, int inOfs, int blocks, long[] st, long[] subH) {
int offset = inOfs;
while (blocks > 0) {
processBlock(data, offset, st, subH);
blocks--;
offset += AES_BLOCK_SIZE;
} }
} }
byte[] digest() { byte[] digest() {
byte[] result = new byte[AES_BLOCK_SIZE]; byte[] result = new byte[AES_BLOCK_SIZE];
putLong(result, 0, state0); putLong(result, 0, state[0]);
putLong(result, 8, state1); putLong(result, 8, state[1]);
reset(); reset();
return result; return result;
} }
......
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,6 +28,8 @@ package javax.swing; ...@@ -28,6 +28,8 @@ package javax.swing;
import java.awt.event.*; import java.awt.event.*;
import java.awt.*; import java.awt.*;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
/** /**
* Manages all the <code>ToolTips</code> in the system. * Manages all the <code>ToolTips</code> in the system.
...@@ -409,9 +411,15 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener ...@@ -409,9 +411,15 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
component.addMouseListener(this); component.addMouseListener(this);
component.removeMouseMotionListener(moveBeforeEnterListener); component.removeMouseMotionListener(moveBeforeEnterListener);
component.addMouseMotionListener(moveBeforeEnterListener); component.addMouseMotionListener(moveBeforeEnterListener);
// use MenuKeyListener for menu items/elements
if (component instanceof JMenuItem) {
((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
((JMenuItem) component).addMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
} else {
component.removeKeyListener(accessibilityKeyListener); component.removeKeyListener(accessibilityKeyListener);
component.addKeyListener(accessibilityKeyListener); component.addKeyListener(accessibilityKeyListener);
} }
}
/** /**
* Removes a component from tooltip control. * Removes a component from tooltip control.
...@@ -421,8 +429,12 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener ...@@ -421,8 +429,12 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
public void unregisterComponent(JComponent component) { public void unregisterComponent(JComponent component) {
component.removeMouseListener(this); component.removeMouseListener(this);
component.removeMouseMotionListener(moveBeforeEnterListener); component.removeMouseMotionListener(moveBeforeEnterListener);
if (component instanceof JMenuItem) {
((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
} else {
component.removeKeyListener(accessibilityKeyListener); component.removeKeyListener(accessibilityKeyListener);
} }
}
// implements java.awt.event.MouseListener // implements java.awt.event.MouseListener
/** /**
...@@ -841,7 +853,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener ...@@ -841,7 +853,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
* Post Tip: Ctrl+F1 * Post Tip: Ctrl+F1
* Unpost Tip: Esc and Ctrl+F1 * Unpost Tip: Esc and Ctrl+F1
*/ */
private class AccessibilityKeyListener extends KeyAdapter { private class AccessibilityKeyListener extends KeyAdapter implements MenuKeyListener {
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (!e.isConsumed()) { if (!e.isConsumed()) {
JComponent source = (JComponent) e.getComponent(); JComponent source = (JComponent) e.getComponent();
...@@ -858,5 +870,32 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener ...@@ -858,5 +870,32 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
} }
} }
} }
@Override
public void menuKeyTyped(MenuKeyEvent e) {}
@Override
public void menuKeyPressed(MenuKeyEvent e) {
if (postTip.equals(KeyStroke.getKeyStrokeForEvent(e))) {
// get element for the event
MenuElement path[] = e.getPath();
MenuElement element = path[path.length - 1];
// retrieve currently highlighted element
MenuSelectionManager msm = e.getMenuSelectionManager();
MenuElement selectedPath[] = msm.getSelectedPath();
MenuElement selectedElement = selectedPath[selectedPath.length - 1];
if (element.equals(selectedElement)) {
// show/hide tooltip message
JComponent source = (JComponent) element.getComponent();
ToolTipManager.this.show(source);
e.consume();
}
}
}
@Override
public void menuKeyReleased(MenuKeyEvent e) {}
} }
} }
...@@ -27,6 +27,7 @@ package sun.java2d.opengl; ...@@ -27,6 +27,7 @@ package sun.java2d.opengl;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Composite; import java.awt.Composite;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment; import java.awt.GraphicsEnvironment;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Transparency; import java.awt.Transparency;
...@@ -598,16 +599,16 @@ public abstract class OGLSurfaceData extends SurfaceData ...@@ -598,16 +599,16 @@ public abstract class OGLSurfaceData extends SurfaceData
* (referenced by the pData parameter). This method is invoked from * (referenced by the pData parameter). This method is invoked from
* the native Dispose() method from the Disposer thread when the * the native Dispose() method from the Disposer thread when the
* Java-level OGLSurfaceData object is about to go away. Note that we * Java-level OGLSurfaceData object is about to go away. Note that we
* also pass a reference to the native GLX/WGLGraphicsConfigInfo * also pass a reference to the OGLGraphicsConfig
* (pConfigInfo) for the purposes of making a context current. * for the purposes of making a context current.
*/ */
static void dispose(long pData, long pConfigInfo) { static void dispose(long pData, OGLGraphicsConfig gc) {
OGLRenderQueue rq = OGLRenderQueue.getInstance(); OGLRenderQueue rq = OGLRenderQueue.getInstance();
rq.lock(); rq.lock();
try { try {
// make sure we have a current context before // make sure we have a current context before
// disposing the native resources (e.g. texture object) // disposing the native resources (e.g. texture object)
OGLContext.setScratchSurface(pConfigInfo); OGLContext.setScratchSurface(gc);
RenderBuffer buf = rq.getBuffer(); RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(12, 4); rq.ensureCapacityAndAlignment(12, 4);
......
...@@ -562,6 +562,14 @@ Java_sun_font_FreetypeFontScaler_getFontMetricsNative( ...@@ -562,6 +562,14 @@ Java_sun_font_FreetypeFontScaler_getFontMetricsNative(
/* See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=657854 */ /* See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=657854 */
#define FT_MulFixFloatShift6(a, b) (((float) (a)) * ((float) (b)) / 65536.0 / 64.0) #define FT_MulFixFloatShift6(a, b) (((float) (a)) * ((float) (b)) / 65536.0 / 64.0)
#define contextAwareMetricsX(x, y) \
(FTFixedToFloat(context->transform.xx) * (x) - \
FTFixedToFloat(context->transform.xy) * (y))
#define contextAwareMetricsY(x, y) \
(-FTFixedToFloat(context->transform.yx) * (x) + \
FTFixedToFloat(context->transform.yy) * (y))
/* /*
* See FreeType source code: src/base/ftobjs.c ft_recompute_scaled_metrics() * See FreeType source code: src/base/ftobjs.c ft_recompute_scaled_metrics()
* http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1659 * http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1659
...@@ -596,7 +604,11 @@ Java_sun_font_FreetypeFontScaler_getFontMetricsNative( ...@@ -596,7 +604,11 @@ Java_sun_font_FreetypeFontScaler_getFontMetricsNative(
metrics = (*env)->NewObject(env, metrics = (*env)->NewObject(env,
sunFontIDs.strikeMetricsClass, sunFontIDs.strikeMetricsClass,
sunFontIDs.strikeMetricsCtr, sunFontIDs.strikeMetricsCtr,
ax, ay, dx, dy, bx, by, lx, ly, mx, my); contextAwareMetricsX(ax, ay), contextAwareMetricsY(ax, ay),
contextAwareMetricsX(dx, dy), contextAwareMetricsY(dx, dy),
bx, by,
contextAwareMetricsX(lx, ly), contextAwareMetricsY(lx, ly),
contextAwareMetricsX(mx, my), contextAwareMetricsY(mx, my));
return metrics; return metrics;
} }
......
/* /*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
* The following methods are implemented in the windowing system (i.e. GLX * The following methods are implemented in the windowing system (i.e. GLX
* and WGL) source files. * and WGL) source files.
*/ */
extern jlong OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo);
extern jboolean OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo); extern jboolean OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo);
extern void OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo); extern void OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo);
...@@ -593,11 +592,14 @@ void ...@@ -593,11 +592,14 @@ void
OGLSD_Dispose(JNIEnv *env, SurfaceDataOps *ops) OGLSD_Dispose(JNIEnv *env, SurfaceDataOps *ops)
{ {
OGLSDOps *oglsdo = (OGLSDOps *)ops; OGLSDOps *oglsdo = (OGLSDOps *)ops;
jlong pConfigInfo = OGLSD_GetNativeConfigInfo(oglsdo); jobject graphicsConfig = oglsdo->graphicsConfig;
JNU_CallStaticMethodByName(env, NULL, "sun/java2d/opengl/OGLSurfaceData", JNU_CallStaticMethodByName(env, NULL, "sun/java2d/opengl/OGLSurfaceData",
"dispose", "(JJ)V", "dispose",
ptr_to_jlong(ops), pConfigInfo); "(JLsun/java2d/opengl/OGLGraphicsConfig;)V",
ptr_to_jlong(ops), graphicsConfig);
(*env)->DeleteGlobalRef(env, graphicsConfig);
oglsdo->graphicsConfig = NULL;
} }
/** /**
......
/* /*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -85,6 +85,9 @@ typedef struct { ...@@ -85,6 +85,9 @@ typedef struct {
* Pointer to native-specific (GLX, WGL, etc.) SurfaceData info, such as the * Pointer to native-specific (GLX, WGL, etc.) SurfaceData info, such as the
* native Drawable handle and GraphicsConfig data. * native Drawable handle and GraphicsConfig data.
* *
* jobject graphicsConfig;;
* Strong reference to the OGLGraphicsConfig used by this OGLSurfaceData.
*
* jint drawableType; * jint drawableType;
* The surface type; can be any one of the surface type constants defined * The surface type; can be any one of the surface type constants defined
* below (OGLSD_WINDOW, OGLSD_TEXTURE, etc). * below (OGLSD_WINDOW, OGLSD_TEXTURE, etc).
...@@ -162,6 +165,7 @@ typedef struct { ...@@ -162,6 +165,7 @@ typedef struct {
struct _OGLSDOps { struct _OGLSDOps {
SurfaceDataOps sdOps; SurfaceDataOps sdOps;
void *privOps; void *privOps;
jobject graphicsConfig;
jint drawableType; jint drawableType;
GLenum activeBuffer; GLenum activeBuffer;
jboolean isOpaque; jboolean isOpaque;
......
...@@ -41,7 +41,8 @@ public abstract class GLXSurfaceData extends OGLSurfaceData { ...@@ -41,7 +41,8 @@ public abstract class GLXSurfaceData extends OGLSurfaceData {
protected X11ComponentPeer peer; protected X11ComponentPeer peer;
private GLXGraphicsConfig graphicsConfig; private GLXGraphicsConfig graphicsConfig;
private native void initOps(X11ComponentPeer peer, long aData); private native void initOps(OGLGraphicsConfig gc, X11ComponentPeer peer,
long aData);
protected native boolean initPbuffer(long pData, long pConfigInfo, protected native boolean initPbuffer(long pData, long pConfigInfo,
boolean isOpaque, boolean isOpaque,
int width, int height); int width, int height);
...@@ -52,7 +53,7 @@ public abstract class GLXSurfaceData extends OGLSurfaceData { ...@@ -52,7 +53,7 @@ public abstract class GLXSurfaceData extends OGLSurfaceData {
super(gc, cm, type); super(gc, cm, type);
this.peer = peer; this.peer = peer;
this.graphicsConfig = gc; this.graphicsConfig = gc;
initOps(peer, graphicsConfig.getAData()); initOps(gc, peer, graphicsConfig.getAData());
} }
public GraphicsConfiguration getDeviceConfiguration() { public GraphicsConfiguration getDeviceConfiguration() {
......
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -54,23 +54,32 @@ jboolean surfaceCreationFailed = JNI_FALSE; ...@@ -54,23 +54,32 @@ jboolean surfaceCreationFailed = JNI_FALSE;
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd, Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
jobject gc,
jobject peer, jlong aData) jobject peer, jlong aData)
{ {
#ifndef HEADLESS #ifndef HEADLESS
GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps)); gc = (*env)->NewGlobalRef(env, gc);
if (gc == NULL) {
if (glxsdo == NULL) { JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
return; return;
} }
OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd, OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd,
sizeof(OGLSDOps)); sizeof(OGLSDOps));
if (oglsdo == NULL) { if (oglsdo == NULL) {
free(glxsdo); (*env)->DeleteGlobalRef(env, gc);
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
return; return;
} }
// later the graphicsConfig will be used for deallocation of oglsdo
oglsdo->graphicsConfig = gc;
GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));
if (glxsdo == NULL) {
JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
return;
}
J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps"); J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps");
...@@ -164,39 +173,6 @@ GLXSD_MakeCurrentToScratch(JNIEnv *env, OGLContext *oglc) ...@@ -164,39 +173,6 @@ GLXSD_MakeCurrentToScratch(JNIEnv *env, OGLContext *oglc)
return JNI_TRUE; return JNI_TRUE;
} }
/**
* Returns a pointer (as a jlong) to the native GLXGraphicsConfigInfo
* associated with the given OGLSDOps. This method can be called from
* shared code to retrieve the native GraphicsConfig data in a platform-
* independent manner.
*/
jlong
OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
{
GLXSDOps *glxsdo;
if (oglsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR,
"OGLSD_GetNativeConfigInfo: ops are null");
return 0L;
}
glxsdo = (GLXSDOps *)oglsdo->privOps;
if (glxsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR,
"OGLSD_GetNativeConfigInfo: glx ops are null");
return 0L;
}
if (glxsdo->configData == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR,
"OGLSD_GetNativeConfigInfo: config data is null");
return 0L;
}
return ptr_to_jlong(glxsdo->configData->glxInfo);
}
/** /**
* Makes the given GraphicsConfig's context current to its associated * Makes the given GraphicsConfig's context current to its associated
* "scratch" surface. If there is a problem making the context current, * "scratch" surface. If there is a problem making the context current,
......
...@@ -41,8 +41,8 @@ public abstract class WGLSurfaceData extends OGLSurfaceData { ...@@ -41,8 +41,8 @@ public abstract class WGLSurfaceData extends OGLSurfaceData {
protected WComponentPeer peer; protected WComponentPeer peer;
private WGLGraphicsConfig graphicsConfig; private WGLGraphicsConfig graphicsConfig;
private native void initOps(long pConfigInfo, WComponentPeer peer, private native void initOps(OGLGraphicsConfig gc, long pConfigInfo,
long hwnd); WComponentPeer peer, long hwnd);
protected native boolean initPbuffer(long pData, long pConfigInfo, protected native boolean initPbuffer(long pData, long pConfigInfo,
boolean isOpaque, boolean isOpaque,
int width, int height); int width, int height);
...@@ -57,7 +57,7 @@ public abstract class WGLSurfaceData extends OGLSurfaceData { ...@@ -57,7 +57,7 @@ public abstract class WGLSurfaceData extends OGLSurfaceData {
long pConfigInfo = gc.getNativeConfigInfo(); long pConfigInfo = gc.getNativeConfigInfo();
long hwnd = peer != null ? peer.getHWnd() : 0L; long hwnd = peer != null ? peer.getHWnd() : 0L;
initOps(pConfigInfo, peer, hwnd); initOps(gc, pConfigInfo, peer, hwnd);
} }
public GraphicsConfiguration getDeviceConfiguration() { public GraphicsConfiguration getDeviceConfiguration() {
......
...@@ -53,17 +53,17 @@ AccessBridgeATInstance::AccessBridgeATInstance(HWND ourABWindow, HWND winABWindo ...@@ -53,17 +53,17 @@ AccessBridgeATInstance::AccessBridgeATInstance(HWND ourABWindow, HWND winABWindo
* AccessBridgeATInstance descructor * AccessBridgeATInstance descructor
*/ */
AccessBridgeATInstance::~AccessBridgeATInstance() { AccessBridgeATInstance::~AccessBridgeATInstance() {
PrintDebugString("\r\nin AccessBridgeATInstance::~AccessBridgeATInstance"); PrintDebugString("[INFO]: in AccessBridgeATInstance::~AccessBridgeATInstance");
// if IPC memory mapped file view is valid, unmap it // if IPC memory mapped file view is valid, unmap it
if (memoryMappedView != (char *) 0) { if (memoryMappedView != (char *) 0) {
PrintDebugString(" unmapping memoryMappedView; view = %p", memoryMappedView); PrintDebugString("[INFO]: unmapping memoryMappedView; view = %p", memoryMappedView);
UnmapViewOfFile(memoryMappedView); UnmapViewOfFile(memoryMappedView);
memoryMappedView = (char *) 0; memoryMappedView = (char *) 0;
} }
// if IPC memory mapped file handle map is open, close it // if IPC memory mapped file handle map is open, close it
if (memoryMappedFileMapHandle != (HANDLE) 0) { if (memoryMappedFileMapHandle != (HANDLE) 0) {
PrintDebugString(" closing memoryMappedFileMapHandle; handle = %p", memoryMappedFileMapHandle); PrintDebugString("[INFO]: closing memoryMappedFileMapHandle; handle = %p", memoryMappedFileMapHandle);
CloseHandle(memoryMappedFileMapHandle); CloseHandle(memoryMappedFileMapHandle);
memoryMappedFileMapHandle = (HANDLE) 0; memoryMappedFileMapHandle = (HANDLE) 0;
} }
...@@ -87,7 +87,7 @@ LRESULT ...@@ -87,7 +87,7 @@ LRESULT
AccessBridgeATInstance::initiateIPC() { AccessBridgeATInstance::initiateIPC() {
DWORD errorCode; DWORD errorCode;
PrintDebugString("\r\nIn AccessBridgeATInstance::initiateIPC()"); PrintDebugString("[INFO]: In AccessBridgeATInstance::initiateIPC()");
// open Windows-initiated IPC filemap & map it to a ptr // open Windows-initiated IPC filemap & map it to a ptr
...@@ -95,10 +95,10 @@ AccessBridgeATInstance::initiateIPC() { ...@@ -95,10 +95,10 @@ AccessBridgeATInstance::initiateIPC() {
FALSE, memoryMappedFileName); FALSE, memoryMappedFileName);
if (memoryMappedFileMapHandle == NULL) { if (memoryMappedFileMapHandle == NULL) {
errorCode = GetLastError(); errorCode = GetLastError();
PrintDebugString(" Failed to CreateFileMapping for %s, error: %X", memoryMappedFileName, errorCode); PrintDebugString("[ERROR]: Failed to CreateFileMapping for %s, error: %X", memoryMappedFileName, errorCode);
return errorCode; return errorCode;
} else { } else {
PrintDebugString(" CreateFileMapping worked - filename: %s", memoryMappedFileName); PrintDebugString("[INFO]: CreateFileMapping worked - filename: %s", memoryMappedFileName);
} }
memoryMappedView = (char *) MapViewOfFile(memoryMappedFileMapHandle, memoryMappedView = (char *) MapViewOfFile(memoryMappedFileMapHandle,
...@@ -106,20 +106,20 @@ AccessBridgeATInstance::initiateIPC() { ...@@ -106,20 +106,20 @@ AccessBridgeATInstance::initiateIPC() {
0, 0, 0); 0, 0, 0);
if (memoryMappedView == NULL) { if (memoryMappedView == NULL) {
errorCode = GetLastError(); errorCode = GetLastError();
PrintDebugString(" Failed to MapViewOfFile for %s, error: %X", memoryMappedFileName, errorCode); PrintDebugString("[ERROR]: Failed to MapViewOfFile for %s, error: %X", memoryMappedFileName, errorCode);
return errorCode; return errorCode;
} else { } else {
PrintDebugString(" MapViewOfFile worked - view: %p", memoryMappedView); PrintDebugString("[INFO]: MapViewOfFile worked - view: %p", memoryMappedView);
} }
// look for the JavaDLL's answer to see if it could read the file // look for the JavaDLL's answer to see if it could read the file
if (strcmp(memoryMappedView, AB_MEMORY_MAPPED_FILE_OK_QUERY) != 0) { if (strcmp(memoryMappedView, AB_MEMORY_MAPPED_FILE_OK_QUERY) != 0) {
PrintDebugString(" JavaVM failed to write to memory mapped file %s", PrintDebugString("[ERROR]: JavaVM failed to write to memory mapped file %s",
memoryMappedFileName); memoryMappedFileName);
return -1; return -1;
} else { } else {
PrintDebugString(" JavaVM successfully wrote to file!"); PrintDebugString("[INFO]: JavaVM successfully wrote to file!");
} }
...@@ -213,8 +213,8 @@ static void do_event(char *buffer, int bufsize,HWND ourAccessBridgeWindow,HWND w ...@@ -213,8 +213,8 @@ static void do_event(char *buffer, int bufsize,HWND ourAccessBridgeWindow,HWND w
LRESULT LRESULT
AccessBridgeATInstance::sendJavaEventPackage(char *buffer, int bufsize, long eventID) { AccessBridgeATInstance::sendJavaEventPackage(char *buffer, int bufsize, long eventID) {
PrintDebugString("AccessBridgeATInstance::sendJavaEventPackage() eventID = %X", eventID); PrintDebugString("[INFO]: AccessBridgeATInstance::sendJavaEventPackage() eventID = %X", eventID);
PrintDebugString("AccessBridgeATInstance::sendJavaEventPackage() (using PostMessage) eventID = %X", eventID); PrintDebugString("[INFO]: AccessBridgeATInstance::sendJavaEventPackage() (using PostMessage) eventID = %X", eventID);
if (eventID & javaEventMask) { if (eventID & javaEventMask) {
do_event(buffer,bufsize,ourAccessBridgeWindow,winAccessBridgeWindow); do_event(buffer,bufsize,ourAccessBridgeWindow,winAccessBridgeWindow);
...@@ -234,7 +234,7 @@ AccessBridgeATInstance::sendJavaEventPackage(char *buffer, int bufsize, long eve ...@@ -234,7 +234,7 @@ AccessBridgeATInstance::sendJavaEventPackage(char *buffer, int bufsize, long eve
LRESULT LRESULT
AccessBridgeATInstance::sendAccessibilityEventPackage(char *buffer, int bufsize, long eventID) { AccessBridgeATInstance::sendAccessibilityEventPackage(char *buffer, int bufsize, long eventID) {
PrintDebugString("AccessBridgeATInstance::sendAccessibilityEventPackage() eventID = %X", eventID); PrintDebugString("[INFO]: AccessBridgeATInstance::sendAccessibilityEventPackage() eventID = %X", eventID);
if (eventID & accessibilityEventMask) { if (eventID & accessibilityEventMask) {
do_event(buffer,bufsize,ourAccessBridgeWindow,winAccessBridgeWindow); do_event(buffer,bufsize,ourAccessBridgeWindow,winAccessBridgeWindow);
......
/* /*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,17 +31,66 @@ ...@@ -31,17 +31,66 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <windows.h> #include <windows.h>
#include <cstdlib>
#include <cstring>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
static FILE* logFP = nullptr;
void initializeFileLogger(char * fileName) {
auto var = "JAVA_ACCESSBRIDGE_LOGDIR";
const auto envfilePath = getenv(var);
if (envfilePath != nullptr && fileName != nullptr) {
auto envFilePathLength = strlen(envfilePath);
auto fileNameLength = strlen(fileName);
auto filePathSize = envFilePathLength + 1 + fileNameLength + 5; //1 for "/", 5 for ".log" and 0;
auto filePath = new char[filePathSize];
memset(filePath, 0, filePathSize*sizeof(char));
memcpy(filePath, envfilePath, envFilePathLength*sizeof(char));
filePath[envFilePathLength] = '/';
memcpy(filePath + envFilePathLength + 1, fileName, fileNameLength*sizeof(char));
memcpy(filePath + envFilePathLength + 1 + fileNameLength, ".log", 4*sizeof(char));
logFP = fopen(filePath, "w");
if (logFP == nullptr) {
printf("\n%s\n", filePath);
PrintDebugString("Could not open file %s", filePath);
}
delete [] filePath;
}
}
void finalizeFileLogger() {
if (logFP) {
fclose(logFP);
logFP = nullptr;
}
}
auto getTimeStamp() -> long long {
LARGE_INTEGER freqLarge;
::QueryPerformanceFrequency(&freqLarge);
long long freq = freqLarge.QuadPart;
LARGE_INTEGER counterLarge;
::QueryPerformanceCounter(&counterLarge);
long long counter = counterLarge.QuadPart;
long long milliDen = 1000;
// prevent possible overflow
long long whole = (counter / freq) * milliDen;
long long part = (counter % freq) * milliDen / freq;
return whole + part;
}
/** /**
* Send debugging info to the appropriate place * Send debugging info to the appropriate place
*/ */
void PrintDebugString(char *msg, ...) { void PrintDebugString(char *msg, ...) {
#ifdef DEBUGGING_ON #ifdef DEBUGGING_ON
char buf[1024]; char buf[1024] = {0};
va_list argprt; va_list argprt;
va_start(argprt, msg); // set up argptr va_start(argprt, msg); // set up argptr
...@@ -54,6 +103,14 @@ extern "C" { ...@@ -54,6 +103,14 @@ extern "C" {
printf("\r\n"); printf("\r\n");
#endif #endif
#endif #endif
if (logFP) {
fprintf(logFP, "[%llu] ", getTimeStamp());
va_list args;
va_start(args, msg);
vfprintf(logFP, msg, args);
va_end(args);
fprintf(logFP, "\r\n");
}
} }
/** /**
...@@ -61,7 +118,7 @@ extern "C" { ...@@ -61,7 +118,7 @@ extern "C" {
*/ */
void PrintJavaDebugString2(char *msg, ...) { void PrintJavaDebugString2(char *msg, ...) {
#ifdef JAVA_DEBUGGING_ON #ifdef JAVA_DEBUGGING_ON
char buf[1024]; char buf[1024] = {0};
va_list argprt; va_list argprt;
va_start(argprt, msg); // set up argptr va_start(argprt, msg); // set up argptr
...@@ -74,13 +131,21 @@ extern "C" { ...@@ -74,13 +131,21 @@ extern "C" {
printf("\r\n"); printf("\r\n");
#endif #endif
#endif #endif
if (logFP) {
fprintf(logFP, "[%llu] ", getTimeStamp());
va_list args;
va_start(args, msg);
vfprintf(logFP, msg, args);
va_end(args);
fprintf(logFP, "\r\n");
}
} }
/** /**
* Wide version of the method to send debugging info to the appropriate place * Wide version of the method to send debugging info to the appropriate place
*/ */
void wPrintDebugString(wchar_t *msg, ...) { void wPrintDebugString(wchar_t *msg, ...) {
#ifdef DEBUGGING_ON #ifdef DEBUGGING_ON
char buf[1024]; char buf[1024] = {0};
char charmsg[256]; char charmsg[256];
va_list argprt; va_list argprt;
...@@ -95,6 +160,14 @@ extern "C" { ...@@ -95,6 +160,14 @@ extern "C" {
printf("\r\n"); printf("\r\n");
#endif #endif
#endif #endif
if (logFP) {
fprintf(logFP, "[%llu] ", getTimeStamp());
va_list args;
va_start(args, msg);
vfwprintf(logFP, msg, args);
va_end(args);
fprintf(logFP, "\r\n");
}
} }
/** /**
...@@ -102,8 +175,8 @@ extern "C" { ...@@ -102,8 +175,8 @@ extern "C" {
*/ */
void wPrintJavaDebugString(wchar_t *msg, ...) { void wPrintJavaDebugString(wchar_t *msg, ...) {
#ifdef JAVA_DEBUGGING_ON #ifdef JAVA_DEBUGGING_ON
char buf[1024]; char buf[1024] = {0};
char charmsg[256]; char charmsg[256] = {0};
va_list argprt; va_list argprt;
va_start(argprt, msg); // set up argptr va_start(argprt, msg); // set up argptr
...@@ -117,6 +190,14 @@ extern "C" { ...@@ -117,6 +190,14 @@ extern "C" {
printf("\r\n"); printf("\r\n");
#endif #endif
#endif #endif
if (logFP) {
fprintf(logFP, "[%llu] ", getTimeStamp());
va_list args;
va_start(args, msg);
vfwprintf(logFP, msg, args);
va_end(args);
fprintf(logFP, "\r\n");
}
} }
#ifdef __cplusplus #ifdef __cplusplus
} }
......
/* /*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -53,6 +53,8 @@ extern "C" { ...@@ -53,6 +53,8 @@ extern "C" {
void PrintJavaDebugString(char *msg, ...); void PrintJavaDebugString(char *msg, ...);
void wPrintJavaDebugString(wchar_t *msg, ...); void wPrintJavaDebugString(wchar_t *msg, ...);
void wPrintDebugString(wchar_t *msg, ...); void wPrintDebugString(wchar_t *msg, ...);
void initializeFileLogger(char * fileName);
void finalizeFileLogger();
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -170,7 +170,7 @@ AccessBridgeEventHandler::firePropertyChange(long vmID, ...@@ -170,7 +170,7 @@ AccessBridgeEventHandler::firePropertyChange(long vmID,
if (propertyChangeFP != (AccessBridge_PropertyChangeFP) 0) { if (propertyChangeFP != (AccessBridge_PropertyChangeFP) 0) {
propertyChangeFP(vmID, event, source, property, oldName, newName); propertyChangeFP(vmID, event, source, property, oldName, newName);
} else { } else {
DEBUG_CODE(AppendToCallInfo(" Error! propertyChangeFP == 0\r\n")); DEBUG_CODE(AppendToCallInfo("[ERROR]: propertyChangeFP == 0"));
} }
} }
...@@ -186,9 +186,9 @@ AccessBridgeEventHandler::firePropertyChange(long vmID, ...@@ -186,9 +186,9 @@ AccessBridgeEventHandler::firePropertyChange(long vmID,
* *
*/ */
#ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
const char fireEventDebugString[] = "\r\nIn AccessBridgeEventHandler::%s(%p, %p); vmID = %X\r\n"; const char fireEventDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s(%p, %p); vmID = %X\r\n";
#else // JOBJECT64 is jlong (64 bit) #else // JOBJECT64 is jlong (64 bit)
const char fireEventDebugString[] = "\r\nIn AccessBridgeEventHandler::%s(%016I64X, %016I64X); vmID = %X\r\n"; const char fireEventDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s(%016I64X, %016I64X); vmID = %X\r\n";
#endif #endif
#define FIRE_EVENT(method, FPprototype, eventFP) \ #define FIRE_EVENT(method, FPprototype, eventFP) \
...@@ -199,18 +199,18 @@ const char fireEventDebugString[] = "\r\nIn AccessBridgeEventHandler::%s(%016I64 ...@@ -199,18 +199,18 @@ const char fireEventDebugString[] = "\r\nIn AccessBridgeEventHandler::%s(%016I64
if (eventFP != (FPprototype) 0) { \ if (eventFP != (FPprototype) 0) { \
eventFP(vmID, event, source); \ eventFP(vmID, event, source); \
} else { \ } else { \
DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0")); \
} \ } \
} }
void AccessBridgeEventHandler::fireJavaShutdown(long vmID) { void AccessBridgeEventHandler::fireJavaShutdown(long vmID) {
DEBUG_CODE(char debugBuf[255]); DEBUG_CODE(char debugBuf[255]);
DEBUG_CODE(sprintf(debugBuf, "\r\nCalling fireJavaShutdown; vmID = %X\r\n", vmID)); DEBUG_CODE(sprintf(debugBuf, "[INFO]: Calling fireJavaShutdown; vmID = %X\r\n", vmID));
DEBUG_CODE(AppendToCallInfo(debugBuf)); DEBUG_CODE(AppendToCallInfo(debugBuf));
if (javaShutdownFP != (AccessBridge_JavaShutdownFP) 0) { if (javaShutdownFP != (AccessBridge_JavaShutdownFP) 0) {
javaShutdownFP(vmID); javaShutdownFP(vmID);
} else { } else {
DEBUG_CODE(AppendToCallInfo(" Error! javaShutdownFP == 0\r\n")); DEBUG_CODE(AppendToCallInfo("[ERROR]: javaShutdownFP == 0"));
} }
} }
...@@ -241,9 +241,9 @@ FIRE_EVENT(firePopupMenuWillBecomeVisible, AccessBridge_PopupMenuWillBecomeVisib ...@@ -241,9 +241,9 @@ FIRE_EVENT(firePopupMenuWillBecomeVisible, AccessBridge_PopupMenuWillBecomeVisib
* *
*/ */
#ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing a no-param property change (%p, %p):\r\n"; const char firePropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing a no-param property change (%p, %p):\r\n";
#else // JOBJECT64 is jlong (64 bit) #else // JOBJECT64 is jlong (64 bit)
const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing a no-param property change (%016I64X, %016I64X):\r\n"; const char firePropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing a no-param property change (%016I64X, %016I64X):\r\n";
#endif #endif
#define FIRE_PROPERTY_CHANGE(method, FPprototype, eventFP) \ #define FIRE_PROPERTY_CHANGE(method, FPprototype, eventFP) \
...@@ -254,7 +254,7 @@ const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::% ...@@ -254,7 +254,7 @@ const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%
if (eventFP != (FPprototype) 0) { \ if (eventFP != (FPprototype) 0) { \
eventFP(vmID, event, source); \ eventFP(vmID, event, source); \
} else { \ } else { \
DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0")); \
} \ } \
} }
...@@ -269,9 +269,9 @@ const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::% ...@@ -269,9 +269,9 @@ const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%
* *
*/ */
#ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing a string property change (%p, %p, %ls, %ls):\r\n"; const char fireStringPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing a string property change (%p, %p, %ls, %ls):\r\n";
#else // JOBJECT64 is jlong (64 bit) #else // JOBJECT64 is jlong (64 bit)
const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing a string property change (%016I64X, %016I64X, %ls, %ls):\r\n"; const char fireStringPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing a string property change (%016I64X, %016I64X, %ls, %ls):\r\n";
#endif #endif
#define FIRE_STRING_PROPERTY_CHANGE(method, FPprototype, eventFP, oldValue, newValue) \ #define FIRE_STRING_PROPERTY_CHANGE(method, FPprototype, eventFP, oldValue, newValue) \
...@@ -283,7 +283,7 @@ const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHand ...@@ -283,7 +283,7 @@ const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHand
if (eventFP != (FPprototype) 0) { \ if (eventFP != (FPprototype) 0) { \
eventFP(vmID, event, source, oldValue, newValue); \ eventFP(vmID, event, source, oldValue, newValue); \
} else { \ } else { \
DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0\r\n")); \
} \ } \
} }
...@@ -298,9 +298,9 @@ const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHand ...@@ -298,9 +298,9 @@ const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHand
* *
*/ */
#ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing an int property change (%p, %p, %d, %d):\r\n"; const char fireIntPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing an int property change (%p, %p, %d, %d):\r\n";
#else // JOBJECT64 is jlong (64 bit) #else // JOBJECT64 is jlong (64 bit)
const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing an int property change (%016I64X, %016I64X, %d, %d):\r\n"; const char fireIntPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing an int property change (%016I64X, %016I64X, %d, %d):\r\n";
#endif #endif
#define FIRE_INT_PROPERTY_CHANGE(method, FPprototype, eventFP) \ #define FIRE_INT_PROPERTY_CHANGE(method, FPprototype, eventFP) \
...@@ -312,7 +312,7 @@ const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler ...@@ -312,7 +312,7 @@ const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler
if (eventFP != (FPprototype) 0) { \ if (eventFP != (FPprototype) 0) { \
eventFP(vmID, event, source, oldValue, newValue); \ eventFP(vmID, event, source, oldValue, newValue); \
} else { \ } else { \
DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0\r\n")); \
} \ } \
} }
...@@ -327,9 +327,9 @@ const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler ...@@ -327,9 +327,9 @@ const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler
* *
*/ */
#ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
const char fireACPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing an AC property change (%p, %p, %p, %p):\r\n"; const char fireACPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing an AC property change (%p, %p, %p, %p):\r\n";
#else // JOBJECT64 is jlong (64 bit) #else // JOBJECT64 is jlong (64 bit)
const char fireACPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing an AC property change (%016I64X, %016I64X, %016I64X, %016I64X):\r\n"; const char fireACPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing an AC property change (%016I64X, %016I64X, %016I64X, %016I64X):\r\n";
#endif #endif
#define FIRE_AC_PROPERTY_CHANGE(method, FPprototype, eventFP) \ #define FIRE_AC_PROPERTY_CHANGE(method, FPprototype, eventFP) \
...@@ -341,7 +341,7 @@ const char fireACPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler: ...@@ -341,7 +341,7 @@ const char fireACPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler:
if (eventFP != (FPprototype) 0) { \ if (eventFP != (FPprototype) 0) { \
eventFP(vmID, event, source, oldValue, newValue); \ eventFP(vmID, event, source, oldValue, newValue); \
} else { \ } else { \
DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0\r\n")); \
} \ } \
} }
......
...@@ -198,8 +198,8 @@ AccessBridgeJavaVMInstance::sendPackage(char *buffer, long bufsize) { ...@@ -198,8 +198,8 @@ AccessBridgeJavaVMInstance::sendPackage(char *buffer, long bufsize) {
toCopy.cbData = bufsize; toCopy.cbData = bufsize;
toCopy.lpData = buffer; toCopy.lpData = buffer;
PrintDebugString("In AccessBridgeVMInstance::sendPackage"); PrintDebugString("[INFO]: In AccessBridgeVMInstance::sendPackage");
PrintDebugString(" javaAccessBridgeWindow: %p", javaAccessBridgeWindow); PrintDebugString("[INFO]: javaAccessBridgeWindow: %p", javaAccessBridgeWindow);
/* This was SendMessage. Normally that is a blocking call. However, if /* This was SendMessage. Normally that is a blocking call. However, if
* SendMessage is sent to another process, e.g. another JVM and an incoming * SendMessage is sent to another process, e.g. another JVM and an incoming
* SendMessage is pending, control will be passed to the DialogProc to handle * SendMessage is pending, control will be passed to the DialogProc to handle
...@@ -280,7 +280,7 @@ AccessBridgeJavaVMInstance::sendMemoryPackage(char *buffer, long bufsize) { ...@@ -280,7 +280,7 @@ AccessBridgeJavaVMInstance::sendMemoryPackage(char *buffer, long bufsize) {
char *done = &memoryMappedView[bufsize]; char *done = &memoryMappedView[bufsize];
*done = 0; *done = 0;
PrintDebugString(" javaAccessBridgeWindow: %p", javaAccessBridgeWindow); PrintDebugString("[INFO]: javaAccessBridgeWindow: %p", javaAccessBridgeWindow);
// See the comment above the call to SendMessageTimeout in SendPackage method above. // See the comment above the call to SendMessageTimeout in SendPackage method above.
UINT flags = SMTO_BLOCK | SMTO_NOTIMEOUTIFNOTHUNG; UINT flags = SMTO_BLOCK | SMTO_NOTIMEOUTIFNOTHUNG;
DWORD_PTR out; // not used DWORD_PTR out; // not used
...@@ -309,7 +309,7 @@ AccessBridgeJavaVMInstance::sendMemoryPackage(char *buffer, long bufsize) { ...@@ -309,7 +309,7 @@ AccessBridgeJavaVMInstance::sendMemoryPackage(char *buffer, long bufsize) {
*/ */
HWND HWND
AccessBridgeJavaVMInstance::findAccessBridgeWindow(long javaVMID) { AccessBridgeJavaVMInstance::findAccessBridgeWindow(long javaVMID) {
PrintDebugString("In findAccessBridgeWindow"); PrintDebugString("[INFO]: In findAccessBridgeWindow");
// no need to recurse really // no need to recurse really
if (vmID == javaVMID) { if (vmID == javaVMID) {
return javaAccessBridgeWindow; return javaAccessBridgeWindow;
...@@ -338,7 +338,7 @@ AccessBridgeJavaVMInstance::findAccessBridgeWindow(long javaVMID) { ...@@ -338,7 +338,7 @@ AccessBridgeJavaVMInstance::findAccessBridgeWindow(long javaVMID) {
*/ */
AccessBridgeJavaVMInstance * AccessBridgeJavaVMInstance *
AccessBridgeJavaVMInstance::findABJavaVMInstanceFromJavaHWND(HWND window) { AccessBridgeJavaVMInstance::findABJavaVMInstanceFromJavaHWND(HWND window) {
PrintDebugString("In findABJavaInstanceFromJavaHWND"); PrintDebugString("[INFO]: In findABJavaInstanceFromJavaHWND");
// no need to recurse really // no need to recurse really
if (javaAccessBridgeWindow == window) { if (javaAccessBridgeWindow == window) {
return this; return this;
......
...@@ -88,17 +88,17 @@ AccessBridgeMessageQueue::getEventsWaiting() { ...@@ -88,17 +88,17 @@ AccessBridgeMessageQueue::getEventsWaiting() {
*/ */
QueueReturns QueueReturns
AccessBridgeMessageQueue::add(AccessBridgeQueueElement *element) { AccessBridgeMessageQueue::add(AccessBridgeQueueElement *element) {
PrintDebugString(" in AccessBridgeMessageQueue::add()"); PrintDebugString("[INFO]: in AccessBridgeMessageQueue::add()");
PrintDebugString(" queue size = %d", size); PrintDebugString("[INFO]: queue size = %d", size);
QueueReturns returnVal = cElementPushedOK; QueueReturns returnVal = cElementPushedOK;
if (queueLocked) { if (queueLocked) {
PrintDebugString(" queue was locked; returning cQueueInUse!"); PrintDebugString("[WARN]: queue was locked; returning cQueueInUse!");
return cQueueInUse; return cQueueInUse;
} }
queueLocked = TRUE; queueLocked = TRUE;
{ {
PrintDebugString(" adding element to queue!"); PrintDebugString("[INFO]: adding element to queue!");
if (end == (AccessBridgeQueueElement *) 0) { if (end == (AccessBridgeQueueElement *) 0) {
if (start == (AccessBridgeQueueElement *) 0 && size == 0) { if (start == (AccessBridgeQueueElement *) 0 && size == 0) {
start = element; start = element;
...@@ -118,7 +118,7 @@ AccessBridgeMessageQueue::add(AccessBridgeQueueElement *element) { ...@@ -118,7 +118,7 @@ AccessBridgeMessageQueue::add(AccessBridgeQueueElement *element) {
} }
} }
queueLocked = FALSE; queueLocked = FALSE;
PrintDebugString(" returning from AccessBridgeMessageQueue::add()"); PrintDebugString("[INFO]: returning from AccessBridgeMessageQueue::add()");
return returnVal; return returnVal;
} }
...@@ -129,17 +129,17 @@ AccessBridgeMessageQueue::add(AccessBridgeQueueElement *element) { ...@@ -129,17 +129,17 @@ AccessBridgeMessageQueue::add(AccessBridgeQueueElement *element) {
*/ */
QueueReturns QueueReturns
AccessBridgeMessageQueue::remove(AccessBridgeQueueElement **element) { AccessBridgeMessageQueue::remove(AccessBridgeQueueElement **element) {
PrintDebugString(" in AccessBridgeMessageQueue::remove()"); PrintDebugString("[INFO]: in AccessBridgeMessageQueue::remove()");
PrintDebugString(" queue size = %d", size); PrintDebugString("[INFO]: queue size = %d", size);
QueueReturns returnVal = cMoreMessages; QueueReturns returnVal = cMoreMessages;
if (queueLocked) { if (queueLocked) {
PrintDebugString(" queue was locked; returning cQueueInUse!"); PrintDebugString("[WARN]: queue was locked; returning cQueueInUse!");
return cQueueInUse; return cQueueInUse;
} }
queueLocked = TRUE; queueLocked = TRUE;
{ {
PrintDebugString(" removing element from queue!"); PrintDebugString("[INFO]: removing element from queue!");
if (size > 0) { if (size > 0) {
if (start != (AccessBridgeQueueElement *) 0) { if (start != (AccessBridgeQueueElement *) 0) {
*element = start; *element = start;
...@@ -161,7 +161,7 @@ AccessBridgeMessageQueue::remove(AccessBridgeQueueElement **element) { ...@@ -161,7 +161,7 @@ AccessBridgeMessageQueue::remove(AccessBridgeQueueElement **element) {
} }
} }
queueLocked = FALSE; queueLocked = FALSE;
PrintDebugString(" returning from AccessBridgeMessageQueue::remove()"); PrintDebugString("[INFO]: returning from AccessBridgeMessageQueue::remove()");
return returnVal; return returnVal;
} }
......
/* /*
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -58,12 +58,29 @@ extern void ...@@ -58,12 +58,29 @@ extern void
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd, Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd,
jlong pConfigInfo, jobject gc, jlong pConfigInfo,
jobject peer, jlong hwnd) jobject peer, jlong hwnd)
{ {
OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, wglsd, OGLSDOps *oglsdo;
WGLSDOps *wglsdo;
gc = (*env)->NewGlobalRef(env, gc);
if (gc == NULL) {
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
return;
}
oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, wglsd,
sizeof(OGLSDOps)); sizeof(OGLSDOps));
WGLSDOps *wglsdo = (WGLSDOps *)malloc(sizeof(WGLSDOps)); if (oglsdo == NULL) {
(*env)->DeleteGlobalRef(env, gc);
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
return;
}
// later the graphicsConfig will be used for deallocation of oglsdo
oglsdo->graphicsConfig = gc;
wglsdo = (WGLSDOps *)malloc(sizeof(WGLSDOps));
J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps"); J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps");
...@@ -159,33 +176,6 @@ WGLSD_MakeCurrentToScratch(JNIEnv *env, OGLContext *oglc) ...@@ -159,33 +176,6 @@ WGLSD_MakeCurrentToScratch(JNIEnv *env, OGLContext *oglc)
return JNI_TRUE; return JNI_TRUE;
} }
/**
* Returns a pointer (as a jlong) to the native WGLGraphicsConfigInfo
* associated with the given OGLSDOps. This method can be called from
* shared code to retrieve the native GraphicsConfig data in a platform-
* independent manner.
*/
jlong
OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
{
WGLSDOps *wglsdo;
if (oglsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR,
"OGLSD_GetNativeConfigInfo: ops are null");
return 0L;
}
wglsdo = (WGLSDOps *)oglsdo->privOps;
if (wglsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR,
"OGLSD_GetNativeConfigInfo: wgl ops are null");
return 0L;
}
return ptr_to_jlong(wglsdo->configInfo);
}
/** /**
* Makes the given GraphicsConfig's context current to its associated * Makes the given GraphicsConfig's context current to its associated
* "scratch" surface. If there is a problem making the context current, * "scratch" surface. If there is a problem making the context current,
......
/* /*
* Copyright (c) 2015, Red Hat, Inc. * Copyright (c) 2015, Red Hat, Inc.
* Copyright (c) 2015, Oracle, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,7 +25,14 @@ ...@@ -24,7 +25,14 @@
/* /*
* @test * @test
* @bug 8069072 * @bug 8069072
* @summary Test vectors for com.sun.crypto.provider.GHASH * @summary Test vectors for com.sun.crypto.provider.GHASH.
*
* Single iteration to verify software-only GHASH algorithm.
* @run main TestGHASH
*
* Multi-iteration to verify test intrinsics GHASH, if available.
* Many iterations are needed so we are sure hotspot will use intrinsic
* @run main TestGHASH -n 10000
*/ */
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -124,16 +132,26 @@ public class TestGHASH { ...@@ -124,16 +132,26 @@ public class TestGHASH {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
TestGHASH test; TestGHASH test;
if (args.length == 0) { String test_class = "com.sun.crypto.provider.GHASH";
test = new TestGHASH("com.sun.crypto.provider.GHASH"); int i = 0;
} else { int num_of_loops = 1;
test = new TestGHASH(args[0]); while (args.length > i) {
if (args[i].compareTo("-c") == 0) {
test_class = args[++i];
} else if (args[i].compareTo("-n") == 0) {
num_of_loops = Integer.parseInt(args[++i]);
}
i++;
} }
System.out.println("Running " + num_of_loops + " iterations.");
test = new TestGHASH(test_class);
i = 0;
while (num_of_loops > i) {
// Test vectors from David A. McGrew, John Viega, // Test vectors from David A. McGrew, John Viega,
// "The Galois/Counter Mode of Operation (GCM)", 2005. // "The Galois/Counter Mode of Operation (GCM)", 2005.
// <http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf> // <http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf>
test.check(1, "66e94bd4ef8a2c3b884cfa59ca342b2e", "", "", test.check(1, "66e94bd4ef8a2c3b884cfa59ca342b2e", "", "",
"00000000000000000000000000000000"); "00000000000000000000000000000000");
test.check(2, test.check(2,
...@@ -162,5 +180,7 @@ public class TestGHASH { ...@@ -162,5 +180,7 @@ public class TestGHASH {
"73806900e49f24b22b097544d4896b42" + "73806900e49f24b22b097544d4896b42" +
"4989b5e1ebac0f07c23f4598", "4989b5e1ebac0f07c23f4598",
"df586bb4c249b92cb6922877e444d37b"); "df586bb4c249b92cb6922877e444d37b");
i++;
}
} }
} }
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test RotatedFontMetricsTest
* @bug 8139178
* @summary This test verifies that rotation does not affect font metrics.
* @run main RotatedFontMetricsTest
*/
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
public class RotatedFontMetricsTest {
static final int FONT_SIZE = Integer.getInteger("font.size", 20);
public static void main(String ... args) {
Font font = new Font(Font.DIALOG, Font.PLAIN, FONT_SIZE);
Graphics2D g2d = createGraphics();
FontMetrics ref = null;
RuntimeException failure = null;
for (int a = 0; a < 360; a += 15) {
Graphics2D g = (Graphics2D)g2d.create();
g.rotate(Math.toRadians(a));
FontMetrics m = g.getFontMetrics(font);
g.dispose();
boolean status = true;
if (ref == null) {
ref = m;
} else {
status = ref.getAscent() == m.getAscent() &&
ref.getDescent() == m.getDescent() &&
ref.getLeading() == m.getLeading() &&
ref.getMaxAdvance() == m.getMaxAdvance();
}
System.out.printf("Metrics a%d, d%d, l%d, m%d (%d) %s\n",
m.getAscent(), m.getDescent(), m.getLeading(), m.getMaxAdvance(),
(int)a, status ? "OK" : "FAIL");
if (!status && failure == null) {
failure = new RuntimeException("Font metrics differ for angle " + a);
}
}
if (failure != null) {
throw failure;
}
System.out.println("done");
}
private static Graphics2D createGraphics() {
BufferedImage dst = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
return dst.createGraphics();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册