pyglet 2.1.5__py3-none-any.whl → 2.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyglet/__init__.py +27 -42
- pyglet/app/base.py +2 -2
- pyglet/clock.py +1 -1
- pyglet/display/base.py +31 -21
- pyglet/display/cocoa.py +25 -1
- pyglet/display/headless.py +1 -1
- pyglet/display/win32.py +134 -18
- pyglet/display/xlib.py +285 -70
- pyglet/event.py +17 -1
- pyglet/experimental/README.md +1 -1
- pyglet/experimental/jobs.py +1 -1
- pyglet/experimental/multitexture_sprite.py +2 -2
- pyglet/font/__init__.py +1 -1
- pyglet/font/base.py +8 -5
- pyglet/font/dwrite/__init__.py +13 -8
- pyglet/font/dwrite/dwrite_lib.py +1 -1
- pyglet/font/user.py +1 -1
- pyglet/gl/base.py +8 -4
- pyglet/gl/cocoa.py +4 -0
- pyglet/gl/gl.py +4 -3
- pyglet/gl/gl.pyi +2320 -0
- pyglet/gl/gl_compat.py +7 -18
- pyglet/gl/gl_compat.pyi +3097 -0
- pyglet/gl/xlib.py +24 -0
- pyglet/graphics/shader.py +34 -20
- pyglet/graphics/vertexbuffer.py +1 -1
- pyglet/gui/frame.py +2 -2
- pyglet/gui/widgets.py +1 -1
- pyglet/image/__init__.py +3 -3
- pyglet/image/buffer.py +3 -3
- pyglet/input/base.py +8 -8
- pyglet/input/linux/evdev.py +1 -1
- pyglet/libs/darwin/cocoapy/cocoalibs.py +3 -1
- pyglet/libs/win32/__init__.py +12 -0
- pyglet/libs/win32/constants.py +4 -0
- pyglet/libs/win32/types.py +97 -0
- pyglet/libs/x11/xrandr.py +166 -0
- pyglet/libs/x11/xrender.py +43 -0
- pyglet/libs/x11/xsync.py +43 -0
- pyglet/math.py +40 -49
- pyglet/media/buffered_logger.py +1 -1
- pyglet/media/codecs/ffmpeg.py +18 -34
- pyglet/media/codecs/gstreamer.py +3 -3
- pyglet/media/codecs/pyogg.py +1 -1
- pyglet/media/codecs/wave.py +6 -0
- pyglet/media/codecs/wmf.py +33 -7
- pyglet/media/devices/win32.py +1 -1
- pyglet/media/drivers/base.py +1 -1
- pyglet/media/drivers/directsound/interface.py +4 -0
- pyglet/media/drivers/listener.py +2 -2
- pyglet/media/drivers/xaudio2/interface.py +6 -2
- pyglet/media/drivers/xaudio2/lib_xaudio2.py +1 -1
- pyglet/media/instrumentation.py +2 -2
- pyglet/media/player.py +2 -2
- pyglet/media/player_worker_thread.py +1 -1
- pyglet/media/synthesis.py +1 -1
- pyglet/model/codecs/gltf.py +1 -1
- pyglet/shapes.py +25 -24
- pyglet/sprite.py +1 -1
- pyglet/text/caret.py +44 -5
- pyglet/text/layout/base.py +3 -3
- pyglet/util.py +1 -1
- pyglet/window/__init__.py +54 -14
- pyglet/window/cocoa/__init__.py +27 -0
- pyglet/window/mouse.py +11 -1
- pyglet/window/win32/__init__.py +40 -14
- pyglet/window/xlib/__init__.py +21 -7
- {pyglet-2.1.5.dist-info → pyglet-2.1.8.dist-info}/METADATA +1 -1
- {pyglet-2.1.5.dist-info → pyglet-2.1.8.dist-info}/RECORD +71 -67
- {pyglet-2.1.5.dist-info → pyglet-2.1.8.dist-info}/LICENSE +0 -0
- {pyglet-2.1.5.dist-info → pyglet-2.1.8.dist-info}/WHEEL +0 -0
pyglet/font/dwrite/__init__.py
CHANGED
|
@@ -207,10 +207,12 @@ class _DWriteTextRenderer(com.COMObject):
|
|
|
207
207
|
self.pixels_per_dip = 1.0
|
|
208
208
|
self.dmatrix = DWRITE_MATRIX()
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
@staticmethod
|
|
211
|
+
def _get_font_reference(font_face: IDWriteFontFace) -> tuple[int, int]:
|
|
211
212
|
"""Unique identifier for each font face."""
|
|
212
213
|
font_file = _get_font_file(font_face)
|
|
213
|
-
|
|
214
|
+
ptr, size = _get_font_ref(font_file, release_file=True)
|
|
215
|
+
return ptr.value, size
|
|
214
216
|
|
|
215
217
|
def DrawUnderline(self, *_args) -> int: # noqa: ANN002, N802
|
|
216
218
|
return com.E_NOTIMPL
|
|
@@ -247,6 +249,9 @@ class _DWriteTextRenderer(com.COMObject):
|
|
|
247
249
|
glyph_renderer: DirectWriteGlyphRenderer = cast(drawing_context, py_object).value
|
|
248
250
|
glyph_run = glyph_run_ptr.contents
|
|
249
251
|
|
|
252
|
+
# Font reference to cache glyphs otherwise cache misses may occur with other glyph indices.
|
|
253
|
+
font_ref = self._get_font_reference(glyph_run.fontFace)
|
|
254
|
+
|
|
250
255
|
if glyph_run.glyphCount == 0:
|
|
251
256
|
glyph = glyph_renderer.font._zero_glyph # noqa: SLF001
|
|
252
257
|
glyph_renderer.current_glyphs.append(glyph)
|
|
@@ -257,7 +262,7 @@ class _DWriteTextRenderer(com.COMObject):
|
|
|
257
262
|
missing = []
|
|
258
263
|
for i in range(glyph_run.glyphCount):
|
|
259
264
|
glyph_indice = glyph_run.glyphIndices[i]
|
|
260
|
-
if glyph_indice not in glyph_renderer.font.glyphs and glyph_indice not in missing:
|
|
265
|
+
if (font_ref, glyph_indice) not in glyph_renderer.font.glyphs and glyph_indice not in missing:
|
|
261
266
|
missing.append(glyph_indice)
|
|
262
267
|
|
|
263
268
|
# Missing glyphs, get their info.
|
|
@@ -266,13 +271,13 @@ class _DWriteTextRenderer(com.COMObject):
|
|
|
266
271
|
|
|
267
272
|
for idx, glyph_indice in enumerate(missing):
|
|
268
273
|
glyph = glyph_renderer.render_single_glyph(glyph_run.fontFace, glyph_indice, metrics[idx], mode)
|
|
269
|
-
glyph_renderer.font.glyphs[glyph_indice] = glyph
|
|
274
|
+
glyph_renderer.font.glyphs[(font_ref, glyph_indice)] = glyph
|
|
270
275
|
|
|
271
276
|
# Set glyphs for run.
|
|
272
277
|
current = []
|
|
273
278
|
for i in range(glyph_run.glyphCount):
|
|
274
279
|
glyph_indice = glyph_run.glyphIndices[i]
|
|
275
|
-
glyph = glyph_renderer.font.glyphs[glyph_indice]
|
|
280
|
+
glyph = glyph_renderer.font.glyphs[(font_ref, glyph_indice)]
|
|
276
281
|
current.append(glyph)
|
|
277
282
|
# In some cases (italics) the offsets may be NULL.
|
|
278
283
|
if glyph_run.glyphOffsets:
|
|
@@ -600,7 +605,7 @@ class DirectWriteGlyphRenderer(base.GlyphRenderer): # noqa: D101
|
|
|
600
605
|
|
|
601
606
|
def _create_bitmap(self, width: int, height: int) -> None:
|
|
602
607
|
"""Creates a bitmap using Direct2D and WIC."""
|
|
603
|
-
# Create a new bitmap, try to
|
|
608
|
+
# Create a new bitmap, try to reuse the bitmap as much as we can to minimize creations.
|
|
604
609
|
if self._bitmap_dimensions[0] != width or self._bitmap_dimensions[1] != height:
|
|
605
610
|
# If dimensions aren't the same, release bitmap to create new ones.
|
|
606
611
|
if self._render_target:
|
|
@@ -1048,7 +1053,7 @@ class Win32DirectWriteFont(base.Font):
|
|
|
1048
1053
|
if hr != 0:
|
|
1049
1054
|
raise Exception("This font file data is not not a font or unsupported.")
|
|
1050
1055
|
|
|
1051
|
-
# We have to rebuild collection
|
|
1056
|
+
# We have to rebuild collection every time we add a font.
|
|
1052
1057
|
# No way to add fonts to the collection once the FontSet and Collection are created.
|
|
1053
1058
|
# Release old one and renew.
|
|
1054
1059
|
if cls._custom_collection:
|
|
@@ -1158,7 +1163,7 @@ class Win32DirectWriteFont(base.Font):
|
|
|
1158
1163
|
metrics = DWRITE_TEXT_METRICS()
|
|
1159
1164
|
layout.GetMetrics(byref(metrics))
|
|
1160
1165
|
layout.Release()
|
|
1161
|
-
return round(metrics.
|
|
1166
|
+
return round(metrics.widthIncludingTrailingWhitespace), round(metrics.height)
|
|
1162
1167
|
|
|
1163
1168
|
@classmethod
|
|
1164
1169
|
def have_font(cls: type[Win32DirectWriteFont], name: str) -> bool:
|
pyglet/font/dwrite/dwrite_lib.py
CHANGED
|
@@ -1049,7 +1049,7 @@ class IDWriteFactory(com.pIUnknown):
|
|
|
1049
1049
|
("CreateCustomRenderingParams",
|
|
1050
1050
|
com.STDMETHOD(FLOAT, FLOAT, FLOAT, UINT, UINT, POINTER(IDWriteRenderingParams))),
|
|
1051
1051
|
("RegisterFontFileLoader",
|
|
1052
|
-
com.STDMETHOD(c_void_p)), #
|
|
1052
|
+
com.STDMETHOD(c_void_p)), # Ambiguous as newer is a pIUnknown and legacy is IUnknown.
|
|
1053
1053
|
("UnregisterFontFileLoader",
|
|
1054
1054
|
com.STDMETHOD(POINTER(IDWriteFontFileLoader_LI))),
|
|
1055
1055
|
("CreateTextFormat",
|
pyglet/font/user.py
CHANGED
|
@@ -201,7 +201,7 @@ class UserDefinedMappingFont(UserDefinedFontBase):
|
|
|
201
201
|
Font size. Should be in pixels. This value will affect scaling if enabled.
|
|
202
202
|
mappings:
|
|
203
203
|
A dict or dict-like object with a ``get`` function.
|
|
204
|
-
The ``get`` function must take a string character, and output :py:class:`~pyglet.
|
|
204
|
+
The ``get`` function must take a string character, and output :py:class:`~pyglet.image.ImageData` if
|
|
205
205
|
found. It also must return ``None`` if no character is found.
|
|
206
206
|
ascent:
|
|
207
207
|
Maximum ascent above the baseline, in pixels. If None, the image height is used.
|
pyglet/gl/base.py
CHANGED
|
@@ -89,6 +89,7 @@ class Config:
|
|
|
89
89
|
'forward_compatible',
|
|
90
90
|
'opengl_api',
|
|
91
91
|
'debug',
|
|
92
|
+
'transparent_framebuffer',
|
|
92
93
|
)
|
|
93
94
|
|
|
94
95
|
#: The OpenGL major version.
|
|
@@ -101,6 +102,8 @@ class Config:
|
|
|
101
102
|
opengl_api: str
|
|
102
103
|
#: Debug mode.
|
|
103
104
|
debug: bool
|
|
105
|
+
#: If the framebuffer should be transparent.
|
|
106
|
+
transparent_framebuffer: bool
|
|
104
107
|
|
|
105
108
|
def __init__(self, **kwargs: float) -> None:
|
|
106
109
|
"""Create a template config with the given attributes.
|
|
@@ -132,7 +135,7 @@ class Config:
|
|
|
132
135
|
"""Return a list of matching complete configs for the given canvas."""
|
|
133
136
|
|
|
134
137
|
def create_context(self, share: Context | None) -> Context: # noqa: ARG002
|
|
135
|
-
"""Create a GL context that
|
|
138
|
+
"""Create a GL context that satisfies this configuration.
|
|
136
139
|
|
|
137
140
|
Args:
|
|
138
141
|
share:
|
|
@@ -180,10 +183,11 @@ class DisplayConfig(Config, abc.ABC):
|
|
|
180
183
|
self.forward_compatible = base_config.forward_compatible
|
|
181
184
|
self.opengl_api = base_config.opengl_api or self.opengl_api
|
|
182
185
|
self.debug = base_config.debug
|
|
186
|
+
self.transparent_framebuffer = base_config.transparent_framebuffer
|
|
183
187
|
|
|
184
188
|
@abc.abstractmethod
|
|
185
189
|
def compatible(self, canvas: Canvas) -> bool:
|
|
186
|
-
"""Determine
|
|
190
|
+
"""Determine compatibility with the canvas."""
|
|
187
191
|
|
|
188
192
|
@abc.abstractmethod
|
|
189
193
|
def create_context(self, share: Context) -> Context:
|
|
@@ -311,7 +315,7 @@ class Context:
|
|
|
311
315
|
# For the static functions below:
|
|
312
316
|
# The garbage collector introduces a race condition.
|
|
313
317
|
# The provided list might be appended to (and only appended to) while this
|
|
314
|
-
# method runs, as it's a `doomed_*` list either on the context or its
|
|
318
|
+
# method runs, as it's a `doomed_*` list either on the context or its object
|
|
315
319
|
# space. If `count` wasn't stored in a local, this method might leak objects.
|
|
316
320
|
@staticmethod
|
|
317
321
|
def _delete_objects(list_: list, deletion_func: Callable[[int, Array[gl.GLuint]], None]) -> None:
|
|
@@ -343,7 +347,7 @@ class Context:
|
|
|
343
347
|
def destroy(self) -> None:
|
|
344
348
|
"""Release the Context.
|
|
345
349
|
|
|
346
|
-
The context will not be
|
|
350
|
+
The context will not be usable after being destroyed. Each platform
|
|
347
351
|
has its own convention for releasing the context and the buffer(s)
|
|
348
352
|
that depend on it in the correct order; this should never be called
|
|
349
353
|
by an application.
|
pyglet/gl/cocoa.py
CHANGED
|
@@ -239,6 +239,10 @@ class CocoaDisplayConfig(DisplayConfig): # noqa: D101
|
|
|
239
239
|
self._pixel_format,
|
|
240
240
|
share_context)
|
|
241
241
|
|
|
242
|
+
if self.transparent_framebuffer:
|
|
243
|
+
opaque = c_int(0)
|
|
244
|
+
nscontext.setValues_forParameter_(byref(opaque), cocoapy.NSOpenGLCPSurfaceOpacity)
|
|
245
|
+
|
|
242
246
|
# No longer needed after context creation.
|
|
243
247
|
if self._pixel_format:
|
|
244
248
|
self._pixel_format.release()
|
pyglet/gl/gl.py
CHANGED
|
@@ -3,9 +3,10 @@ Generated by tools/gengl.py.
|
|
|
3
3
|
Do not modify this file.
|
|
4
4
|
"""
|
|
5
5
|
from __future__ import annotations
|
|
6
|
+
|
|
6
7
|
from ctypes import (
|
|
7
|
-
CFUNCTYPE, POINTER, Structure, c_char, c_double, c_float,
|
|
8
|
-
c_int64, c_short, c_ubyte, c_uint, c_uint64, c_ushort
|
|
8
|
+
CFUNCTYPE, POINTER, Structure, c_byte, c_char, c_double, c_float,
|
|
9
|
+
c_int, c_int64, c_short, c_ubyte, c_uint, c_uint64, c_ushort
|
|
9
10
|
)
|
|
10
11
|
from pyglet.gl.lib import link_GL as _link_function
|
|
11
12
|
from pyglet.gl.lib import c_ptrdiff_t
|
|
@@ -24,7 +25,7 @@ GLenum = c_uint
|
|
|
24
25
|
GLboolean = c_ubyte
|
|
25
26
|
GLbitfield = c_uint
|
|
26
27
|
GLvoid = None
|
|
27
|
-
GLbyte =
|
|
28
|
+
GLbyte = c_byte
|
|
28
29
|
GLubyte = c_ubyte
|
|
29
30
|
GLshort = c_short
|
|
30
31
|
GLushort = c_ushort
|