<commit_before>""" XXX """

from pygame._error import SDLError, unpack_rect
from pygame._sdl import sdl, locked, ffi, FillRect, BlitSurface
from pygame.rect import Rect, new_rect, rect_from_obj
from pygame.color import create_color

class SubSurfaceData(object):
    def __init__(self, owner, pixeloffset, xoffset, yoffset):
        self.owner = owner
        self.pixeloffset = pixeloffset
        self.xoffset = xoffset
        self.yoffset = yoffset

class Surface(object):
    """ Surface((width, height), flags=0, depth=0, masks=None) -> Surface
    Surface((width, height), flags=0, Surface) -> Surface

    pygame object for representing images
    """
    _c_surface = None
    subsurfacedata = None

    def __init__(self, size, flags=0, depth=0, masks=None):
        w, h = unpack_rect(size)
        if isinstance(depth, Surface):
            surface = depth
            depth = 0
        else:
            surface = None

        if depth or masks:
            raise SDLError("XXX: Not implemented!")

        if surface is None:
            if sdl.SDL_GetVideoSurface():
                pix = sdl.SDL_GetVideoSurface().format
            elif sdl.SDL_WasInit(sdl.SDL_INIT_VIDEO):
                pix = sdl.SDL_GetVideoInfo().vfmt
            else:
                pix = ffi.new("SDL_PixelFormat*")
                pix.BitsPerPixel = 32
                pix.Amask = 0
                pix.Rmask = 0xff0000
                pix.Gmask = 0xFF00
                pix.Bmask = 0xFF
            self._c_surface = sdl.SDL_CreateRGBSurface(flags, w, h,
                                                       pix.BitsPerPixel,
                                                       pix.Rmask,
                                                       pix.Gmask,
                                                       pix.Bmask,
                                                       pix.Amask)
            if not self._c_surface:
                raise SDLError.from_sdl_error()

        else:
            raise NotImplementedError("xxx")

    def fill(self, color, rect=None, special_flags=0):
        assert special_flags == 0
        c_color = create_color(color, self._format)
        if rect is not None:
            sdlrect = rect_from_obj(rect)
        else:
            sdlrect = new_rect(0, 0, self._w, self._h)
        with locked(self._c_surface):
            FillRect(self._c_surface, sdlrect, c_color)

    def blit(self, source, destrect, area=None, special_flags=0):
        if area is not None:
            srcrect = rect_from_obj(area)
        else:
            srcrect = new_rect(0, 0, source._w, source._h)
        if isinstance(destrect, tuple):
            destrect = new_rect(destrect[0], destrect[1], source._w, source._h)
        elif isinstance(destrect, Rect):
            destrect = destrect._sdlrect
        BlitSurface(source, srcrect, self, destrect, special_flags)

    def convert_alpha(self, srcsurf=None):
        with locked(self._c_surface):
            newsurf = sdl.SDL_DisplayFormatAlpha(self._c_surface)
        return Surface._from_sdl_surface(newsurf)

    def get_format(self):
        return self._c_surface.format
    _format = property(get_format)
<commit_msg>blit returns a Rect<commit_after>""" XXX """

from pygame._error import SDLError, unpack_rect
from pygame._sdl import sdl, locked, ffi, FillRect, BlitSurface
from pygame.rect import Rect, new_rect, rect_from_obj
from pygame.color import create_color

class SubSurfaceData(object):
    def __init__(self, owner, pixeloffset, xoffset, yoffset):
        self.owner = owner
        self.pixeloffset = pixeloffset
        self.xoffset = xoffset
        self.yoffset = yoffset

class Surface(object):
    """ Surface((width, height), flags=0, depth=0, masks=None) -> Surface
    Surface((width, height), flags=0, Surface) -> Surface

    pygame object for representing images
    """
    _c_surface = None
    subsurfacedata = None

    def __init__(self, size, flags=0, depth=0, masks=None):
        w, h = unpack_rect(size)
        if isinstance(depth, Surface):
            surface = depth
            depth = 0
        else:
            surface = None

        if depth or masks:
            raise SDLError("XXX: Not implemented!")

        if surface is None:
            if sdl.SDL_GetVideoSurface():
                pix = sdl.SDL_GetVideoSurface().format
            elif sdl.SDL_WasInit(sdl.SDL_INIT_VIDEO):
                pix = sdl.SDL_GetVideoInfo().vfmt
            else:
                pix = ffi.new("SDL_PixelFormat*")
                pix.BitsPerPixel = 32
                pix.Amask = 0
                pix.Rmask = 0xff0000
                pix.Gmask = 0xFF00
                pix.Bmask = 0xFF
            self._c_surface = sdl.SDL_CreateRGBSurface(flags, w, h,
                                                       pix.BitsPerPixel,
                                                       pix.Rmask,
                                                       pix.Gmask,
                                                       pix.Bmask,
                                                       pix.Amask)
            if not self._c_surface:
                raise SDLError.from_sdl_error()

        else:
            raise NotImplementedError("xxx")

    def fill(self, color, rect=None, special_flags=0):
        assert special_flags == 0
        c_color = create_color(color, self._format)
        if rect is not None:
            sdlrect = rect_from_obj(rect)
        else:
            sdlrect = new_rect(0, 0, self._w, self._h)
        with locked(self._c_surface):
            FillRect(self._c_surface, sdlrect, c_color)

    def blit(self, source, destrect, area=None, special_flags=0):
        if area is not None:
            srcrect = rect_from_obj(area)
        else:
            srcrect = new_rect(0, 0, source._w, source._h)
        if isinstance(destrect, tuple):
            destrect = new_rect(destrect[0], destrect[1], source._w, source._h)
        elif isinstance(destrect, Rect):
            destrect = destrect._sdlrect
        BlitSurface(source, srcrect, self, destrect, special_flags)
        return Rect(destrect.x, destrect.y, destrect.w, destrect.h)

    def convert_alpha(self, srcsurf=None):
        with locked(self._c_surface):
            newsurf = sdl.SDL_DisplayFormatAlpha(self._c_surface)
        return Surface._from_sdl_surface(newsurf)

    def get_format(self):
        return self._c_surface.format
    _format = property(get_format)

{'fraction_non_alphanumeric': 0.08729913473423981, 'fraction_numerical': 0.00834363411619283, 'mean_word_length': 1.7231804795961296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6913951', 'n_tokens_mistral': 1936, 'n_tokens_neox': 1785, 'n_words': 434}