void AquaSalGraphics::initResolution(NSWindow* nsWindow)
{ if (!nsWindow)
{ if (Application::IsBitmapRendering())
mnRealDPIX = mnRealDPIY = 96; return;
}
// #i100617# read DPI only once; there is some kind of weird caching going on // if the main screen changes // FIXME: this is really unfortunate and needs to be investigated
mnRealDPIX = mnRealDPIY = 96; if( pScreen )
{
NSDictionary* pDev = [pScreen deviceDescription]; if( pDev )
{
NSNumber* pVal = [pDev objectForKey: @"NSScreenNumber"]; if( pVal )
{ // FIXME: casting a long to CGDirectDisplayID is evil, but // Apple suggest to do it this way const CGDirectDisplayID nDisplayID = static_cast<CGDirectDisplayID>([pVal longValue]); const CGSize aSize = CGDisplayScreenSize( nDisplayID ); // => result is in millimeters
mnRealDPIX = static_cast<sal_Int32>((CGDisplayPixelsWide( nDisplayID ) * 25.4) / aSize.width);
mnRealDPIY = static_cast<sal_Int32>((CGDisplayPixelsHigh( nDisplayID ) * 25.4) / aSize.height);
} else
{
OSL_FAIL( "no resolution found in device description" );
}
} else
{
OSL_FAIL( "no device description" );
}
} else
{
OSL_FAIL( "no screen found" );
}
// #i107076# maintaining size-WYSIWYG-ness causes many problems for // low-DPI, high-DPI or for mis-reporting devices // => it is better to limit the calculation result then staticconstint nMinDPI = 72; if( (mnRealDPIX < nMinDPI) || (mnRealDPIY < nMinDPI) )
{
mnRealDPIX = mnRealDPIY = nMinDPI;
} // Note that on a Retina display, the "mnRealDPIX" as // calculated above is not the true resolution of the display, // but the "logical" one, or whatever the correct terminology // is. (For instance on a 5K 27in iMac, it's 108.) So at // least currently, it won't be over 200. I don't know whether // this test is a "sanity check", or whether there is some // real reason to limit this to 200. staticconstint nMaxDPI = 200; if( (mnRealDPIX > nMaxDPI) || (mnRealDPIY > nMaxDPI) )
{
mnRealDPIX = mnRealDPIY = nMaxDPI;
} // for OSX any anisotropy reported for the display resolution is best ignored (e.g. TripleHead2Go)
mnRealDPIX = mnRealDPIY = (mnRealDPIX + mnRealDPIY + 1) / 2;
// setup clipping if (mxClipPath)
{
CGContextBeginPath(maContextHolder.get()); // discard any existing path
CGContextAddPath(maContextHolder.get(), mxClipPath); // set the current path to the clipping path
CGContextClip(maContextHolder.get()); // use it for clipping
}
// set RGB colorspace and line and fill colors
CGContextSetFillColor(maContextHolder.get(), maFillColor.AsArray() );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.