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.
Files changed (71) hide show
  1. pyglet/__init__.py +27 -42
  2. pyglet/app/base.py +2 -2
  3. pyglet/clock.py +1 -1
  4. pyglet/display/base.py +31 -21
  5. pyglet/display/cocoa.py +25 -1
  6. pyglet/display/headless.py +1 -1
  7. pyglet/display/win32.py +134 -18
  8. pyglet/display/xlib.py +285 -70
  9. pyglet/event.py +17 -1
  10. pyglet/experimental/README.md +1 -1
  11. pyglet/experimental/jobs.py +1 -1
  12. pyglet/experimental/multitexture_sprite.py +2 -2
  13. pyglet/font/__init__.py +1 -1
  14. pyglet/font/base.py +8 -5
  15. pyglet/font/dwrite/__init__.py +13 -8
  16. pyglet/font/dwrite/dwrite_lib.py +1 -1
  17. pyglet/font/user.py +1 -1
  18. pyglet/gl/base.py +8 -4
  19. pyglet/gl/cocoa.py +4 -0
  20. pyglet/gl/gl.py +4 -3
  21. pyglet/gl/gl.pyi +2320 -0
  22. pyglet/gl/gl_compat.py +7 -18
  23. pyglet/gl/gl_compat.pyi +3097 -0
  24. pyglet/gl/xlib.py +24 -0
  25. pyglet/graphics/shader.py +34 -20
  26. pyglet/graphics/vertexbuffer.py +1 -1
  27. pyglet/gui/frame.py +2 -2
  28. pyglet/gui/widgets.py +1 -1
  29. pyglet/image/__init__.py +3 -3
  30. pyglet/image/buffer.py +3 -3
  31. pyglet/input/base.py +8 -8
  32. pyglet/input/linux/evdev.py +1 -1
  33. pyglet/libs/darwin/cocoapy/cocoalibs.py +3 -1
  34. pyglet/libs/win32/__init__.py +12 -0
  35. pyglet/libs/win32/constants.py +4 -0
  36. pyglet/libs/win32/types.py +97 -0
  37. pyglet/libs/x11/xrandr.py +166 -0
  38. pyglet/libs/x11/xrender.py +43 -0
  39. pyglet/libs/x11/xsync.py +43 -0
  40. pyglet/math.py +40 -49
  41. pyglet/media/buffered_logger.py +1 -1
  42. pyglet/media/codecs/ffmpeg.py +18 -34
  43. pyglet/media/codecs/gstreamer.py +3 -3
  44. pyglet/media/codecs/pyogg.py +1 -1
  45. pyglet/media/codecs/wave.py +6 -0
  46. pyglet/media/codecs/wmf.py +33 -7
  47. pyglet/media/devices/win32.py +1 -1
  48. pyglet/media/drivers/base.py +1 -1
  49. pyglet/media/drivers/directsound/interface.py +4 -0
  50. pyglet/media/drivers/listener.py +2 -2
  51. pyglet/media/drivers/xaudio2/interface.py +6 -2
  52. pyglet/media/drivers/xaudio2/lib_xaudio2.py +1 -1
  53. pyglet/media/instrumentation.py +2 -2
  54. pyglet/media/player.py +2 -2
  55. pyglet/media/player_worker_thread.py +1 -1
  56. pyglet/media/synthesis.py +1 -1
  57. pyglet/model/codecs/gltf.py +1 -1
  58. pyglet/shapes.py +25 -24
  59. pyglet/sprite.py +1 -1
  60. pyglet/text/caret.py +44 -5
  61. pyglet/text/layout/base.py +3 -3
  62. pyglet/util.py +1 -1
  63. pyglet/window/__init__.py +54 -14
  64. pyglet/window/cocoa/__init__.py +27 -0
  65. pyglet/window/mouse.py +11 -1
  66. pyglet/window/win32/__init__.py +40 -14
  67. pyglet/window/xlib/__init__.py +21 -7
  68. {pyglet-2.1.5.dist-info → pyglet-2.1.8.dist-info}/METADATA +1 -1
  69. {pyglet-2.1.5.dist-info → pyglet-2.1.8.dist-info}/RECORD +71 -67
  70. {pyglet-2.1.5.dist-info → pyglet-2.1.8.dist-info}/LICENSE +0 -0
  71. {pyglet-2.1.5.dist-info → pyglet-2.1.8.dist-info}/WHEEL +0 -0
@@ -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
- def _get_font_reference(self, font_face: IDWriteFontFace) -> tuple[c_void_p, int]:
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
- return _get_font_ref(font_file, release_file=True)
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 re-use the bitmap as much as we can to minimize creations.
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 everytime we add a font.
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.width), round(metrics.height)
1166
+ return round(metrics.widthIncludingTrailingWhitespace), round(metrics.height)
1162
1167
 
1163
1168
  @classmethod
1164
1169
  def have_font(cls: type[Win32DirectWriteFont], name: str) -> bool:
@@ -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)), # Ambigious as newer is a pIUnknown and legacy is IUnknown.
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.iamge.ImageData` if
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 satisifies this configuration.
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 compatability with the canvas."""
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 bject
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 useable after being destroyed. Each platform
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, c_int,
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 = c_char
28
+ GLbyte = c_byte
28
29
  GLubyte = c_ubyte
29
30
  GLshort = c_short
30
31
  GLushort = c_ushort