paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/src/draw draw.cpp,NONE,1.1.2.1 drawable.cpp,N


From: Teunis Peters <address@hidden>
Subject: [paragui-cvs] CVS: paragui/src/draw draw.cpp,NONE,1.1.2.1 drawable.cpp,NONE,1.1.2.1 drawpriv.hh,NONE,1.1.2.1 glSDL.c,NONE,1.1.2.1 Makefile.am,1.3,1.3.2.1 drawline.cpp,1.3,1.3.2.1 drawtile.cpp,1.3,1.3.2.1 gradient.cpp,1.3,1.3.2.1 rotozoom.cpp,1.3,1.3.2.1 setpixel.cpp,1.3,1.3.2.1 stretch.cpp,1.3,1.3.2.1 surface.cpp,1.3,1.3.2.1
Date: Tue, 18 Jun 2002 18:40:42 -0400

Update of /cvsroot/paragui/paragui/src/draw
In directory subversions:/tmp/cvs-serv27818/src/draw

Modified Files:
      Tag: devel-opengl
        Makefile.am drawline.cpp drawtile.cpp gradient.cpp 
        rotozoom.cpp setpixel.cpp stretch.cpp surface.cpp 
Added Files:
      Tag: devel-opengl
        draw.cpp drawable.cpp drawpriv.hh glSDL.c 
Log Message:
Initial checkin of code by Teunis Peters
Added abstraction layer for display support.
Initial OpenGL testing mode - use SDL_GLSDL to activate
A lot of test code is still present - FIXME
Some demos do not operate at all.  Some work barely.
only animation works flawlessly at this time.


***** Error reading new file: [Errno 2] No such file or directory: 'draw.cpp'
***** Error reading new file: [Errno 2] No such file or directory: 
'drawable.cpp'
--- NEW FILE ---
#ifndef PG_DRAWPRIV_HH
#define PG_DRAWPRIV_HH

#ifndef PG_DRAW_H
#include "pgdraw.h"
#endif

namespace PG_Draw {

//! Rotate and scale an SDL_Surface
/*!
  Rotates and scales a 32bit or 8bit SDL_Surface to newly created
  destination surface. If smooth is 1 the destination 32bit surface is
  anti-aliased. If the surface is not 8bit or 32bit RGBA/ABGR it will
  be converted into a 32bit RGBA format on the fly.

  \param src source surface
  \param angle the rotation in degrees
  \param zoom the scaling factor
  \param smooth whether or not to use anti-aliasing

  \return A new surface with the scaled, rotated original surface.
*/

DECLSPEC PG_DrawableSurface* RotoScaleSurface(PG_DrawableSurface *src, double 
angle,
        double zoom, bool smooth = true);

//! Scale an SDL_Surface
/*!
  Scales a 32bit or 8bit SDL_Surface to newly created destination
  surface.  If the surface is not 8bit or 32bit RGBA/ABGR it will be
  converted into a 32bit RGBA format on the fly.

  \param src source surface
  \param zoomx, zoomy width and height scaling factors
  \param smooth whether or not to enable anti-aliasing

  \return A newly created surface with the scaled surface
*/
DECLSPEC PG_DrawableSurface* ScaleSurface(PG_DrawableSurface *src, double 
zoomx, double zoomy,
                                      bool smooth = true);


//! Scale and blit surface
/*!
  Scales a 32 bit or 8 bit SDL_Surface to the size of the destination
  surface dst and blits the result to the destination surface.  If the
  surface is not 8bit or 32bit RGBA/ABGR it will be converted into a
  32bit RGBA format on the fly.

  \param src Source surface
  \param dst destination surface
  \param smooth whether or not to use anti-aliasing */
DECLSPEC void BlitScale(PG_DrawableSurface* src, PG_DrawableSurface* dst, bool 
smooth = true);

/**
        Creates a surface filled with a gradient

        @param r                the dimensions of the surface to be created
        @param gradient the gradient colors to use
        @return                 a SDL_Surface pointer to the new surface

        This function creates a new surface filled with a given gradient 
defined by a set of colors
*/
DECLSPEC PG_DrawableSurface* CreateGradient(const PG_Rect& r, PG_Gradient& 
gradient);

/**
        Creates a surface filled with a gradient

        @param r                the dimensions of the surface to be created
        @param ul               upper/left gradient color
        @param ur               upper/right gradient color
        @param dl               lower/left gradient color
        @param dr               lower/right gradient color
        @return                 a SDL_Surface pointer to the new surface

        This function creates a new surface filled with a given gradient 
defined by a set of colors
*/
DECLSPEC PG_DrawableSurface* CreateGradient(const PG_Rect& r, SDL_Color & ul, 
SDL_Color & ur, SDL_Color & dl, SDL_Color & dr);

/**
*/
DECLSPEC void DrawGradient(PG_DrawableSurface* surface, const PG_Rect& r, 
PG_Gradient& gradient);

/**
*/
DECLSPEC void DrawGradient(PG_DrawableSurface* surface, const PG_Rect& rect, 
const SDL_Color & ul, const SDL_Color & ur, const SDL_Color & dl, const 
SDL_Color & dr);

#if 0
/**
        Create a new SDL surface
        @param w width of the new surface
        @param h height of the new surface
        @param flags surface-flags (default = SDL_SWSURFACE)
        @return pointer to the new surface
        This function creates a new SDL surface
*/
DECLSPEC PG_DrawableSurface* CreateRGBSurface(Uint16 w, Uint16 h, int flags = 
SDL_SWSURFACE);
#endif

#if 0
/**
        Draw a 'themed' surface

        @param surface                  the surface to draw on
        @param r                                        the rectangle of the 
surface to draw in
        @param gradient         pointer to a gradient structure (may be NULL)
        @param background       pointer to a background surface (may be NULL)
        @param bkmode           the mode how to fill in the background surface 
(BKMODE_TILE | BKMODE_STRETCH)
        @param blend                            the blend-level between 
gradient an background
*/
DECLSPEC void DrawThemedSurface(PG_DrawableSurface* surface, const PG_Rect& r, 
PG_Gradient* gradient, PG_DrawableSurface* background, int bkmode, Uint8 blend);
#endif

#if 0
/**
        Draw a line.
        @param surface destination surface
        @param x0 x startposition
        @param y0 y startposition
        @param x1 x endposition
        @param y1 y endposition
        @param color color of the line
        @param width width of the line

        Draws a line with given color and width onto a surface.
*/
DECLSPEC void DrawLine(PG_DrawableSurface* surface, Uint32 x0, Uint32 y0, 
Uint32 x1, Uint32 y1, const SDL_Color& color, Uint8 width = 1);

/**
        Set a pixel.
        @param x x position
        @param y y position
        @param r red color component
        @param g green color component
        @param b blue color component
        @param surface destination surface
*/
DECLSPEC void SetPixel(int x, int y, Uint8 r, Uint8 g, Uint8 b, 
PG_DrawableSurface* surface);
#endif

#if 0
/**
        replacement for SDL_BlitSurface
        @param srf_src  source surface
        @param rect_src PG_Rect of the source rectangle
        @param dst_src  destination surface
        @param rect_dst PG_Rect of the destination rectangle

        This function simply replaces SDL_BlitSurface and uses PG_Rect instead 
of SDL_Rect.
*/
inline void BlitSurface(const SDL_Surface* srf_src, const PG_Rect& rect_src, 
SDL_Surface* srf_dst, const PG_Rect& rect_dst) {
        SDL_BlitSurface((SDL_Surface*)srf_src, (PG_Rect*)&rect_src, srf_dst, 
(PG_Rect*)&rect_dst);
}
#endif

#if 0
DECLSPEC void DrawTile(SDL_Surface* surface, const PG_Rect& ref, const PG_Rect& 
drawrect, SDL_Surface* tilemap);
#endif

#if 0
#ifndef DOXYGEN_SKIP
// These will disappear (moved to another lib)
DECLSPEC void RectStretch(SDL_Surface* src_surface, int xs1, int ys1, int xs2, 
int ys2, SDL_Surface* dst_surface, int xd1, int yd1, int xd2, int yd2, Uint32* 
voiLUT);
DECLSPEC void CreateFilterLUT();
DECLSPEC void PG_SmoothFast(SDL_Surface* src, SDL_Surface* dst);
DECLSPEC void InterpolatePixel(SDL_Surface* src, SDL_Surface* dest);
#endif // DOXYGEN_SKIP
#endif

#if 0  /* obsolete section */
//! Scale an SDL_Surface
/*!
  Scales a 32bit or 8bit SDL_Surface to newly created destination
  surface.  If the surface is not 8bit or 32bit RGBA/ABGR it will be
  converted into a 32bit RGBA format on the fly.

  \param src source surface
  \param rect PG_Rect specifying the width and height of the new surface
  \param smooth whether or not to enable anti-aliasing

  \return A newly created surface with the scaled surface
*/
static inline SDL_Surface *ScaleSurface(SDL_Surface *src, const PG_Rect &rect,
        bool smooth = true) {
        return ScaleSurface(src, static_cast<double>(rect.w) / src->w,
                               static_cast<double>(rect.h) / src->h, smooth);
}

//! Scale an SDL_Surface
/*!
  Scales a 32bit or 8bit SDL_Surface to newly created destination
  surface.  If the surface is not 8bit or 32bit RGBA/ABGR it will be
  converted into a 32bit RGBA format on the fly.

  \param src source surface
  \param newx, newy the width and height of the new surface
  \param smooth whether or not to enable anti-aliasing

  \return A newly created surface with the scaled surface
*/
static inline SDL_Surface *ScaleSurface(SDL_Surface *src, Uint16 newx, Uint16 
newy,
        bool smooth = true) {
        return ScaleSurface(src, static_cast<double>(newx) / src->w,
                               static_cast<double>(newy) / src->h, smooth);
}
#endif /* obsolete section */


} // namespace PG_Draw

