diff options
author | Babak Mahbod <bmahbod@openoffice.org> | 2001-01-23 04:02:58 +0000 |
---|---|---|
committer | Babak Mahbod <bmahbod@openoffice.org> | 2001-01-23 04:02:58 +0000 |
commit | 186c215baf0ab64c6f465c381cac38f427aa574f (patch) | |
tree | 6ca84b8ef5b8d375d1089c9a8807f5c6445f33be /vcl/aqua/source | |
parent | 53f0abcde8e0b25ae6b21bc1bf2001310852b717 (diff) |
Updated APIs for locking and unlocking of GWorld pixel maps.
Methods updated to use the new locking and unlocking pixel map APIs.
Diffstat (limited to 'vcl/aqua/source')
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 208 |
1 files changed, 97 insertions, 111 deletions
diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index f3bbec282298..01ada2f19409 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -2,8 +2,8 @@ * * $RCSfile: salgdi.cxx,v $ * - * $Revision: 1.43 $ - * last change: $Author: bmahbod $ $Date: 2001-01-17 23:12:23 $ + * $Revision: 1.44 $ + * last change: $Author: bmahbod $ $Date: 2001-01-23 05:02:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -120,7 +120,7 @@ static inline BOOL Boolean2BOOL ( const Boolean bBooleanValue ) // ======================================================================= -static void SetWhiteBackColor() +static inline void SetWhiteBackColor() { RGBColor aWhiteBackColor; @@ -137,7 +137,7 @@ static void SetWhiteBackColor() // ----------------------------------------------------------------------- -static void SetBlackForeColor() +static inline void SetBlackForeColor() { RGBColor aBlackForeColor; @@ -711,86 +711,6 @@ static OSStatus GetGDeviceResolution ( long *rGDeviceHRes, // ======================================================================= -static BOOL LockGraphicsPort ( SalGraphicsDataPtr rSalGraphicsData ) -{ - BOOL bCGrafPortLocked = FALSE; - - if ( ( rSalGraphicsData != NULL ) - && ( rSalGraphicsData->mpCGrafPort != NULL ) - ) - { - rSalGraphicsData->mnOSStatus - = LockPortBits( rSalGraphicsData->mpCGrafPort ); - - if ( rSalGraphicsData->mnOSStatus == noErr ) - { - rSalGraphicsData->mhGWorldPixMap - = GetPortPixMap( rSalGraphicsData->mpCGrafPort ); - - rSalGraphicsData->mnOSStatus = QDErr(); - - if ( ( rSalGraphicsData->mnOSStatus == noErr ) - && ( rSalGraphicsData->mhGWorldPixMap != NULL ) - ) - { - rSalGraphicsData->mnGWorldFlags - = GetPixelsState( rSalGraphicsData->mhGWorldPixMap ); - - if ( rSalGraphicsData->mnGWorldFlags == noErr ) - { - Boolean bGWorldPixelsLocked = false; - - bGWorldPixelsLocked - = LockPixels( rSalGraphicsData->mhGWorldPixMap ); - - rSalGraphicsData->mbGWorldPixelsLocked - = Boolean2BOOL( bGWorldPixelsLocked ); - - bCGrafPortLocked = TRUE; - } // if - } // if - } // if - } // if - - return bCGrafPortLocked; -} // LockGraphicsPort - -// ----------------------------------------------------------------------- - -static BOOL UnlockGraphicsPort ( SalGraphicsDataPtr rSalGraphicsData ) -{ - BOOL bCGrafPortUnlocked = FALSE; - - if ( ( rSalGraphicsData != NULL ) - && ( rSalGraphicsData->mhGWorldPixMap != NULL ) - && ( rSalGraphicsData->mnGWorldFlags == noErr ) - && ( rSalGraphicsData->mbGWorldPixelsLocked ) - ) - { - SetPixelsState( rSalGraphicsData->mhGWorldPixMap, - rSalGraphicsData->mnGWorldFlags - ); - - rSalGraphicsData->mnOSStatus = QDErr(); - - if ( ( rSalGraphicsData->mpCGrafPort != NULL ) - && ( rSalGraphicsData->mnOSStatus == noErr ) - ) - { - rSalGraphicsData->mnOSStatus - = UnlockPortBits( rSalGraphicsData->mpCGrafPort ); - - bCGrafPortUnlocked = TRUE; - } // if - } // if - - return bCGrafPortUnlocked; -} // UnlockGraphicsPort - -// ======================================================================= - -// ======================================================================= - static BOOL LockGraphics ( SalGraphics *rSalGraphics ) { BOOL bCGrafPortLocked = FALSE; @@ -910,40 +830,79 @@ static BOOL BeginGraphics ( SalGraphicsDataPtr rSalGraphicsData ) if ( rSalGraphicsData->mnOSStatus == noErr ) { - // Lock our GWorld + // Lock our CGrafPort bits + + rSalGraphicsData->mnOSStatus + = LockPortBits( rSalGraphicsData->mpCGrafPort ); - if ( LockGraphicsPort( rSalGraphicsData ) ) + if ( rSalGraphicsData->mnOSStatus == noErr ) { - // Set background color to white on this GWorld + // Get the PixMap associated with this particular CGrafPort - SetWhiteBackColor(); + rSalGraphicsData->mhGWorldPixMap + = GetPortPixMap( rSalGraphicsData->mpCGrafPort ); - // Set foreground color to black on this GWorld + rSalGraphicsData->mnOSStatus = QDErr(); - SetBlackForeColor(); + if ( ( rSalGraphicsData->mnOSStatus == noErr ) + && ( rSalGraphicsData->mhGWorldPixMap != NULL ) + ) + { + // Get the current PixMap state, i.e., + // is it the memory associated with this + // PixMap is marked to be moved? + + rSalGraphicsData->mnGWorldFlags + = GetPixelsState( rSalGraphicsData->mhGWorldPixMap ); - // If we get here then we may safely start drawing - // to our GWorld + if ( rSalGraphicsData->mnGWorldFlags == noErr ) + { + Boolean bGWorldPixelsLocked = false; - bStartGraphics = TRUE; + // if the PixMap is a relocatable block, + // then mark it as locked. - // Now begin to set the clip region + bGWorldPixelsLocked + = LockPixels( rSalGraphicsData->mhGWorldPixMap ); - if ( ( rSalGraphicsData->mbClipRgnChanged == TRUE ) - && ( rSalGraphicsData->mhClipRgn != NULL ) - ) - { - // Set to the clip region + // convert the locked flag from C boolean + // to C++ BOOL + + rSalGraphicsData->mbGWorldPixelsLocked + = Boolean2BOOL( bGWorldPixelsLocked ); - SetClip( rSalGraphicsData->mhClipRgn ); + // Set background color to white on this GWorld - // Was there an error after setting the clip region? + SetWhiteBackColor(); - rSalGraphicsData->mnOSStatus = QDErr(); + // Set foreground color to black on this GWorld - // Set the new status flag for our port + SetBlackForeColor(); - rSalGraphicsData->mbClipRgnChanged = FALSE; + // If we get here then we may safely start drawing + // to our GWorld + + bStartGraphics = TRUE; + + // Now begin to set the clip region + + if ( ( rSalGraphicsData->mbClipRgnChanged == TRUE ) + && ( rSalGraphicsData->mhClipRgn != NULL ) + ) + { + // Set to the clip region + + SetClip( rSalGraphicsData->mhClipRgn ); + + // Was there an error after setting the clip region? + + rSalGraphicsData->mnOSStatus = QDErr(); + + // Set the new status flag for our port + + rSalGraphicsData->mbClipRgnChanged = FALSE; + } // if + } // if } // if } // if } // if @@ -963,16 +922,39 @@ static BOOL EndGraphics ( SalGraphicsDataPtr rSalGraphicsData ) if ( rSalGraphicsData->mnOSStatus == noErr ) { + // Unlock our CGrafPort + + if ( ( rSalGraphicsData->mhGWorldPixMap != NULL ) + && ( rSalGraphicsData->mnGWorldFlags == noErr ) + && ( rSalGraphicsData->mbGWorldPixelsLocked ) + ) + { + // Set pixel state to its original state + // thus unlocking the PixMap + + SetPixelsState( rSalGraphicsData->mhGWorldPixMap, + rSalGraphicsData->mnGWorldFlags + ); + + rSalGraphicsData->mnOSStatus = QDErr(); + + if ( ( rSalGraphicsData->mpCGrafPort != NULL ) + && ( rSalGraphicsData->mnOSStatus == noErr ) + ) + { + // Unlock the CGrafPort bits + + rSalGraphicsData->mnOSStatus + = UnlockPortBits( rSalGraphicsData->mpCGrafPort ); + } // if + } // if + // Reset the port to its original attributes SetPortPenMode( rSalGraphicsData->mpCGrafPort, rSalGraphicsData->mnPenModePort ); - // Flush the QuickDraw buffer - - QDFlushPortBuffer( rSalGraphicsData->mpCGrafPort, NULL ); - // Unlock focus on the current NSView if ( rSalGraphicsData->mbWindow == TRUE ) @@ -984,9 +966,13 @@ static BOOL EndGraphics ( SalGraphicsDataPtr rSalGraphicsData ) PortChanged( rSalGraphicsData->mpCGrafPort ); - // Unlock the port bits + // Flush the QuickDraw buffer + + QDFlushPortBuffer( rSalGraphicsData->mpCGrafPort, NULL ); - UnlockGraphicsPort( rSalGraphicsData ); + // Was there an error after flushing the QuickDraw buffer + + rSalGraphicsData->mnOSStatus = QDErr(); // Set the new status flag for clip region @@ -2038,7 +2024,7 @@ void SalGraphics::DrawMask( const SalTwoRect* pPosAry, ::CopyDeepMask( pSrcBitMap, pSrcBitMap, pDstBitMap, - &aSrcRect, + &aSrcRect, &aSrcRect, &aDstRect, nCopyMode, |