
    &hц                    >   S SK r S SKrS SKJr  S SKJrJr   S SK7  S SK
r
S SK7  S SKJr  S SKrS SKrS SKrS SKrS\R$                  " 5       :H  r " S S\R(                  5      r " S	 S
\R(                  5      r " S S\R(                  5      r " S S\R(                  5      r " S S\R(                  5      r " S S\R(                  5      r " S S\R(                  5      r " S S\R(                  5      r\S:X  a  \R<                  " 5         gg! \\	4 a     Nf = f)    N)
test_utils)example_pathSurfaceSubclass)*)BufferProxyPyPyc                       \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r\ RB                  " \"RF                  RI                  S5      S:H  S 5      S! 5       r%S" r&S# r'S$ r(S% r)S& r*\+" \,RZ                  S'5      r.\ RB                  " \.(       + S(5      S) 5       r/\ RB                  " \.(       + S(5      S* 5       r0S+ r1S, r2S- r3S. r4S/ r5S0r6g1)2SurfaceTypeTest   c                    Sn[         nSn[        SX!5      n[        R                  " X2U5      nU R	                  XT5        U R                  U[        R                  5        U R                  U[        5        U R                  UR                  5       U5        U R                  UR                  5       U5        U R                  UR                  5       U5        g)zUEnsure a subclassed surface can be used for pixel format
when creating a new surface.   )   %         N)SRCALPHAr   pygameSurfaceassertIsNotassertIsInstanceassertNotIsInstanceassertEqualget_size	get_flagsget_bitsize)selfexpected_depthexpected_flagsexpected_sizedepth_surfacesurfaces         Q/var/www/auris/envauris/lib/python3.13/site-packages/pygame/tests/surface_test.py.test_surface__pixel_format_as_surface_subclass>SurfaceTypeTest.test_surface__pixel_format_as_surface_subclass   s     ! '.Q..N0gv~~6  /:))+];**,n=,,.?    c                    [         R                  " S5      nU R                  UR                  S5      S5        [         R                  R                  S5        [         R                  " S5      nU R                  UR                  S5      S5        g )N)   r(   r   r   r   r   r        r-   )r   r   r   get_atdisplayset_moder   surfs     r#   !test_surface_created_opaque_black1SurfaceTypeTest.test_surface_created_opaque_black+   sd    ~~h'V,n= 	
+~~h'V,n=r&   c                 >   [         R                  " S5      n[         R                  " SSSS5      nUR                  U5        UR	                  SS5        UR                  S5        UR                  5       nU R                  US   S5        U R                  US   S5        g)z.see if surface.set_clip(None) works correctly.   X  
   r   N   r7   )r   r   Rectset_clipmove_ipget_clipr   )r   srress       r#   test_set_clipSurfaceTypeTest.test_set_clip4   s|    NN:&KKBB'	

1			"a	

4jjlQ#Q%r&   c                 j    [         R                  " SSS5      nU R                  [        U5      S5        g )NF   rF   r       z<Surface(70x70x32 SW)>)r   r   r   reprr1   s     r#   
test_printSurfaceTypeTest.test_print@   s)    ~~h2.d%=>r&   c                    [         R                  " S[        SS9nU R                  UR	                  5       [        -  [        5        U R                  UR                  5       S5        [         R                  " SSS5      nU R                  UR                  5       S5        [         R                  " SSS9nU R                  UR                  5       S5        g )NrE   rG   )flagsdepthr   r   r:   rM   )r   r   r   r   r   r   get_bytesize)r   r2   surf_16s      r#   test_keyword_arguments&SurfaceTypeTest.test_keyword_argumentsD   s    ~~hhbA)H4h?))+R0 ..1b1--/3 ..4--/3r&   c                    [         R                  " SSS5      nUR                  S5        UR                  SS5        UR	                  S5      nU R                  U[         R                  5        U R                  US5        UR                  S5        UR                  SS	5        UR	                  S5      nU R                  US
5        g )Nd   rU   r      r   r   r   r)   )r9   r9   r9   r+   r*   )r9      r+   )r   r   r+   r+   )r   r   fillset_atr.   r   Colorr   )r   r?   r@   s      r#   test_set_atSurfaceTypeTest.test_set_atQ   s    NN:q"-	y 	
*+HHVa.-. 	
~	(#HHW,-r&   c                    [         R                  R                  5          [         R                  R	                  [        [        R                  R                  SS5      5      5      nU R                  UR                  S5      [         R                  " SSS5      5        U R                  UR                  S5      [         R                  " SSS5      5        U R                  UR                  S5      [         R                  " SSS5      5        UR                  S[         R                  " SSS5      5        UR                  S[         R                  " SSS5      5        UR                  S[         R                  " SSS5      5        U R                  UR                  S5      [         R                  " SSS5      5        U R                  UR                  S5      [         R                  " SSS5      5        U R                  UR                  S5      [         R                  " SSS5      5        [         R                  R                  5         g! [         R                  R                  5         f = f)	z?png files are loaded in big endian format (BGR rather than RGB)datazBGR.pngr9   r9   r+   r   )r9   r(   )r9   (   N)r   r/   initimageloadr   ospathjoinr   r.   r[   rZ   quit)r   rc   s     r#   test_set_at__big_endian'SurfaceTypeTest.test_set_at__big_endianb   s   	"LL%%l277<<	3R&STEU\\(3V\\#q!5LMU\\(3V\\!S!5LMU\\(3V\\!Q5LM LL6<<Q#:;LL6<<3#:;LL6<<1c#:; U\\(3V\\#q!5LMU\\(3V\\!S!5LMU\\(3V\\!Q5LM NN!FNN!s   HI  I'c                    [         R                  " S[        S5      nU R                  UR	                  5       [        -  [        5        U R                  [        [         R                  S[         R                  S5        [         R                  " S[        5      nUR                  5       S:X  a,  U R                  UR	                  5       [        -  [        5        g g )NrE   rG   rT   rV   )r   r   r   r   r   assertRaises
ValueErrorr   r   r2   surf2s      r#   test_SRCALPHASurfaceTypeTest.test_SRCALPHAy   s    ~~h"5)H4h? 	*fnnj&//SUV x2"$U__.98D %r&   c                     [         R                  R                  5         [         R                  " S5      nU R	                  UR                  5       [        -  S5        g)zOis set to zero, and SRCALPHA is not set by default with no display initialized.rE   r   N)r   r/   rh   r   r   r   r   r1   s     r#   test_flags_default0_nodisplay-SurfaceTypeTest.test_flags_default0_nodisplay   s<    ~~h')H4a8r&   c                 @   [         R                  R                  S5         [         R                  " S5      nU R	                  UR                  5       [        -  S5        [         R                  R                  5         g! [         R                  R                  5         f = f)zWis set to zero, and SRCALPH is not set by default even when the display is initialized.)@     rE   r   N)r   r/   r0   r   r   r   r   rh   r1   s     r#   test_flags_default0_display+SurfaceTypeTest.test_flags_default0_display   sd    
+	">>(+DT^^-8!<NN!FNN!s   =A= = Bc                     S nSnU R                  U" SSU5      S 5        SnU R                  [        USSU5        U R                  [        USSU5        SnU R                  [        USSU5        g )Nc                 4    [         R                  " SXU5        g )Nr`   )r   r   )bpprL   maskss      r#   	make_surf-SurfaceTypeTest.test_masks.<locals>.make_surf   s    NN8U7r&   )      ~       r   rG   r   )i   r   r+   r   rV   )i  o r   r+   r   )r   rl   rm   )r   r~   r}   s      r#   
test_masksSurfaceTypeTest.test_masks   ss    	8 22q%0$7+*iQ>*iQ>+*iQ>r&   c                 |   [         R                  " S[        S5      nUR                  S5        UR	                  5       nU R                  UR                  S5        U R                  UR                  S5        UR                  SS5        UR	                  5       nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        UR                  S	S5        UR	                  5       nU R                  UR                  S
5        U R                  UR                  S
5        U R                  UR                  S5        U R                  UR                  S5        [         R                  " SSS5      nUR                  S5        UR	                  5       nU R                  UR                  UR                  5       5        U R                  UR                  UR                  5       5        UR                  S5        UR	                  5       nU R                  UR                  S5        U R                  UR                  S5        UR                  SS5        UR	                  5       nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        UR                  SS5        UR	                  5       nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        [         R                  R                  5          [         R                  " SSS5      nUR                  S5        UR	                  5         [         R                  R!                  5         g ! [         R                  R!                  5         f = f)NrE   rG   r   r   r   r   r   )   r   )r+   r+   r+   rX   r   rX   )   r   r   r:   rV   rW   r+   r+   r+   <   r      )   rX      )r   r   r   rY   get_bounding_rectr   widthheightrZ   lefttop	get_width
get_heightset_colorkeyr/   rb   rh   )r   r2   
bound_rects      r#   test_get_bounding_rect&SurfaceTypeTest.test_get_bounding_rect   s,   ~~h"5		,++-
))1-**A.H01++-
"-,))1-**A.H01++-
"-,))1-**A.~~h2.		)++-
))4>>+;<**DOO,=>)$++-
))1-**A.Ho.++-
"-,))1-**A.Ho.++-
"-,))2.**B/ 		">>&!Q/DIIo&""$NN!FNN!s   9P  P;c                 d   Sn[         R                  " S[         R                  S5      nUR                  U5        UR	                  5       nUR                  5       nUR                  5       nU R                  UR                  UR                  5        U R                  UR                  S5      U5        g)zEnsure a surface can be copied.r   r   r   r   rG   rG   rG   r`   N)	r   r   r   rY   copyget_rectr   sizer.   )r   colors1s2s1rects2rects         r#   	test_copySurfaceTypeTest.test_copy   sz     ^^Hfoor:
WWYfkk28,e4r&   c                    Sn[         R                  " SSSS5      n[         R                  " S[         R                  S5      nUR	                  X5        [
        R                  " U5       H$  nU R                  UR                  U5      U5        M&     [
        R                  " U5       H$  nU R                  UR                  U5      U5        M&     g)zEnsure a surface can be filled.r   r   r   r   rG   N)r   r;   r   r   rY   r   rect_area_ptsr   r.   rect_outer_boundsassertNotEqual)r   r   	fill_rectr   pts        r#   	test_fillSurfaceTypeTest.test_fill   s     KK1b"-	^^Hfoor:
!**95BRYYr]E2 6 ..y9B		"u5 :r&   c                 *   Sn[         R                  " S5      n[         R                  " S5      nUR                  S[         R                  5        U R	                  UR                  5       [         R                  -  5        UR                  US5        UR                  U5        U R                  UR                  5       UR                  5       [         R                  -  S:g  5        U R	                  UR                  5       [         R                  -  5        g)zTest RLEACCEL flag with fill()   r   r   r+   r   r+   r   r+   r)   r   N)r   r   r   RLEACCEL
assertTruer   
RLEACCELOKblitrY   r   mustlock)r   r   r2   	blit_surfs       r#   test_fill_rleSurfaceTypeTest.test_fill_rle   s    "~~h'NN8,	}foo>	++-0A0AAB		)V$u 9#6#6#86??#Jq"P	
 		++-?@r&   c                    [         R                  " S5      n[         R                  " S5      nUR                  S[         R                  5        U R	                  UR                  5       [         R                  -  5        UR                  US5        U R	                  UR                  5       [         R                  -  5        U R	                  UR                  5       5        g)z"Test RLEACCEL flag with mustlock()rT   r   r   r+   r)   N)	r   r   r   r   r   r   r   r   r   r   r2   r   s      r#   test_mustlock_rle!SurfaceTypeTest.test_mustlock_rle  s    ~~j)NN:.	{FOO<	++-0A0AAB		)V$	++-?@	**,-r&   c                 :   [         R                  " S5      n[         R                  " SS[         R                  S9nUR                  S[         R                  5        U R                  UR                  5       [         R                  -  5        UR                  US5        U R                  UR                  5       [         R                  -  5        U R                  UR                  5       [         R                  -  5        U R                  UR                  5       5        g)zZTest RLEACCEL flag with mustlock() on a surface
with per pixel alpha - new feature in SDL2rT   rG   )rM   rL   )      r   r+   r)   N)
r   r   r   r   r   r   r   r   r   r   r   s      r#   test_mustlock_surf_alpha_rle,SurfaceTypeTest.test_mustlock_surf_alpha_rle  s     ~~j)NN:RvO	3V__E	++-0A0AAB		)V$	++-?@	++-?@	**,-r&   c                    [         R                  " SS5      nUR                  S[         R                  5        U R	                  UR                  5       [         R                  -  5        UR                  5       nU R	                  UR                  5       [         R                  -  5        U R	                  UR                  5       [         R                  -  5        g)z5Test copying a surface set to use run length encodingr   rV   r   N)r   r   r   r   r   r   r   r   )r   r   newsurfs      r#   test_copy_rleSurfaceTypeTest.test_copy_rle  s    ^^Hb)
v7):)::;'')):)::;))+f.?.??@r&   c                 .   SnSn[         R                  " SSSS5      n[         R                  " SS5      n[         R                  " SS5      nUR                  S[         R                  5        UR                  U5        UR                  U5      nUR                  U5        UR                  US5        U R                  UR                  5       [         R                  -  5        U R                  UR                  5       [         R                  -  (       + 5        g	z<Ensure an RLE sub-surface works independently of its parent.r   )rw   rw   r   r+   r   r   rV   r   r)   N)
r   r;   r   r   r   rY   
subsurfacer   r   r   r   r   color2sub_rects0r   r   s          r#   test_subsurface_rle#SurfaceTypeTest.test_subsurface_rle"  s    "%;;r2r2.^^Hb)^^Hb)
v7
]]8$

F89BLLNV__<<=r&   c                 .   SnSn[         R                  " SSSS5      n[         R                  " SS5      n[         R                  " SS5      nUR                  S[         R                  5        UR                  U5        UR                  U5      nUR                  U5        UR                  US5        U R                  UR                  5       [         R                  -  5        U R                  UR                  5       [         R                  -  (       + 5        gr   )r   r;   r   r   r   rY   r   r   r   r   r   r   s          r#   test_subsurface_rle2$SurfaceTypeTest.test_subsurface_rle21  s    "%;;r2r2.^^Hb)^^Hb)
v7
]]8$

