macsurf.cpp

来自「symbian 下的helix player源代码」· C++ 代码 · 共 1,064 行 · 第 1/3 页

CPP
1,064
字号
	::GetForeColor(&hold);
	::RGBForeColor(&keyColor);
	
	PaintRect(&r);
	
	::RGBForeColor(&hold);
	::SetPort(savePort);
    }
}


/************************************************************************
 *  Method:
 *    CMacSurface::_RestoreDCObjects
 */
void
CMacSurface::_RestoreDCObjects(HXxDC hxxDC, void* hOldBrush, void* hOldPen)
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::_GetCompositeionSurfacePNxDC
 */
void
CMacSurface::_GetCompositionSurfaceHXxDC(HXxDC* hdc)
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::_ReleaseCompositionSurfaceHXxDC
 */
void
CMacSurface::_ReleaseCompositionSurfaceHXxDC(HXxDC hdc)
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::_InsureColorMatch
 */
INT32
CMacSurface::_InsureColorMatch(INT32 InColor)
{
    return InColor; // XXXbobclark
}


/************************************************************************
 *  Method:
 *    CMacSurface::_SetColorKey
 */
void
CMacSurface::_SetColorKey(INT32 nColorSpaceLowValue, INT32 nColorSpaceHighValue)
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::_UpdateOverlay
 */
void
CMacSurface::_UpdateOverlay(HXxRect* src, HXxRect* dest, INT32 inFlags)
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::_IsSurfaceVisible
 */
BOOL
CMacSurface::_IsSurfaceVisible()
{
    return TRUE;
}


/************************************************************************
 *  Method:
 *    CMacSurface::_ReleaseSurface
 */
void
CMacSurface::_ReleaseSurface()
{
    if (CMacSurface::zm_pOverlaySurface == this)
    {
	CleanUpOverlay();
	CMacSurface::zm_pOverlaySurface = nil;
    }
}


/************************************************************************
 *  Method:
 *    CMacSurface::_GetDC
 */
HXxDC
CMacSurface::_GetDC(HXxWindow* pWindow)
{
    return NULL; // XXXbobclark gotta figure out what to return, duh
}


/************************************************************************
 *  Method:
 *    CMacSurface::_ReleaseDC
 */
void
CMacSurface::_ReleaseDC(HXxWindow* pWindow, HXxDC pdc)
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::_GetWindowDeviceCords
 */
void
CMacSurface::_GetWindowDeviceCords(HXxRect* rect)
{
    static Point sLastCords = {0,0};
    
    sLastCords.h = 0;
    sLastCords.v = 0;
    ::LocalToGlobal(&sLastCords);
    rect->left = sLastCords.h;
    rect->top = sLastCords.v;
}


/************************************************************************
 *  Method:
 *    CMacSurface::_OverlayAvailable
 */
BOOL
CMacSurface::_OverlayAvailable()
{
    if (!m_bUseOverlays) return FALSE;
    
    return TRUE;
}

/************************************************************************
 *  Method:
 *    CMacSurface::_AllowsOverlayShrinking
 */
BOOL
CMacSurface::_AllowsOverlayShrinking()
{
    return TRUE;
}



// some of the following is from ATI's YUVSDK.


// Some ATI specific definitions

#define 	kATIYUVComponentType			'imdc'
#define		kATIYUVComponentSubType			'yuvs'
#define		kATIYUVComponentManufacturer	'ATI '

#pragma options align=mac68k

//QT 3.x stuff : begin -- Anita
struct YUVSdecompressRecord {
	short width;			// width (in pixels) of a row
	long numStrips;		// number of strips to draw
	long srcDataIncrement;	// increment for srcData between strips
	long baseAddrIncrement;	// increment for baseAddr between strips
	struct Globals *glob;	// pointer to our globals
};
typedef struct YUVSdecompressRecord YUVSdecompressRecord;

// Added for VAU
struct BDCTextureDRP
	{		
		ByteCount dataSize;				// Number of bytes in compressed data
		SInt16  width;					// Width in pixels
		SInt16  height;					// Height in lines
	};
typedef struct BDCTextureDRP BDCTextureDRP;



pascal void MymemoryGoneProc(Ptr memoryBlock, void *refcon);
ICMMemoryDisposedUPP theMemoryProc = nil;

pascal void MymemoryGoneProc(Ptr memoryBlock, void *refcon)
{
	// do nothing.
}