#endif // DRAWPRIV_HH

--- NEW FILE ---
/*(LGPL)
------------------------------------------------------------
        glSDL - SDL 2D API on top of OpenGL
                Slightly Less Ugly Proof-of-Concept Hack
------------------------------------------------------------
 * (c) David Olofson, 2001, 2002
 * This code is released under the terms of the GNU LGPL.
 */

#ifdef HAVE_OPENGL

/*
 * Note that this will result in whining about
 * TexInfo 0 being leaked, as the checking is
 * done before the screen is closed. Ignore. :-)
 */
#define LEAK_TRACKING

#define DBG(x)  x       /*error messages, warnings*/
[...1625 lines suppressed...]

void glSDL_UnloadSurface(SDL_Surface *surface)
{
        if(!IS_GLSDL_SURFACE(surface))
                return;

        _UnloadTexture(glSDL_GetTexInfo(surface));
}


SDL_Surface *glSDL_IMG_Load(const char *file)
{
        SDL_Surface *s;
        s = IMG_Load(file);
        if(s)
                GLSDL_FIX_SURFACE(s);
        return s;
}

#endif /* GLSDL_OFF */

Index: Makefile.am
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** Makefile.am 27 Apr 2002 15:36:55 -0000      1.3
--- Makefile.am 18 Jun 2002 22:40:38 -0000      1.3.2.1
***************
*** 2,5 ****
--- 2,7 ----
  
  libpgdraw_la_SOURCES = \
+       draw.cpp \
+       drawable.cpp \
        surface.cpp \
        rotozoom.cpp \
***************
*** 10,14 ****
        pgpoint.cpp \
        drawtile.cpp \
!       gradient.cpp
  
  EXTRA_DIST =
--- 12,17 ----
        pgpoint.cpp \
        drawtile.cpp \
!       gradient.cpp \
!       glSDL.c
  
  EXTRA_DIST =

Index: drawline.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/drawline.cpp,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** drawline.cpp        15 Apr 2002 13:35:35 -0000      1.3
--- drawline.cpp        18 Jun 2002 22:40:38 -0000      1.3.2.1
***************
*** 30,35 ****
  
  #include "pgdraw.h"
  