F):)::;BLLNV->->>>?r&   c                 X  ^  U 4S jn[         R                  R                  5          [         R                  R                  S5        [         R                  R                  [        [        R                  R                  SS5      5      5      nUR                  5       nUR                  5       nU" U5      nU" U5      nT R                  UR                  5       [         R                  -  5        T R                  UR                  5       [         R                  -  (       + 5        T R!                  UR                  5       U5        T R                  [#        U[         R$                  5      5        [         R                  R'                  5         g! [         R                  R'                  5         f = f)zTest for error/crash when calling set_colorkey() followed
by convert twice in succession. Code originally taken
from solarwolf.c                    > U R                  5       nU R                  U[        5        TR                  U R                  5       U5        U R	                  5       $ N)get_colorkeyr   r   r   convert)imgclearr   s     r#   optimize:SurfaceTypeTest.test_solarwolf_rle_usage.<locals>.optimizeF  sF    $$&EUH-S--/7;;= r&   i    r_   
alien1.pngN)r   r/   rb   r0   rc   rd   r   re   rf   rg   r   r   r   r   r   r   r   
isinstancer   rh   )r   r   rc   orig_colorkeys   `   r#   test_solarwolf_rle_usage(SurfaceTypeTest.test_solarwolf_rle_usageA  s   
	! 		"NN##J/LL%%l277<<3U&VWEMMOE!..0MUOEUOEOOEOO-0A0AABOO 1FOO CCDU//1=AOOJufnn=>NN!FNN!s   EF	 	 F)c                    [         R                  R                  5          [         R                  R                  SSS9  [         R                  " S5      n[         R
                  R                  [        [        R                  R                  SS5      5      5      nUR                  5       nUR                  5       nUR                  U[        5        U R                  UR!                  5       [         R"                  -  5        U R                  UR!                  5       [         R                  -  (       + 5        UR%                  US5        U R                  UR!                  5       [         R"                  -  5        U R                  UR!                  5       [         R                  -  5        UR'                  S5        U R                  UR!                  5       [         R"                  -  (       + 5        U R                  UR!                  5       [         R                  -  (       + 5        [         R                  R)                  5         g	! [         R                  R)                  5         f = f)
z'Test for RLE status after setting alphar   rG   rN   rT   r_   r   r)   Z   N)r   r/   rb   r0   r   rc   rd   r   re   rf   rg   r   r   r   r   r   r   r   r   	set_alpharh   )r   blit_to_surfrc   r   s       r#   test_solarwolf_rle_usage_2*SurfaceTypeTest.test_solarwolf_rle_usage_2]  s    		"NN##Jb#9!>>*5LLL%%l277<<3U&VWEMMOE!..0M }h7OOEOO-0A0AABOO 1FOO CCD eV,OOEOO-0A0AABOOEOO-?@ OOBOO 1F4E4E EEFOO 1FOO CCD NN!FNN!s   HI  I!c                 @   [         R                  R                  5          [         R                  R                  S5        [         R                  " S5      nUR                  S5        [         R                  R                  [        [        R                  R                  SS5      5      5      nUR                  5       nUR                  5       nUR                  S[        5        UR!                  US5        UR#                  S5      nU R%                  UR                  5       U5        UR'                  U[        5        UR                  S5        UR!                  US5        UR#                  S5      nU R)                  UR*                  UR*                  S	S
9  U R)                  UR,                  UR,                  S	S
9  U R)                  UR.                  UR.                  S	S
9  [         R                  R1                  5         g ! [         R                  R1                  5         f = f)Nr   )P   G   r   r_   r   r   r)   2   r   r:   delta)r   r/   rb   r0   r   rY   rc   rd   r   re   rf   rg   r   r   r   r   r   r.   r   r   assertAlmostEqualr@   gbrh   )r   r   rc   r   sample_pixel_rlesample_pixel_no_rles         r#    test_set_alpha__set_colorkey_rle0SurfaceTypeTest.test_set_alpha__set_colorkey_rle|  s   	"NN##J/!>>(3Lo.LL%%l277<<3U&VWEMMOE!..0M OOB)eV,+228< U//1=A}h7o.eV,"."5"5h"?""#3#5#57J7L7LTU"V""#3#5#57J7L7LTU"V""#3#5#57J7L7LTU"V NN!FNN!s   F>G= = Hc                    SnSn[         R                  " SSSS5      n[         R                  " S[         R                  S5      nUR	                  X5      nUR                  S5      nU R                  Xa5        UR                  S5      nUR	                  US	5      nUR                  S
5      n	U R                  Xa5        UR	                  US5      n
U R                  [        U
5      S5        g )Nr   )r(   r(   r(   r   ir   r   rG   r)   )   r   r   r   )r   r   r   r   r   )r   r   r   r   )	r   r;   r   r   rY   r.   r   r   tuple)r   r   r   r   r   r1cr   r2c2r3s              r#   test_fill_negative_coordinates.SurfaceTypeTest.test_fill_negative_coordinates  s     !KKS"b1	^^Hfoor:WWU&IIf" ]]<(WWV^,YYv" WWV-.rL1r&   c                     SnSn[         R                  " SSS5      nUR                  [         R                  XS9  U R	                  UR                  S5      S5        U R	                  UR                  S	5      U5        g
)z(Ensure fill() accepts keyword arguments.rX   r:      r+   rX   rX   r:   r:   r   r   rG   special_flagsr   rectr)   r*   rX   rX   N)r   r   rY   	BLEND_ADDr   r.   )r   r   arear   s       r#   test_fill_keyword_args&SurfaceTypeTest.test_fill_keyword_args  sf    ^^FAr*
f..eG6*N;6*E2r&   c                 f   [         R                  " S[         R                  S5      nU R                  UR	                  5       S5        S He  nUR                  U5        [        S5       H"  nUR                  UR	                  5       5        M$     U R                  UR	                  5       U5        Mg     g)z0Ensure a surface's alpha value can be retrieved.r   rG   r+   )r   rG      r+   r   N)r   r   r   r   	get_alphar   range)r   r   alphats       r#   test_get_alphaSurfaceTypeTest.test_get_alpha  s|    ^^Hfoor:-&ELL1XR\\^,  R\\^U3 'r&   c                    [         R                  R                  5          SnSn[         R                  " S[         R                  U5      nU R                  UR                  5       U5        U R                  UR                  5       U5        SnSn[         R                  " SSU5      nU R                  UR                  5       U5        U R                  UR                  5       U5        SnSn[         R                  " SSU5      nU R                  UR                  5       U5        U R                  UR                  5       U5        U R                  [         R                  5         [         R                  R                  5       n[         R                  R                  5         UR                  5         SSS5        [         R                  R                  5         g! , (       d  f       N-= f! [         R                  R                  5         f = f)	z7Ensure a surface's bit and byte sizes can be retrieved.rG   r   r      r:   r      N)r   r/   rb   r   r   r   rO   r   rl   errorr0   rh   )r   rM   depth_bytesr   r"   s        r#   test_get_bytesize!SurfaceTypeTest.test_get_bytesize  sl   	"EK&//5ABR__.<R^^-u5EK!U3BR__.<R^^-u5EK!U3BR__.<R^^-u5""6<<0 ..113##%$$& 1
 NN! 10
 NN!s%   EG& !AG.G& 
G#G& & Hc                     [         R                  " S[         R                  S5      nU R                  UR	                  5       [         R                  5        g)z*Ensure a surface's flags can be retrieved.r   rG   N)r   r   r   r   r   )r   r   s     r#   test_get_flagsSurfaceTypeTest.test_get_flags  s2    ^^Hfoor:9r&   SDL_VIDEODRIVERdummy&requires a non-"dummy" SDL_VIDEODRIVERc                    [         R                  R                  5          [         R                  R                  SSS9nU R	                  UR                  5       [         R                  -  5        [         R                  R                  S[         R                  S9nU R                  UR                  5       [         R                  -  5        [         R                  R                  SSS9nU R	                  UR                  5       [         R                  -  5        [         R                  R                  S[         R                  S9nU R                  UR                  5       [         R                  -  5        [         R                  R                  SSS9nU R	                  UR                  5       [         R                  -  5        [         R                  R                  S[         R                  S9nU R                  UR                  5       [         R                  -  5        [         R                  R                  SSS9nUR                  5       [         R                  -  (       d0  U R	                  UR                  5       [         R                  -  5         [         R                  R                  S[         R                  S5        U R                  UR                  5       [         R                  -  5        [         R                  R                  5         g ! [         R                   a     N5f = f! [         R                  R                  5         f = f)N)r8     r   )rL   rw   rw   rG   )r   r/   rb   r0   assertFalser   
FULLSCREENr   NOFRAME	RESIZABLEOPENGLr  rh   )r   screen_surfs     r#   test_get_flags__display_surf,SurfaceTypeTest.test_get_flags__display_surf  sP   
 	#	" ..11*A1FK[224v7H7HHI ..11*FDUDU1VKOOK113f6G6GGH !..11*A1FK[224v~~EF ..11*FNN1SKOOK113fnnDE !..11*A1FK[224v7G7GGH ..11*FDTDT1UKOOK113f6F6FFG !..11*A1FK))+fmm;  !6!6!86==!HII''
FMM2F  5 5 7&-- GHNN! << 
 NN!s0   I2L+ /L 0L+ L(%L+ 'L((L+ + Mc                 \   [         R                  R                  5          [         R                  " S5      nUR	                  S5      nU R                  UR                  5       U5        U R                  [         R                  5         [         R                  R                  5       n[         R                  R                  5         UR                  5         SSS5        [         R                  R                  5         g! , (       d  f       N-= f! [         R                  R                  5         f = f)z+Ensure a surface's parent can be retrieved.r   r   )r   r   r   r   N)r   r/   rb   r   r   assertIs
get_parentrl   r  r0   rh   )r   parentchildr"   s       r#   test_get_parentSurfaceTypeTest.test_get_parent   s    	"^^H-F%%l3EMM%**,f5""6<<0 ..113##%""$ 1
 NN! 10
 NN!s%   A&D AC:D :
DD  D+c                     Sn[         R                  " U5      nUR                  5       nU R                  UR                  U5        g)z)Ensure a surface's rect can be retrieved.r3  N)r   r   r   r   r   )r   r   r2   r  s       r#   test_get_rectSurfaceTypeTest.test_get_rect2  s4    ~~d#}}D)r&   c                 D   [        SSS5       H  n[        SSS5       H{  n[        R                  " X45      nU R                  UR	                  5       U5        U R                  UR                  5       U5        U R                  UR                  5       X45        M}     M     g)z;Ensure a surface's size, width and height can be retrieved.r   r+   rG   r  r  N)r  r   r   r   r   r   r   )r   whr?   s       r#   test_get_width__size_and_height/SurfaceTypeTest.test_get_width__size_and_height<  s|    q#r"A1c2&NNA6*  2  3  v6	 ' #r&   c                 X   [         n[        R                  " SSS5      nUR                  S5      nU R	                  XR                  S5        U R	                  XR                  S5        U R                  U[        5        U R	                  XR                  S5        [        R                  " SSS5      nUR                  5       UR                  5       -  UR                  5       -  nUR                  S5      nUR                  S5      nU R                  U[        5        U R                  UR                  U5        U R                  U[        5        U R                  UR                  U5        [        R                  " SSS	5      nUR                  S5      nU R	                  XR                  S5        U R	                  XR                  S5        U R                  U[        5        U R	                  XR                  S5        [        R                  " SSS	5      nUR                  5       UR                  5       -  UR                  5       -  nUR                  S5      nUR                  S5      nU R                  U[        5        U R                  UR                  U5        U R                  U[        5        U R                  UR                  U5        [        R                  " S[        R                  S	5      nUR                  S5      nU R                  U[        5        U R	                  XR                  S5        [        R                  " SSS
5      nUR                  S5      nUR                  S5      nU R	                  XR                  S5        U R	                  XR                  S5        U R                  U[        5        U R                  U[        5        [        R                  " SSS
5      nUR                  5       UR                  5       -  UR                  5       -  nUR                  S5      nUR                  S5      nU R                  U[        5        U R                  UR                  U5        U R                  U[        5        U R                  UR                  U5        [        R                  " SSS5      nUR                  5       UR                  5       -  UR                  5       -  nUR                  S5      nUR                  S5      nUR                  S5      nUR                  S5      nU R                  U[        5        U R                  UR                  U5        U R                  U[        5        U R                  UR                  U5        U R                  U[        5        U R                  U[        5        UR                  S5      nU R	                  XR                  S5        U R	                  XR                  S5        Sn[        R                  " S[        R                  S5      nS H(  n	U R                  UR                  U	5      [        5        M*     [        R                  " SSS5      nUR                  5       n
[        (       d'  [        U
5      nU R                  UR                   S5        [        R                  " SSS5      nU R#                  UR%                  5       5        UR                  S5      n
U R#                  UR%                  5       5        U
R&                  nU R)                  UR%                  5       5        Sn[*        R,                  " 5         U R)                  UR%                  5       5        Sn
[*        R,                  " 5         U R#                  UR%                  5       5        [        R                  " S[        R                  S5      nU R	                  [.        UR                  S5        U R	                  [.        UR                  S5        U R	                  [.        UR                  S5        U R	                  [.        UR                  S5        [        R                  " SSS5      nUR                  S5        UR                  S5        [        R                  " SSS5      n[0        R2                  " U5      nUR                  S5      n
[0        R2                  " U
5      n[*        R,                  " 5         U R)                  U" 5       UL 5        U R)                  U" 5       U
L 5        A
[*        R,                  " 5         U R)                  U" 5       UL 5        U R)                  U" 5       SL 5        A[*        R,                  " 5         U R)                  U" 5       SL 5        g)z>Ensure a buffer view of the surface's pixels can be retrieved.r      r   r   2013)r   rD  r   rV   rG   )r   r   r   rD  N)
rE  rH  aAr@   Rr   Gr   Br:   r   r:    9RGBA   2)rm   r   r   get_viewrl   r   r   rO   r   r   r   lengthr   r   IS_PYPYArrayInterfacendr*  
get_locked__array_interface__r   gccollect	TypeErrorweakrefref)r   Errorr?   v2rT  v0v1v3r   kindvair   weak_sweak_vs                  r#   test_get_viewSurfaceTypeTest.test_get_viewE  s    NN61a(ZZ_%S1%S1b+.%S1NN61a(!AKKM1ALLNBZZ_ZZ_b+.F+b+.F+NN61b)ZZ_%S1%S1b+.%S1NN61b)!AKKM1ALLNBZZ_ZZ_b+.F+b+.F+NN66??B7ZZ_b+.%S1NN61b)ZZ_ZZ_%S1%S1b+.b+.NN61b)!AKKM1ALLNBZZ_ZZ_b+.F+b+.F+NN61b)!AKKM1ALLNBZZ_ZZ_ZZ_ZZ_b+.F+b+.F+b+.b+.\\,'%c2%c2NN66??B7FD!!!**T"2K@ G NN61b)JJLw"BRUUA& NN61b)(JJsO(!!'


'


( NN66??B7)QZZ4)QZZ5)QZZ8)QZZ3 NN61b)	

3	

4 NN61b)QJJsOQ


A&A&


A&D()


D()r&   c                 \   S H  n[         R                  " SSU5      nUR                  5       UR                  5       -  nUR	                  5       nU R                  U[        5        U R                  UR                  U5        U R                  [        U5      SU S35        M     [         R                  " SSS5      nUR                  S5      nUR                  5       UR                  5       -  nUR	                  5       nU R                  U[        5        U R                  UR                  U5        [         R                  " S	SS5      nUR	                  5       nU R                  UR                  5       5        S n[        R                  " 5         U R                  UR                  5       5        g )
Nr   r   rV   rG   rC  r   z<BufferProxy(z)>)rD  r9   rG   )rX   r:   r   rD  rN  )r   r   	get_pitchr   
get_bufferr   r   r   rT  rH   r   r   rX  rZ  r[  r*  )r   bitsizer?   rT  re  r   s         r#   test_get_bufferSurfaceTypeTest.test_get_buffer  s<    'Gvq'2A[[]Q\\^3FA!!![1QXXv.T!WfXR&@A ' NN7Ar*\\,'"--/1MMOa-6* NN61b)LLN'


(r&   get_segcountzold buffer not availablec                    SSK JnJn  [        R                  " S[        R
                  S5      nUR                  5       nU" U5      u  pVU R                  US5        U R                  XcR                  5       UR                  5       -  5        U" US5      u  pxU R                  XR                  5        U R                  Xv5        g )Nr   rr  get_write_bufferrN  rG   rX   )pygame.bufferproxyrr  ru  r   r   r   rn  r   rm  r   _pixels_address	r   rr  ru  r?   re  segcountbuflenseglensegaddrs	            r#   test_get_buffer_oldbuf&SurfaceTypeTest.test_get_buffer_oldbuf  s    ENN66??B7LLN'?1%!?@*1a0"3"34(r&   c                    SSK JnJn  [        R                  " S[        R
                  S5      nUR                  S5      nU" U5      u  pVU R                  US5        U R                  XcR                  5       UR                  5       -  5        U" US5      u  pxU R                  XR                  UR                  5       S-  -   5        U R                  XsR                  5       5        g )Nr   rt  rN  rG   rG  r   rD  )rv  rr  ru  r   r   r   rS  r   rm  r   rw  rO   rx  s	            r#   test_get_view_oldbuf$SurfaceTypeTest.test_get_view_oldbuf  s    ENN66??B7JJsO'?1%!?@*1a0"3"3ann6F6J"JK!12r&   c                 *   [         R                  " S[         R                  S5      nSnU He  nUR                  U5        [	        S5       H"  nUR                  UR                  5       5        M$     U R                  UR                  5       U5        Mg     g )Nr3  rG   ))r(      r(   r+   )   r   r   r+   )   r   r+   r+   r   )r   r   r   r   r  r   r   )r   r?   	colorkeyscolorkeyr  s        r#   test_set_colorkey!SurfaceTypeTest.test_set_colorkey  so     NN8V__b9P	!HNN8$1Xq~~/0  Q^^-x8 "r&   c                     [         R                  " S5      nUR                  5       u  p#pEU R                  [        UR
                  XCX%45        g Nr   )r   r   	get_masksrl   r\  	set_masksr   r?   r@   r   r   rI  s         r#   test_set_masksSurfaceTypeTest.test_set_masks'  s9    NN8$[[]
a)Q[[1,?r&   c                     [         R                  " S5      nUR                  5       u  p#pEU R                  [        UR
                  XCX%45        g r  )r   r   
get_shiftsrl   r\  
set_shiftsr  s         r#   test_set_shiftsSurfaceTypeTest.test_set_shifts,  s9    NN8$\\^
a)Q\\A!<@r&   c                 V   Sn[         R                  " SSS5      n[         R                  " SSS5      nUR                  S5        UR                  [        USUR                  5       S9  U R                  UR                  S	5      S
5        U R                  UR                  S5      U5        g )Nr  r   r   rG   r:   r:   )rX   r:   r  r  )r  sourcedestr  r)   r*   )r   r   rY   r   r  r   r   r.   )r   r   r   r   s       r#   test_blit_keyword_args&SurfaceTypeTest.test_blit_keyword_args1  s    ^^FAr*^^FAr*
	
ibkkmT6*N;6*E2r&   c                 &   [         R                  " SSS5      nSnUR                  U5        [         R                  " SSS5      nSnUR                  U5        UR                  USSS	9  UR                  US
SS	9  UR                  USSS	9  U R	                  UR                  S5      U5        U R	                  UR                  S5      U5        U R	                  UR                  S5      U5        U R	                  UR                  S5      U5        U R	                  UR                  S5      U5        U R	                  UR                  S5      U5        U R	                  UR                  S5      U5        U R	                  UR                  S5      U5        g)z8SDL2 can have more than 16 bits for x, y, width, height.)rU   i	 r   rG   r+   r   r   r,   r   r+   r   rT   )r   i>  rU   rU   )r  r)  )r   i }  rU   rU   ),  r  )r   i rU   rU   )e   r  )   r  )-  r  )r(  r  )r(  r  )rU   r  )c   r  )  r  N)r   r   rY   r   r   r.   )r   big_surfbig_surf_color
backgroundbackground_colors        r#   test_blit_big_rects#SurfaceTypeTest.test_blit_big_rects:  sf   >>,26$n%^^J26
&() 	*3GH*3GH*3GH 	**:6G**:6G**:6G 	**:68HI**:68HI**:68HI**846FG**:68HIr&    N)7__name__
__module____qualname____firstlineno__r$   r3   rB   rI   rQ   r\   ri   rp   rs   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r"  unittestskipIfre   environgetr0  r8  r;  r@  ri  rp  hasattrr   bufferproxyOLDBUFr}  r  r  r  r  r  r  __static_attributes__r  r&   r#   r
   r
      sY   @">
&?4."".E9"?1"f56A .
.A>@ "8">"<2,34"D: __


()W40%"	%"R"$*7S*j)< V''8F__Z!;<
) =
) __Z!;<
3 =
39&@
A
3Jr&   r
   c                   T    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)TestSurfaceBlitiV  z/Tests basic blitting functionality and options.c                 8   [         R                  " SS5      U l        U R                  R                  [         R                  " SSS5      5        [         R                  " SS5      U l        U R
                  R                  [         R                  " SSS5      5        g)zResets starting surfaces.   r  rG   r+   @   r  r   N)r   r   src_surfacerY   r[   dst_surfacer   s    r#   setUpTestSurfaceBlit.setUpv  sj    !>>*b9fll3S9:!>>(B7fll1a34r&   c                 p   U R                   R                  U R                  S5      nU R                  U[        R
                  5        U R                  UR                  S5        [        S5       Vs/ s H  o"U4PM     sn H.  nU R                  U R                   R                  U5      S5        M0     gs  snf )z4Full coverage w/ overflow, specified with Coordinater)   r  r  r   N)
r  r   r  r   r   r;   r   r   r  r.   r   resultxks       r#   test_blit_overflow_coord(TestSurfaceBlit.test_blit_overflow_coord}  s    !!&&t'7'7@ffkk2h/"'),)Qa&),AT--44Q7I -,s   0B3c           	         U R                   R                  U R                  [        R                  " SSSS5      5      nU R                  U[        R                  5        U R                  UR                  S5        [        S5       Vs/ s H  o"U4PM     sn H.  nU R                  U R                   R                  U5      S5        M0     gs  snf )z0Full coverage w/ overflow, specified with a Rectr  r  r  r   N
r  r   r  r   r;   r   r   r   r  r.   r  s       r#   test_blit_overflow_rect'TestSurfaceBlit.test_blit_overflow_rect  s    !!&&t'7'7RSRU9VWffkk2h/"'),)Qa&),AT--44Q7I -,s   C
c                    U R                   R                  U R                  [        R                  " S5      S9nU R                  U[        R                  5        U R                  UR                  S5        U R                  U R                   R                  S5      S5        U R                  U R                   R                  S5      S5        U R                  U R                   R                  S5      S5        U R                  U R                   R                  S5      S	5        U R                  U R                   R                  S5      S	5        g
)zPTest Rectangle Dest, with overflow but with starting rect with top-left at (1,1)rX   rX   rX   rX   )r  ?   r  r)   rW   r  r   r   r  r  r   N	r  r   r  r   r;   r   r   r   r.   r   r  s     r#   test_blit_overflow_nonorigin,TestSurfaceBlit.test_blit_overflow_nonorigin  s    !!&&t'7'7fkk,>W&Xffkk2h/))008)D))0099E))0099E))008/J))00:OLr&   c                 p   U R                   R                  U R                  [        R                  " S5      [        R                  " S5      S9nU R                  U[        R                  5        U R                  UR                  S5        U R                  U R                   R                  S5      S5        U R                  U R                   R                  S5      S5        U R                  U R                   R                  S5      S5        U R                  U R                   R                  S	5      S5        U R                  U R                   R                  S
5      S5        U R                  U R                   R                  S5      S5        U R                  U R                   R                  S5      S5        g)zTesting area constraintr  r:   r:   r:   r:   r  r  r  r)   rW   r  r  r  r  r   r  r  Nr  r  s     r#   test_blit_area_contraint(TestSurfaceBlit.test_blit_area_contraint  sT   !!&&\*\* ' 

 	ffkk2f-))008)D))0099E))0099E))00:IF##F+_	
 	))008/J))008)Dr&   c                 j   U R                   R                  U R                  [        R                  " S5      [        R                  " S5      S9nU R                  U[        R                  5        U R                  UR                  S5        [        S5       Vs/ s H  o"U4PM     sn H.  nU R                  U R                   R                  U5      S5        M0     U R                  U R                   R                  S5      S5        U R                  U R                   R                  S5      S5        g	s  snf )
zTesting zero-overlap condition.) r  rX   rX   )r:   r:   r  r  r  r)   r  rW   r  r  Nr  r  s       r#   test_blit_zero_overlap&TestSurfaceBlit.test_blit_zero_overlap  s    !!&&/0-. ' 

 	ffkk2f-"'),)Qa&),AT--44Q7C -##G,i	
 	))0099E -s   D0c                    [         R                  " S[        S5      nUR                  5       n[        R
                  " UR                  5       5       H3  u  p4UR                  X44USSU45        UR                  X44SUSS45        M5     UR                  US5        [        R
                  " UR                  5       5       H9  nU R                  UR                  U5      S   UR                  U5      S   5        M;     g )Nr  rG   r   r+   r)   rX   )r   r   r   r   r   r   r   rZ   r   r   r.   )r   srcdstijr   s         r#   !test_blit__SRCALPHA_opaque_source1TestSurfaceBlit.test_blit__SRCALPHA_opaque_source  s    nnZ26hhj,,S\\^<DAJJv1a|,JJv1a~. = 	f**3<<>:BSZZ^A.

2q0AB ;r&   c           	      f   [         R                  " S[        S5      nUR                  5       n[        R
                  " UR                  UR                  5       H  u  p4UR                  X45        M     UR                  5       nUR                  US5        [        UR                  5       HW  n[        UR                  5       H;  nUR                  Xg45      =u  ppnXXUSU-
  S-  -  -   4nU R                  X5        M=     MY     U R                  UR                  5       UR                  5       5        g)zbTest that blit operation works on self, alpha value is
correct, and that no RGB distortion occurs.)r  r  rG   r)   r  N)r   r   r   r   r   gradientr   r   rZ   r   r   r  r.   r   )r   test_surfacer  r   
test_colorreference_surfacer  yr@   r   r   rI  reference_colorexpected_colors                 r#   test_blit__blit_to_self'TestSurfaceBlit.test_blit__blit_to_self  s    ~~j(B?$$&(11$**dkkJNB/ K )--/,/tzz"A4;;'1B1I1I1&1QQq"#sQw36F1G,H!J  A ( # 	*335|7L7L7NOr&   c                    ^ ^^ SmS mUU U4S jnUU U4S jn[        SS5       H&  n[        SS5       H  nU" XC5        U" XC5        M     M(     g)	zTests blitting a nonzero alpha surface to another nonzero alpha surface
both straight alpha compositing method. Test is fuzzy (+/- 1/256) to account for
different implementations in SDL1 and SDL2.
r   c                 <    X-
   H  n[        U5      S:  d  M    g   g)zAReturns True if two colors are within (1, 1, 1, 1) of each other.rX   FT)abs)color1r   vals      r#   check_color_diffRTestSurfaceBlit.test_blit__SRCALPHA_to_SRCALPHA_non_zero.<locals>.check_color_diff  s!    s8a<  ' r&   c                   >^ [         R                  " T	[         R                  S5      nUR                  5       n[	        X X45      n[	        XX45      mUR                  U5        UR                  T5        UR                  US5        T[	        [        U4S jU 5       5      5      -   nTR                  T" UR                  S5      U5      5        g)zITests straight alpha case. Source is low alpha, destination is high alpharG   r)   c              3   L   >#    U  H  oS TR                   -
  -  S -  v   M     g7fr+   NrI  ).0r  low_alpha_colors     r#   	<genexpr>dTestSurfaceBlit.test_blit__SRCALPHA_to_SRCALPHA_non_zero.<locals>.high_a_onto_low.<locals>.<genexpr>  s(      FV3!2!223;FV   !$N
r   r   r   r   r[   rY   r   r   r   r.   )
highlowhigh_alpha_surfacelow_alpha_surfacehigh_alpha_colorr  r  r  r   r   s
         @r#   high_a_onto_lowQTestSurfaceBlit.test_blit__SRCALPHA_to_SRCALPHA_non_zero.<locals>.high_a_onto_low  s    !'foor!J 2 7 7 9$S'  $T$9:O##$45""?3##$5v>,u FV 0 N
 OO !3!:!:6!BNSr&   c                   >^ [         R                  " T	[         R                  S5      nUR                  5       n[	        X X45      m[	        XX45      nUR                  T5        UR                  U5        UR                  US5        T[	        [        U4S jU 5       5      5      -   nTR                  T" UR                  S5      U5      5        g)zITests straight alpha case. Source is high alpha, destination is low alpharG   r)   c              3   L   >#    U  H  oS TR                   -
  -  S -  v   M     g7fr  r  )r   r  r
  s     r#   r  dTestSurfaceBlit.test_blit__SRCALPHA_to_SRCALPHA_non_zero.<locals>.low_a_onto_high.<locals>.<genexpr>  s(      GV!3!1!3!334<r  Nr  )
r  r  r  r	  r  r  r
  r  r   r   s
         @r#   low_a_onto_highQTestSurfaceBlit.test_blit__SRCALPHA_to_SRCALPHA_non_zero.<locals>.low_a_onto_high  s    !'foor!J 2 7 7 9$S'  $T$9:O##$45""?3""#5v>- GV 1 N
 OO !2!9!9&!A>Rr&   r   r  r  N)r  )r   r  r  low_ahigh_ar  r   s   `    @@r#   (test_blit__SRCALPHA_to_SRCALPHA_non_zero8TestSurfaceBlit.test_blit__SRCALPHA_to_SRCALPHA_non_zero  sK     		,	, 1c]ES/.. * #r&   c                     [         R                  " SSS5      nUR                  S5      n[         R                  " S[         R                  S5      nUR	                  SU5        UR                  US5        g )N)r   r   r   r   r:   r  rG   r)   )r   r   get_palette_atr   rZ   r   )r   targetr  r  s       r#   test_blit__SRCALPHA32_to_8*TestSurfaceBlit.test_blit__SRCALPHA32_to_8  sX     A.**1-
<fj)FF#r&   )r  r  N)r  r  r  r  __doc__r  r  r  r  r  r  r  r  r  r  r  r  r&   r#   r  r  V  s?    9>5JJ	ME(F CP*>/@$r&   r  c                      \ rS rSr\R
                  " \R                  R                  S5      S:H  S5      S 5       r	\R
                  " \R                  R                  S5      S:H  S5      S 5       r
\R
                  " \R                  R                  S5      S:H  S5      S 5       rS rS	 rS
 rS rS r\R
                  " S\R$                  " 5       ;   =(       d    S\R$                  " 5       ;   S5      S 5       rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S  r#S! r$S" r%S# r&S$ r'S% r(S& r)S' r*S( r+S) r,S* r-S+ r.S, r/S- r0S. r1S/ r2S0 r3S1 r4S2 r5S3 r6S4 r7S5 r8S6 r9S7 r:S8 r;S9 r<S:r=g;)<GeneralSurfaceTestsi(  r$  r%  r&  c                    [         R                  R                  5          [         R                  R                  S5        [         R                  R                  [        [        R                  R                  SS5      5      5      n[         R                  R                  [        [        R                  R                  SS5      5      5      nU R                  UR                  5       S5        U R                  UR                  5       S5        U R                  [        UR                  S5      5      S5        U R                  [        UR                  S5      5      S	5        UR                  S
5      nU R                  [        U5      S5        U R                  UR                  5       UR                  5       5        [         R                  R                  5         g ! [         R                  R                  5         f = f)Nr   r_   zcity.pngz	brick.png)r*   r+   r+   r+   r+   )r*   r*   rG   z<Surface(24x24x32 SW)>z<Surface(469x137x32 SW)>r   z<Surface(24x24x8 SW)>)r   r/   rb   r0   rc   rd   r   re   rf   rg   r   get_paletterH   r   rh   )r   imim2im3s       r#   test_image_convert_bug_131.GeneralSurfaceTests.test_image_convert_bug_131)  sL    		"NN##J/""<VZ0P#QRB,,##Lfk1R$STCR^^-/UVS__.0PQT"**R.13KLT#++b/24NO **Q-CT#Y(?@S__.0@A NN!FNN!s   FG  G8c                 R   [         R                  R                  5         [         R                  " S5      nU R	                  [         R
                  SUR                  5        [         R                  R                  5           UR                  S5        UR                  [         R                  " S5      5        U R	                  [         R
                  SUR                  5        [         R                  R                  S5         UR                  5         [         R                  R                  5         g! [         R
                   a    U R                  S5         Nf = f! [         R
                   a    U R                  S5         Nqf = f! [         R                  R                  5         f = f)z?Ensure initialization exceptions are raised
for surf.convert().r  display initializedrG   z-convert() should not raise an exception here.No video moder   N)
r   r/   rh   r   assertRaisesRegexr  r   rb   failr0   r1   s     r#   test_convert_init%GeneralSurfaceTests.test_convert_initF  s"    	~~f%v||-BDLLQ	"KR V^^F34 ""6<<$,,ONN##J/K NN! << K		IJK << K		IJK NN!sI    6D0 6A
F E 0%EF EF %F F FF  F&c                    [         R                  R                  5         [         R                  " S5      nU R	                  [         R
                  SUR                  5        [         R                  R                  5          U R	                  [         R
                  SUR                  5        [         R                  R                  S5         UR                  5         [         R                  R                  5         g! [         R
                   a    U R                  S5         NFf = f! [         R                  R                  5         f = f)zEEnsure initialization exceptions are raised
for surf.convert_alpha().r  r'  r(  r   z3convert_alpha() should not raise an exception here.N)
r   r/   rh   r   r)  r  convert_alpharb   r0   r*  r1   s     r#   test_convert_alpha_init+GeneralSurfaceTests.test_convert_alpha_initd  s     	~~f%v||-BDDVDVW		"""6<<$BTBTUNN##J/Q""$ NN! << Q		OPQ NN!s+   ?A
D$ 
C9 9%D!D$  D!!D$ $ Ec                    [         R                  R                  5          [         R                  R                  S5        [         R                  " SSS5      nUR                  5       nU R                  UR                  5       [        -  [        5        U R                  UR                  5       S5        [         R                  R                  5         g! [         R                  R                  5         f = f)zSEnsure that the surface returned by surf.convert_alpha()
has alpha blending enabledr   rT   r   rG   r+   N)r   r/   rb   r0   r   r.  r   r   r   r  rh   )r   r   s1_alphas      r#   test_convert_alpha_SRCALPHA/GeneralSurfaceTests.test_convert_alpha_SRCALPHA|  s     			"NN##J/
Ar2B'')HX//1H<hGX//137NN!FNN!s   BC  C1c                    [         R                  " S[         R                  S5      nUR                  S5        [         R                  " S[         R                  S5      nU R	                  UR                  S5      S5        UR                  US5        U R	                  UR                  S5      S5        U R	                  UR                  S5      S5        g)zblit should be white.r  rG   )r+   r+   r+   rU   r)   r   N)r   r   r   rY   r   r.   r   )r   surf1ro   s      r#   test_src_alpha_issue_1289-GeneralSurfaceTests.test_src_alpha_issue_1289  s    vv;

'(vv;f-|<

5&!f-/CDf-/CDr&   c                    0 SS_SS_SS_SS_SS	_S
S_SS_SS_SS_SS_SS_SS	_SS_SS_SS_SS_SS_0 SS_S S!_S"S#_S$S%_S&S'_S(S_S)S_S*S+_S,S-_S.S/_S0S1_S2S3_S4S5_S6S7_S8S_S9S:_S;S+_E0 S<S=_S>S?_S@SA_SBSC_SDSE_SFS_SGSH_SISJ_SKSL_SMSN_SOSP_SQSR_SSSE_STS_SUSV_SWSX_SYSZ_ES[S\S]SESS^S_S`SaSbScSdSSe.En/ SfQn0 n[        U[        U5      [        U5      5       H  u  pEn[        U[        U5      U5       H  u  pxn	U R                  UUU	UUUSg9   [        R                  " Sh[        R
                  Si5      n
U
R                  USjX45        [        R                  " Sh[        R
                  Si5      nUR                  USjXV45        UR                  U
Sk5        XEU4XxU	44nUR                  Sl5      X<'   U R                  X<   X   5        SmSmSm5        M     M     U R                  X15        gm! , (       d  f       GM  = f)n8"What pygame 1.9.x did". Is the alpha blitter as before?r   r+   r+   r  r   r+   r+   r+   r<  rX      rX   r<  A      rC  r   r+      r+   r<  ~   r  rI  >   r+   r   r+   r<  r  rI  r  r  r+   r   r+   r<  rD  rC  rD     r+   k   r+   r<  r@  rX   r@     r+   r:   r+   r<  r   r+   r+   r   r+   rX   r@  r@  r  rX   r+   r@  r@  r[  r?  rX   r+   r@  r+   r[  rB     r+      r+   r[  rH  r[  rM  r  r+      r+   r[  rP  r[  rU  r[  r   rC  rD  rD  r  rC  r+   rD  rD  rk  r?  r  r+   rw   rw   rk  rB  rC  r+   rD     rk  rH  _   r+         rk  rM  `   r+      rv  rk  rP     r+   rt     rk  rU  rk  r   rI  r  r  r  rI  r+   r  r  r  r?  }   r+   r  r  r  rB  n   r+         r  rH  rI  r+   r  r   r  rM  rI  r+   rI  r   r  rP     r+   O   rv  r  rU  rW  r+   rX   r+   r  r   r  rI  rI  r  r  r+   rI  rI  r  r?  r  rB  o   r+         r  rH  r  r+   rI  rf  r  rM  r  r+   rI  r   r  rP  r  r+   N   rv  r  rU  r@  r+   rX   r+   r  r   rD  rC  rC  r  rD  r+   rC  rC  r  r?     r+   B   r  r  rB     r+   r  r   r  rH  rz  r+   ry  r  r  rM  rz  r+   rt  r  r  rP  rD  r+   rC  rq  r  rU  r  r   r@  rX   rX   r  r@  r+   rX   rX   r  r?  rW  r+   r:   r:   r  rB     r+   4   r  r   r+   r  r  r   r+   r  r     r+   3   rw   r   r+   r+   r   rX   r+   r@  rX   rC  r+   rD  rC  rI  r+   r  rI  r  r+   rI  r  rD  r+   rC  rD  r@  r+   rX   r@  )r  rH  )r  rM  )r  rP  )r  rU  )r  r   )r  r  )r  r?  )r  rB  )r  rH  )r  rM  )r  rP  )r  rU  )r  r   r   rX   rC  rI  r  rD  r@  r+   src_rsrc_bsrc_adest_rdest_bdest_ar  r  rG   r+   r)   rC  !   N
zipreversedsubTestr   r   r   rY   r   r.   r   r   results_expectednumsresultsdst_rdst_bdst_ar  r  r  src_surf	dest_surfkeys                r#   test_src_alpha_compatible-GeneralSurfaceTests.test_src_alpha_compatible  s\   &A
(*<A
(*<A
 +,?A
 -.A	A

 -.AA
 ,-AA
 +,>A
 +,>A
 )*<A
 )*<A
 +,?A
 -.AA
 -.AA
 ,-AA
 +,>A
  +,>!A
" *+>#A
$ *+>%A
& ,-@'A
( ./B)A
* ./B+A
, -.A-A
. ,-?/A
0 ,-?1A
2 +,@3A
4 +,@5A
6 -.B7A
8 /0D9A
: /0D;A
< ./B=A
> -.@?A
@ -.@AA
B +,@CA
D +,@EA
F -.BGA
H /0DIA
J /0DKA
L ./BMA
N -.@OA
P -.@QA
R )*<SA
T )*<UA
V +,?WA
X -.AYA
Z -.A[A
\ ,-@]A
^ +,>_A
` +,>aA
b '(8cA
d '(8eA
f )*<gA
h -@,?+>*<*<(8(8*<,@,@+>*<*<AA
H 3#&tXd^Xd^#LE%'*4$'F#e\\    "   &~~hLHMM5#u"<= &x" MINNE3#=>NN8V4!%052GHC#,#3#3H#=GL$$W\3C3HI!  (G $M( 	3%    B8G%%
G5c                    0 SS_SS_SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS
_SS_SS_SS_0 SS_SS_SS_SS_SS_S S_S!S_S"S#_S$S#_S%S&_S'S(_S)S(_S*S+_S,S_S-S_S.S#_S/S#_E0 S0S&_S1S(_S2S(_S3S+_S4S_S5S_S6S7_S8S7_S9S:_S;S<_S=S<_S>S?_S@S_SAS_SBSC_SDSC_SESF_ES#S#SGSSSCSCSFS#S#SGSSSH.En/ SIQn0 n[        U[        U5      [        U5      5       H  u  pEn[        U[        U5      U5       H  u  pxn	U R                  UUU	UUUSJ9   [        R                  " SK[        R
                  SL5      n
U
R                  USMX45        [        R                  " SK[        R
                  SL5      nUR                  USMXV45        UR                  U
SN5        XEU4XxU	44nUR                  SO5      X<'   U R                  X<   X   5        SPSPSP5        M     M     U R                  X15        gP! , (       d  f       GM  = f)Qr:  r;  r=  r>  rA  )ra  r+   r+   r+   rG  )r  r+      r+   rL  rO  )   r+   f   r+   rT  rY  rX  rZ  r]  r_  rc  rd  rg  rh  ri  rj  )D   r+   r  r  rm  ro  )r  r+   r     rr  )U   r+   r     rw  r{  )   r+   r  r+   r  r  r  )w   r+   r  r  r  r  )r  r+         r  )r  r+   r  r  r  r  )r  r+   r  r  r  r  r  r  r  r  r  r  r  r  r  )r  r+   r  r  r  r  )r  r+   r  r  r  )r  r+   r  r  r  r  )r  r+   r  r  r  r  r  r  r  r  )r  r+   r  r  )r  r+   r  r  r  r  r  r  r   r+   r)   r  Nr  r  s                r#   test_src_alpha_compatible_16bit3GeneralSurfaceTests.test_src_alpha_compatible_16bit  s\   &A
(*<A
(*<A
 +,?A
 -.A	A

 -.AA
 ,-AA
 +,>A
 +,>A
 )*<A
 )*<A
 +,?A
 -.AA
 -.AA
 ,-AA
 +,>A
  +,>!A
" *+>#A
$ *+>%A
& ,-@'A
( ./B)A
* ./B+A
, -.A-A
. ,-?/A
0 ,-?1A
2 +,@3A
4 +,@5A
6 -.B7A
8 /0D9A
: /0D;A
< ./B=A
> -.@?A
@ -.@AA
B +,@CA
D +,@EA
F -.BGA
H /0DIA
J /0DKA
L ./BMA
N -.@OA
P -.@QA
R )*<SA
T )*<UA
V +,@WA
X -.AYA
Z -.A[A
\ ,-@]A
^ +,>_A
` +,>aA
b '(8cA
d '(8eA
f )*<gA
h -A,@+>*<*<(8(8*<,@,@+>*<*<AA
H 3#&tXd^Xd^#LE%'*4$'F#e\\    "   &~~hLHMM5#u"<= &x" MINNE3#=>NN8V4!%052GHC#,#3#3H#=GL$$W\3C3HI!  (G $M( 	3% r  c                    0 SS_SS_SS_SS_SS	_S
S_SS_SS_SS_SS_SS_SS	_SS_SS_SS_SS_SS_0 SS_S S!_S"S#_S$S%_S&S'_S(S_S)S_S*S+_S,S-_S.S/_S0S1_S2S3_S4S5_S6S7_S8S_S9S:_S;S+_E0 S<S=_S>S?_S@SA_SBSC_SDSE_SFS_SGSH_SISJ_SKSL_SMSN_SOSP_SQSR_SSSE_STS_SUSV_SWSX_SYSZ_ES[S\S]SESS^S_S`SaSbScSdSSe.En/ SfQn0 n[        U[        U5      [        U5      5       GH  u  pEn[        U[        U5      U5       H  u  pxn	U R                  UUU	UUUSg9   [        R                  " Sh[        R
                  Si5      n
U
R                  USjUSj45        U
R                  U	5        [        R                  " Sh[        R
                  Si5      nUR                  USjXV45        UR                  U
Sk5        XEU4XxU	44nUR                  Sl5      X<'   U R                  X<   X   5        SmSmSm5        M     GM     U R                  X15        gm! , (       d  f       GM  = f)nzdoes the SDL 1 style blitter in pygame 2 work with set_alpha(),
this feature only exists in pygame 2/SDL2 SDL1 did not support
combining surface and pixel alphar;  r=  r>  rA  rE  rG  rJ  rL  rN  rO  rQ  rT  rV  rX  rY  rZ  r\  r]  r^  r_  r`  rc  rd  re  rg  rh  ri  rj  rl  rm  rn  ro  rp  rr  rs  rw  rx  r{  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rG   r+   r)   r  N)r  r  r  r   r   r   rY   r   r   r.   r   r  s                r#   &test_sdl1_mimic_blitter_with_set_alpha:GeneralSurfaceTests.test_sdl1_mimic_blitter_with_set_alphau  sl   
A
(*<A
(*<A
 +,?A
 -.A	A

 -.AA
 ,-AA
 +,>A
 +,>A
 )*<A
 )*<A
 +,?A
 -.AA
 -.AA
 ,-AA
 +,>A
  +,>!A
" *+>#A
$ *+>%A
& ,-@'A
( ./B)A
* ./B+A
, -.A-A
. ,-?/A
0 ,-?1A
2 +,@3A
4 +,@5A
6 -.B7A
8 /0D9A
: /0D;A
< ./B=A
> -.@?A
@ -.@AA
B +,@CA
D +,@EA
F -.BGA
H /0DIA
J /0DKA
L ./BMA
N -.@OA
P -.@QA
R )*<SA
T )*<UA
V +,?WA
X -.AYA
Z -.A[A
\ ,-@]A
^ +,>_A
` +,>aA
b '(8cA
d '(8eA
f )*<gA
h -@,?+>*<*<(8(8*<,@,@+>*<*<AA
H 3#&tXd^Xd^#LE%'*4$'F#e\\    "   &~~hLHMM5#uc":;&&u- &x" MINNE3#=>NN8V4!%052GHC#,#3#3H#=GL$$W\3C3HI#  (G $M* 	3' s   C
G99
H	armaarch64z.sdl2 blitter produces different results on armc                 0   0 SS_SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS
_SS_SS_SS_SS_0 SS _S!S"_S#S$_S%S&_S'S(_S)S_S*S_S+S,_S-S._S/S0_S1S2_S3S4_S5S6_S7S_S8S_S9S:_S;S<_E0 S=S>_S?S2_S@S4_SAS6_SBS_SCS_SDSE_SFSG_SHSI_SJSK_SLSM_SNSO_SPS_SQS_SRSS_STSU_SVSW_ESXSYSZSSS[S\S]S^SYSZSSS_.En/ S`Qn0 n[        U[        U5      [        U5      5       GH*  u  pEn[        U[        U5      U5       GH  u  pxn	U R                  UUU	UUUSa9   [        R                  " Sb[        R
                  Sc5      n
U
R                  USdX45        [        R                  " Sb[        R
                  Sc5      nUR                  USdXV45        UR                  U
Se[        R                  Sf9  XEU4XxU	44n[        UR                  Sg5      5      X<'   [        Sh5       H  nU R                  X<   U   X   U   ShSi9  M      SjSjSj5        GM     GM-     gj! , (       d  f       GM#  = f)kzXChecking that the BLEND_ALPHA_SDL2 flag works - this feature
only exists when using SDL2r;  r=  r>  )r   rW  rW  rW  rA  )r   rW     rW  rG  )rK  rW  rf  rW  rL  )r  rW  r  rW  rO  )   rW  i   rW  rT  )   rW  r   rW  rX  rY  rZ  r\  r]  )r   rW  r  r  r_  )r   rW  r  r  rc  )rK  rW  r  r  rd  rg  rh  ri  rj  rl  rm  )r  rW     r  ro  )r  rW  r     rr  )^   rW        rw  )rt  rW     r  r{  )   rW  ]   rF  r  r  r  r  r  )r  rW  rI  rI  r  )m   rW        r  )r  rW  r     r  )rI  rW  r  r  r  )   rW  M   r  r  r  r  r  r  )rI  rW  r  r  r  )r  rW        r  r  r  r  r  r  r  r  )r  rW  r  r  r  )rz  rW  b   p   r  )r
  rW  r	  r  r  )r
  rW  r	  r  r  )r  rW  r  r  r  r  r  r  r  )r  rW  r   r   r  )r  rW  r   r  )r  rW  rK  r  )rf  rW  rK  rI  )   rW  r   r  )r+   r+   r   r   )rW  rW  r   r   )   rW  r   r  )rf  rW  rK  r  r  r  r  r  rG   r+   r)   r  r  r   r   N)r  r  r  r   r   r   rY   r   BLEND_ALPHA_SDL2r   r.   r  r   )r   r  r  r  r  r  r  r  r  r  r  r  r  r  s                 r#   test_src_alpha_sdl2_blitter/GeneralSurfaceTests.test_src_alpha_sdl2_blitter  s   A
(*<A
(*<A
 +,?A
 -.A	A

 -.AA
 ,-AA
 +,>A
 +,>A
 )*<A
 )*<A
 +,?A
 -.AA
 -.AA
 ,-AA
 +,>A
  +,>!A
" *+>#A
$ *+>%A
& ,-@'A
( ./B)A
* ./B+A
, -.A-A
. ,-?/A
0 ,-?1A
2 +,@3A
4 +,@5A
6 -.B7A
8 /0D9A
: /0D;A
< ./B=A
> -.@?A
@ -.@AA
B +,@CA
D +,@EA
F -.BGA
H /0DIA
J /0DKA
L ./BMA
N -.@OA
P -.@QA
R )*<SA
T )*<UA
V +,?WA
X -.AYA
Z -.A[A
\ ,-@]A
^ +,>_A
` +,>aA
b '(8cA
d '(8eA
f )*<gA
h -@,?+>*<*<(8(8*<,?,?+>*<*<AA
H 3#&tXd^Xd^#LE%'*4$'F#e\\    "   &~~hLHMM5#u"<= &x" MINNE3#=>NN &8O8O #  "%052GHC#()9)9()C#DGL"1X..#LO-=-B1-EQ /  &%  (G $M s   C%H
Hc                    [         R                  " S[         R                  S5      nUR                  S5        [         R                  " S5      nUR                  S5        UR	                  US5        UR                  S5      nUR                  S5        UR                  S5        UR	                  US5        UR                  S5      nU R                  X45        g )Nr   rG   )r+   r+   r+   rw   )rU   rU   rU   r)   rw   )r   r   r   rY   r   r.   r   r   )r   r  r  no_surf_alpha_colsurf_alpha_cols        r#   +test_opaque_destination_blit_with_set_alpha?GeneralSurfaceTests.test_opaque_destination_blit_with_set_alphaA  s    >>(FOOR@*+NN8,	'x(%,,V4'C x("))&1*;r&   c                 $    U R                  5         g r   )r*  r  s    r#   todo_test_convert%GeneralSurfaceTests.todo_test_convertT  s    		r&   c                    Sn[        USS5      n[        SSS5      n[        R                  R                  5          UR	                  U5      nU R                  XC5        U R                  XB5        U R                  U[        R                  5        U R                  U[         5        U R                  UR                  5       U5        [        R                  R                  5         g! [        R                  R                  5         f = f)z3Ensure convert accepts a Surface subclass argument.r  ra  r   rG   )r   =   N)r   r   r/   rb   r   r   r   r   r   r   rh   r   r    convert_surfacer!   r"   s        r#   .test_convert__pixel_format_as_surface_subclassBGeneralSurfaceTests.test_convert__pixel_format_as_surface_subclassp  s     )-B?'!R8		"%--m<GW4W6!!'6>>:!!'?;W--/?NN!FNN!s   B	C$ $ Dc                    [         R                  R                  5          [         R                  R                  S5        [         R                  " SSS5      n[         R                  R                  U5      n[         R                  " SSS5      nUR                  5       n[         R                  " SSS5      nUR                  5       n[         R                  " SSS5      nUR                  5       n[         R                  " SSS5      n	U	R                  5       n
[         R                  " SSS5      nUR                  5       n[         R                  " SSS	5      nUR                  5       nU R                  UR                  5       S
5        U R                  UR                  5       S
5        U R                  UR                  5       S
5        U R                  UR                  5       S
5        U R                  U
R                  5       S
5        U R                  UR                  5       S
5        U R                  UR                  5       S
5        U R                  UR                  5       S5        U R                  UR                  5       S5        U R                  UR                  5       S5        U R                  UR                  5       S5        U R                  U
R                  5       S5        U R                  UR                  5       S5        U R                  UR                  5       S5        U R                  [         R                  5         [         R                  R                  5       n[         R                  R                  5         UR                  5         SSS5        [         R                  R                  5         g! , (       d  f       N-= f! [         R                  R                  5         f = f)zHEnsure the surface returned by surf.convert_alpha
has alpha values addedr   rT   r   rG   r   r  r  r   rV   r+   N)r   r/   rb   r0   r   r.  r   r  r   rl   r  rh   )r   r   r2  r   s2_alphas3s3_alphas4s4_alphas5s5_alphas6s6_alphas7s7_alphar"   s                   r#   test_convert_alpha&GeneralSurfaceTests.test_convert_alpha  s    	.	"NN##J/
Ar2B~~33B7H
Ar2B'')H
Aq1B'')H
Ar2B'')H
Ar2B'')H
Ar2B'')H
Ar2B'')HX//137X//137X//137X//137X//137X//137X//137X113R8X113R8X113R8X113R8X113R8X113R8X113R8""6<<0 ..113##%%%' 1 NN! 10 NN!s%   L%O
 AN9O
 9
OO
 
 O*c                 \   Sn[        U[        S5      n[        S[        S5      n[        R                  R	                  5          [        R                  R                  S5        UR                  U5      nU R                  XC5        U R                  XB5        U R                  U[        R                  5        U R                  U[         5        U R                  UR                  5       U5        [        R                  R                  5         g! [        R                  R                  5         f = f)z9Ensure convert_alpha accepts a Surface subclass argument.r(  rG   )r   9   r   N)r   r   r   r/   rb   r0   r.  r   r   r   r   r   rh   r*  s        r#   4test_convert_alpha__pixel_format_as_surface_subclassHGeneralSurfaceTests.test_convert_alpha__pixel_format_as_surface_subclass  s     )-2F'(B?	"NN##H- &33MBGW4W6!!'6>>:!!'?;W--/?NN!FNN!s   B(D  D+c                 :   [         R                  R                  5          [         R                  " S[        S5      nUR                  SS5      nUR                  SS5      nUR                  SS5      nUR                  S	S
5      nUR                  SS5      nU R                  UR                  5       S5        U R                  UR                  5       S5        U R                  UR                  5       S5        U R                  UR                  5       S5        U R                  UR                  5       S5        U R                  UR                  5       S5        U R                  [         R                  5         [         R                  R                  5       n[         R                  R                  5         UR                  5         S S S 5        [         R                  R                  5         g ! , (       d  f       N-= f! [         R                  R                  5         f = f)Nr  rG   r  )"   r   r)   )r   r   )r  rD  )r(   r   )   rX   )   rC  r   rB  r  r   )r   	   )r   r9   r3  )r   r/   rb   r   r   r   r   get_abs_offsetrl   r  r0   rh   )r   r6  sub_level_1sub_level_2sub_level_3sub_level_4sub_level_5r"   s           r#   test_get_abs_offset'GeneralSurfaceTests.test_get_abs_offset  s   	"^^Hh;F !++FH=K%00BK%00BK%00BK%00@K V224f=[7796B[7796B[7796B[7798D[7798D""6<<0 ..113##%&&( 1
 NN! 10
 NN!s%   EG: 5AG)G: )
G73G: : Hc                    [         R                  R                  5          [         R                  " S[        S5      nUR                  SS5      nUR                  SS5      nUR                  SS5      nUR                  SS5      nUR                  SS	5      nUR                  S
S5      nU R                  [        UR
                  SS5        U R                  [        UR
                  S
S5        U R                  [        UR
                  S
S5        U R                  UR                  5       U5        U R                  UR                  5       UR                  5       5        U R                  UR                  5       U5        U R                  UR                  5       U5        U R                  UR                  5       U5        U R                  UR                  5       U5        U R                  UR                  5       UR                  5       R                  5       5        U R                  [         R                  5         [         R                  R                  5       n[         R                  R                  5         UR                  5         S S S 5        [         R                  R                  5         g ! , (       d  f       N-= f! [         R                  R                  5         f = f)Nr   rG   r  )r  r  )r  r  rF  rF  )r   r   r  rE  r)   r:   rX   r   r   rT   )r   r   )r   r/   rb   r   r   r   rl   rm   r   get_abs_parentr5  r  r0   rh   )	r   r6  rH  rI  rJ  rK  rL  sub_level_6r"   s	            r#   test_get_abs_parent'GeneralSurfaceTests.test_get_abs_parent  s-   "	"^^Hh;F !++FH=K%00BK%00@K%00@K%00@K%00@K j&*;*;VZPj+*@*@&'Rj+*@*@&&Q V224f= [779;;Q;Q;ST[7796B[7796B[7796B[7796B**,k.D.D.F.U.U.W ""6<<0 ..113##%&&( 1
 NN! 10
 NN!s%   HJ< 7AJ+J< +
J95J< < Kc                 "   [         R                  " SSS5      n[         R                  " SSS5      n[         R                  " SSS	5      n[         R                  " S
SS5      n[         R                  " SSS5      nUR                  SU5        UR                  SU5        UR                  SU5        UR                  SU5        UR	                  S5      nU R                  U[         R                  5        U R                  Xb5        U R                  UR	                  S5      U5        U R                  UR	                  S5      U5        U R                  UR	                  S5      U5        S H$  nU R                  [        UR                  U5        M&     g )Nr  r   rV   rX   r:   r  r   r9   r  rU   r   r   rB  r)   )r   rX   rX   r   r  ))r  r   )r   r  )r:   r   r   r:   )	r   r   r[   rZ   r.   r   r   rl   
IndexError)r   r2   c00c01c10c11r   ps           r#   test_get_atGeneralSurfaceTests.test_get_at  s/   ~~fa,ll1a#ll1b"%ll3A&ll1a#FC FC FC FC KKa. V,c2V,c2V,c23Aj$++q9 4r&   c           
      &   [         R                  " SSS5      nS Hs  n[         R                  " SSU5      nUR                  U5        UR	                  S5      nU R                  UUR                  U5      SXCR                  U5      U4-  5        Mu     g )	Nr9   r(   r   rl  r  r   r)   z%i != %i, bitsize: %i)r   r[   r   rY   get_at_mappedr   map_rgb)r   r   ro  r2   pixels        r#   test_get_at_mapped&GeneralSurfaceTests.test_get_at_mapped%  s    RR(&G>>&!W5DIIe&&v.EU#'5,,u2Ew*OO	 'r&   c                    [         R                  R                  5          SnSn[         R                  " U[         R                  U5      nU R                  UR                  5       U5        U R                  UR                  5       U5        Sn[         R                  " U[         R                  U5      nU R                  UR                  5       U5        U R                  UR                  5       U5        Sn[         R                  " USU5      nU R                  UR                  5       U5        U R                  UR                  5       U5        SnU R                  [        [         R                  USU5        SnU R                  [        [         R                  USU5        SnU R                  [        [         R                  USU5        U R                  [         R                  5         [         R                  R                  5       n[         R                  R                  5         UR                  5         S S S 5        [         R                  R                  5         g ! , (       d  f       N-= f! [         R                  R                  5         f = f)	Nr   rG   r   r  r   r  r      )r   r/   rb   r   r   r   r   r   rl   rm   r  r0   rh   )r   r    r   r"   s       r#   test_get_bitsize$GeneralSurfaceTests.test_get_bitsize1  s   %	"$M  Nnn]FOO^TGW--/?W002NCNnn]FOO^TGW--/?W002NCNnn]A~FGW--/?W002NCNFNNM1n  NFNNM1n "NFNNM1n ""6<<0 ..113##%##% 1
 NN! 10
 NN!s%   GI+ &AI3I+ 
I($I+ + Jc                 t    [         R                  " S5      nUR                  5       nU R                  US5        g )Nr6   )r   r   r7   r8   )r   r   r>   r   )r   r?   	rectangles      r#   test_get_clip!GeneralSurfaceTests.test_get_clipZ  s,    NN:&JJL	$45r&   c                    [         R                  R                  5          [         R                  " SSS5      nU R	                  UR                  5       5        UR                  S 5        U R	                  UR                  5       5        Su  p#pE[         R                  " X#U5      nUR                  U5        U R                  UR                  5       X#US45        UR                  U[         R                  5        U R                  UR                  5       X#US45        UR                  [         R                  " US-   US-   US-   5      5        U R                  UR                  5       X#US45        UR                  [         R                  " X#XE5      5        U R                  UR                  5       X#US45        [         R                  R                  SSS5      n[         R                  R                  5         U R                  [         R                  5         UR                  5         S S S 5        g ! , (       d  f       g = f! [         R                  R                  SSS5      n[         R                  R                  5         U R                  [         R                  5         UR                  5         S S S 5        f ! , (       d  f       f = f= f)Nr6   r   rG   )r(   ra   r   r  r+   rX   r)  )r   r/   rb   r   assertIsNoner   r   r[   r   r   r   r0   rh   rl   r  )r   r?   r@   r   r   rI  r  s          r#   test_get_colorkey%GeneralSurfaceTests.test_get_colorkey_  s   "	!z1b1Aann./ NN4 ann./ (JA!||A!,HNN8$ Q^^-a~> NN8V__5Q^^-a~> NN6<<Aq1ua!e<= 01C.ANN6<<a34 Q^^-a~> ''
Ar:ANN!""6<<0  100 ''
Ar:ANN!""6<<0  100s1   FH? H..
H<?AK	J8/	K	8
KK	c                     SnU H=  u  p#[         R                  " X#45      nUR                  5       nU R                  X55        M?     g )N)r  r  r9   )r9   r  )rX     )rv  rX   rv  rv  )r   r   r   r   )r   sizesr   r   r2   found_heights         r#   test_get_height#GeneralSurfaceTests.test_get_height  s=    R"ME>>5/2D??,LV2 #r&   c                 ,   S n[         R                  " S5      nU R                  UR                  5       U" U5      5        UR	                  5         U R                  UR                  5       U" U5      5        UR                  5         U R                  UR                  5       U" U5      5        [         R                  " S5      nUR	                  5         UR	                  5         U R                  UR                  5       U" U5      5        UR                  5         U R                  UR                  5       U" U5      5        UR                  5         U R                  UR                  5       U" U5      5        [         R                  " S5      n[        S5       H  nUR	                  5         M     U R                  UR                  5       U" U5      5        [        S5       H  nUR                  5         M     U R                  UR                  5       5        [         R                  " S5      nUR                  5         U R                  UR                  5       U" U5      5        UR                  5         U R                  UR                  5       U" U5      5        g )Nc                     [         R                  " S5      n UR                  U S5        g! [         R                   a     gf = f)Nr`   r)   FT)r   r   r   r  )r"   newSurfs     r#   blit_locked_test=GeneralSurfaceTests.test_get_locked.<locals>.blit_locked_test  s@    nnX.GWf-  << s   + AArT   rv  )r   r   r4  rX  lockunlockr  r*  )r   r  r2   r  s       r#   test_get_locked#GeneralSurfaceTests.test_get_locked  s   	 ~~j)doo')9$)?@		doo')9$)?@doo')9$)?@ ~~j)				doo')9$)?@doo')9$)?@doo')9$)?@ ~~j)tAIIK doo')9$)?@tAKKM *+ ~~j)doo')9$)?@doo')9$)?@r&   c                    [         R                  " S5      nU R                  UR                  5       S5        UR	                  5         U R                  UR                  5       U45        UR                  5         U R                  UR                  5       S5        [         R                  " U5      nU R                  UR                  5       S5        UR                  5         U R                  UR                  5       S5        U R                  [        5         SR                  5         S S S 5        UR	                  5         UR	                  5         UR	                  5         U R                  UR                  5       XU45        UR                  5         UR                  5         U R                  UR                  5       U45        UR                  5         U R                  UR                  5       S5        g ! , (       d  f       N= f)NrT   r  DUMMY)r   r   r   	get_locksr  r  
PixelArrayr   closerl   AttributeError)r   r"   pxarrays      r#   test_get_locks"GeneralSurfaceTests.test_get_locks  s|    ..,**,b1 	**,wj9 	**,b1 ##G,G--/4 	**,b1 ~. / 	**,w.IJ**,wj9**,b1 /.s   G00
G>c                    [         R                  R                  5          SnSnSnSnSn[         R                  R                  S5      n[         R                  " S5      n[         R                  " SSUS9n[         R                  " SS	US9n	[         R                  " SS
US9n
[         R                  " SSUS9n[         R                  " SSUS9nUR                  5       nU R                  U[        5        U R                  [        U5      S5        U H=  nU R                  U[        5        U R                  US5        U R                  US5        M?     UR                  5       S:X  a  U R                  US5        O&UR                  5       S:X  a  U R                  US5        U R                  UR                  5       S5        U R                  U	R                  5       S5        U R                  U
R                  5       S5        U R                  UR                  5       S5        U R                  UR                  5       S5        U R                  [         R                  5         [         R                  R                  S5      n[         R                  R                  5         UR                  5         SSS5        [         R                  R                  5         g! , (       d  f       N-= f! [         R                  R                  5         f = f)z*Ensure a surface's losses can be retrieved)      r  r   i |  i  r   r   i   i  r   r   r   r   r+   r   )r   r   r   r+   rT   r   )rM   r}   r  r   rV   rG   r   r   )r   r   r   r   )r   r   r   r   )r   r   rB  r   )r  r  r  r   )r  r:   r  r   r   N)r   r/   rb   r0   r   
get_lossesr   r   r   lenintassertGreaterEqualassertLessEqualrl   r  rh   )r   mask8mask15mask16mask24mask32display_surfr2   	surf_8bit
surf_15bit
surf_16bit
surf_24bit
surf_32bitlosseslossr"   s                   r#   test_get_losses#GeneralSurfaceTests.test_get_losses  sR   -	"#E(F)F.F7F ">>22:>L>>*-Dz%HI
"FKJ
"FKJ
"FKJ
"FKJ __&F!!&%0S[!,%%dC0''a0$$T1-  &&(L8  6((*l:  6Y113\BZ224lCZ224lCZ224lCZ224lC ""6<<0 ..11*=##%""$ 1
 NN! 10
 NN!s%   H=K# AK+K# 
K K# # Lc                     SS/nSS/n[        [        X5      5       HJ  u  p4[        R                  " S[        R                  U5      nU R                  X5R                  5       5        ML     g)z,
Ensure that get_mask can return RGBA mask.
)   rb  r  i   )r   r   r+   r   r   rG   r`   N)listr  r   r   r   r   r  r   r}   depthsexpectedrM   r"   s         r#   test_get_masks__rgba(GeneralSurfaceTests.test_get_masks__rgba  s_    
 -<
 b#C$67OHnnXvFGX'8'8':;  8r&   c                     / SQn/ SQn[        [        X5      5       HD  u  p4[        R                  " SSU5      nUS:X  a  SnU R	                  X5R                  5       5        MF     g)z+
Ensure that get_mask can return RGB mask.
))ry  r  r  r   )r  rb  r  r   r  r  r  r  )r   r  r  r   rV   rG   r`   r   r   r   N)r  r  r   r   r   r  r  s         r#   test_get_masks__rgb'GeneralSurfaceTests.test_get_masks__rgb%  s[    
 )#C$67OHnnXq%8Gz3X'8'8':;	  8r&   c                    U R                  [        R                  5         [        R                  R	                  S5      n[        R                  R                  5         UR                  5         SSS5        g! , (       d  f       g= f)zH
Ensure that after display.quit, calling get_masks raises pygame.error.
r`   N)rl   r   r  r/   r0   rh   r  )r   r"   s     r#   test_get_masks__no_surface.GeneralSurfaceTests.test_get_masks__no_surface8  sR     v||,nn--h7GNN! -,,s   AA77
Bc                    [         R                  R                  5          [         R                  " S5      nU R	                  UR                  5       S5        UR                  SSSS5      nU R	                  UR                  5       S5        U R                  [         R                  5         [         R                  R                  5       n[         R                  R                  5         UR                  5         SSS5        [         R                  R                  5         g! , (       d  f       N-= f! [         R                  R                  5         f = f)zqget_offset returns the (0,0) if surface is not a child
returns the position of child subsurface inside of parent
rT   r)   rX   r9   r  N)r   r/   rb   r   r   
get_offsetr   rl   r  r0   rh   )r   r2   subsurfr"   s       r#   test_get_offset#GeneralSurfaceTests.test_get_offsetA  s     		">>*-DT__.7 ooaB3GW//16:""6<<0 ..113##%""$ 1
 NN! 10
 NN!s%   B	D. )AD6D. 
D+'D. . Ec                    [        S5       Vs/ s H  n[        XU5      PM     nn[        R                  " SSS5      nUR	                  U5        UR                  5       nU R                  [        U5      [        U5      5        [        XB5       H  u  pVU R                  XV5        M     U H#  nU R                  U[        R                  5        M%     g s  snf )Nr  r  r   r   )
r  r[   r   r   set_paletter   r   r  r  r   )r   r  paletter2   palette2r  r   s          r#   test_get_palette$GeneralSurfaceTests.test_get_paletteU  s    +0:6:a5q>:6~~fa+!##%XG5+EBR# ,A!!!V\\2  7s   Cc                    [         R                  " SSS5      n[         R                  " SSSS5      nUR                  SU5        UR	                  S5      nU R                  U[         R                  5        U R                  X25        U R                  [        UR                  S5        U R                  [        UR                  S	5        g )
Nr  r   r   rX   r:   r  r+   r  r  )	r   r   r[   set_palette_atr  r   r   rl   rZ  )r   r2   r   r   s       r#   test_get_palette_at'GeneralSurfaceTests.test_get_palette_ata  s    ~~fa+Q1c*Au%$$Q'ffll3'*d&9&92>*d&9&93?r&   c                    Sn/ SQnU GHg  u  p4U GHZ  n[         R                  " X44US9nUR                  5       nUR                  UR	                  5       -  nUR                  5       n	U R                  X5        UR                  5       n
UR                  U
5      nUR                  5       nUR                  UR	                  5       -  nUR                  5       nU R                  X5        U
R                  U* S-  U* S-  5      nUR                  U5      nUR                  5       nUR                  [        UR	                  5       5      -  nUR                  5       nU R                  UU5        GM]     GMj     g )N)r  )rD  r  )r  rD  )r:     )r  r:   )r  r  r   rV   rG   rN   r:   )r   r   rn  rT  r   rm  r   r   r   inflatefloat)r   rx  r  r   r   rM   r2   buffpitch
test_pitchrect1subsurf1	sub_buff1
sub_pitch1test_sub_pitch1rect2subsurf2	sub_buff2
sub_pitch2test_sub_pitch2s                       r#   test_get_pitch"GeneralSurfaceTests.test_get_pitchl  s?   J"ME~~uoUC(doo&77!^^-
  3??51$//1	&--0C0C0EE
"*"4"4"6  =ufqj6'A+>??51$//1	&--h6I6I6K0LL
"*"4"4"6  _=)   #r&   c                    / SQnSnSnU Hv  n[         R                  " SUS9nUR                  U5        UR                  5       u  pgpUR                  U5        UR                  5       u  ppU R	                  XgX4XX45        Mx     g)zW
Tests whether Surface.get_shifts returns proper
RGBA shifts under various conditions.
r  r  Nr   rN   )r   r   r   r  r   )r   r  r  off	bit_depthr"   r   g1b1a1r  g2b2a2s                 r#   test_get_shifts#GeneralSurfaceTests.test_get_shifts  s     InnXY?Ge$$//1NBBc"$//1NBBbb-/?@  r&   c                     SnU H?  u  p#[         R                  " X#45      nUR                  5       nU R                  X#4U5        MA     g )N)r  ru  rw  )rX   i  )i  rX   )r  i  )r   r   r   r   )r   rx  r   r   r2   
found_sizes         r#   test_get_size!GeneralSurfaceTests.test_get_size  s@    R"ME>>5/2DJe_j9 #r&   c                    [         R                  " S5      nUR                  5         U R                  UR	                  5       5        [         R                  " S5      nUR                  5         UR                  5         UR                  5         U R                  UR	                  5       5        UR                  5         UR                  5         UR                  5         U R                  UR	                  5       5        UR                  5         U R                  UR	                  5       5        UR                  5         U R                  UR	                  5       5        [         R                  " S5      nUR                  5         UR                  5         U R                  UR	                  5       5        UR                  5         U R                  UR	                  5       5        UR                  5         U R                  UR	                  5       5        g NrT   )r   r   r  r   rX  r  r*  r1   s     r#   	test_lockGeneralSurfaceTests.test_lock  sC   : ~~j)		)* ~~j)				)*				)*)**+ ~~j)				)*)**+r&   c                 ,   [        SSSS5      n[        R                  " S[        S5      nUR	                  U5      nU R                  UR                  U5      U5        U R                  UR                  S5      S5        UR                  U5        U R                  UR                  S5      U5        UR                  S5        U R                  UR                  S5      S5        UR                  SU5        U R                  UR                  S5      U5        g )	Nr   r  r+   r  rR  rG   r)   r   )
r[   r   r   r   rd  r   	unmap_rgbr.   rY   rZ   )r   r   r2   r   s       r#   test_map_rgb GeneralSurfaceTests.test_map_rgb  s    ac2&~~fh3LL*E2V,l;		!V,e4		,V,l;FAV,e4r&   c                    [         R                  " S5      nUR                  S5      nU R                  UR	                  5       5        U R                  UR	                  5       5        Sn/ nUR                  U5        UR                  U5        U Hj  nUR                  US   R                  U5      5        U R                  US   R	                  5       5        U R                  US   R	                  5       5        Ml     g )N)ri  ri  )r   r   ri  ri  ))r   r      r  )r   r   r  r  )r   r   r  r  r  )r   r   r   r   r   r*  append)r   r2   r  rects
surf_stackr  s         r#   test_mustlock!GeneralSurfaceTests.test_mustlock  s    ~~l+//"45((*+)F
$'"Djn77=>OOJrN3356OOJrN3356 r&   c                    [         R                  " S[        S5      nUR                  S5        UR	                  S5        U R                  SUR                  5       5        [         R                  " S[        S5      nUR                  S5        UR                  US5        U R                  UR                  S5      S   SS5        g)	z&surf.set_alpha(None) disables blendingr  rG   r   r+   r   r  Nr+   r   r   r+   r)   r   zthe red component should be 0)	r   r   r   rY   r   r   r  r   r.   r   r?   r   s      r#   test_set_alpha_none'GeneralSurfaceTests.test_set_alpha_none  s    NN68R0	 	Dq{{}-^^FHb1
 !
66*1-q2QRr&   c                 H   [         R                  " S[        S5      nUR                  S5        UR	                  S5        [         R                  " S[        S5      nUR                  S5        UR                  US5        U R                  UR                  S5      S   SS5        g	)
z4surf.set_alpha(x), where x != None, enables blendingr  rG   r  r+   r  r)   r   z#the red component should be above 0N)r   r   r   rY   r   r   assertGreaterr.   r  s      r#   test_set_alpha_value(GeneralSurfaceTests.test_set_alpha_value	  s~    NN68R0	 	C^^FHb1
 !
6IIfa !%J	
r&   c                    [         R                  R                  [        [        R
                  R                  SS5      5      5      nUR                  5       nU R                  UR                  5       UR                  U5         U5        g)zRtest bug discovered by robertpfeiffer
https://github.com/pygame/pygame/issues/721
r_   
alien2.pngN)r   rc   rd   r   re   rf   rg   r   r   r   rd  r   r2   r  s      r#   test_palette_colorkey)GeneralSurfaceTests.test_palette_colorkey	  sa     ||  bggll6<.P!QR!))+DLL,=>Dr&   c                    [         R                  R                  [        [        R
                  R                  SS5      5      5      nUR                  5       nUR                  SU5        U R                  UR                  S5      U5        g Nr_   r  r)   )r   rc   rd   r   re   rf   rg   r   rZ   r   r.   r  s      r#   test_palette_colorkey_set_px0GeneralSurfaceTests.test_palette_colorkey_set_px 	  s_    ||  bggll6<.P!QR!FC V,c2r&   c                    [         R                  R                  [        [        R
                  R                  SS5      5      5      nUR                  5       nUR                  U5        U R                  UR                  S5      U5        g r  )r   rc   rd   r   re   rf   rg   r   rY   r   r.   r  s      r#   test_palette_colorkey_fill.GeneralSurfaceTests.test_palette_colorkey_fill&	  s\    ||  bggll6<.P!QR!		#V,c2r&   c           
         [        S5       Vs/ s H  n[        R                  " XU5      PM     nn[        US   5      US'   [        US   5      SS US'   [        R                  " SSS5      nUR                  U5        [        S5       Hf  nU R                  UR                  X!   5      USU4-  5        X!   nUR                  U5        U R                  UR                  S	5      USU4-  5        Mh     [        S5       H   n[        R                  " S
U-
  SS5      X!'   M"     UR                  USS 5        [        S5       Hf  nU R                  UR                  X!   5      USU4-  5        X!   nUR                  U5        U R                  UR                  S	5      USU4-  5        Mh     U R                  [        UR
                  [        SSSS5      /5        U R                  [        UR
                  S5        g s  snf )Nr  r9   r   r   r  r  r   zpalette color %ir)   r+   rX   r:   r@  )rX   r:   r  r@  )r  r   r[   r   r   r  r   rd  rY   r.   rl   rm   )r   r  r  r2   r   s        r#   test_set_palette$GeneralSurfaceTests.test_set_palette,	  s   27*=*Q6<<a(*=GBK(GBK(1-~~fa+!sAT\\'*5q:LPQt:ST
AIIaLT[[0!5G1$5NO	 
 rAcAgq!4GJ 2'sAT\\'*5q:LPQt:ST
AIIaLT[[0!5G1$5NO	 
 	*d&6&6q!Q9L8MN*d&6&6G) >s   !G<c                     SS/-  n[         R                  " SSS5      nU R                  [         R                  UR                  U5        g )Nr  r9   r(   r   r  r   rG   )r   r   rl   r  r  )r   r  r2   s      r#   test_set_palette__fail*GeneralSurfaceTests.test_set_palette__failC	  s<    &~~fa,&,,(8(8'Br&   c                    [         R                  " SSS9nSS/-  nSUS'   UR                  U5        UR                  SS	5        U R	                  UR                  S5      S
5        U R	                  UR                  S5      S5        g )Nr  r   rN   r  r  )r   ra   r   rX   r)   )r   r   ra   )r   ra   r   r+   rX  )r9   r(   r   r+   )r   r   r  rZ   r   r.   r   r2   r  s      r#   test_set_palette__set_at,GeneralSurfaceTests.test_set_palette__set_atH	  sy    ~~fA.&!
! 	FL)V,.?@V,.?@r&   c                    [         R                  " SSS5      nUR                  S5      n[        SSSS5      nX2:X  a  [        SSSS5      nUR	                  SU5        U R                  UR                  S5      U5        [        U5      nUR	                  SU5        U R                  UR                  S5      U5        [        U5      SS nUR	                  SU5        U R                  UR                  S5      U5        U R                  [        UR                  S	U5        U R                  [        UR                  S
U5        g )Nr  r   r   r9   rX   r+   r:   r  r  r  )	r   r   r  r[   r  r   r   rl   rZ  )r   r2   originalreplacementnexts        r#   test_set_palette_at'GeneralSurfaceTests.test_set_palette_atT	  s   ~~fa+&&r*Aq!S)"1a-KB,,,R0+>XB%,,R0$7Xq#B%,,R0$7*d&9&93L*d&9&92{Kr&   c                    [         R                  " S5      nUR                  SSSS5      nUR                  S5      nU R                  [        UR                  S5        U R                  UR                  5       UR                  5       5        U R                  UR                  5       UR                  5       5        U R                  UR                  5       UR                  5       5        [         R                  R                  [         R                  5      nU R                  [         R                  UR                  S5        g )Nr3  r   rX   )r   r   rX   rX   )r   r   rX   rX   i  r   )r   r   r   rl   rm   r   r  r  r  __new__r  )r   r2   r?   s      r#   test_subsurface#GeneralSurfaceTests.test_subsurfacee	  s    , ~~h'OOAq!Q'OOL) 	*doo7HI):;(89):; ~~%%fnn5&,,Fr&   c                    [         R                  " S5      nUR                  5         UR                  5         U R	                  UR                  5       5        [         R                  " S5      nUR                  5         UR                  5         UR                  5         U R                  UR                  5       5        UR                  5         U R	                  UR                  5       5        [         R                  " S5      nUR                  5         U R	                  UR                  5       5        UR                  5         U R	                  UR                  5       5        [         R                  " S5      nUR                  5         UR                  5         U R	                  UR                  5       5        UR                  5         UR                  5         U R	                  UR                  5       5        g r  )r   r   r  r  r*  rX  r   r1   s     r#   test_unlockGeneralSurfaceTests.test_unlock	  s=   ~~j)		*+ ~~j)				)**+ ~~j)*+*+ ~~j)		*+		*+r&   c           
      D   [         R                  " SSS5      nSnSnUR                  X25        UR                  U5      nU R	                  XB5        U R                  U[         R                  5        SnSSS	[        S
4[        S4/nU H  u  pg[         R                  " SXg5      nUR                  UR                  U5      5      nUR                  U5        UR                  S5      nU R	                  UUSXHXg4-  5        U R                  U[         R                  5        M     g )Nr  r   r   )rX   rX   rX   C   )r  r  r  r+   )r   r   )r   rV   )r   rG   r   rG   r)   z %s != %s, flags: %i, bitsize: %i)r   r   r  r  r   r   r[   r   rd  rY   r.   )	r   r2   r   r  
unmapped_cformatsrL   ro  comparison_cs	            r#   test_unmap_rgb"GeneralSurfaceTests.test_unmap_rgb	  s    ~~fa+A!^^A&
'j&,,7 GWxnxnM%NE>>&%9DQ8JIIaL;;v.L2U<= !!*fll; &r&   c                    / SQnU GH  u  p#n[         R                  " SSU5      nUR                  S5        UR                  SS5        UR                  5       nUR	                  XSU45        UR                  X45        UR                  5       u  px[        U5       H  n	[        U5       Hv  n
U R                  XS9   U R                  UR                  X45      UR                  X45      SUR                  X45      UR                  X45      UUU4-  5        S S S 5        Mx     M     GM"     [         R                  " S	SS
5      nUR                  S5        UR                  SS5        UR                  5       n[        SSSS5      nUR                  U5        UR                  U5        UR	                  X[R                  S-   UR                  S-   4UR                  5       5        UR                  SS5        UR                  5       u  px[        U5       HG  n	[        U5       H5  n
U R                  UR                  X45      UR                  X45      5        M7     MI     Sn[         R                  " S[         R                   S
5      nUR                  S5        UR#                  SU5        UR                  SS9  U R                  UR                  S5      U5        UR                  SS9  U R                  UR                  S5      U5        UR                  SSS9  U R                  UR                  S5      U5        UR                  SSS9  U R                  UR                  S5      U5        g ! , (       d  f       GM  = f)N))r   r:   r  )r   r:   r  )rV   r:   r  )rG   r:   r  )rG   r  r   )rG   r   r   )rG   r   r   )rG   r   r   )rG   r   )rG   r   r.  )rG   r.  r:   )rG   r:   r.  r`   r   r  r  r  )r  r  z %s != %s, bpp:, %i, x: %i, y: %i)r(   r   rG   )rD  rX   rB  rB  r  rX   r   rC  r:   r  r   r  r  )dxrQ  )dyr  )r0  r/  r  r   )r/  r0  r)   )r   r   rY   r   r   scrollr   r  r  r   r.   r;   r<   r  r  r>   r   rZ   )r   scrollsro  r/  r0  r2   compr>  r?  r  r  clip
spot_colors                r#   test_scrollGeneralSurfaceTests.test_scroll	  s   
  'OG>>(Aw7DIIk"IIk<099;DIIdH%KK==?DA1XqA/(( KK/ KK/> $QF 3 $QF 3 ' " " 0/ "   '0 ~~h2.		+		+|,yy{Aq!R dd		$!TVVaZ0$--/BAq}}qA1X  aV!4dkk1&6IJ   &