/* static */
void CMacSurface::ConstructOverlay(long screenCoorX, long screenCoorY, long screenWidth, long screenHeight, long sourceWidth, long sourceHeight,
		RgnHandle maskRgn)
{
    // first let's find our component.

    ComponentDescription cd;
    Component c = NULL;
    Component foundComponent = NULL;

    cd.componentType = 'imdc';
    cd.componentSubType = 'yuvs';
    cd.componentManufacturer = 0;
    
    cd.componentFlags = 0;
    cd.componentFlagsMask = 0;

    while ((c = FindNextComponent(c, &cd)) != 0)
    {
        HX_ASSERT(foundComponent == NULL);
        foundComponent = c;
        break;
    }

    // this chunk o' code assumes local coordinates.

    Point local;
    local.h = screenCoorX;
    local.v = screenCoorY;
    if (!IsRunningNativeOnMacOSX())
    {
        GlobalToLocal(&local);
    }

    Rect srcR, dstR;

    srcR.left = 0;
    srcR.top = 0;
    srcR.right = sourceWidth;
    srcR.bottom = sourceHeight;

    dstR.left = local.h;
    dstR.top = local.v;
    dstR.right = local.h + screenWidth;
    dstR.bottom = local.v + screenHeight;

    zm_ImageDescriptionHandle = (ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription));

    (**zm_ImageDescriptionHandle).idSize = sizeof(ImageDescription);
    (**zm_ImageDescriptionHandle).cType = 'yuvs';
    (**zm_ImageDescriptionHandle).width = srcR.right-srcR.left;
    (**zm_ImageDescriptionHandle).height = srcR.bottom-srcR.top;
    (**zm_ImageDescriptionHandle).hRes = 72L << 16;
    (**zm_ImageDescriptionHandle).vRes = 72L << 16;
    (**zm_ImageDescriptionHandle).frameCount = 1;
    (**zm_ImageDescriptionHandle).clutID = -1;

    MatrixRecord matrix;

    RectMatrix(&matrix, &srcR, &dstR);

    OSErr err = DecompressSequenceBeginS(
                    &zm_SequenceID,
                    zm_ImageDescriptionHandle,
                    nil, 0, // data pointer and data length
                    nil, // use the current port
                    nil, // go to screen
                    &srcR,
                    &matrix,
                    ditherCopy,
                    maskRgn,
                    codecFlagUseImageBuffer,
                    codecNormalQuality,
                    foundComponent);

    zm_nOverlayRowBytes = (srcR.right-srcR.left) * 2;
    zm_nOverlayBufferSize = (srcR.bottom - srcR.top) * zm_nOverlayRowBytes;
    
    if ((zm_nOverlayBufferSize == zm_nHoldOverlayBufSize) && zm_pHoldOverlayBuf)
    {
        zm_pOverlayBuf = zm_pHoldOverlayBuf;
    }
    else
    {
        zm_pOverlayBuf = ::NewPtr(zm_nOverlayBufferSize);
        if (zm_pHoldOverlayBuf)
        {
            ::DisposePtr((Ptr)zm_pHoldOverlayBuf);
        }
        zm_pHoldOverlayBuf = zm_pOverlayBuf;
        zm_nHoldOverlayBufSize = zm_nOverlayBufferSize;
    }
}


void CMacSurface::CleanUpOverlay()
{
    if (zm_SequenceID)
    {
        CDSequenceEnd(zm_SequenceID);
    }
    zm_SequenceID = NULL;
    
    if (zm_pOverlayBuf)
    {
        // xxxbobclark don't dispose this; hold on to it in
        // zm_pHoldOverlayBuf in case we create another overlay
        // of the same size. Saves allocation and initialization
        // time, plus sidesteps some alpha-blending bugs.
        // DisposePtr((Ptr)zm_pOverlayBuf);
    }
    zm_pOverlayBuf = nil;
    
    zm_nOverlayRowBytes = 0;
    zm_nOverlayBufferSize = 0;
    
    if (zm_OverlayMaskRgn)
    {
        ::DisposeRgn(zm_OverlayMaskRgn);
    }
    zm_OverlayMaskRgn = NULL;

    if (zm_ImageDescriptionHandle)
    {
        ::DisposeHandle((Handle)zm_ImageDescriptionHandle);
    }
    zm_ImageDescriptionHandle = NULL;
}

RgnHandle
CMacSurface::BuildOverlayVisRgn()
{
    // This assumes that the decomp params
    // rectangle has already been set up!
    //
    // It also assumes that the port has
    // been set to the correct window!
    //
    // The caller must dispose of the
    // region!
    
    HX_ASSERT(IsMacInCooperativeThread());
    
    RgnHandle rgn = ::NewRgn();
    
    ::RectRgn(rgn, &bogusDecompParams.decompParams.dstRect);

    return rgn;
}

#pragma options align=reset

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?