Commits

Anonymous committed a3ed104

subsurface blit (untested)

Comments (0)

Files changed (2)

 AUDIO_U16SYS            = SDL.constants.AUDIO_U16SYS
 AUDIO_S16SYS            = SDL.constants.AUDIO_S16SYS
 
+def _t(a, b, c, d):
+    return (ord(a) << 24) | (ord(b) << 16) | (ord(c) << 8) | ord(d)
+
+SCRAP_TEXT              = _t('T', 'E', 'X', 'T')
+SCRAP_BMP               = _t('B', 'M', 'P', ' ')
+
+BLEND_ADD               = 0x01
+BLEND_SUB               = 0x02
+BLEND_MULT              = 0x03
+BLEND_MIN               = 0x04
+BLEND_MAX               = 0x05
+
 NOEVENT                 = SDL.constants.SDL_NOEVENT
 ACTIVEEVENT             = SDL.constants.SDL_ACTIVEEVENT
 KEYDOWN                 = SDL.constants.SDL_KEYDOWN
         raise NotImplementedError, 'TODO'
     
     if destobj._subsurface:
-        raise NotImplementedError, 'TODO'
+        subdata = destobj._subsurface
+        owner = subdata.owner
+        subsurface = owner._surf
+        suboffsetx = subdata.offsetx
+        suboffsety = subdata.offsety
+
+        while owner._subsurface:
+            subdata = owner._subsurface
+            owner = subdata.owner
+            subsurface = owner._surf
+            suboffsetx += subdata.offsetx
+            suboffsety += subdata.offsety
+
+        orig_clip = SDL_GetClipRect(subsurface)
+        sub_clip = SDL_GetClipRect(dst)
+        sub_clip.x += suboffsetx
+        sub_clip.y += suboffset.y
+        SDL_SetClipRect(subsurface, sub_clip)
+        dstrect.x += suboffsetx
+        dstrect.y += suboffsety
+        dst = subsurface
+    else:
+        destobj._prep()
+
+    srcobj._prep()
 
     # Can't blit alpha to 8 bit, creashes SDL
     if dst.format.BytesPerPixel == 1 and \
     if didconvert:
         SDL_FreeSurface(src)
 
+    if subsurface:
+        SDL_SetClipRect(subsurface, orig_clip)
+        dstrect.x -= suboffsetx
+        dstrect.y -= suboffsety
+    else:
+        destobj._unprep()
+    srcobj._unprep()
+
     if result == -2:
         raise pygame.base.error, 'Surface was lost'