📄 macsurf.cpp
字号:
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;
static BOOL zbWeveExploredOverlayCapabilities = FALSE;
static BOOL zbOverlayAvailable = FALSE;
if (!zbWeveExploredOverlayCapabilities)
{
zbWeveExploredOverlayCapabilities = TRUE;
// start out by assuming that we can use ATI's
// deferred-task-safe overlay code. We'll fall
// back on Apple's mechanism if necessary.
zm_bUsingFauxCodec = FALSE;
if (!zbOverlayAvailable)
{
zm_bUsingFauxCodec = TRUE;
zbOverlayAvailable = TRUE;
FauxCodecRegister();
}
}
return zbOverlayAvailable;
}
/************************************************************************
* 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)
{
// xxxbobclark if we're running native on OS X, then the screen coordinates are in
// local coordinates. If we're NOT running native on OS X then the screen coordinates
// are in global coordinates. The reason for this is that we have a chance to talk
// directly to the hardware on OS 9 and below, which requires global coordinates. On
// OS X by using local coordinates we ensure that we can accurately hit a moving window.
// (If we try to use global coords on OS X, it's possible that the window is moved
// between when the global coords are figured out and we construct the overlay.
if (zm_bUsingFauxCodec)
{
// xxxbobclark if we're using the faux codec, then as of this
// writing, on OS 9, we can not blit at interrupt time. This
// presents us with a dilemma. For one thing, a lot of work
// went into interrupt-time blitting. And in many cases it is
// a vast improvement. Worse, it is hard to tell at compile
// time or even runtime whether ITB sans overlay is better than
// overlay sans ITB. We can make some runtime assumptions,
// like at what destination size the dropped frames due to
// yuv-rgb conversions equal the dropped frames due to not
// having ITB active... but even that can shift due to conditions
// like, say, an email program checking mail in the background.
// I think I'm going to make some assumptions that the user
// won't be doing all kinds of things in the background.
// Note that this will suddenly become a non-issue once we
// move to OS X (because we can ITB without any concerns)
// or Apple helps us use the Image Compression Manager ("faux
// codec") mechanism at deferred time.
// xxxbobclark ... although the settings preferences could
// dictate that we use overlay; if for example ITB is turned
// off but overlay is turned on in the preferences, we should
// always do overlay...
// OK we need to set up zm_pOverlayBuf, zm_nOverlayRowBytes, and zm_bSafeToOverlayBlit
// Oh, and zm_nOverlayBufferSize.
// first let's find our component.
ComponentDescription cd;
Component c = NULL;
Component foundComponent = NULL;
cd.componentType = 'imdc';
cd.componentSubType = 'yuvs';
cd.componentManufacturer = 'RNWK';
// xxxbobclark if we pass in zero for the componentManufacturer
// instead of 'RNWK', it will still grab an actual codec. And if
// we haven't done FauxCodecRegister() it still grabs one, at least
// on Jaguar. This is very interesting. It may be possible that on
// Jaguar and later, the faux codec trick is redundant. I'm reluctant
// to remove it now, but it could bear looking into.
cd.componentFlags = 0;
cd.componentFlagsMask = 0;
while ((c = FindNextComponent(c, &cd)) != 0)
{
HX_ASSERT(foundComponent == NULL);
foundComponent = c;
break;
// xxxbobclark this is a short-term kludge. The real problem is that every time pnvideo
// is loaded and a surface used for overlay, it calls FauxCodecRegister. pnvideo's terminate
// routine should call some corresponding FauxCodecUnregister, but since it doesn't yet,
// a pile of faux codecs gets added to every time pnvideo is unloaded/reloaded. This doesn't
// typically happen in the player but in the embedded player it can happen frequently.
// By breaking out of this loop now we only use (apparently) the most recently installed
// version, which fortunately is the one still in loaded pnvideo code.
// The fix should be straightforward: unregister the faux codec from the dtor which tears down
// the overlay or worst case from the shlb's terminate routine. xxxbobclark 6/12/02 this should
// be one of the first things fixed when I have a chance.
}
// 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;
}
}
else
{
// ATI-specific overlay implementation
HX_ASSERT( NULL == "no non-faux-codec mechanism!");
}
}
void CMacSurface::CleanUpOverlay()
{
if (zm_bUsingFauxCodec)
{
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;
}
else
{
// ATI-specific overlay implementation
}
}
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -