Skip to content

Commit 10bc90e

Browse files
authored
Port Texture to C code (#3330)
* Add interface for _sdl2.video classes * Add interface for _sdl2.video classes * Add interface for _sdl2.video classes * Add interface for _sdl2.video classes * Add interface for _sdl2.video classes * Add interface for _sdl2.video classes * Add interface for _sdl2.video classes * Add interface for _sdl2.video classes * Add interface for _sdl2.video classes * Add interface for _sdl2.video classes * Squashed commit of the following: commit 813f384 Author: Josip Komljenović <[email protected]> Date: Wed Jan 29 15:43:45 2025 +0100 Add interface for _sdl2.video classes commit 702958c Author: Josip Komljenović <[email protected]> Date: Wed Jan 29 15:38:01 2025 +0100 Add interface for _sdl2.video classes commit 081b032 Author: Josip Komljenović <[email protected]> Date: Wed Jan 29 15:33:20 2025 +0100 Add interface for _sdl2.video classes commit c9ffd1c Author: Josip Komljenović <[email protected]> Date: Wed Jan 29 15:25:10 2025 +0100 Add interface for _sdl2.video classes * Port Renderer to C code * Port Renderer to C code * Squashed commit of the following: commit 813f384 Author: Josip Komljenović <[email protected]> Date: Wed Jan 29 15:43:45 2025 +0100 Add interface for _sdl2.video classes commit 702958c Author: Josip Komljenović <[email protected]> Date: Wed Jan 29 15:38:01 2025 +0100 Add interface for _sdl2.video classes commit 081b032 Author: Josip Komljenović <[email protected]> Date: Wed Jan 29 15:33:20 2025 +0100 Add interface for _sdl2.video classes commit c9ffd1c Author: Josip Komljenović <[email protected]> Date: Wed Jan 29 15:25:10 2025 +0100 Add interface for _sdl2.video classes * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code * Port Texture to C code
1 parent 0328697 commit 10bc90e

File tree

7 files changed

+962
-21
lines changed

7 files changed

+962
-21
lines changed

buildconfig/stubs/pygame/__init__.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ from .constants import (
204204
FLASH_BRIEFLY as FLASH_BRIEFLY,
205205
FLASH_CANCEL as FLASH_CANCEL,
206206
FLASH_UNTIL_FOCUSED as FLASH_UNTIL_FOCUSED,
207+
FLIP_HORIZONTAL as FLIP_HORIZONTAL,
208+
FLIP_NONE as FLIP_NONE,
209+
FLIP_VERTICAL as FLIP_VERTICAL,
207210
FONT_CENTER as FONT_CENTER,
208211
FONT_LEFT as FONT_LEFT,
209212
FONT_RIGHT as FONT_RIGHT,
@@ -643,6 +646,9 @@ from .constants import (
643646
SYSWMEVENT as SYSWMEVENT,
644647
TEXTEDITING as TEXTEDITING,
645648
TEXTINPUT as TEXTINPUT,
649+
TEXTUREACCESS_STATIC as TEXTUREACCESS_STATIC,
650+
TEXTUREACCESS_STREAMING as TEXTUREACCESS_STREAMING,
651+
TEXTUREACCESS_TARGET as TEXTUREACCESS_TARGET,
646652
TIMER_RESOLUTION as TIMER_RESOLUTION,
647653
USEREVENT as USEREVENT,
648654
USEREVENT_DROPFILE as USEREVENT_DROPFILE,

buildconfig/stubs/pygame/_render.pyi

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing import Optional, Protocol, Union, final
1+
from collections.abc import Iterable
2+
from typing import Any, Optional, Protocol, Union, final
23

34
from pygame.color import Color
45
from pygame.rect import Rect
56
from pygame.surface import Surface
67
from pygame.typing import ColorLike, IntPoint, Point, RectLike, SequenceLike
78
from pygame.window import Window
8-
from typing_extensions import deprecated # added in 3.13
99

1010
class _DrawableClass(Protocol):
1111
# Object that has the draw method that accepts area and dest arguments
@@ -74,7 +74,74 @@ class Renderer:
7474

7575
@final
7676
class Texture:
77-
pass
77+
def __init__(
78+
self,
79+
renderer: Renderer,
80+
size: Iterable[int],
81+
depth: int = 0,
82+
static: bool = False,
83+
streaming: bool = False,
84+
target: bool = False,
85+
scale_quality: Optional[int] = None,
86+
) -> None: ...
87+
@property
88+
def alpha(self) -> int: ...
89+
@alpha.setter
90+
def alpha(self, value: int) -> None: ...
91+
@property
92+
def blend_mode(self) -> int: ...
93+
@blend_mode.setter
94+
def blend_mode(self, value: int) -> None: ...
95+
@property
96+
def color(self) -> Color: ...
97+
@color.setter
98+
def color(self, value: ColorLike) -> None: ...
99+
@property
100+
def width(self) -> int: ...
101+
@property
102+
def height(self) -> int: ...
103+
@property
104+
def renderer(self) -> Renderer: ...
105+
@classmethod
106+
def from_surface(cls, renderer: Renderer, surface: Surface) -> Texture: ...
107+
def draw(
108+
self,
109+
srcrect: Optional[RectLike] = None,
110+
dstrect: Optional[RectLike] = None,
111+
angle: float = 0.0,
112+
origin: Optional[Iterable[int]] = None,
113+
flip_x: bool = False,
114+
flip_y: bool = False,
115+
) -> None: ...
116+
def draw_triangle(
117+
self,
118+
p1_xy: Point,
119+
p2_xy: Point,
120+
p3_xy: Point,
121+
p1_uv: Point = (0.0, 0.0),
122+
p2_uv: Point = (1.0, 1.0),
123+
p3_uv: Point = (0.0, 1.0),
124+
p1_mod: ColorLike = (255, 255, 255, 255),
125+
p2_mod: ColorLike = (255, 255, 255, 255),
126+
p3_mod: ColorLike = (255, 255, 255, 255),
127+
) -> None: ...
128+
def draw_quad(
129+
self,
130+
p1_xy: Point,
131+
p2_xy: Point,
132+
p3_xy: Point,
133+
p4_xy: Point,
134+
p1_uv: Point = (0.0, 0.0),
135+
p2_uv: Point = (1.0, 0.0),
136+
p3_uv: Point = (1.0, 1.0),
137+
p4_uv: Point = (0.0, 1.0),
138+
p1_mod: ColorLike = (255, 255, 255, 255),
139+
p2_mod: ColorLike = (255, 255, 255, 255),
140+
p3_mod: ColorLike = (255, 255, 255, 255),
141+
p4_mod: ColorLike = (255, 255, 255, 255),
142+
) -> None: ...
143+
def get_rect(self, **kwargs: Any) -> Rect: ...
144+
def update(self, surface: Surface, area: Optional[RectLike] = None) -> None: ...
78145

79146
@final
80147
class Image:

buildconfig/stubs/pygame/constants.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ FINGERUP: int
126126
FLASH_BRIEFLY: int
127127
FLASH_CANCEL: int
128128
FLASH_UNTIL_FOCUSED: int
129+
FLIP_HORIZONTAL: int
130+
FLIP_NONE: int
131+
FLIP_VERTICAL: int
129132
FONT_CENTER: int
130133
FONT_LEFT: int
131134
FONT_RIGHT: int
@@ -565,6 +568,9 @@ SYSTEM_CURSOR_WAITARROW: int
565568
SYSWMEVENT: int
566569
TEXTEDITING: int
567570
TEXTINPUT: int
571+
TEXTUREACCESS_STATIC: int
572+
TEXTUREACCESS_STREAMING: int
573+
TEXTUREACCESS_TARGET: int
568574
TIMER_RESOLUTION: int
569575
USEREVENT: int
570576
USEREVENT_DROPFILE: int

buildconfig/stubs/pygame/locals.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ FINGERUP: int
127127
FLASH_BRIEFLY: int
128128
FLASH_CANCEL: int
129129
FLASH_UNTIL_FOCUSED: int
130+
FLIP_HORIZONTAL: int
131+
FLIP_NONE: int
132+
FLIP_VERTICAL: int
130133
FONT_CENTER: int
131134
FONT_LEFT: int
132135
FONT_RIGHT: int
@@ -567,6 +570,9 @@ SYSTEM_CURSOR_WAITARROW: int
567570
SYSWMEVENT: int
568571
TEXTEDITING: int
569572
TEXTINPUT: int
573+
TEXTUREACCESS_STATIC: int
574+
TEXTUREACCESS_STREAMING: int
575+
TEXTUREACCESS_TARGET: int
570576
TIMER_RESOLUTION: int
571577
USEREVENT: int
572578
USEREVENT_DROPFILE: int

src_c/constants.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,13 @@ MODINIT_DEFINE(constants)
328328
DEC_CONSTS(WINDOWICCPROFCHANGED, PGE_WINDOWICCPROFCHANGED);
329329
DEC_CONSTS(WINDOWDISPLAYCHANGED, PGE_WINDOWDISPLAYCHANGED);
330330

331+
DEC_CONST(TEXTUREACCESS_STATIC);
332+
DEC_CONST(TEXTUREACCESS_STREAMING);
333+
DEC_CONST(TEXTUREACCESS_TARGET);
334+
DEC_CONST(FLIP_NONE);
335+
DEC_CONST(FLIP_HORIZONTAL);
336+
DEC_CONST(FLIP_VERTICAL);
337+
331338
DEC_CONST(CONTROLLERAXISMOTION);
332339
DEC_CONST(CONTROLLERBUTTONDOWN);
333340
DEC_CONST(CONTROLLERBUTTONUP);

0 commit comments

Comments
 (0)