! void plotpixel(SDL_Surface* surface, Uint32 x, Uint32 y, const SDL_Color& c, 
Uint8 width, int *pixelflag) {
        Uint32 xp, yp, xf, yf;
        static Uint32 oldx, oldy;
--- 30,38 ----
  
  #include "pgdraw.h"
+ #include "drawpriv.hh"
  
! namespace PG_Draw {
! 
! void plotpixel(PG_DrawableSurface* surface, Uint32 x, Uint32 y, const 
SDL_Color& c, Uint8 width, int *pixelflag) {
        Uint32 xp, yp, xf, yf;
        static Uint32 oldx, oldy;
***************
*** 40,44 ****
        //      width=1? Only need to draw 1 pixel
        if(width==1) {
!               PG_Draw::SetPixel(x, y, c.r, c.g, c.b, surface);
        } else {
  
--- 43,47 ----
        //      width=1? Only need to draw 1 pixel
        if(width==1) {
!               surface->SetPixel(x, y, c);
        } else {
  
***************
*** 55,59 ****
                        for (xf=0; xf<width; xf++) {
                                for (yf=0; yf<width; yf++) {
!                                       PG_Draw::SetPixel(xf+xp, yf+yp, c.r, 
c.g, c.b, surface);
                                }
                        }
--- 58,62 ----
                        for (xf=0; xf<width; xf++) {
                                for (yf=0; yf<width; yf++) {
!                                       surface->SetPixel(xf+xp, yf+yp, c);
                                }
                        }
***************
*** 68,72 ****
                                //      only need to draw the bottom pixels
                                for (xf=0; xf<width; xf++) {
!                                       PG_Draw::SetPixel(xf+xp, 
yp-1+(width-1), c.r, c.g, c.b, surface);
                                }
                        }
--- 71,75 ----
                                //      only need to draw the bottom pixels
                                for (xf=0; xf<width; xf++) {
!                                       surface->SetPixel(xf+xp, 
yp-1+(width-1), c);
                                }
                        }
***************
*** 76,80 ****
                                //      only need to draw the most right pixels
                                for (yf=0; yf<width; yf++) {
!                                       PG_Draw::SetPixel(xp-1+(width-1), 
yp+yf, c.r, c.g, c.b, surface);
                                }
                        }
--- 79,83 ----
                                //      only need to draw the most right pixels
                                for (yf=0; yf<width; yf++) {
!                                       surface->SetPixel(xp-1+(width-1), 
yp+yf, c);
                                }
                        }
***************
*** 85,89 ****
                                //      only need to draw the most left pixels
                                for (yf=0; yf<width; yf++) {
!                                       PG_Draw::SetPixel(xp+1, yp+yf, c.r, 
c.g, c.b, surface);
                                }
                        }
--- 88,92 ----
                                //      only need to draw the most left pixels
                                for (yf=0; yf<width; yf++) {
!                                       surface->SetPixel(xp+1, yp+yf, c);
                                }
                        }
***************
*** 96,100 ****
  }
  
! void octant0(SDL_Surface* surface, Uint32 x0, Uint32 y0, Uint32 deltax, 
Uint32 deltay,
               int xdirection, const SDL_Color& color, Uint8 width, int 
pixelflag)
  {
--- 99,103 ----
  }
  
! void octant0(PG_DrawableSurface* surface, Uint32 x0, Uint32 y0, Uint32 
deltax, Uint32 deltay,
               int xdirection, const SDL_Color& color, Uint8 width, int 
pixelflag)
  {
***************
*** 131,135 ****
  } /* end of the function */
  
! void octant1(SDL_Surface* surface, Uint32 x0, Uint32 y0, Uint32 deltax, 
Uint32 deltay,
               int xdirection, const SDL_Color& color, Uint8 width, int 
pixelflag)
  {
--- 134,138 ----
  } /* end of the function */
  
! void octant1(PG_DrawableSurface* surface, Uint32 x0, Uint32 y0, Uint32 
deltax, Uint32 deltay,
               int xdirection, const SDL_Color& color, Uint8 width, int 
pixelflag)
  {
***************
*** 167,171 ****
  } /* end of the function */
  
! void PG_Draw::DrawLine(SDL_Surface* surface, Uint32 x0, Uint32 y0, Uint32 x1, 
Uint32 y1, const SDL_Color& color, Uint8 width) {
        int deltax;
        int deltay;
--- 170,174 ----
  } /* end of the function */
  
! void __DrawLine(PG_DrawableSurface* surface, Uint32 x0, Uint32 y0, Uint32 x1, 
Uint32 y1, const SDL_Color& color, Uint8 width) {
        int deltax;
        int deltay;
***************
*** 213,214 ****
--- 216,227 ----
  
  } /* end of the function */
+ 
+ 
+ void PG_DrawableSurface::DrawLine(Uint32 x0, Uint32 y0,
+                                          Uint32 x1, Uint32 y1,
+                                          const SDL_Color& color,
+                                          Uint8 width = 1) {
+   __DrawLine(this, x0,y0,x1,y1,color,width);
+ };
+ 
+ }; /* namespace PG_Draw */

Index: drawtile.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/drawtile.cpp,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** drawtile.cpp        15 Apr 2002 13:35:35 -0000      1.3
--- drawtile.cpp        18 Jun 2002 22:40:38 -0000      1.3.2.1
***************
*** 30,33 ****
--- 30,79 ----
  
  #include "pgdraw.h"
+ #include "drawpriv.hh"
+ 
+ #if 1
+ void PG_Draw::PG_DrawableSurface::DrawTile(const PG_Rect& refv,
+                                          const PG_Rect& drawrect,
+                                          PG_DrawableSurface* tilemap) {
+   /* fprintf(stderr, "%s:%s:%i\n", __FILE__, __FUNCTION__, __LINE__); */
+   PG_Point index1;
+   PG_Point index2;
+   PG_Rect oldclip;
+   
+   if (!tilemap)
+     return;
+   
+   if (!tilemap->ref->w || !tilemap->ref->h || !ref->w || !ref->h)
+     return;
+   
+   int dx = abs(drawrect.x - refv.x);
+   int dy = abs(drawrect.y - refv.y);
+   
+   index1.x = dx / tilemap->ref->w;
+   index1.y = dy / tilemap->ref->h;
+   
+   index2.x = (dx + drawrect.w + tilemap->ref->w - 1) / tilemap->ref->w;
+   index2.y = (dy + drawrect.h + tilemap->ref->h - 1) / tilemap->ref->h;
+   
+   GetClipRect(oldclip);
+   SetClipRect(drawrect);
+   
+   PG_Rect src(0,0, tilemap->ref->w, tilemap->ref->h);
+   PG_Rect dst = src;
+   
+   for(int y = index1.y; y < index2.y; y++) {
+     for(int x = index1.x; x < index2.x; x++) {
+       
+       dst.x = refv.x + x * tilemap->ref->w;
+       dst.y = refv.y + y * tilemap->ref->h;
+ 
+       BlitSurface(tilemap, src, dst);
+     }
+   }
+   
+   SetClipRect(oldclip);
+ };
+ 
+ #else
  
  void PG_Draw::DrawTile(SDL_Surface* surface, const PG_Rect& ref, const 
PG_Rect& drawrect, SDL_Surface* tilemap) {
***************
*** 63,67 ****
                        dst.y = ref.y + y * tilemap->h;
  
!                       PG_Draw::BlitSurface(tilemap, src, surface, dst);
                }
        }
--- 109,113 ----
                        dst.y = ref.y + y * tilemap->h;
  
!                       ::PG_Draw::BlitSurface(tilemap, src, surface, dst);
                }
        }
***************
*** 69,70 ****
--- 115,123 ----
        SDL_SetClipRect(surface, (SDL_Rect*)&oldclip);
  }
+ 
+ void PG_Draw::PG_DrawableSurface::DrawTile(const PG_Rect& refv,
+                                          const PG_Rect& drawrect,
+                                          PG_DrawableSurface* tilemap) {
+   ::PG_Draw::DrawTile(this->ref, refv, drawrect, tilemap->ref);
+ };
+ #endif

