/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
#import "LWCToolkit.h"
#import "ThreadUtilities.h"
/*
* Convert the mode string to the more convinient bits per pixel value
*/
{
if ((CFStringCompare(mode, CFSTR(kIO30BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)) {
// This is a strange mode, where we using 10 bits per RGB component and pack it into 32 bits
// Java is not ready to work with this mode but we have to specify it as supported
return 30;
}
else if (CFStringCompare(mode, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
return 32;
}
else if (CFStringCompare(mode, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
return 16;
}
else if (CFStringCompare(mode, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
return 8;
}
return 0;
}
/*
* Find the best possible match in the list of display modes that we can switch to based on
* the provided parameters.
*/
static CGDisplayModeRef getBestModeForParameters(CFArrayRef allModes, int w, int h, int bpp, int refrate) {
int thisBpp = 0;
for(n = 0; n < numModes; n++ ) {
continue;
}
if (thisBpp != bpp || (int)CGDisplayModeGetHeight(cRef) != h || (int)CGDisplayModeGetWidth(cRef) != w) {
// One of the key parameters does not match
continue;
}
return cRef;
}
// Refresh rate might be 0 in display mode and we ask for specific display rate
// but if we do not find exact match then 0 refresh rate might be just Ok
// Exact match
return cRef;
}
// Not exactly what was asked for, but may fit our needs if we don't find an exact match
}
}
return bestGuess;
}
/*
* Create a new java.awt.DisplayMode instance based on provided CGDisplayModeRef
*/
h = CGDisplayModeGetHeight(mode);
w = CGDisplayModeGetWidth(mode);
return ret;
}
/*
* Class: sun_awt_CGraphicsDevice
* Method: nativeGetXResolution
* Signature: (I)D
*/
{
// TODO: this is the physically correct answer, but we probably want
// to use NSScreen API instead...
// 1 inch == 25.4 mm
return dpi;
}
/*
* Class: sun_awt_CGraphicsDevice
* Method: nativeGetYResolution
* Signature: (I)D
*/
{
// TODO: this is the physically correct answer, but we probably want
// to use NSScreen API instead...
// 1 inch == 25.4 mm
return dpi;
}
/*
* Class: sun_awt_CGraphicsDevice
* Method: nativeGetScreenInsets
* Signature: (I)D
*/
{
break;
}
}
}];
// Convert between Cocoa's coordinate system and Java.
return ret;
}
/*
* Class: sun_awt_CGraphicsDevice
* Method: nativeSetDisplayMode
* Signature: (IIIII)V
*/
{
CGDisplayModeRef closestMatch = getBestModeForParameters(allModes, (int)w, (int)h, (int)bpp, (int)refrate);
if (closestMatch != NULL) {
if (retCode == kCGErrorSuccess) {
}
}
}];
} else {
}
}
/*
* Class: sun_awt_CGraphicsDevice
* Method: nativeGetDisplayMode
* Signature: (I)Ljava/awt/DisplayMode
*/
{
return ret;
}
/*
* Class: sun_awt_CGraphicsDevice
* Method: nativeGetDisplayMode
* Signature: (I)[Ljava/awt/DisplayModes
*/
{
if (!jreturnArray) {
NSLog(@"CGraphicsDevice can't create java array of DisplayMode objects");
return nil;
}
CFIndex n;
for (n=0; n < numModes; n++) {
continue;
}
}
}
return jreturnArray;
}
/*
* Class: sun_awt_CGraphicsDevice
* Method: nativeGetScaleFactor
* Signature: (I)D
*/
{
}
break;
}
}
}];
return ret;
}