⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdl_quartzvideo.m

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 M
📖 第 1 页 / 共 4 页
字号:
                        shadowSide = 18;                        shadowTop = 4;                        shadowBottom = 22;                    }                    else if (winLevel == kCGSWindowLevelUtility) {                        shadowSide = 8;                        shadowTop = 4;                        shadowBottom = 12;                    }                    else if (winLevel == kCGSWindowLevelNormal) {                        /*                             These numbers are for foreground windows,                            they are too big (but will work) for background windows                         */                        shadowSide = 20;                        shadowTop = 10;                        shadowBottom = 24;                    }                    else if (winLevel == kCGSWindowLevelDock) {                        /* Create dock icon cache */                        if (numCachedDockIcons != (i-firstDockIcon) ||                            dockIconCacheMiss) {                            numCachedDockIcons = i - firstDockIcon;                            SDL_memcpy (dockIcons, &(windows[firstDockIcon]),                                    numCachedDockIcons * sizeof(*windows));                        }                        /* no shadow */                        shadowSide = 0;                        shadowTop = 0;                        shadowBottom = 0;                    }                    else {                        /*                            kCGSWindowLevelDockLabel,                            kCGSWindowLevelDock,                            kOther???                        */                        /* no shadow */                        shadowSide = 0;                        shadowTop = 0;                        shadowBottom = 0;                    }                    CGSGetScreenRectForWindow (cgsConnection, windows[i], &winRect);                    winRect.origin.x -= shadowSide;                    winRect.origin.y -= shadowTop;                    winRect.size.width += shadowSide;                    winRect.size.height += shadowBottom;                    if (NSIntersectsRect (contentRect, winRect)) {                        obscured = SDL_TRUE;                        break;                    }                } /* window was not our window */            } /* iterate over windows */        } /* get cgsConnection */    } /* window is visible */        return obscured;#else    return SDL_TRUE;#endif}/* Locking functions for the software window buffer */static int QZ_LockWindow (_THIS, SDL_Surface *surface) {        return LockPortBits ( [ window_view qdPort ] );}static void QZ_UnlockWindow (_THIS, SDL_Surface *surface) {    UnlockPortBits ( [ window_view qdPort ] );}/* Resize icon, BMP format */static const unsigned char QZ_ResizeIcon[] = {    0x42,0x4d,0x31,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00,    0x00,0x00,0x0d,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x01,0x00,0x18,0x00,0x00,0x00,    0x00,0x00,0xfb,0x01,0x00,0x00,0x13,0x0b,0x00,0x00,0x13,0x0b,0x00,0x00,0x00,0x00,    0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0b,0xff,0xff,    0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda,0xda,    0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8,    0xe8,0xe8,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xda,0xda,0xda,0x87,    0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8,0xe8,    0xe8,0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xff,0xff,0xff,0x0b,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd5,0xd5,0xd5,0x87,0x87,0x87,0xe8,0xe8,0xe8,    0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,    0xda,0xda,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xd7,0xd7,0xd7,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda,    0xda,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xff,0xff,0xff,0x0b,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7,0xd7,0xd7,    0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xda,0xda,0xda,0x87,0x87,0x87,0xe8,    0xe8,0xe8,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7,0xd7,0xd7,0x87,0x87,0x87,0xe8,0xe8,    0xe8,0xff,0xff,0xff,0xdc,0xdc,0xdc,0x87,0x87,0x87,0xff,0xff,0xff,0x0b,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xd9,0xd9,0xd9,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xdc,    0xdc,0xdc,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdb,0xdb,    0xdb,0x87,0x87,0x87,0xe8,0xe8,0xe8,0xff,0xff,0xff,0xff,0xff,0xff,0x0b,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdb,0xdb,0xdb,0x87,0x87,0x87,0xe8,    0xe8,0xe8,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0x87,0x87,0x87,0xff,0xff,0xff,0x0b,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdc,    0xdc,0xdc,0xff,0xff,0xff,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0b};static void QZ_DrawResizeIcon (_THIS, RgnHandle dirtyRegion) {    /* Check if we should draw the resize icon */    if (SDL_VideoSurface->flags & SDL_RESIZABLE) {            Rect    icon;        SetRect (&icon, SDL_VideoSurface->w - 13, SDL_VideoSurface->h - 13,                     SDL_VideoSurface->w, SDL_VideoSurface->h);                            if (RectInRgn (&icon, dirtyRegion)) {                    SDL_Rect icon_rect;                        /* Create the icon image */            if (resize_icon == NULL) {                            SDL_RWops *rw;                SDL_Surface *tmp;                                rw = SDL_RWFromConstMem (QZ_ResizeIcon, sizeof(QZ_ResizeIcon));                tmp = SDL_LoadBMP_RW (rw, SDL_TRUE);                                                                                resize_icon = SDL_ConvertSurface (tmp, SDL_VideoSurface->format, SDL_SRCCOLORKEY);                SDL_SetColorKey (resize_icon, SDL_SRCCOLORKEY, 0xFFFFFF);                                SDL_FreeSurface (tmp);            }                        icon_rect.x = SDL_VideoSurface->w - 13;            icon_rect.y = SDL_VideoSurface->h - 13;            icon_rect.w = 13;            icon_rect.h = 13;                        SDL_BlitSurface (resize_icon, NULL, SDL_VideoSurface, &icon_rect);        }    }}static void QZ_UpdateRects (_THIS, int numRects, SDL_Rect *rects) {    if (SDL_VideoSurface->flags & SDL_OPENGLBLIT) {        QZ_GL_SwapBuffers (this);    }    else if ( [ qz_window isMiniaturized ] ) {            /* Do nothing if miniaturized */    }        else if ( ! QZ_IsWindowObscured (qz_window) ) {        /* Use direct copy to flush contents to the display */        CGrafPtr savePort;        CGrafPtr dstPort, srcPort;        const BitMap  *dstBits, *srcBits;        Rect     dstRect, srcRect;        Point    offset;        int i;        GetPort (&savePort);        dstPort = CreateNewPortForCGDisplayID ((UInt32)display_id);        srcPort = [ window_view qdPort ];        offset.h = 0;        offset.v = 0;        SetPort (srcPort);        LocalToGlobal (&offset);        SetPort (dstPort);        LockPortBits (dstPort);        LockPortBits (srcPort);        dstBits = GetPortBitMapForCopyBits (dstPort);        srcBits = GetPortBitMapForCopyBits (srcPort);        for (i = 0; i < numRects; i++) {            SetRect (&srcRect, rects[i].x, rects[i].y,                     rects[i].x + rects[i].w,                     rects[i].y + rects[i].h);            SetRect (&dstRect,                     rects[i].x + offset.h,                     rects[i].y + offset.v,                     rects[i].x + rects[i].w + offset.h,                     rects[i].y + rects[i].h + offset.v);            CopyBits (srcBits, dstBits,                      &srcRect, &dstRect, srcCopy, NULL);        }        SetPort (savePort);    }    else {        /* Use QDFlushPortBuffer() to flush content to display */        int i;        RgnHandle dirty = NewRgn ();        RgnHandle temp  = NewRgn ();        SetEmptyRgn (dirty);        /* Build the region of dirty rectangles */        for (i = 0; i < numRects; i++) {            MacSetRectRgn (temp, rects[i].x, rects[i].y,                        rects[i].x + rects[i].w, rects[i].y + rects[i].h);            MacUnionRgn (dirty, temp, dirty);        }        QZ_DrawResizeIcon (this, dirty);                /* Flush the dirty region */        QDFlushPortBuffer ( [ window_view qdPort ], dirty );        DisposeRgn (dirty);        DisposeRgn (temp);    }}static void QZ_VideoQuit (_THIS) {    CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;    /* Restore gamma settings */    CGDisplayRestoreColorSyncSettings ();    /* Ensure the cursor will be visible and working when we quit */    CGDisplayShowCursor (display_id);    CGAssociateMouseAndMouseCursorPosition (1);        if (mode_flags & SDL_FULLSCREEN) {        /* Fade to black to hide resolution-switching flicker (and garbage           that is displayed by a destroyed OpenGL context, if applicable) */        if (CGAcquireDisplayFadeReservation (5, &fade_token) == kCGErrorSuccess) {            CGDisplayFade (fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE);        }        QZ_UnsetVideoMode (this, TRUE);        if (fade_token != kCGDisplayFadeReservationInvalidToken) {            CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);            CGReleaseDisplayFadeReservation (fade_token);        }    }    else        QZ_UnsetVideoMode (this, TRUE);        CGPaletteRelease (palette);    if (opengl_library) {        SDL_UnloadObject(opengl_library);        opengl_library = NULL;    }    this->gl_config.driver_loaded = 0;    if (field_edit) {        [field_edit release];        field_edit = NULL;    }}#if 0 /* Not used (apparently, it's really slow) */static int  QZ_FillHWRect (_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color) {    CGSDisplayHWFill (display_id, rect->x, rect->y, rect->w, rect->h, color);    return 0;}#endifstatic int  QZ_LockHWSurface(_THIS, SDL_Surface *surface) {    return 1;}static void QZ_UnlockHWSurface(_THIS, SDL_Surface *surface) {}static int QZ_AllocHWSurface(_THIS, SDL_Surface *surface) {    return(-1); /* unallowed (no HWSURFACE support here). */}static void QZ_FreeHWSurface (_THIS, SDL_Surface *surface) {}/* int QZ_FlipHWSurface (_THIS, SDL_Surface *surface) {     return 0; } *//* Gamma functions */int QZ_SetGamma (_THIS, float red, float green, float blue) {    const CGGammaValue min = 0.0, max = 1.0;    if (red == 0.0)        red = FLT_MAX;    else        red = 1.0 / red;    if (green == 0.0)        green = FLT_MAX;    else        green = 1.0 / green;    if (blue == 0.0)        blue = FLT_MAX;    else        blue  = 1.0 / blue;    if ( CGDisplayNoErr == CGSetDisplayTransferByFormula         (display_id, min, max, red, min, max, green, min, max, blue) ) {        return 0;    }    else {        return -1;    }}int QZ_GetGamma (_THIS, float *red, float *green, float *blue) {    CGGammaValue dummy;    if ( CGDisplayNoErr == CGGetDisplayTransferByFormula         (display_id, &dummy, &dummy, red,          &dummy, &dummy, green, &dummy, &dummy, blue) )        return 0;    else        return -1;}int QZ_SetGammaRamp (_THIS, Uint16 *ramp) {    const CGTableCount tableSize = 255;    CGGammaValue redTable[tableSize];    CGGammaValue greenTable[tableSize];    CGGammaValue blueTable[tableSize];    int i;    /* Extract gamma values into separate tables, convert to floats between 0.0 and 1.0 */    for (i = 0; i < 256; i++)        redTable[i % 256] = ramp[i] / 65535.0;    for (i=256; i < 512; i++)        greenTable[i % 256] = ramp[i] / 65535.0;    for (i=512; i < 768; i++)        blueTable[i % 256] = ramp[i] / 65535.0;    if ( CGDisplayNoErr == CGSetDisplayTransferByTable         (display_id, tableSize, redTable, greenTable, blueTable) )        return 0;    else        return -1;}int QZ_GetGammaRamp (_THIS, Uint16 *ramp) {    const CGTableCount tableSize = 255;    CGGammaValue redTable[tableSize];    CGGammaValue greenTable[tableSize];    CGGammaValue blueTable[tableSize];    CGTableCount actual;    int i;    if ( CGDisplayNoErr != CGGetDisplayTransferByTable         (display_id, tableSize, redTable, greenTable, blueTable, &actual) ||         actual != tableSize)        return -1;    /* Pack tables into one array, with values from 0 to 65535 */    for (i = 0; i < 256; i++)        ramp[i] = redTable[i % 256] * 65535.0;    for (i=256; i < 512; i++)        ramp[i] = greenTable[i % 256] * 65535.0;    for (i=512; i < 768; i++)        ramp[i] = blueTable[i % 256] * 65535.0;    return 0;}

⌨️ 快捷键说明

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