Exemplo n.º 1
0
static void SDLFrameBoundary(SDL_Surface* screen)
{
    // are we (not) recording AVI?
    BOOL recordingAVIVideo = (tasflags.aviMode & 1);
    if(!recordingAVIVideo || !screen)
    {
        // if not recording AVI, it's a regular frame boundary.
        FrameBoundary(nullptr, CAPTUREINFO::TYPE_NONE);
    }
    else
    {
        // if we are, it's still a regular frame boundary,
        // but we prepare extra info for the AVI capture around it.
        DDSURFACEDESC desc = { sizeof(DDSURFACEDESC) };
        SDL_LockSurface(screen);
        desc.lpSurface = screen->pixels;
        desc.dwWidth = screen->w;
        desc.dwHeight = screen->h;
        desc.lPitch = screen->pitch;
        desc.ddpfPixelFormat.dwRGBBitCount = screen->format->BitsPerPixel;
        desc.ddpfPixelFormat.dwRBitMask = screen->format->Rmask;
        desc.ddpfPixelFormat.dwGBitMask = screen->format->Gmask;
        desc.ddpfPixelFormat.dwBBitMask = screen->format->Bmask;
        if(desc.ddpfPixelFormat.dwRGBBitCount == 8 && screen->format->palette)
            memcpy(&activePalette[0], &screen->format->palette->entries[0], min(256, screen->format->palette->entryCount));

        FrameBoundary(&desc, CAPTUREINFO::TYPE_DDSD);

        SDL_UnlockSurface(screen); 
    }
}
Exemplo n.º 2
0
    HOOKFUNC BOOL WINAPI MySwapBuffers(HDC hdc)
    {
        depth_SwapBuffers++;
        //if(!usingSDLOrDD)
        if (!redrawingScreen)
        {
            //		int localFramecount = framecount;
            //		if(localFramecount == framecount)
            if (!PresentOGLD3D())
            {
                SwapBuffers(hdc);
                // TODO: FrameBoundaryHDCtoAVI here?
                FrameBoundary();
            }
        }
        //else
        {
            // maybe this branch is just broken?
            // rescue: the beagles crashes with no clear callstack if we get here.
            // disabled for now.
                    //SwapBuffers(hdc);
        }
        depth_SwapBuffers--;

        return TRUE;
    }
Exemplo n.º 3
0
    HOOKFUNC BOOL WINAPI MyStretchBlt(HDC hdcDest,
            int nXOriginDest, int nYOriginDest,
            int nWidthDest, int nHeightDest,
            HDC hdcSrc,
            int nXOriginSrc, int nYOriginSrc,
            int nWidthSrc, int nHeightSrc,
            DWORD dwRop)
    {
        bool isFrameBoundary = false;
        if (!usingSDLOrDD /*&& !inPauseHandler*/ && !redrawingScreen)
        {
            if (dwRop == SRCCOPY)
            {
                HWND hwnd = WindowFromDC(hdcDest);
                if (hwnd /*&& !hwndRespondingToPaintMessage[hwnd]*/)
                {
                    if ((/*s_gdiPhaseDetector.AdvanceAndCheckCycleBoundary(MAKELONG(nXOriginDest,nYOriginDest))
                        ||*/ tls.peekedMessage) && VerifyIsTrustedCaller(!tls.callerisuntrusted))
                    {
                        if ((nWidthSrc >= gdiFrameBigEnoughWidth && nHeightSrc >= gdiFrameBigEnoughHeight)
                            || HDCSizeBigEnoughForFrameBoundary(hdcSrc))
                        {
                            isFrameBoundary = true;
                        }
                    }
                }
            }
        }

        ENTER();


        BOOL rv = TRUE;
        if (!ShouldSkipDrawing(false, WindowFromDC(hdcDest) != 0))
        {
            if (s_gdiPendingRefresh && !redrawingScreen)
            {
                redrawingScreen = true;
                RedrawScreenGDI();
                redrawingScreen = false;
            }
            rv = StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop);
        }
        else
            s_gdiPendingRefresh = true;

        if (isFrameBoundary)
        {
            tls.peekedMessage = FALSE;
            if (!(tasflags.aviMode & 1))
                FrameBoundary(NULL, CAPTUREINFO_TYPE_NONE);
            else
                FrameBoundaryHDCtoAVI(hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc);
            s_hdcSrcSaved = hdcSrc;
            s_hdcDstSaved = hdcDest;
        }

        return rv;
    }
