@@ -442,12 +442,6 @@ class Surface:
442442 blending will be disabled. This full alpha is compatible with other
443443 kinds of transparency.
444444
445- This value is different than the per pixel Surface alpha. For a surface
446- with per pixel alpha, blanket alpha is ignored and ``None`` is returned.
447-
448- .. versionchangedold:: 2.0 per-surface alpha can be combined with per-pixel
449- alpha.
450-
451445 The optional flags argument can be set to ``pygame.RLEACCEL`` to provide
452446 better performance on non accelerated displays. An ``RLEACCEL`` Surface
453447 will be slower to modify, but quicker to blit as a source.
@@ -459,11 +453,77 @@ class Surface:
459453 def get_alpha (self ) -> Optional [int ]:
460454 """Get the current Surface transparency value.
461455
462- Return the current alpha value for the Surface. If the blendmode of the
463- Surface is not ``pygame.BLENDMODE_NONE``, this method will always return
464- a valid value in the range 0 (fully transparent) - 255 (fully opaque).
465- Otherwise, this method will return None until an alpha is set with
466- :meth:`set_alpha()` (the set alpha value will be returned).
456+ Return the current alpha value for the Surface which is an integer in the
457+ range 0 (fully transparent) - 255 (fully opaque) set by :meth:`set_alpha()`.
458+ Until an alpha is set this method will return None.
459+ """
460+
461+ def lock (self ) -> None :
462+ """Lock the Surface memory for pixel access.
463+
464+ Lock the pixel data of a Surface for access. On accelerated Surfaces, the
465+ pixel data may be stored in volatile video memory or nonlinear compressed
466+ forms. When a Surface is locked the pixel memory becomes available to
467+ access by regular software. Code that reads or writes pixel values will
468+ need the Surface to be locked.
469+
470+ Surfaces should not remain locked for more than necessary. A locked
471+ Surface can often not be displayed or managed by pygame.
472+
473+ Not all Surfaces require locking. The :meth:`mustlock()` method can
474+ determine if it is actually required. There is no performance penalty for
475+ locking and unlocking a Surface that does not need it.
476+
477+ All pygame functions will automatically lock and unlock the Surface data
478+ as needed. If a section of code is going to make calls that will
479+ repeatedly lock and unlock the Surface many times, it can be helpful to
480+ wrap the block inside a lock and unlock pair.
481+
482+ It is safe to nest locking and unlocking calls. The surface will only be
483+ unlocked after the final lock is released.
484+ """
485+
486+ def unlock (self ) -> None :
487+ """Unlock the Surface memory from pixel access.
488+
489+ Unlock the Surface pixel data after it has been locked. The unlocked
490+ Surface can once again be drawn and managed by pygame. See the
491+ :meth:`lock()` documentation for more details.
492+
493+ All pygame functions will automatically lock and unlock the Surface data
494+ as needed. If a section of code is going to make calls that will
495+ repeatedly lock and unlock the Surface many times, it can be helpful to
496+ wrap the block inside a lock and unlock pair.
497+
498+ It is safe to nest locking and unlocking calls. The surface will only be
499+ unlocked after the final lock is released.
500+ """
501+
502+ def mustlock (self ) -> bool :
503+ """Test if the Surface requires locking.
504+
505+ Returns ``True`` if the Surface is required to be locked to access pixel
506+ data. Usually pure software Surfaces do not require locking. This method
507+ is rarely needed, since it is safe and quickest to just lock all Surfaces
508+ as needed.
509+
510+ All pygame functions will automatically lock and unlock the Surface data
511+ as needed. If a section of code is going to make calls that will
512+ repeatedly lock and unlock the Surface many times, it can be helpful to
513+ wrap the block inside a lock and unlock pair.
514+ """
515+
516+ def get_locked (self ) -> bool :
517+ """Test if the Surface is current locked.
518+
519+ Returns ``True`` when the Surface is locked. It doesn't matter how many
520+ times the Surface is locked.
521+ """
522+
523+ def get_locks (self ) -> tuple [Any , ...]:
524+ """Gets the locks for the Surface.
525+
526+ Returns the currently existing locks for the Surface.
467527 """
468528
469529 def get_at (self , x_y : Point , / ) -> Color :
@@ -958,74 +1018,6 @@ class Surface:
9581018 .. versionadded:: 2.5.1
9591019 """
9601020
961- def lock (self ) -> None :
962- """Lock the Surface memory for pixel access.
963-
964- Lock the pixel data of a Surface for access. On accelerated Surfaces, the
965- pixel data may be stored in volatile video memory or nonlinear compressed
966- forms. When a Surface is locked the pixel memory becomes available to
967- access by regular software. Code that reads or writes pixel values will
968- need the Surface to be locked.
969-
970- Surfaces should not remain locked for more than necessary. A locked
971- Surface can often not be displayed or managed by pygame.
972-
973- Not all Surfaces require locking. The :meth:`mustlock()` method can
974- determine if it is actually required. There is no performance penalty for
975- locking and unlocking a Surface that does not need it.
976-
977- All pygame functions will automatically lock and unlock the Surface data
978- as needed. If a section of code is going to make calls that will
979- repeatedly lock and unlock the Surface many times, it can be helpful to
980- wrap the block inside a lock and unlock pair.
981-
982- It is safe to nest locking and unlocking calls. The surface will only be
983- unlocked after the final lock is released.
984- """
985-
986- def unlock (self ) -> None :
987- """Unlock the Surface memory from pixel access.
988-
989- Unlock the Surface pixel data after it has been locked. The unlocked
990- Surface can once again be drawn and managed by pygame. See the
991- :meth:`lock()` documentation for more details.
992-
993- All pygame functions will automatically lock and unlock the Surface data
994- as needed. If a section of code is going to make calls that will
995- repeatedly lock and unlock the Surface many times, it can be helpful to
996- wrap the block inside a lock and unlock pair.
997-
998- It is safe to nest locking and unlocking calls. The surface will only be
999- unlocked after the final lock is released.
1000- """
1001-
1002- def mustlock (self ) -> bool :
1003- """Test if the Surface requires locking.
1004-
1005- Returns ``True`` if the Surface is required to be locked to access pixel
1006- data. Usually pure software Surfaces do not require locking. This method
1007- is rarely needed, since it is safe and quickest to just lock all Surfaces
1008- as needed.
1009-
1010- All pygame functions will automatically lock and unlock the Surface data
1011- as needed. If a section of code is going to make calls that will
1012- repeatedly lock and unlock the Surface many times, it can be helpful to
1013- wrap the block inside a lock and unlock pair.
1014- """
1015-
1016- def get_locked (self ) -> bool :
1017- """Test if the Surface is current locked.
1018-
1019- Returns ``True`` when the Surface is locked. It doesn't matter how many
1020- times the Surface is locked.
1021- """
1022-
1023- def get_locks (self ) -> tuple [Any , ...]:
1024- """Gets the locks for the Surface.
1025-
1026- Returns the currently existing locks for the Surface.
1027- """
1028-
10291021 @property
10301022 def width (self ) -> int :
10311023 """Surface width in pixels (read-only).
0 commit comments