19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*
29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    SDL - Simple DirectMedia Layer
39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Copyright (C) 1997-2012 Sam Lantinga
49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Copyright (C) 2001  Hsieh-Fu Tsai
59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Copyright (C) 2002  Greg Haerr <greg@censoft.com>
69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is free software; you can redistribute it and/or
89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    modify it under the terms of the GNU Library General Public
99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License as published by the Free Software Foundation; either
109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    version 2 of the License, or (at your option) any later version.
119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is distributed in the hope that it will be useful,
139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    but WITHOUT ANY WARRANTY; without even the implied warranty of
149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Library General Public License for more details.
169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    You should have received a copy of the GNU Library General Public
189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License along with this library; if not, write to the Free
199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Sam Lantinga
229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    slouken@libsdl.org
239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Hsieh-Fu Tsai
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    clare@setabox.com
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h"
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_nximage_c.h"
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects)
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    int           i, j, xinc, yinc, destinc, rowinc ;
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    int           x, y, w, h ;
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    unsigned char * src = NULL, * dest = NULL ;
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("enter NX_NormalUpdate\n") ;
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    /* These are the values for the incoming image */
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    xinc = this -> screen -> format -> BytesPerPixel ;
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    yinc = this -> screen -> pitch ;
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    for (i = 0; i < numrects; ++ i) {
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        x = rects [i].x, y = rects [i].y ;
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        w = rects [i].w, h = rects [i].h ;
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        src = SDL_Image + y * yinc + x * xinc ;
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef ENABLE_NANOX_DIRECT_FB
489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        if (Clientfb) {
499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            if (currently_fullscreen)
509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) +
519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    ((x+OffsetX) * fbinfo.bytespp));
529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            else
539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp));
549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            destinc = fbinfo.pitch;
559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        }
569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        else
579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        {
599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            dest = Image_buff ;
609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            destinc = w * xinc ;
619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        }
629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        rowinc = w * xinc;
639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        // apply GammaRamp table
659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888)
669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall          && GammaRamp_R && GammaRamp_G && GammaRamp_B) {
679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            Uint8 * ptrsrc ;
689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            Uint8 * ptrdst ;
699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            int   k ;
709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                ptrsrc = src ;
739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                ptrdst = dest ;
749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                for (k = w; k > 0; -- k) {
759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    *ptrdst++ = GammaRamp_B [*ptrsrc++] >> 8;
769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    *ptrdst++ = GammaRamp_G [*ptrsrc++] >> 8;
779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    *ptrdst++ = GammaRamp_R [*ptrsrc++] >> 8;
789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    *ptrdst++ = 0;
799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    ++ptrsrc;
809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                }
819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            }
829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        }
839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if 1 /* This is needed for microwindows 0.90 or older */
849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        else if (pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) {
859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            Uint8 * ptrsrc ;
869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            Uint8 * ptrdst ;
879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            int   k ;
889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                ptrsrc = src ;
919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                ptrdst = dest ;
929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                for (k = w; k > 0; -- k) {
939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    *ptrdst++ = *ptrsrc++;
949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    *ptrdst++ = *ptrsrc++;
959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    *ptrdst++ = *ptrsrc++;
969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    *ptrdst++ = 0;
979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    ++ptrsrc;
989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                }
999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            }
1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        }
1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        else
1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        {
1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            for (j = h; j > 0; -- j, src += yinc, dest += destinc)
1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                SDL_memcpy (dest, src, rowinc) ;
1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        }
1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        if (!Clientfb) {
1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            if (currently_fullscreen) {
1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff,
1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                    pixel_type) ;
1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            } else {
1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ;
1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            }
1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        }
1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    GrFlush();
1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("leave NX_NormalUpdate\n") ;
1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint NX_SetupImage (_THIS, SDL_Surface * screen)
1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    int size = screen -> h * screen -> pitch ;
1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("enter NX_SetupImage\n") ;
1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    screen -> pixels = (void *) SDL_malloc (size) ;
1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (!Clientfb) {
1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        Image_buff = (unsigned char *) SDL_malloc (size) ;
1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        if (screen -> pixels == NULL || Image_buff == NULL) {
1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            SDL_free (screen -> pixels) ;
1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            SDL_free (Image_buff) ;
1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            SDL_OutOfMemory () ;
1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            return -1 ;
1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        }
1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    SDL_Image = (unsigned char *) screen -> pixels ;
1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    this -> UpdateRects = NX_NormalUpdate ;
1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("leave NX_SetupImage\n") ;
1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    return 0 ;
1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid NX_DestroyImage (_THIS, SDL_Surface * screen)
1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("enter NX_DestroyImage\n") ;
1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (SDL_Image) SDL_free (SDL_Image) ;
1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (Image_buff) SDL_free (Image_buff) ;
1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (screen) screen -> pixels = NULL ;
1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("leave NX_DestroyImage\n") ;
1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint NX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags)
1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    int            retval ;
1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    GR_SCREEN_INFO si ;
1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("enter NX_ResizeImage\n") ;
1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    NX_DestroyImage (this, screen) ;
1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    retval = NX_SetupImage (this, screen) ;
1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    GrGetScreenInfo (& si) ;
1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    OffsetX = (si.cols - screen -> w) / 2 ;
1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    OffsetY = (si.rows - screen -> h) / 2 ;
1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef ENABLE_NANOX_DIRECT_FB
1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (Clientfb) {
1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        /* Get current window position and fb pointer*/
1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        if (currently_fullscreen)
1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            GrGetWindowFBInfo(FSwindow, &fbinfo);
1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        else
1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            GrGetWindowFBInfo(SDL_Window, &fbinfo);
1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("leave NX_ResizeImage\n") ;
1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    return retval ;
1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid NX_RefreshDisplay (_THIS)
1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("enter NX_RefreshDisplay\n") ;
1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    // Don't refresh a display that doesn't have an image (like GL)
1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (! SDL_Image) {
1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        return;
1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef ENABLE_NANOX_DIRECT_FB
1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (Clientfb) {
1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        int j;
1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        char *src, *dest = NULL;
1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        int xinc, yinc, rowinc;
1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrGetWindowFBInfo(SDL_Window, &fbinfo);
2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        xinc = this -> screen -> format -> BytesPerPixel ;
2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        yinc = this -> screen -> pitch ;
2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        src = SDL_Image;
2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        if (currently_fullscreen)
2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) +
2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                (OffsetX * fbinfo.bytespp));
2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        else
2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            dest = fbinfo.winpixels;
2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        rowinc = xinc * this -> screen -> w;
2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch)
2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            SDL_memcpy (dest, src, rowinc) ;
2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    else
2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    {
2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        if (currently_fullscreen) {
2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w,
2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                this -> screen -> h, SDL_Image, pixel_type) ;
2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        } else {
2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w,
2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall                this -> screen -> h, SDL_Image, pixel_type) ;
2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        }
2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    GrFlush();
2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Dprintf ("leave NX_RefreshDisplay\n") ;
2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
231