Exemplo n.º 4
0
HOOKFUNC void SDLCALL MySDL_GL_SwapBuffers()
{
    debuglog(LCF_SDL|LCF_OGL|LCF_FRAME, __FUNCTION__ " called.\n");
    usingSDLOrDD = true;
    bool alreadyDidBoundary = false;
    //if(!ShouldSkipDrawing(true, false))
    {
        //SDL_GL_SwapBuffers(); // FIXME: replace with directx equivalent since opengl is lethal when combined with savestates
        if(PresentOGLD3D())
            alreadyDidBoundary = true;
    }
    if(!used_sdl_flip && !alreadyDidBoundary)
        FrameBoundary();
}
Exemplo n.º 5
0
 HOOKFUNC int WINAPI MyStretchDIBits(HDC hdc, int xDest, int yDest, int DestWidth, int DestHeight, int xSrc, int ySrc, int SrcWidth, int SrcHeight, CONST VOID * lpBits, CONST BITMAPINFO * lpbmi, UINT iUsage, DWORD rop)
 {
     int rv = StretchDIBits(hdc, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight, lpBits, lpbmi, iUsage, rop);
     if (!usingSDLOrDD /*&& !inPauseHandler*/ && !redrawingScreen)
     {
         HWND hwnd = WindowFromDC(hdc);
         if (hwnd /*&& !hwndRespondingToPaintMessage[hwnd]*/)
         {
             if (rv != 0 && rv != GDI_ERROR && rop == SRCCOPY && (/*s_gdiPhaseDetector.AdvanceAndCheckCycleBoundary(MAKELONG(xDest,yDest))
                 ||*/ tls.peekedMessage) && VerifyIsTrustedCaller(!tls.callerisuntrusted))
             {
                 if (!(tasflags.aviMode & 1))
                     FrameBoundary(NULL, CAPTUREINFO_TYPE_NONE);
                 else
                     FrameBoundaryDIBitsToAVI(lpBits, *lpbmi);
                 tls.peekedMessage = FALSE;
             }
         }
     }
     return rv;
 }
Exemplo n.º 6
0
 HOOKFUNC int WINAPI MySetDIBitsToDevice(HDC hdc, int xDest, int yDest, DWORD w, DWORD h, int xSrc, int ySrc, UINT StartScan, UINT cLines, CONST VOID * lpvBits, CONST BITMAPINFO * lpbmi, UINT ColorUse)
 {
     int rv = SetDIBitsToDevice(hdc, xDest, yDest, w, h, xSrc, ySrc, StartScan, cLines, lpvBits, lpbmi, ColorUse);
     if (!usingSDLOrDD /*&& !inPauseHandler*/ && !redrawingScreen)
     {
         HWND hwnd = WindowFromDC(hdc);
         if (hwnd /*&& !hwndRespondingToPaintMessage[hwnd]*/)
         {
             if (rv != 0 && rv != GDI_ERROR && (/*s_gdiPhaseDetector.AdvanceAndCheckCycleBoundary(MAKELONG(xDest,yDest))
                 ||*/ tls.peekedMessage) && VerifyIsTrustedCaller(!tls.callerisuntrusted))
             {
                 if (!(tasflags.aviMode & 1))
                     FrameBoundary(NULL, CAPTUREINFO_TYPE_NONE);
                 else
                     FrameBoundaryDIBitsToAVI(lpvBits, *lpbmi);
                 tls.peekedMessage = FALSE;
             }
         }
     }
     return rv;
 }