~~ffoor:		"#FJ'qV,j9qV,j9qQV,j9rb!V,j9O 0/s   :AM*	*
M:r  N)>r  r  r  r  r  r  re   r  r  r$  r+  r/  r3  r7  r  r  r  platformmachiner  r"  r%  r,  r:  r>  rM  rU  r`  rf  rj  rn  rr  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r	  r  r  r  r  r  r!  r$  r+  r6  r  r  r&   r#   r  r  (  s   __


()W40"	"2 __


()W40"	"4 __


()W40"	"("
Em4^m4^`4D __!!##FyH4D4D4F'F8a	aL<&8"$2"h","@$"L:&
'"R6
$!L3,A\*2X0"d<<& "(
3	@>6A0:8,t57 
S
E33H.C

AL"&GP,@<8@:r&   r  c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)SurfaceSubtypeTesti
  zAIssue #280: Methods that return a new Surface preserve subclassesc                 @    [         R                  R                  5         g r   r   r/   rb   r  s    r#   r  SurfaceSubtypeTest.setUp
      r&   c                 @    [         R                  R                  5         g r   r   r/   rh   r  s    r#   tearDownSurfaceSubtypeTest.tearDown
  r?  r&   c                    Sn[        U[        S5      nUR                  5       nU R                  X#5        U R	                  U[
        R                  5        U R	                  U[
        R                  5        U R	                  U[         5        U R	                  U[         5        U R                  UR                  5        U R                  [        [        US5        U R                  UR                  5       U5        g)zEnsure method copy() preserves the surface's class

When Surface is subclassed, the inherited copy() method will return
instances of the subclass. Non Surface fields are uncopied, however.
This includes instance attributes.
r   rG   test_attributeN)r   r   r   r   r   r   r   r   rE  rl   r  getattrr   r   r   r    ms1ms2s       r#   r   SurfaceSubtypeTest.test_copy
  s     !mXr:hhj"c6>>2c6>>2c?3c?3**+.'38HI7r&   c                    Sn[        USS5      nUR                  S5      nU R                  X#5        U R                  U[        R
                  5        U R                  U[        R
                  5        U R                  U[         5        U R                  U[         5        U R                  UR                  5        U R                  [        [        US5        U R                  UR                  5       U5        g)zEnsure method convert() preserves the surface's class

When Surface is subclassed, the inherited convert() method will return
instances of the subclass. Non Surface fields are omitted, however.
This includes instance attributes.
r   r   rV   rE  N)r   r   r   r   r   r   r   rE  rl   r  rF  r   r   rG  s       r#   test_convertSurfaceSubtypeTest.test_convert)
  s     !mQ3kk"o"c6>>2c6>>2c?3c?3**+.'38HI7r&   c                 j   [         R                  R                  S5        Sn[         R                  " U[        S5      n[        U[        S5      nUR                  U5      nU R                  X45        U R                  U[         R                  5        U R                  U[         R                  5        U R                  U[
        5        U R                  U[
        5        U R                  UR                  5        U R                  [        [        US5        U R                  UR                  5       U5        g)zEnsure method convert_alpha() preserves the surface's class

When Surface is subclassed, the inherited convert_alpha() method will
return instances of the subclass. Non Surface fields are omitted,
however. This includes instance attributes.
)ra   ra   r   r   rG   rE  N)r   r/   r0   r   r   r   r.  r   r   r   rE  rl   r  rF  r   r   )r   r    r?   rH  rI  s        r#   r:  %SurfaceSubtypeTest.test_convert_alpha=
  s     	) NN=(B7mXr:""c6>>2c6>>2c?3c?3**+.'38HI7r&   c                    Sn[        S[        S5      nUR                  SU5      nU R                  X#5        U R	                  U[
        R                  5        U R	                  U[
        R                  5        U R	                  U[         5        U R	                  U[         5        U R                  UR                  5        U R                  [        [        US5        U R                  UR                  5       U5        g)zEnsure method subsurface() preserves the surface's class

When Surface is subclassed, the inherited subsurface() method will
return instances of the subclass. Non Surface fields are uncopied,
however. This includes instance attributes.
r9   r  r   rG   r   r   rE  N)r   r   r   r   r   r   r   r   rE  rl   r  rF  r   r   rG  s       r#   r!  "SurfaceSubtypeTest.test_subsurfaceS
  s     !h"5nnV]3"c6>>2c6>>2c?3c?3**+.'38HI7r&   r  N)r  r  r  r  r  r  rB  r   rL  r:  r!  r  r  r&   r#   r;  r;  
  s#    K8(8(8,8r&   r;  c                   ~   \ rS rSr \  \R                  " 5       \R                  :H  r
S rS rS rS rS rS rS	 r\R&                  " \R(                  (       + S
5      S 5       r\R&                  " \R(                  (       + S
5      S 5       r\R&                  " \R(                  (       + S
5      S 5       r\R&                  " \R(                  (       + S
5      S 5       r\R&                  " \R(                  (       + S
5      S 5       r\R&                  " \R(                  (       + S
5      S 5       rSrg! \ a    Sr GN1f = f)SurfaceGetBufferTestih
  )ignoresubprocess_ignorec                    UR                  5       u  p#UR                  5       nUR                  5       nUR                  nUR	                  S5      n[
        (       Gdc  [        [        -  [        -  nUR                  5       X$-  :X  a	  U[        -  n[        U5      n	U R                  U	R                  S5        U R                  U	R                  S5        U R                  U	R                  S5        U R                  U	R                  U5        U R                  U	R                   S   U5        U R                  U	R                   S   U5        U R                  U	R"                  S   U5        U R                  U	R"                  S   U5        U R                  U	R$                  U5        U R                  U	R&                  U5        g g )NrE  r:   ur   rX   )r   rO   rm  rw  rS  rU  PAI_ALIGNEDPAI_NOTSWAPPEDPAI_WRITEABLEPAI_FORTRANrV  r   tworW  typekinditemsizeshapestridesrL   r_   )
r   r?   s_ws_h
s_bytesizes_pitchs_pixelsre  rL   inters
             r#   _check_interface_2D(SurfaceGetBufferTest._check_interface_2Dr
  sX   ::<^^%
++-$$ JJsOw.0=@E{{} 00$"1%EUYY*UXXq)U^^S1U^^Z8U[[^S1U[[^S1U]]1-z:U]]1-w7U[[%0UZZ2! r&   c                 >   UR                  5       u  p#UR                  5       nUR                  5       nUR                  n[	        UR                  5       5      nUSS / SQ:X  a  U R                  (       a  SnSn	OUS-
  nSn	O|USS / SQ:X  a  U R                  (       a  SnSn	O[US-
  nSn	OSUSS / SQ:X  a  U R                  (       a  SnSn	O2US-
  nSn	O*USS / S	Q:X  a  U R                  (       a  SnSn	O	US
-
  nSn	Og UR                  S5      n
[        (       Gd  [        U
5      n[        [        -  [        -  nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                   S5        U R                  UR"                  S5        U R                  UR$                  S   U5        U R                  UR$                  S   U5        U R                  UR$                  S   S5        U R                  UR&                  S   U5        U R                  UR&                  S   U5        U R                  UR&                  S   U	5        U R                  UR(                  U5        U R                  UR*                  Xh-   5        g g )Nr   r  )r   r   r   rX   r  )r   r   rV   r:   )r   r   r   )rV   r   r   r   rH  rY  )r   rO   rm  rw  r  r  	lilendianrS  rU  rV  rZ  r[  r\  r   r^  rW  r_  r`  ra  rb  rL   r_   )r   r?   rc  rd  re  rf  rg  s_shiftsoffsetstepre  rh  rL   s                r#   _check_interface_3D(SurfaceGetBufferTest._check_interface_3D
  sB   ::<^^%