Index: gradient.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/gradient.cpp,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** gradient.cpp        15 Apr 2002 13:35:35 -0000      1.3
--- gradient.cpp        18 Jun 2002 22:40:38 -0000      1.3.2.1
***************
*** 33,37 ****
  
  #include "pgdraw.h"
! SDL_Surface* PG_Draw::CreateGradient(const PG_Rect& r, PG_Gradient& gradient) 
{
        return CreateGradient(
                   r,
--- 33,41 ----
  
  #include "pgdraw.h"
! #include "drawpriv.hh"
! 
! namespace PG_Draw {
! 
! PG_DrawableSurface* CreateGradient(const PG_Rect& r, PG_Gradient& gradient) {
        return CreateGradient(
                   r,
***************
*** 42,70 ****
  }
  
! SDL_Surface* PG_Draw::CreateGradient(const PG_Rect& r, SDL_Color & ul, 
SDL_Color & ur, SDL_Color & dl, SDL_Color & dr) {
!       SDL_Surface* screen = SDL_GetVideoSurface();
! 
        assert(screen);
! 
!       SDL_Surface *grd = PG_Draw::CreateRGBSurface(r.w, r.h);
  
        r.my_xpos = 0;
        r.my_ypos = 0;
!       PG_Draw::DrawGradient(grd, r, ul, ur, dl, dr);
  
        return grd;
  }
  
! void PG_Draw::DrawGradient(SDL_Surface* surface, const PG_Rect& r, 
PG_Gradient& gradient) {
!       PG_Draw::DrawGradient(
!           surface,
!           r,
!           gradient.colors[0],
!           gradient.colors[1],
!           gradient.colors[2],
!           gradient.colors[3]);
  }
  
! void PG_Draw::DrawGradient(SDL_Surface * surface, const PG_Rect& rect, const 
SDL_Color & ul, const SDL_Color & ur, const SDL_Color & dl, const SDL_Color & 
dr) {
        Sint32 v00,v01,v02;
        Sint32 v10,v11,v12;
--- 46,77 ----
  }
  
! PG_DrawableSurface* CreateGradient(const PG_Rect& r, SDL_Color & ul, 
SDL_Color & ur, SDL_Color & dl, SDL_Color & dr) {
! #if 0
!         SDL_Surface* screen = SDL_GetVideoSurface();
        assert(screen);
! #endif
!       PG_Draw* draw = PG_Draw::GetDefaultDrawable();
!       PG_DrawableSurface *grd = draw->CreateDrawableSurface(r.w, r.h);
!         // CreateRGBSurface(r.w, r.h);
  
        r.my_xpos = 0;
        r.my_ypos = 0;
!       // DrawGradient(grd, r, ul, ur, dl, dr);
!       grd->DrawGradient(r, ul, ur, dl, dr);
  
        return grd;
  }
  
! void DrawGradient(PG_DrawableSurface* surface, const PG_Rect& r, PG_Gradient& 
gradient) {
!   DrawGradient(
!                         surface,
!                         r,
!                         gradient.colors[0],
!                         gradient.colors[1],
!                         gradient.colors[2],
!                         gradient.colors[3]);
  }
  
! void DrawGradient(PG_DrawableSurface* surface, const PG_Rect& rect, const 
SDL_Color & ul, const SDL_Color & ur, const SDL_Color & dl, const SDL_Color & 
dr) {
        Sint32 v00,v01,v02;
        Sint32 v10,v11,v12;
***************
*** 79,98 ****
              return;
  
!     if (w > surface->w || h > surface->h)
              return;
  
!       Uint32 c1 = SDL_MapRGB(surface->format, ul.r, ul.g, ul.b);
!       Uint32 c2 = SDL_MapRGB(surface->format, ur.r, ur.g, ur.b);
!       Uint32 c3 = SDL_MapRGB(surface->format, dl.r, dl.g, dl.b);
!       Uint32 c4 = SDL_MapRGB(surface->format, dr.r, dr.g, dr.b);
  
        // solid color gradient ?
        if((c1 == c2) && (c2 == c3) && (c3 == c4)) {
!               SDL_FillRect(surface, (PG_Rect*)&rect, c1);
                return;
        }
  
        PG_Rect clip;
!       SDL_GetClipRect(surface, &clip);
        PG_Rect drawrect = rect.IntersectRect(clip);
  
--- 86,105 ----
              return;
  
!     if (w > surface->getScreen()->w || h > surface->getScreen()->h)
              return;
  
!       Uint32 c1 = SDL_MapRGB(surface->getScreen()->format, ul.r, ul.g, ul.b);
!       Uint32 c2 = SDL_MapRGB(surface->getScreen()->format, ur.r, ur.g, ur.b);
!       Uint32 c3 = SDL_MapRGB(surface->getScreen()->format, dl.r, dl.g, dl.b);
!       Uint32 c4 = SDL_MapRGB(surface->getScreen()->format, dr.r, dr.g, dr.b);
  
        // solid color gradient ?
        if((c1 == c2) && (c2 == c3) && (c3 == c4)) {
!               surface->FillRect(rect, c1);
                return;
        }
  
        PG_Rect clip;
!       surface->GetClipRect(clip);
        PG_Rect drawrect = rect.IntersectRect(clip);
  
***************
*** 134,138 ****
        b2 += v12 * ox;
  
!       SDL_PixelFormat* format = surface->format;
        Uint8 Rloss = 8+format->Rloss;
        Uint8 Gloss = 8+format->Gloss;
--- 141,145 ----
        b2 += v12 * ox;
  
!       SDL_PixelFormat* format = surface->getScreen()->format;
        Uint8 Rloss = 8+format->Rloss;
        Uint8 Gloss = 8+format->Gloss;
***************
*** 144,149 ****
  
        Uint8 bpp = format->BytesPerPixel;
!       Uint32 pitch = surface->pitch;
!       Uint8* bits = ((Uint8 *) surface->pixels) + (rect.y + oy)* pitch + 
(rect.x + ox)* bpp;
        Uint32 y_pitch = pitch*drawrect.h - bpp;
        register Uint32 pixel = 0;
--- 151,156 ----
  
        Uint8 bpp = format->BytesPerPixel;
!       Uint32 pitch = surface->getScreen()->pitch;
!       Uint8* bits = ((Uint8 *) surface->getScreen()->pixels) + (rect.y + oy)* 
pitch + (rect.x + ox)* bpp;
        Uint32 y_pitch = pitch*drawrect.h - bpp;
        register Uint32 pixel = 0;
***************
*** 165,169 ****
  
                        if ( bpp == 1 )
!                               pixel = SDL_MapRGB ( surface->format, r>>8, 
g>>8, b>>8 );
                        else
                                pixel =  (r>>Rloss) << Rshift
--- 172,176 ----
  
                        if ( bpp == 1 )
!                               pixel = SDL_MapRGB ( 
surface->getScreen()->format, r>>8, g>>8, b>>8 );
                        else
                                pixel =  (r>>Rloss) << Rshift
***************
*** 183,192 ****
  
                                case 3: {                       /* 
Format/endian independent */
!                                               Uint8 ri = (pixel >> 
surface->format->Rshift) & 0xFF;
!                                               Uint8 gi = (pixel >> 
surface->format->Gshift) & 0xFF;
!                                               Uint8 bi = (pixel >> 
surface->format->Bshift) & 0xFF;
!                                               *((bits) + 
surface->format->Rshift / 8) = ri;
!                                               *((bits) + 
surface->format->Gshift / 8) = gi;
!                                               *((bits) + 
surface->format->Bshift / 8) = bi;
                                        }
                                        break;
--- 190,199 ----
  
                                case 3: {                       /* 
Format/endian independent */
!                                               Uint8 ri = (pixel >> 
surface->getScreen()->format->Rshift) & 0xFF;
!                                               Uint8 gi = (pixel >> 
surface->getScreen()->format->Gshift) & 0xFF;
!                                               Uint8 bi = (pixel >> 
surface->getScreen()->format->Bshift) & 0xFF;
!                                               *((bits) + 
surface->getScreen()->format->Rshift / 8) = ri;
!                                               *((bits) + 
surface->getScreen()->format->Gshift / 8) = gi;
!                                               *((bits) + 
surface->getScreen()->format->Bshift / 8) = bi;
                                        }
                                        break;
***************
*** 216,217 ****
--- 223,226 ----
  
  }
+ 
+ } /* namespace PG_Draw */

Index: rotozoom.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/rotozoom.cpp,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** rotozoom.cpp        15 Apr 2002 13:35:35 -0000      1.3
--- rotozoom.cpp        18 Jun 2002 22:40:38 -0000      1.3.2.1
***************
*** 35,38 ****
--- 35,39 ----
  #include "paragui.h"
  #include "pgdraw.h"
+ #include "drawpriv.hh"
  
  #define MAX(a,b)    (((a) > (b)) ? (a) : (b))
***************
*** 55,59 ****
  // 32bit Zoomer with optional anti-aliasing by bilinear interpolation.
  // Zoomes 32bit RGBA/ABGR 'src' surface to 'dst' surface.
[...983 lines suppressed...]
  
  
  /*
--- 741,756 ----
  }
  
! void BlitScale(PG_DrawableSurface *src, PG_DrawableSurface *dst, bool smooth) 
{
!       PG_DrawableSurface *tmp =
!               ScaleSurface(src,
!                            static_cast<double>(dst->getScreen()->w) / 
src->getScreen()->w,
!                            static_cast<double>(dst->getScreen()->h) / 
src->getScreen()->h,
!                            smooth);
!       PG_Rect emptyrect;
!       dst->BlitSurface(tmp, emptyrect, emptyrect);
!       delete tmp; // SDL_FreeSurface(tmp);
  }
  
+ }; /* namespace PG_Draw */
  
  /*

Index: setpixel.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/setpixel.cpp,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** setpixel.cpp        15 Apr 2002 13:35:35 -0000      1.3
--- setpixel.cpp        18 Jun 2002 22:40:38 -0000      1.3.2.1
***************
*** 30,35 ****
  
  #include "pgdraw.h"
  
! void PG_Draw::SetPixel(int x, int y, Uint8 r, Uint8 g, Uint8 b, SDL_Surface * 
surface) {
        static Uint8 old_r = 0;
        static Uint8 old_g = 0;
--- 30,38 ----
  
  #include "pgdraw.h"
+ #include "drawpriv.hh"
  
! namespace PG_Draw {
! 
! static void __SetPixel(int x, int y, Uint8 r, Uint8 g, Uint8 b, 
PG_DrawableSurface* surface) {
        static Uint8 old_r = 0;
        static Uint8 old_g = 0;
***************
*** 41,46 ****
        static Uint8 bpp;
  
!       static SDL_Rect rect;
!       SDL_GetClipRect(surface, &rect);
  
        if((x < rect.x) || (y < rect.y)) {
--- 44,52 ----
        static Uint8 bpp;
  
!       static PG_Rect rect;
!       static SDL_PixelFormat* format;
!       format = surface->getScreen()->format;
! 
!       surface->GetClipRect(rect);
  
        if((x < rect.x) || (y < rect.y)) {
***************
*** 52,60 ****
        }
  
!       bpp = surface->format->BytesPerPixel;
!       bits = ((Uint8 *) surface->pixels) + y * surface->pitch + x * bpp;
  
        if(!((old_r==r) && (old_g==g) && (old_b==b))) {
!               pixel = SDL_MapRGB(surface->format, r, g, b);
                old_r = r;
                old_g = g;
--- 58,66 ----
        }
  
!       bpp = format->BytesPerPixel;
!       bits = ((Uint8 *) surface->getScreen()->pixels) + y * 
surface->getScreen()->pitch + x * bpp;
  
        if(!((old_r==r) && (old_g==g) && (old_b==b))) {
!               pixel = SDL_MapRGB(format, r, g, b);
                old_r = r;
                old_g = g;
***************
*** 73,82 ****
  
                case 3: {                       /* Format/endian independent */
!                               ri = (pixel >> surface->format->Rshift) & 0xFF;
!                               gi = (pixel >> surface->format->Gshift) & 0xFF;
!                               bi = (pixel >> surface->format->Bshift) & 0xFF;
!                               *((bits) + surface->format->Rshift / 8) = ri;
!                               *((bits) + surface->format->Gshift / 8) = gi;
!                               *((bits) + surface->format->Bshift / 8) = bi;
                        }
                        break;
--- 79,88 ----
  
                case 3: {                       /* Format/endian independent */
!                               ri = (pixel >> format->Rshift) & 0xFF;
!                               gi = (pixel >> format->Gshift) & 0xFF;
!                               bi = (pixel >> format->Bshift) & 0xFF;
!                               *((bits) + format->Rshift / 8) = ri;
!                               *((bits) + format->Gshift / 8) = gi;
!                               *((bits) + format->Bshift / 8) = bi;
                        }
                        break;
***************
*** 87,88 ****
--- 93,100 ----
        }
  }