Exemplo n.º 7
0
    HOOKFUNC BOOL WINAPI MyBitBlt(HDC hdcDest,
            int nXDest, int nYDest,
            int nWidth, int nHeight,
            HDC hdcSrc,
            int nXSrc, int nYSrc,
            DWORD dwRop)
    {
        bool isFrameBoundary = false;
        if (!usingSDLOrDD /*&& !inPauseHandler*/ && !redrawingScreen)
        {
            if (dwRop == SRCCOPY)
            {
                HWND hwnd = WindowFromDC(hdcDest);
                if (hwnd /*&& !hwndRespondingToPaintMessage[hwnd]*/)
                {
                    if ((/*s_gdiPhaseDetector.AdvanceAndCheckCycleBoundary(MAKELONG(nXDest,nYDest))
                        ||*/ tls.peekedMessage) && VerifyIsTrustedCaller(!tls.callerisuntrusted))
                    {
                        if ((nWidth >= gdiFrameBigEnoughWidth && nHeight >= gdiFrameBigEnoughHeight)
                            || HDCSizeBigEnoughForFrameBoundary(hdcSrc))
                        {
                            isFrameBoundary = true;
                        }
                    }
                }
            }
        }

        ENTER(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);



        BOOL rv = TRUE;
        if (!ShouldSkipDrawing(false, WindowFromDC(hdcDest) != 0))
        {
            if (s_gdiPendingRefresh && !redrawingScreen)
            {
                redrawingScreen = true;
                RedrawScreenGDI();
                redrawingScreen = false;
            }
            if (!fakeDisplayValid)
            {
                rv = BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
            }
            else
            {
                HWND hwnd = WindowFromDC(hdcDest);
                RECT realRect;
                if (!GetClientRect(hwnd, &realRect) || (realRect.right == fakeDisplayWidth && realRect.bottom == fakeDisplayHeight))
                {
                    rv = BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
                }
                else
                {
                    // support resized fake-fullscreen windows in games like Lyle in Cube Sector
                    // a little iffy: sprites leave pixels behind occasionally at non-integral scales
                    HDC hdcTemp = 0;
                    HDC hdc = hdcDest;
                    if (realRect.right > fakeDisplayWidth || realRect.bottom > fakeDisplayHeight)
                    {
                        // sidestep clip region (it can't be expanded without switching HDCs)
                        hdcTemp = GetDC(hwnd);
                        hdc = hdcTemp;
                    }
                    // FIXME this feature actually broke, it's drawing at 100% size again no matter the window size,
                    // it probably broke because of extra hooking of functions like GetClientRect.
                    RECT dstRect = { nXDest, nYDest, nXDest + nWidth, nYDest + nHeight };
                    RECT fakeRect = { 0, 0, fakeDisplayWidth, fakeDisplayHeight };
                    RescaleRect(dstRect, fakeRect, realRect);
                    rv = StretchBlt(hdc, dstRect.left, dstRect.top, dstRect.right - dstRect.left, dstRect.bottom - dstRect.top, hdcSrc, nXSrc, nYSrc, nWidth, nHeight, dwRop);
                    if (hdcTemp)
                        ReleaseDC(hwnd, hdcTemp);
                }
            }
        }
        else
            s_gdiPendingRefresh = true;

        if (isFrameBoundary)
        {
            tls.peekedMessage = FALSE;
            if (!(tasflags.aviMode & 1))
                FrameBoundary(NULL, CAPTUREINFO_TYPE_NONE);
            else
                FrameBoundaryHDCtoAVI(hdcSrc, nXSrc, nYSrc, nWidth, nHeight);
            s_hdcSrcSaved = hdcSrc;
            s_hdcDstSaved = hdcDest;
        }

        return rv;
    }