Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ repos:
(?x)^(
^src_c/_sdl2/.*$
| ^src_c/doc/.*$
| ^src_c/.+/.*_doc.h$
| docs/reST/_static/script.js
| docs/reST/_templates/header.h
| src_c/include/sse2neon.h
Expand Down
2 changes: 1 addition & 1 deletion buildconfig/Setup.Android.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ key src_c/key.c $(SDL) $(DEBUG)
mouse src_c/mouse.c $(SDL) $(DEBUG)
rect src_c/rect.c src_c/pgcompat_rect.c $(SDL) $(DEBUG)
rwobject src_c/rwobject.c $(SDL) $(DEBUG)
surface src_c/simd_blitters_sse2.c src_c/simd_blitters_avx2.c src_c/surface.c src_c/alphablit.c src_c/surface_fill.c src_c/simd_surface_fill_avx2.c src_c/simd_surface_fill_sse2.c $(SDL) $(DEBUG)
surface src_c/surface/simd_blitters_sse2.c src_c/surface/simd_blitters_avx2.c src_c/surface/surface.c src_c/surface/alphablit.c src_c/surface/surface_fill.c src_c/surface/simd_surface_fill_avx2.c src_c/surface/simd_surface_fill_sse2.c $(SDL) $(DEBUG) -Isrc_c/include
surflock src_c/surflock.c $(SDL) $(DEBUG)
time src_c/time.c $(SDL) $(DEBUG)
joystick src_c/joystick.c $(SDL) $(DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion buildconfig/Setup.Emscripten.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ math src_c/math.c $(SDL) $(DEBUG)
GFX = src_c/SDL_gfx/SDL_gfxPrimitives.c


static src_c/static.c $(SDL) $(FREETYPE) $(FONT) $(MIXER) $(IMAGE) $(PNG) $(JPEG) $(DEBUG)
static src_c/static.c $(SDL) $(FREETYPE) $(FONT) $(MIXER) $(IMAGE) $(PNG) $(JPEG) $(DEBUG) -Isrc_c/include

# these should not be altered they already are in static.c merging file above
time src_c/void.c
Expand Down
2 changes: 1 addition & 1 deletion buildconfig/Setup.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ key src_c/key.c $(SDL) $(DEBUG)
mouse src_c/mouse.c $(SDL) $(DEBUG)
rect src_c/rect.c src_c/pgcompat_rect.c $(SDL) $(DEBUG)
rwobject src_c/rwobject.c $(SDL) $(DEBUG)
surface src_c/simd_blitters_sse2.c src_c/simd_blitters_avx2.c src_c/surface.c src_c/alphablit.c src_c/surface_fill.c src_c/simd_surface_fill_avx2.c src_c/simd_surface_fill_sse2.c $(SDL) $(DEBUG)
surface src_c/surface/simd_blitters_sse2.c src_c/surface/simd_blitters_avx2.c src_c/surface/surface.c src_c/surface/alphablit.c src_c/surface/surface_fill.c src_c/surface/simd_surface_fill_avx2.c src_c/surface/simd_surface_fill_sse2.c $(SDL) $(DEBUG) -Isrc_c/include
surflock src_c/surflock.c $(SDL) $(DEBUG)
time src_c/time.c $(SDL) $(DEBUG)
joystick src_c/joystick.c $(SDL) $(DEBUG)
Expand Down
21 changes: 20 additions & 1 deletion buildconfig/make_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import os
import subprocess
import glob

rst_dir = 'docs'
rst_source_dir = os.path.join(rst_dir, 'reST')
Expand All @@ -11,6 +12,20 @@
c_header_dir = os.path.join('src_c', 'doc')


ignore_dirs = ["freetype"]


def move_doc_headers():
for file in glob.glob(f'{c_header_dir}/*.h'):
file_name = file.replace(c_header_dir + os.sep, '')
module_name = file.replace('_doc.h', '').replace(c_header_dir + os.sep, '')
if module_name not in ignore_dirs:
args = ['src_c', module_name]
path = os.path.join(*args)
if os.path.exists(path):
os.replace(file, os.path.join(path, file_name))


def run():
full_generation_flag = False
for argument in sys.argv[1:]:
Expand All @@ -27,7 +42,11 @@ def run():
if full_generation_flag:
subprocess_args.append('-E')
print("Executing sphinx in subprocess with args:", subprocess_args)
return subprocess.run(subprocess_args).returncode
returncode = subprocess.run(subprocess_args).returncode
if returncode != 0:
return returncode
move_doc_headers()
return 0
except Exception:
print('---')
print('Have you installed sphinx?')
Expand Down
2 changes: 1 addition & 1 deletion docs/reST/c_api/surface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Class Surface API exported by pygame.surface
************************************************

src_c/surface.c
src_c/surface/surface.c
===============

This extension module defines Python type :py:class:`pygame.Surface`.
Expand Down
2 changes: 1 addition & 1 deletion src_c/freetype/ft_pixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef _PYGAME_FREETYPE_PIXEL_H_
#define _PYGAME_FREETYPE_PIXEL_H_

#include "../surface.h"
#include "../surface/surface.h"

#define GET_RGB_VALS(pixel, fmt, r, g, b, a) \
(r) = ((pixel) & (fmt)->Rmask) >> (fmt)->Rshift; \
Expand Down
2 changes: 1 addition & 1 deletion src_c/gfxdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include "doc/gfxdraw_doc.h"

#include "surface.h"
#include "surface/surface.h"

#include "pgcompat.h"

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src_c/simd_shared.h → src_c/include/simd_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef SIMD_SHARED_H
#define SIMD_SHARED_H

#include "_surface.h"
#include "../surface/_surface.h"

int
pg_sse2_at_runtime_but_uncompiled();
Expand Down
2 changes: 1 addition & 1 deletion src_c/mask.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mask_get_size(PyObject *self, PyObject *_null)
* Returns:
* Rect object or NULL to indicate a fail
*
* Ref: src_c/surface.c surf_get_rect()
* Ref: src_c/surface/surface.c surf_get_rect()
*/
static PyObject *
mask_get_rect(PyObject *self, PyObject *args, PyObject *kwargs)
Expand Down
50 changes: 1 addition & 49 deletions src_c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -84,55 +84,7 @@ rwobject = py.extension_module(
subdir: pg,
)

# TODO: support SDL3
if sdl_api != 3
simd_blitters_avx2 = static_library(
'simd_blitters_avx2',
'simd_blitters_avx2.c',
dependencies: pg_base_deps,
c_args: simd_avx2_flags + warnings_error,
)

simd_blitters_sse2 = static_library(
'simd_blitters_sse2',
'simd_blitters_sse2.c',
dependencies: pg_base_deps,
c_args: simd_sse2_neon_flags + warnings_error,
)

simd_surface_fill_avx2 = static_library(
'simd_surface_fill_avx2',
'simd_surface_fill_avx2.c',
dependencies: pg_base_deps,
c_args: simd_avx2_flags + warnings_error,
)

simd_surface_fill_sse2 = static_library(
'simd_surface_fill_sse2',
'simd_surface_fill_sse2.c',
dependencies: pg_base_deps,
c_args: simd_sse2_neon_flags + warnings_error,
)

surface = py.extension_module(
'surface',
[
'surface.c',
'alphablit.c',
'surface_fill.c',
],
c_args: warnings_error,
link_with: [
simd_blitters_avx2,
simd_blitters_sse2,
simd_surface_fill_avx2,
simd_surface_fill_sse2,
],
dependencies: pg_base_deps,
install: true,
subdir: pg,
)
endif
subdir('surface')

surflock = py.extension_module(
'surflock',
Expand Down
2 changes: 1 addition & 1 deletion src_c/pixelarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "doc/pixelarray_doc.h"

#include "surface.h"
#include "surface/surface.h"
#if !defined(BUILD_STATIC)
static char FormatUint8[] = "B";
static char FormatUint16[] = "=H";
Expand Down
2 changes: 1 addition & 1 deletion src_c/pixelcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <stddef.h>

#include "palette.h"
#include "include/palette.h"

#include "pgcompat.h"

Expand Down
2 changes: 1 addition & 1 deletion src_c/simd_transform.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define NO_PYGAME_C_API
#include "_surface.h"
#include "surface/_surface.h"

/* TODO: This compat code should probably go in some place like simd_shared.h
* That header file however is inconsistently used at the moment and not
Expand Down
10 changes: 5 additions & 5 deletions src_c/static.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ PyInit_pygame_static()
#undef pgSurface_Type
#undef pgSurface_SetSurface

#include "surface.c"
#include "simd_blitters_avx2.c"
#include "simd_blitters_sse2.c"
#include "surface/surface.c"
#include "surface/simd_blitters_avx2.c"
#include "surface/simd_blitters_sse2.c"

#include "window.c"

Expand Down Expand Up @@ -430,9 +430,9 @@ PyInit_pygame_static()

#include "gfxdraw.c"

#include "alphablit.c"
#include "surface/alphablit.c"

#include "surface_fill.c"
#include "surface/surface_fill.c"
#include "pixelarray.c"
#include "pixelcopy.c"
#include "newbuffer.c"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src_c/_surface.h → src_c/surface/_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef _SURFACE_H
#define _SURFACE_H

#include "_pygame.h"
#include "../_pygame.h"
#include "surface.h"

#endif
2 changes: 1 addition & 1 deletion src_c/alphablit.c → src_c/surface/alphablit.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#define NO_PYGAME_C_API
#include "_surface.h"
#include "simd_shared.h"
#include "../include/simd_shared.h"
#include "simd_blitters.h"

static void
Expand Down
55 changes: 55 additions & 0 deletions src_c/surface/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# TODO: support SDL3
if sdl_api != 3
simd_blitters_avx2 = static_library(
'simd_blitters_avx2',
'simd_blitters_avx2.c',
include_directories: '../include',
dependencies: pg_base_deps,
c_args: simd_avx2_flags + warnings_error,
)

simd_blitters_sse2 = static_library(
'simd_blitters_sse2',
'simd_blitters_sse2.c',
include_directories: '../include',
dependencies: pg_base_deps,
c_args: simd_sse2_neon_flags + warnings_error,
)

simd_surface_fill_avx2 = static_library(
'simd_surface_fill_avx2',
'simd_surface_fill_avx2.c',
include_directories: '../include',
dependencies: pg_base_deps,
c_args: simd_avx2_flags + warnings_error,
)

simd_surface_fill_sse2 = static_library(
'simd_surface_fill_sse2',
'simd_surface_fill_sse2.c',
include_directories: '../include',
dependencies: pg_base_deps,
c_args: simd_sse2_neon_flags + warnings_error,
)

surface = py.extension_module(
'surface',
[
'surface.c',
'alphablit.c',
'surface_fill.c',
],
include_directories: '../include',
c_args: warnings_error,
link_with: [
simd_blitters_avx2,
simd_blitters_sse2,
simd_surface_fill_avx2,
simd_surface_fill_sse2,
],
dependencies: pg_base_deps,
install: true,
subdir: pg,
)
install_data('surface.pyi', install_dir: pg_dir, install_tag: 'pg-tag')
endif
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#if PG_ENABLE_ARM_NEON
// sse2neon.h is from here: https://github.com/DLTcollab/sse2neon
#include "include/sse2neon.h"
#include "sse2neon.h"
#endif /* PG_ENABLE_ARM_NEON */

/* See if we are compiled 64 bit on GCC or MSVC */
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#if PG_ENABLE_ARM_NEON
// sse2neon.h is from here: https://github.com/DLTcollab/sse2neon
#include "include/sse2neon.h"
#include "sse2neon.h"
#endif /* PG_ENABLE_ARM_NEON */

#define BAD_SSE2_FUNCTION_CALL \
Expand Down
4 changes: 2 additions & 2 deletions src_c/surface.c → src_c/surface/surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include "palette.h"

#include "structmember.h"
#include "pgcompat.h"
#include "doc/surface_doc.h"
#include "../pgcompat.h"
#include "surface_doc.h"

/* stdint.h is missing from some versions of MSVC. */
#ifdef _MSC_VER
Expand Down
2 changes: 1 addition & 1 deletion src_c/surface.h → src_c/surface/surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <SDL.h>
#endif

#include "pygame.h"
#include "../pygame.h"

/* Blend modes */
#define PYGAME_BLEND_ADD 0x1
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src_c/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <math.h>
#include <string.h>

#include "simd_shared.h"
#include "include/simd_shared.h"
#include "simd_transform.h"
#include "scale.h"

Expand Down
Loading