++-$$' Aa=J&~~ $aa]k)~~ $aa]j(~~ $aa]k)~~ $a JJsOw"1%E.0=@EUYY*UXXq)U^^S1U^^Q/U[[^S1U[[^S1U[[^Q/U]]1-z:U]]1-w7U]]1-t4U[[%0UZZ):; r&   c                    UR                  5       u  p4UR                  5       nUR                  5       nUR                  nUR	                  5       nUR                  5       n	X   (       d  g X   n
U
S-  nU R                  (       d  X[-
  S-
  nUR                  SU   5      n[        (       GdF  [        U5      n[        [        -  [        -  nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                   S5        U R                  UR"                  S5        U R                  UR$                  S   U5        U R                  UR$                  S   U5        U R                  UR&                  S   U5        U R                  UR&                  S   U5        U R                  UR(                  U5        U R                  UR*                  X{-   5        g g )Nr   rX   rgbar:   rY  r   )r   rO   rm  rw  r  r  rl  rS  rU  rV  rZ  r[  r\  r   r^  rW  r_  r`  ra  rb  rL   r_   )r   r?   planerc  rd  re  rf  rg  rm  s_masksalpha_shiftrn  re  rh  rL   s                  r#   _check_interface_rgba*SurfaceGetBufferTest._check_interface_rgba
  s   ::<^^%
++-$$<<>++- ~o!~~(1,F JJve}%w"1%E.0=@EUYY*UXXq)U^^S1U^^Q/U[[^S1U[[^S1U]]1-z:U]]1-w7U[[%0UZZ):; r&   c                    U R                  [        R                  " SSS5      5        U R                  [        R                  " SSS5      5        U R                  [        R                  " S[        R                  S5      5        U R	                  [        R                  " SSS5      5        U R	                  [        R                  " SSS5      5        U R                  [        R                  " SSS5      5        U R	                  [        R                  " SSS5      5        U R                  [        R                  " S[        R                  S5      5        U R	                  [        R                  " S[        R                  S5      5        g )NrC  r   r   r   rV   )r   r   rG   )ri  r   r   r   rp  r  s    r#   test_array_interface)SurfaceGetBufferTest.test_array_interface
  s     1!=>  2!>?  !LM  2!>?  2!>?  2!>?  2!>?  !LM  !LMr&   c                 l   Sn[         R                  " USS5      n[        UR                  5       5      n/ SQnUSS U:X  d  USS USSS2   :X  a6  USSS2   USS	 -   nU R	                  [         R                  " USSU5      5        [         R                  " USS
5      n[        UR                  5       5      n/ SQnUSS U:X  d  USS USSS2   :X  a6  USSS2   USS	 -   nU R	                  [         R                  " USS
U5      5        / SQnU R	                  [         R                  " USSU5      5        g)z.Test non-default color byte orders on 3D viewsrC  r   rG   )r+   r   r   r  Nr  r:   r   rV   )r   r   r   r   )r   r   r  r  rp  )r   szr?   ru  r}   s        r#   test_array_interface_masks/SurfaceGetBufferTest.test_array_interface_masks
  s-    NN2q"%q{{}%(1Q<5 GAaLE$B$K$?AErENWQq\1E$$V^^B2u%EFNN2q"%q{{}%(1Q<5 GAaLE$B$K$?AErENWQq\1E$$V^^B2u%EF1  Ar5!ABr&   c                     / SQ/ SQ/ SQ/ SQ4 HQ  nU Vs/ s H  nSU-  PM
     nn[         R                  " S[         R                  SU5      nU R                  US5        MS     g s  snf )	Nr   r   r   rV   r   r   rV   r   rV   r   r   r   r   r   r   rV   r+   r   r:   rG   r  )r   r   r   rw  )r   shiftsr?   r}   s       r#   test_array_interface_alpha/SurfaceGetBufferTest.test_array_interface_alpha  sY    %~~~VF(./1TQYE/vvEBA&&q!, W/s   A%c                 4   / SQ/ SQ/ SQ/ SQ4 H  nU Vs/ s H  nSU-  PM
     nnSUS'   [        S5       HU  n[        R                  " SSS	5      nU R                  X$5        [        R                  " SSS
5      nU R                  X$5        MW     M     g s  snf )Nr  r  r  r  r+   r   r  r  rV   rG   )r  r   r   rw  )r   r  r?   r}   rt  s        r#   test_array_interface_rgb-SurfaceGetBufferTest.test_array_interface_rgb  s    %~~~VF(./1TQYE/E!HqNN61b1**14NN61b1**14	 " W/s   Bznewbuf not implementedc                    SSK Jn  UR                  n[        R                  " SSS5      nUR                  5       nU" XAR                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  UR                  5        U R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  S L 5        U R                  UR                   S L 5        U R#                  UR$                  5        U R                  UR&                  UR(                  5        U" XAR*                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R#                  UR$                  5        U" XAR,                  5      nU R                  UR                  S5        U R                  UR                  S5        U" XAR.                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  UR                  5        U R                  UR                  S5        U R                  UR                  UR                  45        U R                  UR                  S L 5        U R                  UR                   S L 5        U R#                  UR$                  5        U R                  UR&                  UR(                  5        U" XAR0                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  S5        UR3                  S5      nUR                  5       nU" XAR                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  UR                  5        U R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  S L 5        U R                  UR                   S L 5        U R#                  UR$                  5        U R                  UR&                  UR(                  5        U" XAR4                  5      nU R                  UR                  S5        U R                  UR                  S5        U" XAR6                  5      nU R                  UR                  S5        U R                  UR                  S5        U" XAR8                  5      nU R                  UR                  S5        U R                  UR                  S5        g )	Nr   buftoolsr9   rB  rG   rX   rM  )rX   rX   rX   rD  r   )pygame.tests.test_utilsr  Importerr   r   rn  PyBUF_SIMPLEr   ndimr   formatr  rT  r`  ra  rb  
suboffsetsr*  readonlybufrw  PyBUF_WRITABLEPyBUF_FORMATPyBUF_NDPyBUF_STRIDESr   PyBUF_C_CONTIGUOUSPyBUF_F_CONTIGUOUSPyBUF_ANY_CONTIGUOUSr   r  r  r?   rI  r   r   s          r#   test_newbuf_PyBUF_flags_bytes2SurfaceGetBufferTest.test_newbuf_PyBUF_flags_bytes  s1   4$$NN7Ar*LLNQ--.#D())Q'4(		T)*,-$ 1 12Q//0#D()$Q--.#3'Q))*#D())Q'188+.		T)*,-$ 1 12Q../#D()D)\\,'MMOQ--.#D())Q'4(		T)*,-$ 2 23Q334#D)Q334#D)Q556#D)r&   c                    SSK Jn  UR                  n[        R                  " SSS5      nUR                  S5      nU" XAR                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  UR                  5        U R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  S L 5        U R                  UR                   S L 5        U R#                  UR$                  5        U R                  UR&                  UR(                  5        g )Nr   r  r  rG   rF  rX   )r  r  r  r   r   rS  r  r   r  r   r  r  rT  r`  ra  rb  r  r*  r  r  rw  r   r  r  r?   rI  r   s         r#   test_newbuf_PyBUF_flags_0D/SurfaceGetBufferTest.test_newbuf_PyBUF_flags_0DY  s     	5$$NN7Ar*JJsOQ--.#D())Q'4(		T)*,-$ 1 12r&   c                    SSK Jn  UR                  n[        R                  " SSS5      nUR                  S5      nU" XAR                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  UR                  5        U R                  UR                  UR                  5       5        U R                  UR                  S L 5        U R                  UR                   S L 5        U R                  UR"                  S L 5        U R%                  UR&                  5        U R                  UR(                  UR*                  5        U" XAR,                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R%                  UR&                  5        U" XAR.                  5      nU R                  UR                  S5        U R                  UR                  S5        U" XAR0                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  UR                  5        U R                  UR                  UR                  5       5        U R                  UR                  UR3                  5       UR5                  5       -  45        U R                  UR                   S L 5        U R                  UR"                  S L 5        U R%                  UR&                  5        U R                  UR(                  UR*                  5        U" XAR6                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                   UR                  5       45        g )Nr   r  r  rG   rG  =IrX   )r  r  r  r   r   rS  r  r   r  r   r  r  rT  r`  rO   ra  rb  r  r*  r  r  rw  r  r  r  r   r   r  r  s         r#   test_newbuf_PyBUF_flags_1D/SurfaceGetBufferTest.test_newbuf_PyBUF_flags_1Dm  s   4$$NN7Ar*JJsOQ--.#D())Q^^%564(		T)*,-$ 1 12Q//0#D()$Q--.#4(Q))*#D())Q^^%561;;=1<<>#A"CD		T)*,-$ 1 12Q../#D()Q^^%5$78r&   c                    SSK Jn  UR                  n[        R                  " SSS5      nUR                  S5      nU" XAR                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  UR                  5        U R                  UR                  UR                  5       5        U R                  UR                  S L 5        U R                  UR                   S L 5        U R                  UR"                  S L 5        U R%                  UR&                  5        U R                  UR(                  UR*                  5        U" XAR,                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  UR                  5        U R                  UR                  UR                  5       5        U R                  UR                  UR/                  5       5        U R                  UR                   UR                  5       UR1                  5       45        U R                  UR"                  S L 5        U R%                  UR&                  5        U R                  UR(                  UR*                  5        U" XAR2                  5      nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                   UR                  5       UR1                  5       45        U" XAR4                  5      nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                   UR                  5       UR1                  5       45        U" XAR6                  5      nU R                  UR                  S5        U R                  UR                  S 5        U R                  UR                   UR                  5       UR1                  5       45        U" XAR8                  5      nU R                  UR                  S5        U R                  UR                  S 5        U R                  UR                   UR                  5       UR1                  5       45        U R;                  [<        X$UR>                  5        U R;                  [<        X$UR@                  5        URC                  S5      nUR                  S5      nU" XAR,                  5      nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  UR                  5        U R                  UR                  UR                  5       5        U R                  UR                  UR/                  5       5        U R                  UR                   UR                  5       UR1                  5       45        U R                  UR"                  S L 5        U R%                  UR&                  5        U R                  UR(                  UR*                  5        U" XAR4                  5      nU R                  UR                  S5        U R                  UR                  S5        U R;                  [<        X$UR                  5        U R;                  [<        X$URD                  5        U R;                  [<        X$URF                  5        U R;                  [<        X$UR>                  5        U R;                  [<        X$UR@                  5        U R;                  [<        X$UR6                  5        U R;                  [<        X$UR8                  5        g )	Nr   r  r  rG   rE  r:   r  r  )$r  r  r  r   r   rS  r  r   r  r   r  r  rT  r`  rO   ra  rb  r  r*  r  r  rw  r  r   rm  PyBUF_RECORDS_ROPyBUF_RECORDSr  r  rl   BufferErrorr  r  r   r  r  r  s          r#   test_newbuf_PyBUF_flags_2D/SurfaceGetBufferTest.test_newbuf_PyBUF_flags_2D  s   4$$NN7Ar*JJsO Q--.#D())Q^^%564(		T)*,-$ 1 12Q../#D())Q^^%56!**,/Q^^%5q{{}$EF,-$ 1 12Q112#4(Q^^%5q{{}$EFQ../#4(Q^^%5q{{}$EFQ334#4(Q^^%5q{{}$EFQ556#4(Q^^%5q{{}$EF+xH4E4EF+xH4O4OP\\,'KKQ../#D())R__%67"++-0R__%6$FG,-$ 2 23Q../#4(+xH4I4IJ+xH4I4IJ+xH4K4KL+xH4E4EF+xH4O4OP+xH4O4OP+xH4Q4QRr&   c                    SSK Jn  UR                  n[        R                  " SSS5      nUR                  5       u  pEpgU R                  (       a  US:X  a  SnSn	OSnSn	OUS	:X  a  SnSn	OSnSn	UR                  S
5      n
U" XR                  5      nUR                  5       u  pXS4nSUR                  5       U4nU R                  UR                  S5        U R                  UR                  S L 5        U R                  UR                  U
R                   5        U R                  UR"                  S5        U R                  UR$                  U5        U R                  UR&                  U5        U R                  UR(                  S L 5        U R+                  UR,                  5        U R                  UR.                  UR0                  U	-   5        U" XR2                  5      nU R                  UR                  S5        U R                  UR                  S5        U R                  UR&                  U5        U" XR4                  5      nU R                  UR                  S5        U R                  UR                  S5        U R                  UR&                  U5        U R7                  [8        X*UR:                  5        U R7                  [8        X*UR<                  5        U R7                  [8        X*UR>                  5        U R7                  [8        X*UR@                  5        U R7                  [8        X*URB                  5        U R7                  [8        X*URD                  5        U R7                  [8        X*URF                  5        g )Nr   r  r  rB  rV   r+   rX   r  r:   r   rH  r  rM  )$r  r  r  r   r   r  rl  rS  r  r   rm  r   r  r   r  r  rT  r`  ra  rb  r  r*  r  r  rw  r  r  rl   r  r  r  r  r  r  r  r  )r   r  r  r?   rmaskgmaskbmaskamask
color_stepaddr_offsetrI  r   r>  r?  ra  rb  s                   r#   test_newbuf_PyBUF_flags_3D/SurfaceGetBufferTest.test_newbuf_PyBUF_flags_3D  s   4$$NN7Ar*%&[[]"e>> 

 

JJsOQ../zz|aQ[[]J.#D())Q'%(G,,-$ 1 1K ?@Q112#3'G,Q../#3'G,+xH4I4IJ+xH4I4IJ+xH4K4KL+xH4E4EF+xH4O4OP+xH4O4OP+xH4Q4QRr&   c                    SSK Jn  UR                  n[        R                  " SSS5      nUR                  5       u  pEpgU R                  (       a  US:X  a  SnOSnOUS:X  a  SnOSnUR                  S5      n	U" XR                  5      n
UR                  5       u  pX4nUR                  5       UR                  5       4nU R                  U
R                  S5        U R                  U
R                  S L 5        U R                  U
R                   U	R"                  5        U R                  U
R$                  S	5        U R                  U
R&                  U5        U R                  U
R(                  U5        U R                  U
R*                  S L 5        U R-                  U
R.                  5        U R                  U
R0                  UR2                  U-   5        U" XR4                  5      n
U R                  U
R                  S5        U R                  U
R                  S
5        U R                  U
R(                  U5        U" XR6                  5      n
U R                  U
R                  S5        U R                  U
R                  S
5        U R                  U
R(                  U5        U R9                  [:        X)UR<                  5        U R9                  [:        X)UR>                  5        U R9                  [:        X)UR@                  5        U R9                  [:        X)URB                  5        U R9                  [:        X)URD                  5        U R9                  [:        X)URF                  5        U R9                  [:        X)URH                  5        g )Nr   r  r  rV   r+   r:   r   rK  rX   rM  )%r  r  r  r   r   r  rl  rS  r  r   rO   rm  r   r  r   r  r  rT  r`  ra  rb  r  r*  r  r  rw  r  r  rl   r  r  r  r  r  r  r  r  )r   r  r  r?   r  r  r  r  r  rI  r   r>  r?  ra  rb  s                  r#   test_newbuf_PyBUF_flags_rgba1SurfaceGetBufferTest.test_newbuf_PyBUF_flags_rgba  s    	5$$NN7Ar*%&[[]"e>>  JJsOQ../zz|.."AKKM1#D())Q'%(G,,-$ 1 1K ?@Q112#3'G,Q../#3'G,+xH4I4IJ+xH4I4IJ+xH4K4KL+xH4E4EF+xH4O4OP+xH4O4OP+xH4Q4QRr&   r  N)r  r  r  r  rV  	NameError__tags__r   get_sdl_byteorder
LIL_ENDIANrl  ri  rp  rw  rz  r~  r  r  r  r  HAVE_NEWBUFr  r  r  r  r  r  r  r  r&   r#   rU  rU  h
  sk   3 ((*f.?.??I34?<B<@	NC*-5 __+++-EF9* G9*v __+++-EF3 G3& __+++-EF$9 G$9L __+++-EFDS GDSL __+++-EF0S G0Sd __+++-EF.S G.SE  323s   D0 0D<;D<rU  c                       \ rS rSrS rS r/ SQrSr/ SQrSS jr	SS	 jr
SS
 jrSS jrS rS rS rS rS rS rS rS rSrg)SurfaceBlendTesti@  c                 @    [         R                  R                  5         g r   r=  r  s    r#   r  SurfaceBlendTest.setUpA      r&   c                 @    [         R                  R                  5         g r   rA  r  s    r#   rB  SurfaceBlendTest.tearDownE  r?  r&   )r*   )r9   r   r   r   )r   K   rU   r  )rw      rU   rw   )r   rU   rw   r+   rQ  ))r)   rX   )rR  rX   ))rF  r   r:   )rR  r:   ))r   r   r  ))r   rB  r  ))rF  r   r   )rD  r   Nc                     Uc  U R                   nSnU(       a	  U[        -  n[        R                  " U R                  XA5      nUS:X  a$  UR                  U Vs/ s H  ofS S PM	     sn5        U$ s  snf Nr   r   r  )_test_paletter   r   r   	surf_sizer  r   ro  srcalphar  rL   r2   r   s          r#   _make_surfaceSurfaceBlendTest._make_surface[  sj    ?((GXE~~dnne=a<W5WeW56 6s   A/c                     Uc  U R                   nUR                  US   S5        UR                  US   S5        UR                  US   S5        UR                  US   S5        g )	NrX   )r   r   r   rB  r:   )r   r   r   rB  r  )r   rB  r   rB  r   )r   rB  r   rB  r  rY   r  s      r#   _fill_surfaceSurfaceBlendTest._fill_surfacef  sZ    ?((G		'!*l+		'!*l+		'!*l+		'!*l+r&   c                 L    U R                  XU5      nU R                  XC5        U$ r   )r  r  )r   ro  r  r  r2   s        r#   _make_src_surface"SurfaceBlendTest._make_src_surfacen  s'    !!'W=4)r&   c                    Uc  U R                   nUR                  5       S:X  a/  U Vs/ s H"  oAR                  UR                  U5      5      PM$     nnU R                   H_  u  pVU R                  UR                  U5      X&   SUR                  U5      X&   UR                  5       UR                  5       UU4-  5        Ma     g s  snf )Nr   z(%s != %s: flags: %i, bpp: %i, posn: %s%s)r  r   r  rd  _test_pointsr   r.   r   )r   r2   r  msgr   posnr  s          r#   _assert_surface SurfaceBlendTest._assert_surfaces  s    ?((G#@GH1~~dll1o6GH((GDD!
:KK%JNN$$$& ) Is   )Cc                 
   U R                  S5      U R                  S5      U R                  SSS9U R                  S5      U R                  S5      U R                  SSS9/nU R                  S5      U R                  S5      U R                  SSS9U R                  S5      U R                  S5      U R                  SSS9/nSSS	 4S
SS 4SSS 4SS[        4SS[        4/nU GHy  nU R                   Vs/ s H"  oTR                  UR                  U5      5      PM$     nnU GH5  nU GH*  u  pn
UR                  UR                  U	5      5      n/ nU H  n[        S5       Vs/ s H  o" X   X   5      PM     nnUR                  5       S   (       a  UR                  US   5        OUR                  S5        UR                  UR                  U5      5      nUR                  U5        M     UR                  U	5        UR                  US[        [        U5      S9  U R                  UUSXR                  5       UR!                  5       4-  5        GM-     GM8     GM|     U R                  S5      nUR                  5       n[        R"                  " UR%                  5       SSUS   US   US   US   /5      nU H  u  pn
/ nU R                   HT  n[        S5       Vs/ s H  o" X   UU   5      PM     nnUR                  S5        UR                  ['        U5      5        MV     UR                  U	5        UR                  US[        [        U5      S9  U R                  X|SU 35        M     U R                  S5      nUR                  5       n[        U5      S:X  a  U Vs/ s H  nUS-	  PM
     nnOU Vs/ s H  nUS-  PM
     nn[        R"                  " UR%                  5       SSU5      nU R)                  U5        [        R"                  " UR%                  5       SSU5      nU H  u  pn
/ nU R                   HT  n[        S5       Vs/ s H  o" X   UU   5      PM     nnUR                  S5        UR                  ['        U5      5        MV     UR                  U	5        UR                  US[        [        U5      S9  U R                  X|SU 35        M     g s  snf s  snf s  snf s  snf s  snf s  snf )Nr   r   Tr  rV   rG   r  r   r   rU   r+   c                     [        X-   S5      $ Nr+   minrI  r   s     r#   <lambda>2SurfaceBlendTest.test_blit_blend.<locals>.<lambda>      #aeS/r&   	BLEND_SUB)rU   r   r   rU   c                     [        X-
  S5      $ Nr   maxr  s     r#   r  r        #aeQ-r&   
BLEND_MULT)rU   rw   r   r   c                     X-  S-   S-	  $ Nr+   r   r  r  s     r#   r  r        AES=Q:Nr&   	BLEND_MINr  	BLEND_MAXr   r+   r   r+   r  r+   r)   r  $, op: %s, src bpp: %i, src flags: %ir   r:   rX   , r   )r  r  r  r  r  r  rd  r  r  r  rY   r   rF  r   r  r   r   r   r   r   r  )r   sourcesdestinationsblendr  r   src_paletter  
blend_name	dst_coloropdcr_  scr  r}   	src_colorpatms                      r#   test_blit_blend SurfaceBlendTest.test_blit_blend  s   ""1%""2&""2"5""2&""2&""2"5
 q!r"rD1r"r"rD1
 +-IJ+-GH+-NO*C0*C0
 CBFBTBTUBTQ==Q8BTKU#16-J2s{{9'=>BA)7<Qx@x!Rru-x@==?1-HHRUOHHSMMM#++a.9 * HHY'HHS&
8SHT((.)??+<cmmoNO	 27 $ 4 $$R(nnLLNArE!HeAha%(#K
 */%J2A!//	=B1XFXR	il3XFq" 0 HHYHHS&
0KHL  2j\):; */ $$R(u:#%*+UQ!VUE+E%*+UQ!VUE+nnS\\^QE:3nnS\\^QE:).%J2A!//	=B1XFXR	il3XFq" 0 HHYHHS&
0KHL  2j\):; */k V A6 G ,+ Gs$   6)S#$S( S-%S2;S7S<c                  	  ^^^ U R                  S5      U R                  S5      U R                  SSS9U R                  S5      U R                  S5      U R                  SSS9/nU R                  S5      U R                  S5      U R                  SSS9U R                  S5      U R                  S5      U R                  SSS9/nSSS	 4S
SS 4SSS 4SS[        4SS[        4/nU GHZ  nU R                   Vs/ s H"  oTR                  UR                  U5      5      PM$     nnU GH  nU GH  u  nmmUR                  UR                  T5      5      n	/ n
U Hw  n[        S5       Vs/ s H  nT" X   X   5      PM     nnUR                  5       S   (       d  SUS'   UR                  UR                  U5      5      nU
R                  U5        My     UR                  T5        UR                  US[        [        U5      S9  U R                  UU
SXR                  5       UR!                  5       4-  5        GM     GM     GM]     U R                  SSS9nUR                  5       n[        R"                  " UR%                  5       [&        SUS   US   US   US   45      nU H  u  nmmU R                   V^s/ s H#  m[)        UUU4S j[        S5       5       5      PM%     n
nUR                  T5        UR                  US[        [        U5      S9  U R                  XzSU 35        M     [        R"                  " S[&        S5      n[        R"                  " S[&        S5      n[        R"                  " S[&        S5      nUR                  S5        UR                  S5        UR+                  S 5      nUR+                  S 5      nUR                  US[,        S9  UR                  S5        UR                  S!S 5        [        S5       Hs  n[        S"5       Ha  nU R/                  UR1                  UU45      UR1                  UU45      S#UR1                  UU45      UR1                  UU45      UU4-  5        Mc     Mu     g s  snf s  snf s  snf )$Nr   r   Tr  rV   rG   BLEND_RGBA_ADDr  c                     [        X-   S5      $ r  r  r  s     r#   r  7SurfaceBlendTest.test_blit_blend_rgba.<locals>.<lambda>      s15#r&   BLEND_RGBA_SUBc                     [        X-
  S5      $ r  r  r  s     r#   r  r        s15!}r&   BLEND_RGBA_MULTr   rD  rU   r+   c                     X-  S-   S-	  $ r  r  r  s     r#   r  r        #RS?Sr&   BLEND_RGBA_MINr  BLEND_RGBA_MAXr   r  r+   r)   r  r  r:   rX   r   c              3   B   >#    U  H  nT" TU   TU   5      v   M     g 7fr   r  )r   r  r   r  r  s     r#   r  8SurfaceBlendTest.test_blit_blend_rgba.<locals>.<genexpr>  s#     Ghb1y|44hs   r  )r   r9   )rX   r:   r  r   )ra   r   r(   r9   )r:   r  r   r   ))   rG   r  rC  r9   z%s != %s at (%i, %i))r  r  r  r  r  r  rd  r  r  r  rY   r   rF  r   r  r   r   r   r   r   r   r   r
  r   r.   )r   r  r  r  r  r   r  r  r  r  r_  r  r  r}   r  tstsubsrcsubdstr  r  r   r  s                 `     @@r#   test_blit_blend_rgba%SurfaceBlendTest.test_blit_blend_rgba  sF   ""1%""2&""2"5""2&""2&""2"5
 q!r"rD1r"r"rD1
 02NO02LM 02ST/5/5
 CBFBTBTUBTQ==Q8BTKU#16-J	2s{{9'=>BA)7<Qx@x!Rru-x@"}}q1#&AaDMM#++a.9 * HHY'HHS&
8SHT((.)??+<cmmoNO	 27 $ 8 $$R$$7nnLLNHb58U1XuQxq*R
 */%J	2 "&!3!3!3I GeAhGG!3   HHYHHS&
0KHL  2j\):; */ nnWh3nnWh3nnWh3!"--FF.A!"!<0qA2Y  JJ1v&JJ1v&*zz1a&)3::q!f+=q!DE  i V A6s   9)R(R9*Rc                          SS jnU R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " S	S	S	S	5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " S	S	S	S	5      5      6   U R                   " U" [        R                  " S	S	S	S	5      [        R                  " S	S	S	S	5      5      6   U R                   " U" [        R                  " S
S
S
S
5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " S
S
S
S
5      5      6   U R                   " U" [        R                  " S
S
S
S
5      [        R                  " S
S
S
S
5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      5      6   U R                  [        U[        R                  " SSSS5      [        R                  " SSSS5      SSS9  U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSSSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSSSSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSSSSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSSSSSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSSS96   U R                   " U" [        R                  " SSSS5      [        R                  " SSSS5      SSSSS96   g ) NTc           	         US:X  aA  [         R                  " USU5      nX/n	UR                  U	5        UR                  U	S   5        O^U(       a.  [         R                  " U[        U5      nUR                  U 5        O)[         R                  " USU5      nUR                  U 5        US:X  aA  [         R                  " USU5      n
X/n	U
R                  U	5        U
R                  U	S   5        O^U(       a.  [         R                  " U[        U5      n
U
R                  U5        O)[         R                  " USU5      n
U
R                  U5        U
R                  US[        S9  U
R                  [        [        US   S-  5      5      [        [        US   S-  5      5      45      nU R                  S:X  a  UnGOU R                  S:X  a  U nO[         R                  " U R                  UR                  -   UR                  S-   U R                  -  S-	  -
  U R                  UR                  -   UR                  S-   U R                  -  S-	  -
  U R                  UR                  -   UR                  S-   U R                  -  S-	  -
  U R                  UR                  -   UR                  S-   U R                  -  S-	  -
  5      nU(       d  SUl
        X4$ )Nr   r   rX   r)   r  g       @r+   )r   r   r  rY   r   r   BLEND_PREMULTIPLIEDr.   r  r  rI  r[   r@   r   r   )src_coldst_colsrc_sizedst_sizesrc_bit_depthdst_bit_depthsrc_has_alphadst_has_alphar  r  r  
actual_colexpected_cols                r#   test_premul_surfHSurfaceBlendTest.test_blit_blend_premultiplied.<locals>.test_premul_surf8  sA    !nnXq-@",($nnXxG!nnXq-@!!nnXq-@",($nnXxG!nnXq-@!HHS&0CHDU8A;,-.E(1+:K4L0MNJ
 yyA~&c!&  &||YY*wyy1}		.IQ.NOYY*wyy1}		.IQ.NOYY*wyy1}		.IQ.NOYY*wyy1}		.IQ.NO	  !!$ --r&   ra   r(   r   r  r:   rF  r  rw   r+   r)   )r$  r%  r   r   rP  )ra  r'  )E   r.  )r$  r%  r(  F)r$  r%  r)  )r$  r%  r(  r)  rV   )r$  r%  r'  r(  r)  )r$  r%  r&  r(  r)  )r$  r%  r&  r'  r(  r)  r   )r$  r%  r&  )r$  r%  r'  )r$  r%  r&  r'  )r3  r3  rG   rG   TT)r   r   r[   rl   rZ  )r   r,  s     r#   test_blit_blend_premultiplied.SurfaceBlendTest.test_blit_blend_premultiplied7  s    8	.v 	fll2r1b96<<BPQSU;VW	
 	fll1aA6RQPR8ST	
 	fll2r1b96<<1aQR;ST	
 	fll1aA6Q1a8PQ	
 	fll1aA6RQPR8ST	
 	fll2r1b96<<1aQR;ST	
 	fll1aA6Q1a8PQ	
 	fll1aA6RQPR8ST	
 	fll2r1b96<<1aQR;ST	
 	fll1aA6Q1a8PQ	
 	S#sC0&,,r2q"2M	
 	RQ+V\\#sC-M	
 	S#sC0&,,sCc2R	
 	S#sC0&,,r2q"2M	
 	RQ+V\\#sC-M	
 	S#sC0&,,sCc2R	
 	S#sC0&,,r2q"2M	
 	RQ+V\\#sC-M	
 	S#sC0&,,sCc2R	
 	LLc3,LLc3, 	 	
 	RQ+RQ+		
 	RQ+RQ+!!		
 	RQ,RQ+!!"	
 	RQ+RQ,!!#	
 	RQ,RQ,!!##		
 	RQ,RQ,!! "#
	
 	RQ,RQ,!! #"
	
 	RQ,RQ,!!  ##		
 	RQ,RQ,!!	
 	RQ,RQ,!!	
 	RQ,RQ,!!		
r&   c                 t   SnSn[         R                  " SSS5      nUR                  [         R                  XS9nU R	                  [         R
                  " S5      U5        U R	                  UR                  S5      S	5        U R	                  UR                  S
5      U5        [         R                  " S5      n[         R                  " S5      nU R                  XV5        [         R                  " SSS5      nUR                  U5        UR                  [         R
                  " SSSS5      5      nU R	                  UR                  S5      U5        U R	                  UR                  S5      U5        UR                  US[         R                  5        U R	                  UR                  S5      U5        U R	                  UR                  S5      U5        UR                  US[         R                  5        U R	                  UR                  S5      U5        U R	                  UR                  S5      U5        g)z%test that an oversized rect works ok.r  )rX   rX   r   r   r   r   rG   r
  )rX   rX   r  r  r)   r*   r  blackredr`   rX   r9   r   )r   rF  )r   r  r9   rX   )r   r   r9   rX   N)r   r   rY   r  r   r;   r.   r[   r   r   BLEND_RGB_ADD)	r   r   r  r   r@   r2  r3  r2   r  s	            r#   test_blit_blend_big_rect)SurfaceBlendTest.test_blit_blend_big_rectO  s   ^^FAr*GG&"2"2%GK\2A66*N;6*E2W%ll5!E'~~h2.		%//&++aB":;V,e4V,e4S.&*>*>?V,e4V,e4S-)=)=>V,e4V,e4r&   c                     U R                  SSS9nUR                  S5        UR                  S 5        U R                  SSS9nUR                  US[        S9  U R                  UR                  S5      S5        g )NrG   Tr  )r   r   r   r  r)   r  r*   )r  rY   r   r   r
  r   r.   )r   r  r  s      r#   test_GET_PIXELVALS#SurfaceBlendTest.test_GET_PIXELVALSl  sq    
   d 3 d  d 3fN;F+^<r&   c                    U R                  S5      U R                  S5      U R                  SSS9U R                  S5      U R                  S5      U R                  SSS9/nSSS	 4S
SS 4SSS 4SS[        4SS[        4/nU GHN  nU R                   Vs/ s H"  oCR	                  UR                  U5      5      PM$     nnU GH
  u  pgnUR	                  UR                  U5      5      n	U R                  U5        / n
U H  n[        S5       Vs/ s H  o" X   X   5      PM     nnUR                  5       S   (       a  UR                  US   5        OUR                  S5        UR	                  UR                  U5      5      nU
R                  U5        M     UR                  U[        [        U5      S9  U R                  X:SU 35        GM     GMQ     g s  snf s  snf )Nr   r   Tr  rV   rG   r  r  c                     [        X-   S5      $ r  r  r  s     r#   r  2SurfaceBlendTest.test_fill_blend.<locals>.<lambda>  r  r&   r  c                     [        X-
  S5      $ r  r  r  s     r#   r  r<    r  r&   r  r  c                     X-  S-   S-	  $ r  r  r  s     r#   r  r<    r  r&   r  r  r  r  r+   r  r  r  r  r  r  r  rd  r  r  r  r  rY   rF  r   r  r   r  r  r  r   dst_paletter  
fill_colorr  fcr_  r  r  s                r#   test_fill_blend SurfaceBlendTest.test_fill_blendx  s   q!r"rD1r"r"rD1
 +-IJ+-GH+-NO*C0*C0
  CBFBTBTUBTQ==Q8BTKU.3*
]]3;;z#:;""3'%B388<8aBE25)8A<}}q)Ackk!n5AHHQK & 76:3NO$$Sr*->? /4  U =s   )GG
c                 ~   U R                  S5      U R                  S5      U R                  SSS9U R                  S5      U R                  S5      U R                  SSS9/nSSS	 4S
SS 4SSS 4SS[        4SS[        4/nU GH+  nU R                   Vs/ s H"  oCR	                  UR                  U5      5      PM$     nnU H  u  pgnUR	                  UR                  U5      5      n	U R                  U5        / n
U Hv  n[        S5       Vs/ s H  o" X   X   5      PM     nnUR                  5       S   (       d  SUS'   UR	                  UR                  U5      5      nU
R                  U5        Mx     UR                  U[        [        U5      S9  U R                  X:SU 35        M     GM.     g s  snf s  snf )Nr   r   Tr  rV   rG   r
  r  c                     [        X-   S5      $ r  r  r  s     r#   r  7SurfaceBlendTest.test_fill_blend_rgba.<locals>.<lambda>  r  r&   r  c                     [        X-
  S5      $ r  r  r  s     r#   r  rH    r  r&   r  r  c                     X-  S-   S-	  $ r  r  r  s     r#   r  rH    r  r&   r  r  r  r   r  r+   r  r  r?  r@  s                r#   test_fill_blend_rgba%SurfaceBlendTest.test_fill_blend_rgba  s   q!r"rD1r"r"rD1
 02NO02LM 02ST/5/5
  CBFBTBTUBTQ==Q8BTKU.3*
]]3;;z#:;""3'%B388<8aBE25)8A<==?1-"!ckk!n5AHHQK & 76:3NO$$Sr*->? /4  U =s   )F5F:
c                 <   [         R                  " S[         R                  S5      nUR                  [         R                  " SSSS5      5        UR                  5       nU R                  UR                  S5      [         R                  " SSSS5      5        [         R                  " S[         R                  S5      nUR                  [         R                  " SSSS5      5        UR                  5       nU R                  UR                  S5      [         R                  " SSSS5      5        [         R                  " SSS5      nUR                  [         R                  " SSSS5      5        U R                  [        5         UR                  5         S	S	S	5        / S
QnU H  u  pxn	[        S5       H  n
U R                  XxXS9   [         R                  " S[         R                  S5      nUR                  [         R                  " XxX5      5        UR                  5       nU R                  UR                  S5      [	        US-   U
-  S-	  US-   U
-  S-	  U	S-   U
-  S-	  U
5      5        S	S	S	5        M     M     g	! , (       d  f       N= f! , (       d  f       M  = f)z+Ensure that .premul_alpha() works correctlyrT   rG   r+   rU   r   r   r  r   N))rw   r   J   L   S   rV   )   r   rB  )rN  r   rN  rO  )rR  r      )r  r   rN  )ry     r  )r  r  r   )   Y   rN  )   rF  r  )rR  r  rB  )r@   r   r   rI  r`   rR  rX   r   )r   r   r   rY   r[   premul_alphar   r.   rl   rm   r  r  )r   r   r2  r   r/  invalid_surftest_colorsr@   r   r   rI  r2   s               r#   test_surface_premul_alpha*SurfaceBlendTest.test_surface_premul_alpha  s    ^^J<
S#sC01??$2FLLc3PS4TU ^^J<
S#sC01??$2FLLc3PS4TU ~~j!R8&,,sCc:;z*%%' +
 #GA!3Z\\Aa\5!>>(FOORHDIIfll167,,.D$$F+!eq[Q.!eq[Q.!eq[Q.		 65   #' +** 65s   I;B%J;
J	
Jr  FNr   )NrO  )r  r  r  r  r  rB  r  r  r  r  r  r  r  r  r  r/  r5  r8  rD  rK  r[  r  r  r&   r#   r  r  @  sg    M I	L	,
(W<rUnV
p5:
= @D@@3r&   r  c                      \ rS rSrSrS rS r/ SQrSrSS jr	SS	 jr
S
 rS r\R                  " S\R                   " 5       ;   S5      S 5       r\R                  " S\R                   " 5       ;   S5      S 5       rS rS rS rS rS rSrg)SurfaceSelfBlitTesti  zaBlit to self tests.

This test case is in response to https://github.com/pygame/pygame/issues/19
c                 @    [         R                  R                  5         g r   r=  r  s    r#   r  SurfaceSelfBlitTest.setUp  r  r&   c                 @    [         R                  R                  5         g r   rA  r  s    r#   rB  SurfaceSelfBlitTest.tearDown  r?  r&   )r*   )r+   r   r   r   r  )rF  rB  Nc                 t    Uc  U R                   nUR                  US   5        UR                  US   S5        g )NrX   r:   )rX   r:   rX   r:   r  r  s      r#   r  !SurfaceSelfBlitTest._fill_surface   s4    ?((G		'!*		'!*l+r&   c                 
   Uc  U R                   nSnU(       a	  U[        -  n[        R                  " U R                  XA5      nUS:X  a$  UR                  U Vs/ s H  ofS S PM	     sn5        U R                  XS5        U$ s  snf r  )r  r   r   r   r  r  r  r  s          r#   r  !SurfaceSelfBlitTest._make_surface  sx    ?((GXE~~dnne=a<W5WeW564) 6s   B c                 >   UR                  5       u  p4[        U5       H|  n[        U5       Hj  nU R                  UR                  XV45      UR                  XV45      SUR                  XV45      UR                  XV45      UR	                  5       4-  5        Ml     M~     g )Nz%s != %s, bpp: %i)r   r  r   r.   r   )r   rI  r   r>  r?  r  r  s          r#   _assert_same SurfaceSelfBlitTest._assert_same  s    zz|qA1X  HHaV$HHaV$+88QF+QXXqf-=q}}OP	  r&   c           
      H   SnSnSnSS/n/ SQn[         R                  " S[        S5      /n[         R                  " SSS5      nUR                  S5        UR	                  U5        [         R                  " SSS5      nUR                  S	5        UR	                  U5        U H}  nU Ht  u  ppnUR                  U5        UR                  US
5        UR                  US5        UR                  XzU4XSS45        U R                  UR                  U5      U5        Mv     M     g )Nr*   )r  r  rG   r+   r  ))r   r   rX   r   )r   r   )r   r   1   rX   )r  r:   )r   r   rl  rl  )r  r  )rl  r   r   rX   rY  )rl  r   r   rl  )r   r  rT   rG   r   r+   )r   rX   r   )r   r   r   r   )r   r   r   r   r   )
r   r   r   r   r  r   rY   r   r   r.   )r   bgc
rectc_leftrectc_rightcolorsoverlapssurfsr2   s_xs_yd_xd_y	test_posns                r#   test_overlap_check&SurfaceSelfBlitTest.test_overlap_check  s    '
*&(:;
 
Hb9:~~j!R0sT~~j!R0)$TD19-#I		#		+7		*n5		$c
Sr2,>?  Y!7E 2: r&   ppc64lezknown ppc64le issuec                 t   [         R                  R                  S5        / SQnU GH  nU R                  U5      nUR	                  U R
                  S   5        UR                  US5        / nU R
                   H4  nUR                  UR                  U5      5      nUR                  U5        M6     US   S   US   S   US   S   S4US'   U R                  SSUS	9nUR                  US5        UR                  S 5        U R                  U5      nUR                  US
5        U R                  X75        GM     g )NrU   r   rl  rX   r  r   r   r:   rG   Tr  r  r)   )r   r/   r0   r  r   r  r   r  rd  r  r   ri  r   bitsizesro  r2   r_  r   tmpr3  s           r#   test_colorkey!SurfaceSelfBlitTest.test_colorkeyA  s    		*"G%%g.Dd0034IIdF#A''NN4<<?3 ( aDGQqT!Wad1gq1AaD$$R$$BCHHS&!MM$%%g.DIIc6"d)  r&   c                 :   [         R                  R                  S5        / SQnU H  nU R                  U5      nUR	                  S5        UR                  US5        / nU R                   HA  nUR                  UR                  U5      5      nUR                  US   US   US   S45        MC     U R                  SS	US
9nUR                  US5        UR	                  S 5        U R                  U5      nUR                  US5        U R                  X75        M     g )Nr|  rl  r  r}  r   rX   r:   rG   Tr~  r)   )r   r/   r0   r  r   r   r  r  rd  r  ri  r  s           r#   test_blanket_alpha&SurfaceSelfBlitTest.test_blanket_alphaX  s     		*"G%%g.DNN3IIdF#A''NN4<<?3!A$!adC01 ( $$R$$BCHHS&!MM$%%g.DIIc6"d)  r&   c                     SS/nU HX  nU R                  USS9nU R                  USS9nUR                  US5        UR                  US5        U R                  X45        MZ     g )Nr   rG   Tr  r}  )r  r   ri  )r   r  ro  r2   r3  s        r#   test_pixel_alpha$SurfaceSelfBlitTest.test_pixel_alpham  si    8G%%g%=D%%g%=DIIdF#IIdF#d)  r&   c           
      ^   / SQn/ SQnU H  nU R                  U5      nU R                  U5      nU Ht  nU R                  U5        U R                  U5        UR                  US[        [        U5      S9  UR                  US[        [        U5      S9  U R                  XE5        Mv     M     g )Nrl  )r  r  r  r  r  r}  r  r  r  r   rF  r   ri  r   r  blendsro  r2   r3  r  s          r#   
test_blendSurfaceSelfBlitTest.test_blendv  s    "SG%%g.D%%g.D""4(""4(		$gfe6L	M		$gfe6L	M!!$-    r&   c           
      Z   SS/n/ SQnU H  nU R                  USS9nU R                  USS9nU Ht  nU R                  U5        U R                  U5        UR                  US[        [        U5      S9  UR                  US[        [        U5      S9  U R                  XE5        Mv     M     g )Nr   rG   )r
  r  r  r  r  Tr  r}  r  r  r  s          r#   test_blend_rgba#SurfaceSelfBlitTest.test_blend_rgba  s    8
  G%%g%=D%%g%=D""4(""4(		$gfe6L	M		$gfe6L	M!!$-    r&   c                 <   U R                  SSS9nUR                  5       nUR                  US5        UR                  S5      nUR                  US5        AU R	                  X5        S nUR                  S5      nU R                  [        R                  XAU5        g )	NrG   Tr  r}  )r  r   rB  rB  r)   c                 (    U R                  US5        g )Nr)   )r   )dr?   s     r#   do_blit4SurfaceSelfBlitTest.test_subsurface.<locals>.do_blit  s    FF1fr&   r	  )r  r   r   r   ri  rl   r   r  )r   r2   r3  subr  s        r#   r!  #SurfaceSelfBlitTest.test_subsurface  s    !!"t!4yy{		$ool+v$%
	 ool+&,,s;r&   c                     [         R                  " S[         R                  S5      nU R                  UR	                  5       S5        UR                  5       nU R                  UR	                  5       S5        g)z;issue 581: alpha of surface copy with SRCALPHA is set to 0.r3  rG   r+   N)r   r   r   r   r  r   rn   s      r#   test_copy_alpha#SurfaceSelfBlitTest.test_copy_alpha  sQ    ~~h<)3/		*C0r&   r  r   r]  )r  r  r  r  r  r  rB  r  r  r  r  ri  rx  r  r  r8  unamer  r  r  r  r  r!  r  r  r  r&   r#   r_  r_    s    
 GMI,
FD __Y(.."224IJ* K*, __Y(.."224IJ* K*(*..&<&1r&   r_  c                   &    \ rS rSrS rS rS rSrg)SurfaceFillTesti  c                 @    [         R                  R                  5         g r   r=  r  s    r#   r  SurfaceFillTest.setUp  r?  r&   c                 @    [         R                  R                  5         g r   rA  r  s    r#   rB  SurfaceFillTest.tearDown  r?  r&   c           	         [         R                  R                  S5      nUR                  SS5        UR                  SS5        UR                  SS5        UR                  SS5        UR	                  S5        UR                  S	S
S5        UR                  S	S[         R
                  5        UR                  SS[         R                  5        UR                  SS[         R                  5        UR                  SS[         R                  5        UR                  SS[         R                  5        UR                  S	S[         R                  5        UR                  SS[         R                  5        UR                  SS[         R                  5        UR                  SS[         R                  5        UR                  SS[         R                  5        UR                  S	S[         R                  5        UR                  SS[         R                   5        UR                  SS[         R"                  5        UR                  SS[         R$                  5        UR                  S	S[         R&                  5        [         R                  R)                  5         [+        SSS 5       H:  nU R-                  UR/                  S U45      UR/                  S!SU-
  45      5        M<     g )"Nr   r  )r   r   rv   rb  )rv   rb  rv   rb  r   )rv   r   rv   rb  )r   rb  rv   rb  )r   r   rv   r   )r+   r   r   r  )r  r   rv   r   r   )r  r   rv   r   )r   r  r  r  )r  r   rv   r   )r   r  r  r  )r  r   rv   r   )r  x   rv   r   )r  r   r   r  )r  r  rv   r   )r     rv   r   )r     rv   r   )r  rb  rv   r   )r  i  rv   r   )r  r  rv   r   )r  J  rv   r   )r  ih  rv   r   )r  i  rv   r   )r  i  rv   r   )r  r  rv   r   r   r   r9   r  )r   r/   r0   rY   r<   r  r  r  r  r  r
  r  r  r  r  r4  BLEND_RGB_SUBBLEND_RGB_MULTBLEND_RGB_MINBLEND_RGB_MAXflipr  r   r.   )r   screenr  s      r#   r   SurfaceFillTest.test_fill  s4   ((4 	K!12K!56K!34K!34 	() 	$&7;$&8&:J:JK&(:F<L<LM$&8&:K:KL&(;V=M=MN$&96;K;KL$&96;P;PQ&(;V=R=RS$&96;Q;QR&(;V=R=RS$&96;P;PQ$&96;O;OP&(;V=Q=QR$&96;P;PQ&(;V=Q=QR$&96;O;OP 	 q#r"AV]]B73V]]Cq>5RS #r&   r  N)r  r  r  r  r  rB  r   r  r  r&   r#   r  r    s    $Tr&   r  __main__)re   r  pygame.testsr   r  r   r    pygame.tests.test_utils.arrinterImportErrorr  r   pygame.localsrv  r   r8  rZ  r]  ctypespython_implementationrU  TestCaser
   r  r  r;  rU  r  r_  r  r  mainr  r&   r#   <module>r     s$   	  #
	2   *  	  
H224
4zJh'' zJzO$h'' O$da:(++ a:H/Y8** Y8xUS8,, USpm
x(( m
`~1(++ ~1B+Th'' +T\ zMMO i~ 	Y 		s   D DD