+ 
+ void PG_DrawableSurface::SetPixel(int x, int y, const SDL_Color& color) {
+   __SetPixel(x, y, color.r, color.g, color.b, this);
+ };
+ 
+ }; /* namespace PG_Draw */

Index: stretch.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/stretch.cpp,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** stretch.cpp 15 Apr 2002 13:35:35 -0000      1.3
--- stretch.cpp 18 Jun 2002 22:40:38 -0000      1.3.2.1
***************
*** 33,36 ****
--- 33,44 ----
  
  #include "pgdraw.h"
+ #include "drawpriv.hh"
+ 
+ namespace PG_Draw {
+ DECLSPEC void RectStretch(SDL_Surface* src_surface, int xs1, int ys1, int 
xs2, int ys2, SDL_Surface* dst_surface, int xd1, int yd1, int xd2, int yd2, 
Uint32* voiLUT);
+ DECLSPEC void CreateFilterLUT();
+ DECLSPEC void PG_SmoothFast(SDL_Surface* src, SDL_Surface* dst);
+ DECLSPEC void InterpolatePixel(SDL_Surface* src, SDL_Surface* dest);
+ };
  
  #if ! defined( macintosh ) && ! defined( __MWERKS__ )
***************
*** 637,640 ****
--- 645,649 ----
  }
  
