home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-15 | 20.5 KB | 886 lines | [TEXT/KAHL] |
- ///--------------------------------------------------------------------------------------
- // SpriteFrame.c
- //
- // Portions are copyright: © 1991-94 Tony Myles, All rights reserved worldwide.
- //
- // Description: implementation of the frame stuff
- ///--------------------------------------------------------------------------------------
-
-
- #ifndef __SWCOMMON__
- #include "SWCommonHeaders.h"
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __SPRITEWORLDUTILS__
- #include "SpriteWorldUtils.h"
- #endif
-
- #ifndef __SPRITECOMPILER__
- #include "SpriteCompiler.h"
- #endif
-
- #ifndef __SPRITEFRAME__
- #include "SpriteFrame.h"
- #endif
-
-
- ///--------------------------------------------------------------------------------------
- // SWCreateWindowFrame
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC OSErr SWCreateWindowFrame(
- FramePtr* newFrameP,
- Rect* frameRect)
- {
- OSErr err = noErr;
- GDHandle currentGDH;
- GWorldPtr windowGWorld;
- FramePtr tempFrameP = NULL;
- short depth;
- long numScanLines;
- Point globalOffset;
-
- SWAssert( newFrameP != NULL && frameRect != NULL );
-
- *newFrameP = NULL;
-
- GetGWorld( &windowGWorld, ¤tGDH );
- // more scanlines than we need, but this saves us from
- // needing to calculate an offset in BlitPixie
-
- SWAssert( windowGWorld != NULL );
-
- numScanLines = (frameRect->bottom - frameRect->top) +
- (frameRect->top - windowGWorld->portRect.top);
-
- globalOffset = topLeft( *frameRect );
- LocalToGlobal( &globalOffset );
-
- tempFrameP = (FramePtr)NewPtrClear((Size)sizeof(FrameRec) +
- (sizeof(unsigned long) * numScanLines));
-
- if (tempFrameP != NULL)
- {
- SWAssert( currentGDH != NULL && (**currentGDH).gdPMap != NULL );
-
- depth = (**(**currentGDH).gdPMap).pixelSize;
- tempFrameP->framePort = windowGWorld;
-
- tempFrameP->frameRect = *frameRect;
-
- // cache frameRowBytes for use by our blitter routine
-
- tempFrameP->frameRowBytes = (**tempFrameP->framePort->portPixMap).rowBytes & 0x7FFF;
-
- // this calculation generates a mask value that we use to
- // long word align the rectangle when we draw the frame.
- // note that the expression "sizeof(long) * kBitsPerByte" gives us
- // the number of bits in a long.
-
- tempFrameP->rightAlignFactor = ((sizeof(long) * kBitsPerByte) / depth) - 1;
- tempFrameP->leftAlignFactor = ~(tempFrameP->rightAlignFactor);
-
- // useCount not used for window/work/back frames
- tempFrameP->useCount = 0;
-
- // here we set up an array of offsets to the scan lines of
- // this frame. this allows us to address a particular scan line
- // without doing a costly multiply.
- tempFrameP->numScanLines = numScanLines;
- tempFrameP->scanLinePtrArray = (unsigned long*)(tempFrameP + 1);
-
- {
- tempFrameP->worldRectOffset = 0;
-
- if (depth < 8 )
- {
- short roundOff;
-
- roundOff = 8/depth;
- tempFrameP->worldRectOffset =
- (globalOffset.h - frameRect->left) -
- (((globalOffset.h - frameRect->left)/roundOff)*roundOff);
- }
-
- for (numScanLines = 0; numScanLines < tempFrameP->numScanLines; numScanLines++)
- {
- tempFrameP->scanLinePtrArray[numScanLines] =
- ((numScanLines+(globalOffset.v - frameRect->top) ) *
- tempFrameP->frameRowBytes) +
- (globalOffset.h - frameRect->left)*4/(32/depth);
- }
- }
-
- tempFrameP->sharesGWorld = false;
-
- *newFrameP = tempFrameP;
- }
- else
- {
- err = MemError();
- }
-
- if (err != noErr)
- {
- if (tempFrameP != NULL)
- {
- DisposePtr((Ptr)tempFrameP);
- }
- }
-
- SWSetStickyIfError( err );
- return err;
- }
-
-
- ///--------------------------------------------------------------------------------------
- // SWCreateFrameFromCicnResource
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC OSErr SWCreateFrameFromCicnResource(
- SpriteWorldPtr destSpriteWorld,
- FramePtr* newFrameP,
- short iconResID,
- MaskType maskType)
- {
- OSErr err;
- GWorldPtr saveGWorld;
- GDHandle saveGDH;
- GDHandle theGDH;
- FramePtr tempFrameP;
- CIconHandle cIconH;
- RgnHandle maskRgn;
- Rect frameRect;
-
- SWAssert( destSpriteWorld != NULL && newFrameP != NULL );
-
- *newFrameP = NULL;
- tempFrameP = NULL;
-
- GetGWorld(&saveGWorld, &saveGDH);
-
- cIconH = GetCIcon( iconResID );
-
- if (cIconH != NULL)
- {
- HNoPurge((Handle)cIconH);
- frameRect = (**cIconH).iconPMap.bounds;
-
- theGDH = destSpriteWorld->mainSWGDH;
-
- err = SWCreateFrame(theGDH, &tempFrameP, &frameRect);
- }
- else
- {
- err = MemError();
- if ( err == noErr )
- err = resNotFound;
- }
-
- if (err == noErr)
- {
- (void)LockPixels( GetGWorldPixMap(tempFrameP->framePort) );
- SetGWorld(tempFrameP->framePort, nil);
- EraseRect( &frameRect );
- PlotCIcon(&frameRect, cIconH);
- UnlockPixels( GetGWorldPixMap(tempFrameP->framePort) );
-
- // make a region mask
- if ((maskType & kRegionMask) != 0)
- {
- err = SWCreateRegionFromCIconMask(&maskRgn, cIconH);
-
- if (err == noErr)
- {
- SWSetFrameMaskRgn(tempFrameP, maskRgn);
- }
- }
- }
-
- if (err == noErr)
- {
- // make a pixel mask
- if ((maskType & kPixelMask) != 0)
- {
- err = SWCreateGWorldFromCIconMask(destSpriteWorld, &tempFrameP->maskPort, cIconH);
-
- if (err == noErr && destSpriteWorld->pixelDepth <= 8)
- {
- (void)LockPixels( GetGWorldPixMap(tempFrameP->maskPort) );
- SetGWorld(tempFrameP->maskPort, nil);
- InvertRect(&tempFrameP->maskPort->portRect);
- UnlockPixels( GetGWorldPixMap(tempFrameP->maskPort) );
- }
- }
- }
-
- if (cIconH != NULL)
- {
- DisposeCIcon(cIconH);
- }
-
- if (err == noErr)
- {
- *newFrameP = tempFrameP;
- }
-
- if (err != noErr)
- {
- // an error occurred so dispose of anything we managed to create
- if (tempFrameP != NULL)
- {
- SWDisposeFrame(tempFrameP);
- }
- }
-
- SetGWorld(saveGWorld, nil);
-
- SWSetStickyIfError( err );
- return err;
- }
-
-
- ///--------------------------------------------------------------------------------------
- // SWCreateFrameFromPictResource
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC OSErr SWCreateFrameFromPictResource(
- SpriteWorldPtr destSpriteWorld,
- FramePtr* newFrameP,
- short pictResID,
- short maskResID,
- MaskType maskType)
- {
- OSErr err;
- GWorldPtr saveGWorld;
- GDHandle saveGDH;
- GDHandle theGDH;
- PicHandle spritePictH,
- maskPictH;
- FramePtr tempFrameP;
- RgnHandle maskRgn;
- Rect frameRect;
-
- SWAssert( destSpriteWorld != NULL && newFrameP != NULL );
-
- tempFrameP = NULL;
- *newFrameP = NULL;
-
- GetGWorld(&saveGWorld, &saveGDH);
-
- spritePictH = GetPicture(pictResID);
-
- if (spritePictH != NULL)
- {
- frameRect = (**spritePictH).picFrame;
- OffsetRect( &frameRect, -frameRect.left, -frameRect.top );
-
- theGDH = destSpriteWorld->mainSWGDH;
-
- err = SWCreateFrame(theGDH, &tempFrameP, &frameRect);
-
- if (err == noErr)
- {
- (void)LockPixels( GetGWorldPixMap(tempFrameP->framePort) );
- SetGWorld(tempFrameP->framePort, nil);
- EraseRect(&frameRect);
- DrawPicture(spritePictH, &frameRect);
- UnlockPixels( GetGWorldPixMap(tempFrameP->framePort) );
- ReleaseResource((Handle)spritePictH);
- }
-
- // make a region mask
- if (((maskType & kRegionMask) != 0) && (err == noErr))
- {
- maskPictH = GetPicture(maskResID);
-
- if (maskPictH != NULL)
- {
- err = SWCreateRegionFromPict(&maskRgn, maskPictH );
-
- ReleaseResource((Handle)maskPictH);
- }
- else
- {
- err = MemError();
- if ( err == noErr )
- err = resNotFound;
- }
-
- if (err == noErr)
- {
- SWSetFrameMaskRgn(tempFrameP, maskRgn);
- }
- }
-
- // make a pixel mask
- if (((maskType & kPixelMask) != 0) && (err == noErr))
- {
- err = SWCreateGWorldFromPictResource(destSpriteWorld, &tempFrameP->maskPort, maskResID);
-
- if (err == noErr)
- {
- if ( pictResID == maskResID )
- {
- err = SWBlackenGWorld( tempFrameP->maskPort );
- }
- if (err == noErr && destSpriteWorld->pixelDepth <= 8)
- {
- (void)LockPixels( GetGWorldPixMap(tempFrameP->maskPort) );
- SetGWorld(tempFrameP->maskPort, nil);
- InvertRect(&tempFrameP->maskPort->portRect);
- UnlockPixels( GetGWorldPixMap(tempFrameP->maskPort) );
- }
- }
- }
-
- if (err == noErr)
- {
- *newFrameP = tempFrameP;
- }
- else
- {
- // an error occurred so dispose of anything we managed to create
- if (tempFrameP != NULL)
- {
- SWDisposeFrame(tempFrameP);
- }
- }
- }
- else
- {
- err = MemError();
- if ( err == noErr )
- err = resNotFound;
- }
-
- SetGWorld(saveGWorld, nil);
-
- SWSetStickyIfError( err );
- return err;
- }
-
-
- SW_FUNC OSErr SWCreateFrameFromGWorldAndRectStart(
- GWorldPtr *tempMaskGWorld,
- int maxWidth,
- int maxHeight)
- {
- return SWCreateRegionFromGWorldAndRectStart( tempMaskGWorld, maxWidth, maxHeight );
- }
-
- SW_FUNC void SWCreateFrameFromGWorldAndRectFinish(
- GWorldPtr tempMaskGWorld)
- {
- SWCreateRegionFromGWorldAndRectFinish( tempMaskGWorld );
- }
-
- SW_FUNC OSErr SWCreateFrameFromGWorldAndRectPartial(
- FramePtr* newFrameP,
- GWorldPtr pictGWorld,
- GWorldPtr maskGWorld,
- GWorldPtr tempMaskGWorld,
- Rect* frameRect,
- MaskType maskType)
- {
- OSErr err = noErr;
- short depth;
- long numScanLines;
- FramePtr tempFrameP;
- RgnHandle maskRgn;
-
- SWAssert( newFrameP != NULL && pictGWorld != NULL && frameRect != NULL );
-
- tempFrameP = NULL;
- *newFrameP = NULL;
-
- numScanLines = frameRect->bottom - frameRect->top;
- depth = (**(GetGWorldPixMap( pictGWorld ))).pixelSize;
-
- tempFrameP = (FramePtr)NewPtrClear((Size)sizeof(FrameRec) +
- (sizeof(unsigned long) * (numScanLines+1)));
-
- if (tempFrameP != NULL)
- {
- tempFrameP->framePort = pictGWorld;
- if ((maskType & kPixelMask) != 0) {
- SWAssert( maskGWorld != NULL );
- tempFrameP->maskPort = maskGWorld;
- }
- tempFrameP->frameRect = *frameRect;
- tempFrameP->sharesGWorld = true;
- tempFrameP->numScanLines = numScanLines;
-
- SWInitializeFrame( tempFrameP, depth );
- }
- else
- {
- err = MemError();
- }
-
- if (err == noErr)
- {
- // make a region mask
- if (((maskType & kRegionMask) != 0) && (err == noErr))
- {
- err = SWCreateRegionFromGWorldAndRectPartial(&maskRgn, maskGWorld, tempMaskGWorld, frameRect);
-
- if (err == noErr)
- {
- SWSetFrameMaskRgn(tempFrameP, maskRgn);
- }
- }
-
- if (err == noErr)
- {
- *newFrameP = tempFrameP;
- }
- else
- {
- // an error occurred so dispose of anything we managed to create
- if (tempFrameP != NULL)
- {
- SWDisposeFrame(tempFrameP);
- }
- }
- }
-
- SWSetStickyIfError( err );
- return err;
- }
-
- ///--------------------------------------------------------------------------------------
- // SWCreateFrameFromGWorldAndRect
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC OSErr SWCreateFrameFromGWorldAndRect(
- FramePtr* newFrameP,
- GWorldPtr pictGWorld,
- GWorldPtr maskGWorld,
- Rect* frameRect,
- MaskType maskType)
- {
- OSErr err;
- GWorldPtr tempMaskGWorld;
-
- err = SWCreateFrameFromGWorldAndRectStart( &tempMaskGWorld, frameRect->right - frameRect->left, frameRect->bottom - frameRect->top );
- if ( err == noErr ) {
- err = SWCreateFrameFromGWorldAndRectPartial( newFrameP, pictGWorld, maskGWorld, tempMaskGWorld, frameRect, maskType );
- SWCreateFrameFromGWorldAndRectFinish( tempMaskGWorld );
- }
- return err;
- }
-
- ///--------------------------------------------------------------------------------------
- // SWCreateFrame
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC OSErr SWCreateFrame(
- GDHandle theGDH,
- FramePtr* newFrameP,
- Rect* frameRect)
- {
- OSErr err = noErr;
- short depth;
- GWorldPtr frameGWorld;
- FramePtr tempFrameP;
- long numScanLines;
-
- *newFrameP = NULL;
- frameGWorld = NULL;
-
- SWAssert( theGDH != NULL && newFrameP != NULL && frameRect != NULL );
- SWAssert( (**theGDH).gdPMap != NULL );
-
- depth = (**(**theGDH).gdPMap).pixelSize;
-
- numScanLines = frameRect->bottom - frameRect->top;
-
- tempFrameP = (FramePtr)NewPtrClear((Size)sizeof(FrameRec) +
- (sizeof(unsigned long) * (numScanLines+1)));
-
- if (tempFrameP != NULL)
- {
- err = NewGWorld( &frameGWorld, depth, frameRect, nil, theGDH, noNewDevice );
-
- if (err == noErr)
- {
- tempFrameP->framePort = frameGWorld;
- tempFrameP->frameRect = *frameRect;
- tempFrameP->tileMaskIsSolid = false;
- tempFrameP->isFrameLocked = false;
- tempFrameP->numScanLines = numScanLines;
- tempFrameP->sharesGWorld = false;
-
- SWInitializeFrame( tempFrameP, depth );
-
- *newFrameP = tempFrameP;
- }
- }
- else
- {
- err = MemError();
- }
-
- if (err != noErr)
- {
- if (tempFrameP != NULL)
- {
- if (tempFrameP->framePort != NULL)
- DisposeGWorld(tempFrameP->framePort);
- DisposePtr((Ptr)tempFrameP);
- }
- }
-
- SWSetStickyIfError( err );
- return err;
- }
-
-
- ///--------------------------------------------------------------------------------------
- // SWCreateFrameFromDepth
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC OSErr SWCreateFrameFromDepth(
- FramePtr* newFrameP,
- short depth,
- Rect* frameRect)
- {
- OSErr err = noErr;
- GWorldPtr frameGWorld;
- FramePtr tempFrameP;
- long numScanLines;
-
- *newFrameP = NULL;
- frameGWorld = NULL;
-
- SWAssert( depth > 0 && newFrameP != NULL && frameRect != NULL );
-
- numScanLines = frameRect->bottom - frameRect->top;
-
- tempFrameP = (FramePtr)NewPtrClear((Size)sizeof(FrameRec) +
- (sizeof(unsigned long) * (numScanLines+1)));
-
- if (tempFrameP != NULL)
- {
- err = NewGWorld( &frameGWorld, depth, frameRect, nil, nil, 0 );
-
- if (err == noErr)
- {
- tempFrameP->framePort = frameGWorld;
- tempFrameP->frameRect = *frameRect;
- tempFrameP->tileMaskIsSolid = false;
- tempFrameP->isFrameLocked = false;
- tempFrameP->numScanLines = numScanLines;
- tempFrameP->sharesGWorld = false;
-
- SWInitializeFrame( tempFrameP, depth );
-
- *newFrameP = tempFrameP;
- }
- }
- else
- {
- err = MemError();
- }
-
- if (err != noErr)
- {
- if (tempFrameP != NULL)
- {
- if (tempFrameP->framePort != NULL)
- DisposeGWorld(tempFrameP->framePort);
- DisposePtr((Ptr)tempFrameP);
- }
- }
-
- SWSetStickyIfError( err );
- return err;
- }
-
-
- SW_FUNC OSErr SWCloneFrame(
- FramePtr cloneFrameP,
- FramePtr* newFrameP)
- {
- OSErr err;
- FramePtr tempFrameP;
-
- SWAssert( cloneFrameP != NULL );
-
- tempFrameP = (FramePtr)NewPtrClear(GetPtrSize((Ptr)cloneFrameP));
-
- if (tempFrameP != NULL)
- {
- *tempFrameP = *cloneFrameP;
-
- tempFrameP->scanLinePtrArray = (unsigned long*)(tempFrameP + 1);
- tempFrameP->maskRgn = NULL;
- tempFrameP->sharesGWorld = true;
- tempFrameP->useCount = 0;
- tempFrameP->pixCodeH = NULL;
- tempFrameP->frameBlitterP = NULL;
-
- if ( cloneFrameP->maskRgn != NULL )
- {
- tempFrameP->maskRgn = cloneFrameP->maskRgn;
- err = HandToHand( &(Handle)tempFrameP->maskRgn );
- if ( err != noErr )
- {
- tempFrameP->maskRgn = NULL;
- }
- }
-
- if ( err == noErr && cloneFrameP->pixCodeH != NULL )
- {
- tempFrameP->pixCodeH = cloneFrameP->pixCodeH;
- err = HandToHand( &(Handle)tempFrameP->pixCodeH );
- if ( err != noErr )
- {
- tempFrameP->pixCodeH = NULL;
- }
- }
-
- }
- else
- {
- err = MemError();
- }
-
- if (err == noErr)
- {
- if (tempFrameP->isFrameLocked) // Fill in some extra fields like frameBlitterP
- {
- SWUnlockFrame( tempFrameP );
- SWLockFrame( tempFrameP );
- }
- *newFrameP = tempFrameP;
- }
- else
- {
- if (tempFrameP != NULL)
- {
- SWDisposeFrame( tempFrameP );
- }
- *newFrameP = NULL;
- }
-
- SWSetStickyIfError( err );
- return err;
- }
-
-
- ///--------------------------------------------------------------------------------------
- // SWInitializeFrame
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC void SWInitializeFrame(
- FramePtr tempFrameP,
- short depth )
- {
- long numScanLines;
-
- SWAssert( tempFrameP != NULL && depth > 0 );
- SWAssert( tempFrameP->framePort != NULL && tempFrameP->framePort->portPixMap != NULL );
-
- // cache frameRowBytes for use by our blitter routine
-
- tempFrameP->frameRowBytes = (**tempFrameP->framePort->portPixMap).rowBytes & 0x7FFF;
-
- // this calculation generates a mask value that we use to
- // long word align the rectangle when we draw the frame.
- // note that the expression "sizeof(long) * kBitsPerByte" gives us
- // the number of bits in a long.
-
- tempFrameP->rightAlignFactor = ((sizeof(long) * kBitsPerByte) / depth) - 1;
- tempFrameP->leftAlignFactor = ~(tempFrameP->rightAlignFactor);
-
- // the useCount keeps track of the number of sprites that
- // are using this frame. we need to know this so we don't
- // dispose this frame twice when we are disposing the
- // sprites that use it.
- tempFrameP->useCount = 0;
-
- tempFrameP->worldRectOffset = 0;
-
- // here we set up an array of offsets to the scan lines of
- // this frame. this allows us to address a particular scan line
- // without doing a costly multiply.
- tempFrameP->scanLinePtrArray = (unsigned long*)(tempFrameP + 1);
-
- for (numScanLines = 0; numScanLines < tempFrameP->numScanLines; numScanLines++)
- {
- tempFrameP->scanLinePtrArray[numScanLines] =
- ((tempFrameP->frameRect.top+numScanLines) * tempFrameP->frameRowBytes);
- }
- }
-
-
- ///--------------------------------------------------------------------------------------
- // SWDisposeFrame
- ///--------------------------------------------------------------------------------------
- SW_FUNC Boolean SWDisposeFrame(
- FramePtr oldFrameP)
- {
- Boolean frameDisposed;
-
- SWAssert( oldFrameP != NULL );
-
- frameDisposed = false;
- if (oldFrameP != NULL)
- {
- // is this frame still in use by another sprite?
- if (oldFrameP->useCount > 1)
- {
- // one less sprite is using it now!
- oldFrameP->useCount--;
- }
- else // no more sprites are using this frame
- {
- frameDisposed = true;
- if (oldFrameP->framePort != NULL)
- {
- if ( !oldFrameP->sharesGWorld )
- DisposeGWorld(oldFrameP->framePort);
- oldFrameP->framePort = NULL;
- }
-
- if (oldFrameP->maskRgn != NULL)
- {
- DisposeRgn(oldFrameP->maskRgn);
- oldFrameP->maskRgn = NULL;
- }
-
- if (oldFrameP->maskPort != NULL)
- {
- if ( !oldFrameP->sharesGWorld )
- DisposeGWorld(oldFrameP->maskPort);
- oldFrameP->maskPort = NULL;
- }
-
- if (oldFrameP->pixCodeH != NULL)
- {
- DisposeHandle((Handle)oldFrameP->pixCodeH);
- oldFrameP->pixCodeH = NULL;
- oldFrameP->frameBlitterP = NULL;
- }
-
- DisposePtr((Ptr)oldFrameP);
- oldFrameP = NULL;
- }
- }
- return frameDisposed;
- }
-
-
- ///--------------------------------------------------------------------------------------
- // SWSetFrameMaskRgn
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC void SWSetFrameMaskRgn(
- FramePtr srcFrameP,
- RgnHandle maskRgn)
- {
- SWAssert( srcFrameP != NULL && maskRgn != NULL );
-
- srcFrameP->maskRgn = maskRgn;
-
- srcFrameP->offsetPoint.h = (**maskRgn).rgnBBox.left;
- srcFrameP->offsetPoint.v = (**maskRgn).rgnBBox.top;
- }
-
-
- ///--------------------------------------------------------------------------------------
- // SWLockFrame
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC void SWLockFrame(
- FramePtr srcFrameP)
- {
- PixMapHandle pixMapH;
-
- SWAssert( srcFrameP != NULL );
-
- if ( !srcFrameP->isFrameLocked ) {
- srcFrameP->isFrameLocked = true;
-
- pixMapH = GetGWorldPixMap( srcFrameP->framePort );
- (void)LockPixels( pixMapH );
- HLockHi( (Handle)pixMapH );
- srcFrameP->framePixHndl = pixMapH;
- srcFrameP->framePix = (PixMapPtr)StripAddress( *(Handle)pixMapH );
- srcFrameP->frameBaseAddr = GetPixBaseAddr( pixMapH );
- srcFrameP->frameRowBytes = (**pixMapH).rowBytes & 0x7FFF;
-
- if (srcFrameP->pixCodeH != NULL)
- {
- HLockHi((Handle)srcFrameP->pixCodeH);
- srcFrameP->frameBlitterP = (BlitFuncPtr)StripAddress( *srcFrameP->pixCodeH );
- }
-
- if (srcFrameP->maskPort != NULL)
- {
- pixMapH = GetGWorldPixMap( srcFrameP->maskPort );
- (void)LockPixels( pixMapH );
- HLockHi( (Handle)pixMapH );
- srcFrameP->maskPixHndl = pixMapH;
- srcFrameP->maskPix = (PixMapPtr)StripAddress( *(Handle)pixMapH );
- srcFrameP->maskBaseAddr = GetPixBaseAddr( pixMapH );
- }
- }
- }
-
-
- ///--------------------------------------------------------------------------------------
- // SWUnlockFrame
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC void SWUnlockFrame(
- FramePtr srcFrameP)
- {
- SWAssert( srcFrameP != NULL );
-
- if ( srcFrameP->isFrameLocked ) {
- srcFrameP->isFrameLocked = false;
-
- if (srcFrameP->framePort != NULL)
- {
- HUnlock( (Handle)srcFrameP->framePixHndl );
- UnlockPixels(srcFrameP->framePixHndl);
- }
-
- if (srcFrameP->maskPort != NULL)
- {
- HUnlock( (Handle)srcFrameP->maskPixHndl );
- UnlockPixels(srcFrameP->maskPixHndl);
- }
-
- srcFrameP->framePix = NULL;
- srcFrameP->frameBaseAddr = NULL;
- srcFrameP->maskPix = NULL;
- srcFrameP->maskBaseAddr = NULL;
-
- if (srcFrameP->pixCodeH != NULL)
- {
- HUnlock((Handle)srcFrameP->pixCodeH);
- srcFrameP->frameBlitterP = NULL;
- }
- }
- }
-