diff options
author | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2009-12-21 20:40:13 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2009-12-21 20:40:13 +0100 |
commit | c15bb1c231307a09254adbc1338019d5a49b6024 (patch) | |
tree | 41360fbd2279c1d1a088d714389fbdd76959478f /vcl/aqua/source/gdi | |
parent | 3b790d2e0926c75a8a919e02bfad05d1b1aff800 (diff) | |
parent | 0c5348ff2c5cede4607555fdab45642db10b07ba (diff) |
aw078: resync to DEV300m68for integration
Diffstat (limited to 'vcl/aqua/source/gdi')
-rwxr-xr-x | vcl/aqua/source/gdi/salatslayout.cxx | 40 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salatsuifontutils.cxx | 9 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 79 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salnativewidgets.cxx | 5 |
4 files changed, 88 insertions, 45 deletions
diff --git a/vcl/aqua/source/gdi/salatslayout.cxx b/vcl/aqua/source/gdi/salatslayout.cxx index 7ecef01cf0d5..1387a46c6345 100755 --- a/vcl/aqua/source/gdi/salatslayout.cxx +++ b/vcl/aqua/source/gdi/salatslayout.cxx @@ -70,12 +70,13 @@ private: // to prevent ATS overflowing the Fixed16.16 values // ATS font requests get size limited by downscaling huge fonts // in these cases the font scale becomes something bigger than 1.0 - float mfFontScale; + float mfFontScale; private: bool InitGIA( ImplLayoutArgs* pArgs = NULL ) const; bool GetIdealX() const; bool GetDeltaY() const; + void InvalidateMeasurements(); int Fixed2Vcl( Fixed ) const; // convert ATSU-Fixed units to VCL units int AtsuPix2Vcl( int ) const; // convert ATSU-Pixel units to VCL units @@ -302,17 +303,15 @@ void ATSLayout::AdjustLayout( ImplLayoutArgs& rArgs ) nPixelWidth = rArgs.mpDXArray[ mnCharCount - 1 ]; // workaround for ATSUI not using trailing spaces for justification - mnTrailingSpaceWidth = 0; int i = mnCharCount; - while( (--i > 0) && IsSpacingGlyph( rArgs.mpStr[mnMinCharPos+i]|GF_ISCHAR ) ) - mnTrailingSpaceWidth += rArgs.mpDXArray[i] - rArgs.mpDXArray[i-1]; - if( i <= 0 ) + while( (--i >= 0) && IsSpacingGlyph( rArgs.mpStr[mnMinCharPos+i]|GF_ISCHAR ) ) {} + if( i < 0 ) // nothing to do if the text is all spaces return; // #i91685# trailing letters are left aligned (right aligned for RTL) - mnTrailingSpaceWidth += rArgs.mpDXArray[i]; + mnTrailingSpaceWidth = rArgs.mpDXArray[ mnCharCount-1 ]; if( i > 0 ) - mnTrailingSpaceWidth -= rArgs.mpDXArray[i-1]; - InitGIA(); // ensure valid mpCharWidths[] + mnTrailingSpaceWidth -= rArgs.mpDXArray[ i-1 ]; + InitGIA(); // ensure valid mpCharWidths[], TODO: use GetIdealX() instead? mnTrailingSpaceWidth -= Fixed2Vcl( mpCharWidths[i] ); // ignore trailing space for calculating the available width nOrigWidth -= mnTrailingSpaceWidth; @@ -326,11 +325,15 @@ void ATSLayout::AdjustLayout( ImplLayoutArgs& rArgs ) if( !nPixelWidth ) return; - // HACK: justification requests which change the width by just one pixel are probably + // HACK: justification requests which change the width by just one pixel were probably // #i86038# introduced by lossy conversions between integer based coordinate system + // => ignoring such requests has many more benefits than eventual drawbacks if( (nOrigWidth >= nPixelWidth-1) && (nOrigWidth <= nPixelWidth+1) ) return; + // changing the layout will make all previous measurements invalid + InvalidateMeasurements(); + ATSUAttributeTag nTags[3]; ATSUAttributeValuePtr nVals[3]; ByteCount nBytes[3]; @@ -354,7 +357,7 @@ void ATSLayout::AdjustLayout( ImplLayoutArgs& rArgs ) if( eStatus != noErr ) return; - // check result of the justied layout + // update the measurements of the justified layout to match the justification request if( rArgs.mpDXArray ) InitGIA( &rArgs ); } @@ -1071,6 +1074,23 @@ bool ATSLayout::GetDeltaY() const return true; } +// ----------------------------------------------------------------------- + +#define DELETEAZ( X ) { delete[] X; X = NULL; } + +void ATSLayout::InvalidateMeasurements() +{ + mnGlyphCount = -1; + DELETEAZ( mpGlyphIds ); + DELETEAZ( mpCharWidths ); + DELETEAZ( mpChars2Glyphs ); + DELETEAZ( mpGlyphs2Chars ); + DELETEAZ( mpGlyphRTLFlags ); + DELETEAZ( mpGlyphAdvances ); + DELETEAZ( mpGlyphOrigAdvs ); + DELETEAZ( mpDeltaY ); +} + // ======================================================================= #if 0 diff --git a/vcl/aqua/source/gdi/salatsuifontutils.cxx b/vcl/aqua/source/gdi/salatsuifontutils.cxx index 8e38981a3c7c..23755ae2f571 100644 --- a/vcl/aqua/source/gdi/salatsuifontutils.cxx +++ b/vcl/aqua/source/gdi/salatsuifontutils.cxx @@ -207,6 +207,13 @@ static bool GetDevFontAttributes( ATSUFontID nFontID, ImplDevFontAttributes& rDF rDFA.meItalic = ITALIC_NONE; rDFA.mbSymbolFlag = false; + // ignore bitmap fonts + ATSFontRef rATSFontRef = FMGetATSFontRefFromFont( nFontID ); + ByteCount nHeadLen = 0; + OSStatus rc = ATSFontGetTable( rATSFontRef, 0x68656164/*head*/, 0, 0, NULL, &nHeadLen ); + if( (rc != noErr) || (nHeadLen <= 0) ) + return false; + // all scalable fonts on this platform are subsettable rDFA.mbSubsettable = true; rDFA.mbEmbeddable = false; @@ -216,7 +223,7 @@ static bool GetDevFontAttributes( ATSUFontID nFontID, ImplDevFontAttributes& rDF // prepare iterating over all name strings of the font ItemCount nFontNameCount = 0; - OSStatus rc = ATSUCountFontNames( nFontID, &nFontNameCount ); + rc = ATSUCountFontNames( nFontID, &nFontNameCount ); if( rc != noErr ) return false; int nBestNameValue = 0; diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index f38b9852e57e..263a5b6e6803 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -405,6 +405,16 @@ void AquaSalGraphics::initResolution( NSWindow* pWin ) DBG_ERROR( "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 + static const int nMinDPI = 72; + if( (mnRealDPIX < nMinDPI) || (mnRealDPIY < nMinDPI) ) + mnRealDPIX = mnRealDPIY = nMinDPI; + static const int 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; @@ -932,27 +942,29 @@ bool AquaSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPol AddPolygonToPath( xPath, rPolygon, true, !getAntiAliasB2DDraw(), IsPenVisible() ); } - // use the path to prepare the graphics context - CGContextSaveGState( mrContext ); - CGContextBeginPath( mrContext ); - CGContextAddPath( mrContext, xPath ); const CGRect aRefreshRect = CGPathGetBoundingBox( xPath ); - CGPathRelease( xPath ); - #ifndef NO_I97317_WORKAROUND // #i97317# workaround for Quartz having problems with drawing small polygons - if( (aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125) ) - return true; + if( ! ((aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125)) ) #endif + { + // use the path to prepare the graphics context + CGContextSaveGState( mrContext ); + CGContextBeginPath( mrContext ); + CGContextAddPath( mrContext, xPath ); + + // draw path with antialiased polygon + CGContextSetShouldAntialias( mrContext, true ); + CGContextSetAlpha( mrContext, 1.0 - fTransparency ); + CGContextDrawPath( mrContext, kCGPathEOFillStroke ); + CGContextRestoreGState( mrContext ); + + // mark modified rectangle as updated + RefreshRect( aRefreshRect ); + } - // draw path with antialiased polygon - CGContextSetShouldAntialias( mrContext, true ); - CGContextSetAlpha( mrContext, 1.0 - fTransparency ); - CGContextDrawPath( mrContext, kCGPathEOFillStroke ); - CGContextRestoreGState( mrContext ); + CGPathRelease( xPath ); - // mark modified rectangle as updated - RefreshRect( aRefreshRect ); return true; } @@ -967,13 +979,15 @@ bool AquaSalGraphics::drawPolyLine( const ::basegfx::B2DPolygon& rPolyLine, if( nPointCount <= 0 ) return true; - // reject strange requests + // reject requests that cannot be handled yet if( rLineWidths.getX() != rLineWidths.getY() ) return false; // #i101491# Aqua does not support B2DLINEJOIN_NONE; return false to use // the fallback (own geometry preparation) - if(basegfx::B2DLINEJOIN_NONE == eLineJoin) + // #i104886# linejoin-mode and thus the above only applies to "fat" lines + if( (basegfx::B2DLINEJOIN_NONE == eLineJoin) + && (rLineWidths.getX() > 1.3) ) return false; // setup line attributes @@ -990,27 +1004,28 @@ bool AquaSalGraphics::drawPolyLine( const ::basegfx::B2DPolygon& rPolyLine, CGMutablePathRef xPath = CGPathCreateMutable(); AddPolygonToPath( xPath, rPolyLine, rPolyLine.isClosed(), !getAntiAliasB2DDraw(), true ); - // use the path to prepare the graphics context - CGContextSaveGState( mrContext ); - CGContextAddPath( mrContext, xPath ); const CGRect aRefreshRect = CGPathGetBoundingBox( xPath ); - CGPathRelease( xPath ); - #ifndef NO_I97317_WORKAROUND // #i97317# workaround for Quartz having problems with drawing small polygons - if( (aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125) ) - return true; + if( ! ((aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125)) ) #endif + { + // use the path to prepare the graphics context + CGContextSaveGState( mrContext ); + CGContextAddPath( mrContext, xPath ); + // draw path with antialiased line + CGContextSetShouldAntialias( mrContext, true ); + CGContextSetLineJoin( mrContext, aCGLineJoin ); + CGContextSetLineWidth( mrContext, rLineWidths.getX() ); + CGContextDrawPath( mrContext, kCGPathStroke ); + CGContextRestoreGState( mrContext ); + + // mark modified rectangle as updated + RefreshRect( aRefreshRect ); + } - // draw path with antialiased line - CGContextSetShouldAntialias( mrContext, true ); - CGContextSetLineJoin( mrContext, aCGLineJoin ); - CGContextSetLineWidth( mrContext, rLineWidths.getX() ); - CGContextDrawPath( mrContext, kCGPathStroke ); - CGContextRestoreGState( mrContext ); + CGPathRelease( xPath ); - // mark modified rectangle as updated - RefreshRect( aRefreshRect ); return true; } diff --git a/vcl/aqua/source/gdi/salnativewidgets.cxx b/vcl/aqua/source/gdi/salnativewidgets.cxx index 6cd4e78a2d1a..754358823a93 100644 --- a/vcl/aqua/source/gdi/salnativewidgets.cxx +++ b/vcl/aqua/source/gdi/salnativewidgets.cxx @@ -430,9 +430,10 @@ BOOL AquaSalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart #define CTRL_STATE_SELECTED 0x0040 #define CTRL_CACHING_ALLOWED 0x8000 // set when the control is completely visible (i.e. not clipped) */ -static ThemeDrawState getState( ControlState nState ) +UInt32 AquaSalGraphics::getState( ControlState nState ) { - if( (nState & CTRL_STATE_ENABLED) == 0 ) + bool bDrawActive = mpFrame ? ([mpFrame->getWindow() isKeyWindow] ? true : false) : true; + if( (nState & CTRL_STATE_ENABLED) == 0 || ! bDrawActive ) { if( (nState & CTRL_STATE_HIDDEN) == 0 ) return kThemeStateInactive; |