+ #if 0
  SDL_Surface* PG_CopyRect(SDL_Surface* s, int x, int y, int w, int h) {
        SDL_Surface* image = new_image(w, h);
***************
*** 649,652 ****
--- 658,662 ----
        return image;
  }
+ #endif
  
  

Index: surface.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/surface.cpp,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** surface.cpp 15 Apr 2002 13:35:35 -0000      1.3
--- surface.cpp 18 Jun 2002 22:40:38 -0000      1.3.2.1
***************
*** 30,309 ****
  
  #include "pgdraw.h"
  
! SDL_Surface* PG_Draw::CreateRGBSurface(Uint16 w, Uint16 h, int flags) {
!       SDL_Surface* screen = SDL_GetVideoSurface();
! 
!       return SDL_CreateRGBSurface (
!                               flags,
!                               w, h,
!                               screen->format->BitsPerPixel,
!                               screen->format->Rmask,
!                               screen->format->Gmask,
!                               screen->format->Bmask,
!                               0);
  }
  
! void PG_Draw::DrawThemedSurface(SDL_Surface* surface, const PG_Rect& r, 
PG_Gradient* gradient,
!                                       SDL_Surface* background, int bkmode, 
Uint8 blend) {
!       static PG_Rect srcrect;
!       static PG_Rect dstrect;
!       int x,y,i;
!       bool bColorKey = false;
!       Uint32 uColorKey;
!       Uint32 c;
!               
!       // check if we have anything to do
!       if(!gradient && !background) {
!               return;
!       }
! 
!       if (!r.h || !r.w)
!               return;
! 
!       // draw the gradient first
!       if((background == NULL) || (background && (blend > 0))) {
!               if(gradient != NULL) {
!                       DrawGradient(surface, r, *gradient);
!               }
!       }
! 
!       if(!background)
!               return;
        
!       if (!background->w || !background->h)
!             return;
! 
!       int yc;
!       int xc;
!       SDL_Surface* temp;
!       int w,h;
! 
!       bColorKey = (background->flags & SDL_SRCCOLORKEY);
!       Uint8 rc,gc,bc;
        
!       SDL_GetRGB(background->format->colorkey, background->format, &rc, &gc, 
&bc);
!       uColorKey = (rc << 16) | (gc << 8) | bc;
        
!       if(((gradient == NULL) || (blend == 0)) && bColorKey) {
!               SDL_SetColorKey(background, 0, 0);
        }
        
!       switch(bkmode) {
! 
!               //
!               // BKMODE_TILE
!               //
! 
!               case BKMODE_TILE:
!                       // tile the background image over the r in surface
!                       dstrect = r;
! 
!                       srcrect.SetRect(0, 0, background->w, background->h);
! 
!                       yc = (r.my_height / background->h) +1;
!                       xc = (r.my_width / background->w) +1;
! 
!                       for(y=0; y<yc; y++) {
!                               for(x=0; x<xc; x++) {
! 
!                                       dstrect.SetRect(
!                                           r.my_xpos + background->w * x,
!                                           r.my_ypos + background->h * y,
!                                           background->w,
!                                           background->h);
! 
!                                       srcrect.my_width = background->w;
!                                       srcrect.my_height = background->h;
! 
!                                       if((dstrect.my_xpos + dstrect.my_width 
-1) > r.my_width) {
!                                               dstrect.my_width = r.my_width - 
dstrect.my_xpos;
!                                       }
! 
!                                       if((dstrect.my_ypos + dstrect.my_height 
-1) > r.my_height) {
!                                               dstrect.my_height = r.my_height 
- dstrect.my_ypos;
!                                       }
! 
!                                       srcrect.my_width = dstrect.my_width;
!                                       srcrect.my_height = dstrect.my_height;
!       
!                                       if(blend > 0) {
!                                               SDL_SetAlpha(background, 
SDL_SRCALPHA, 255-blend);
!                                       } else {
!                                               SDL_SetAlpha(background, 0, 0);
!                                       }
!                                       PG_Draw::BlitSurface(background, 
srcrect, surface, dstrect);
!                               }
!                       }
!                       break;
! 
!               //
!               // BKMODE_STRETCH
!               //
! 
!               case BKMODE_STRETCH:
!                       // stretch the background to fit the surface
! 
!                       // Scale the background to fit this widget, using
!                       // anti-aliasing
!                       temp = PG_Draw::ScaleSurface(background, r);
! 
!                       // set per surface alpha
!                       if(blend > 0) {
!                               SDL_SetAlpha(temp, SDL_SRCALPHA, 255-blend);
!                       } else {
!                               SDL_SetAlpha(temp, 0, 0);
!                       }
! 
!                       // blit it
!                       SDL_BlitSurface(temp, NULL, surface, (PG_Rect*)&r);
! 
!                       // free the temp surface
!                       SDL_FreeSurface(temp);
!                       break;
! 
!               //
!               // BKMODE_3TILEH
!               //
! 
!               case BKMODE_3TILEH:
!                       // source rectangles
!                       h = r.h;
!                       w = (int)( ( (double)h / (double)background->h) * 
(double)background->w );
!                       srcrect.SetRect(0,0,w,h);
!                       w /= 3;
! 
!             if (!w)
!                     break;
! 
!                       // rescale surface
! 
!                       if(h == background->h) {
!                               temp = background;
!                       }
!                       else {
!                               temp = PG_Draw::ScaleSurface(background, 
srcrect);
!                       }
! 
!                       // set per surface alpha
!                       if(blend > 0) {
!                               SDL_SetAlpha(temp, SDL_SRCALPHA, 255-blend);
!                       } else {
!                               SDL_SetAlpha(temp, 0, 0);
!                       }
! 
!                       // blit part 1 (left)
! 
!                       SDL_SetClipRect(surface, NULL);
!                       dstrect.SetRect(r.x,r.y,w,h);
!                       srcrect.SetRect(0, 0, w, h);
!                       PG_Draw::BlitSurface(temp, srcrect, surface, dstrect);
! 
!                       // blit part 2 (middle)
! 
!                       // set cliprect
!                       dstrect.SetRect(r.x+w, r.y, r.w-w*2, h);
!                       SDL_SetClipRect(surface, &dstrect);
! 
!                       // blit it
!                       srcrect.SetRect(w, 0, w, h);
!                       for(i = 1; i<(r.w/w); i++) {
!                               dstrect.SetRect(r.x+w*i, r.y, w, h);
!                               PG_Draw::BlitSurface(temp, srcrect, surface, 
dstrect);
!                       }
!                       SDL_SetClipRect(surface, NULL);
! 
!                       // blit part 3 (right)
! 
!                       dstrect.SetRect(r.x+r.w-w, r.y,w,h);
!                       srcrect.SetRect(w*2, 0, w, h);
!                       PG_Draw::BlitSurface(temp, srcrect, surface, dstrect);
! 
!                       // free temp surface
!                       if(h != background->h) {
!                               SDL_FreeSurface(temp);
!                       }
! 
!                       break;
! 
!               //
!               // BKMODE_3TILEV
!               //
! 
!               case BKMODE_3TILEV:
!                       // source rectangles
!                       w = r.w;
!                       h = (int)( ( (double)w / (double)background->w) * 
(double)background->h );
!                       srcrect.SetRect(0,0,w,h);
!                       h /= 3;
! 
!             if (!h)
!                     break;
! 
!                       // rescale surface
! 
!                       if(w == background->w) {
!                               temp = background;
!                       }
!                       else {
!                               temp = PG_Draw::ScaleSurface(background, 
srcrect);
!                       }
! 
!                       // set per surface alpha
!                       if(blend > 0) {
!                               SDL_SetAlpha(temp, SDL_SRCALPHA, 255-blend);
!                       } else {
!                               SDL_SetAlpha(temp, 0, 0);
!                       }
! 
!                       // blit part 1 (top)
! 
!                       SDL_SetClipRect(surface, NULL);
!                       dstrect.SetRect(r.x,r.y,w,h);
!                       srcrect.SetRect(0, 0, w, h);
!                       PG_Draw::BlitSurface(temp, srcrect, surface, dstrect);
! 
!                       // blit part 2 (middle)
! 
!                       // set cliprect
!                       dstrect.SetRect(r.x,r.y+h,w,r.h-h*2);
!                       SDL_SetClipRect(surface, &dstrect);
! 
!                       // blit it
!                       srcrect.SetRect(0, h, w, h);
!                       for(i = 1; i<(r.h/h); i++) {
!                               dstrect.SetRect(r.x, r.y+h*i, w, h);
!                               PG_Draw::BlitSurface(temp, srcrect, surface, 
dstrect);
!                       }
!                       SDL_SetClipRect(surface, NULL);
! 
!                       // blit part 3 (bottom)
! 
!                       dstrect.SetRect(r.x,r.y+r.h-h,w,h);
!                       srcrect.SetRect(0, h*2, w, h);
!                       PG_Draw::BlitSurface(temp, srcrect, surface, dstrect);
! 
!                       // free temp surface
!                       if(w != background->w) {
!                               SDL_FreeSurface(temp);
!                       }
! 
!                       break;
! 
        }
! 
!       if(((gradient == NULL) || (blend == 0)) && bColorKey) {
!               c = SDL_MapRGB(
!                       background->format,
!                       (uColorKey>>16) & 0xFF,
!                       (uColorKey>>8) & 0xFF,
!                       uColorKey & 0xFF);
!               SDL_SetColorKey(background, SDL_SRCCOLORKEY, c);
!               
!               c = SDL_MapRGB(
!                       surface->format,
!                       (uColorKey>>16) & 0xFF,
!                       (uColorKey>>8) & 0xFF,
!                       uColorKey & 0xFF);
!               SDL_SetColorKey(surface, SDL_SRCCOLORKEY, c);
        }
! }
--- 30,318 ----
  
  #include "pgdraw.h"
+ #include "drawpriv.hh"
  
! namespace PG_Draw {
! #if 0
! PG_DrawableSurface* CreateRGBSurface(Uint16 w, Uint16 h, int flags) {
!   PG_Draw* draw = PG_Draw::GetDefaultDrawable();
!   PG_DrawableSurface* screen;
!   screen = draw->GetVideoSurface();
! 
!   return draw->CreateDrawableSurface(flags,w,h,
!                                    screen->ref->format->BitsPerPixel,
!                                    screen->ref->format->Rmask,
!                                    screen->ref->format->Gmask,
!                                    screen->ref->format->Bmask,
!                                    0);
  }
+ #endif
  
! void PG_DrawableSurface::DrawThemedSurface(const PG_Rect& r,
!                                          PG_Gradient* gradient,
!                                          PG_DrawableSurface* background, 
!                                          int bkmode, Uint8 blend) {
!   static PG_Rect srcrect;
!   static PG_Rect dstrect;
!   int x,y,i;
!   bool bColorKey = false;
!   Uint32 uColorKey;
!   Uint32 c;
!   // fprintf(stderr, "%s:%s:%i\n", __FILE__, __FUNCTION__, __LINE__);
!   
!   // check if we have anything to do
!   if(!gradient && !background) {
!     return;
!   }
!   
!   if (!r.h || !r.w)
!     return;
!   
!   // draw the gradient first
!   if((background == NULL) || (background && (blend > 0))) {
!     if(gradient != NULL) {
!       this->DrawGradient(r, *gradient);
!     }
!   }
!   
!   if(!background)
!     return;
!   
!   if (!background->ref->w || !background->ref->h)
!     return;
!   
!   int yc;
!   int xc;
!   PG_DrawableSurface* temp;
!   int w,h;
!   
!   bColorKey = (background->ref->flags & SDL_SRCCOLORKEY);
!   Uint8 rc,gc,bc;
!   
!   SDL_GetRGB(background->ref->format->colorkey, background->ref->format, &rc, 
&gc, &bc);
!   uColorKey = (rc << 16) | (gc << 8) | bc;
!   
!   if(((gradient == NULL) || (blend == 0)) && bColorKey) {
!     background->SetColorKey(0, 0);
!   }
!   
!   switch(bkmode) {
!     //
!     // BKMODE_TILE
!     //
!   case BKMODE_TILE: {
!     // tile the background image over the r in surface
!     dstrect = r;
!     
!     srcrect.SetRect(0, 0, background->ref->w, background->ref->h);
!     
!     yc = (r.my_height / background->ref->h) +1;
!     xc = (r.my_width / background->ref->w) +1;
!     
!     for(y=0; y<yc; y++) {
!       for(x=0; x<xc; x++) {
        
!       dstrect.SetRect(
!                       r.my_xpos + background->ref->w * x,
!                       r.my_ypos + background->ref->h * y,
!                       background->ref->w,
!                       background->ref->h);
        
!       srcrect.my_width = background->ref->w;
!       srcrect.my_height = background->ref->h;
        
!       if((dstrect.my_xpos + dstrect.my_width -1) > r.my_width) {
!         dstrect.my_width = r.my_width - dstrect.my_xpos;
        }
        
!       if((dstrect.my_ypos + dstrect.my_height -1) > r.my_height) {
!         dstrect.my_height = r.my_height - dstrect.my_ypos;
        }
!       
!       srcrect.my_width = dstrect.my_width;
!       srcrect.my_height = dstrect.my_height;
!       
!       if(blend > 0) {
!         background->SetAlpha(SDL_SRCALPHA, 255-blend);
!       } else {
!         background->SetAlpha(0, 0);
        }
!       this->BlitSurface(background, srcrect, dstrect);
!       }
!     }
!     break;
!   } /* BKMODE_TILE */
!     
!     //
!     // BKMODE_STRETCH
!     //
!   case BKMODE_STRETCH: {
!     // stretch the background to fit the surface
!     
!     // Scale the background to fit this widget, using
!     // anti-aliasing
!     temp = background->ScaleSurface(r);
!     
!     // set per surface alpha
!     if(blend > 0) {
!       temp->SetAlpha(SDL_SRCALPHA, 255-blend);
!     } else {
!       temp->SetAlpha(0, 0);
!     }
!     
!     // blit it
!     PG_Rect emptyrect;
!     this->BlitSurface(temp, emptyrect, r);
!     
!     // free the temp surface
!     delete temp; // SDL_FreeSurface(temp);
!     break;
!   } /* BKMODE_STRETCH */
!     
!     //
!     // BKMODE_3TILEH
!     //
!   case BKMODE_3TILEH: {
!     // source rectangles
!     h = r.h;
!     w = (int)( ( (double)h / (double)background->ref->h) * 
(double)background->ref->w );
!     srcrect.SetRect(0,0,w,h);
!     w /= 3;
!     
!     if (!w)
!       break;
!     
!     // rescale surface
!     
!     if(h == background->ref->h) {
!       temp = background;
!     }
!     else {
!       temp = background->ScaleSurface(srcrect);
!     }
!     
!     // set per surface alpha
!     if(blend > 0) {
!       temp->SetAlpha(SDL_SRCALPHA, 255-blend);
!     } else {
!       temp->SetAlpha(0, 0);
!     }
!     
!     // blit part 1 (left)
!     
!     PG_Rect emptyrect;
!     this->SetClipRect(emptyrect);
!     dstrect.SetRect(r.x,r.y,w,h);
!     srcrect.SetRect(0, 0, w, h);
!     this->BlitSurface(temp, srcrect, dstrect);
!     
!     // blit part 2 (middle)
!     
!     // set cliprect
!     dstrect.SetRect(r.x+w, r.y, r.w-w*2, h);
!     this->SetClipRect(dstrect);
!     
!     // blit it
!     srcrect.SetRect(w, 0, w, h);
!     for(i = 1; i<(r.w/w); i++) {
!       dstrect.SetRect(r.x+w*i, r.y, w, h);
!       this->BlitSurface(temp, srcrect, dstrect);
!     }
!     this->SetClipRect(emptyrect);
!     
!     // blit part 3 (right)
!     
!     dstrect.SetRect(r.x+r.w-w, r.y,w,h);
!     srcrect.SetRect(w*2, 0, w, h);
!     this->BlitSurface(temp, srcrect, dstrect);
!     
!     // free temp surface
!     if(h != background->ref->h) {
!       delete temp; // SDL_FreeSurface(temp);
!     }
!     
!     break;
!   } /* BKMODE_3TILEH */
!     
!     //
!     // BKMODE_3TILEV
!     //
!   case BKMODE_3TILEV: {
!     // source rectangles
!     w = r.w;
!     h = (int)( ( (double)w / (double)background->ref->w) * 
(double)background->ref->h );
!     srcrect.SetRect(0,0,w,h);
!     h /= 3;
!     
!     if (!h)
!       break;
!     
!     // rescale surface
!     
!     if(w == background->ref->w) {
!       temp = background;
!     }
!     else {
!       temp = background->ScaleSurface(srcrect);
!     }
!     
!     // set per surface alpha
!     if(blend > 0) {
!       temp->SetAlpha(SDL_SRCALPHA, 255-blend);
!     } else {
!       temp->SetAlpha(0, 0);
!     }
!     
!     // blit part 1 (top)
!     
!     PG_Rect emptyrect;
!     this->SetClipRect(emptyrect);
!     dstrect.SetRect(r.x,r.y,w,h);
!     srcrect.SetRect(0, 0, w, h);
!     this->BlitSurface(temp, srcrect, dstrect);
!     
!     // blit part 2 (middle)
!     
!     // set cliprect
!     dstrect.SetRect(r.x,r.y+h,w,r.h-h*2);
!     this->SetClipRect(dstrect);
!     
!     // blit it
!     srcrect.SetRect(0, h, w, h);
!     for(i = 1; i<(r.h/h); i++) {
!       dstrect.SetRect(r.x, r.y+h*i, w, h);
!       this->BlitSurface(temp, srcrect, dstrect);
!     }
!     this->SetClipRect(emptyrect);
!     
!     // blit part 3 (bottom)
!     
!     dstrect.SetRect(r.x,r.y+r.h-h,w,h);
!     srcrect.SetRect(0, h*2, w, h);
!     this->BlitSurface(temp, srcrect, dstrect);
!     
!     // free temp surface
!     if(w != background->ref->w) {
!       delete temp; // SDL_FreeSurface(temp);
!     }
!     
!     break;
!   } /* BKMODE_3TILEV */
!   }
!   
!   if(((gradient == NULL) || (blend == 0)) && bColorKey) {
!     c = SDL_MapRGB(
!                  background->ref->format,
!                  (uColorKey>>16) & 0xFF,
!                  (uColorKey>>8) & 0xFF,
!                  uColorKey & 0xFF);
!     background->SetColorKey(SDL_SRCCOLORKEY, c);
!     
!     c = SDL_MapRGB(ref->format,
!                  (uColorKey>>16) & 0xFF,
!                  (uColorKey>>8) & 0xFF,
!                  uColorKey & 0xFF);
!     this->SetColorKey(SDL_SRCCOLORKEY, c);
!   }
! };
! 
! }; /* namespace PG_Draw */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]