[svn:parrot] r40110 - in trunk: . config/gen/call_list runtime/parrot/library runtime/parrot/library/SDL

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed Jul 15 19:34:48 UTC 2009


Author: NotFound
Date: Wed Jul 15 19:34:47 2009
New Revision: 40110
URL: https://trac.parrot.org/parrot/changeset/40110

Log:
[lib] Fix SDL font color, TT #798, richardh++

Modified:
   trunk/CREDITS
   trunk/config/gen/call_list/misc.in
   trunk/runtime/parrot/library/SDL.pir
   trunk/runtime/parrot/library/SDL/Font.pir

Modified: trunk/CREDITS
==============================================================================
--- trunk/CREDITS	Wed Jul 15 15:13:06 2009	(r40109)
+++ trunk/CREDITS	Wed Jul 15 19:34:47 2009	(r40110)
@@ -788,6 +788,11 @@
 E: rurban at cpan.org
 D: cygwin, 64-bit pbc compat, float converters, bignum.pmc
 
+N: Richard Hainsworth
+U: finanalyst
+E: richard at rusrating.ru
+D: bugfix SDL Font
+
 N: Richard Tibbetts
 D: Divide by zero exceptions in some PMCs
 

Modified: trunk/config/gen/call_list/misc.in
==============================================================================
--- trunk/config/gen/call_list/misc.in	Wed Jul 15 15:13:06 2009	(r40109)
+++ trunk/config/gen/call_list/misc.in	Wed Jul 15 19:34:47 2009	(r40110)
@@ -227,6 +227,8 @@
 v    pip
 p    pti
 i    ppp
+# added by RNH for the RenderXXX_XXXX text routines 
+p    ptii
 
 # Used by SDL::Font
 p    ti

Modified: trunk/runtime/parrot/library/SDL.pir
==============================================================================
--- trunk/runtime/parrot/library/SDL.pir	Wed Jul 15 15:13:06 2009	(r40109)
+++ trunk/runtime/parrot/library/SDL.pir	Wed Jul 15 19:34:47 2009	(r40110)
@@ -219,6 +219,7 @@
     loadlib ttf_lib, 'libSDL_ttf'
     if ttf_lib goto initialize
     loadlib ttf_lib, 'cygSDL_ttf-2-0-0'
+# RNH this is not trapping a non-existent libSDL_ttf library
     unless ttf_lib goto error
 
   initialize:
@@ -243,15 +244,21 @@
   success:
     dlfunc nci_sub, ttf_lib, 'TTF_OpenFont', 'pti'
     set_hll_global ['SDL::NCI::TTF'], 'OpenFont', nci_sub
-
-    dlfunc nci_sub, ttf_lib, 'TTF_RenderText_Solid', 'pptp'
+#RNH changes: all text routines expect an integer, not a pmc, for color parameter
+    dlfunc nci_sub, ttf_lib, 'TTF_RenderText_Solid', 'ppti'
     set_hll_global ['SDL::NCI::TTF'], 'RenderText_Solid', nci_sub
-    dlfunc nci_sub, ttf_lib, 'TTF_RenderUTF8_Solid', 'pptp'
+    dlfunc nci_sub, ttf_lib, 'TTF_RenderUTF8_Solid', 'ppti'
     set_hll_global ['SDL::NCI::TTF'], 'RenderUTF8_Solid', nci_sub
 
     # this one could be wrong
-    dlfunc nci_sub, ttf_lib, 'TTF_RenderUNICODE_Solid', 'pptp'
+    dlfunc nci_sub, ttf_lib, 'TTF_RenderUNICODE_Solid', 'ppti'
     set_hll_global ['SDL::NCI::TTF'], 'RenderUNICODE_Solid', nci_sub
+# RNH Additions. Add UTF8_Shaded and FontLine skip
+    dlfunc nci_sub, ttf_lib, 'TTF_RenderUTF8_Shaded', 'pptii'
+    set_hll_global ['SDL::NCI::TTF'], 'RenderUTF8_Shaded', nci_sub
+    dlfunc nci_sub, ttf_lib, 'TTF_FontLineSkip', 'ip'
+    set_hll_global ['SDL::NCI::TTF'], 'FontLineSkip', nci_sub
+#end additions
 
     dlfunc nci_sub, ttf_lib, 'TTF_SizeText', 'ipt33'
     set_hll_global ['SDL::NCI::TTF'], 'SizeText', nci_sub

Modified: trunk/runtime/parrot/library/SDL/Font.pir
==============================================================================
--- trunk/runtime/parrot/library/SDL/Font.pir	Wed Jul 15 15:13:06 2009	(r40109)
+++ trunk/runtime/parrot/library/SDL/Font.pir	Wed Jul 15 19:34:47 2009	(r40110)
@@ -136,14 +136,29 @@
     font_surface = new 'SDL::Surface'
     font_surface.'init'( 'height' => 0, 'width' => 0 )
 
-    .local pmc RenderText_Solid
-    get_hll_global RenderText_Solid, ['SDL::NCI::TTF'], 'RenderText_Solid'
+# RNH use RenderUTF8 in preference to RenderText by default
+    .local pmc RenderUTF8_Solid
+    get_hll_global RenderUTF8_Solid, ['SDL::NCI::TTF'], 'RenderUTF8_Solid'
+
+    .local int color
+# RNH font routine takes color in the order rgb rather than bgr used by surface.pir hence cannot rely on color.get_integer
+    .local int component
+    .local pmc colors
+    colors = color_pmc.'color'()
+
+    component = colors['b']
+    component <<= 16
+    color = component
+
+    component = colors['g']
+    component <<= 8
+    color += component
 
-    .local pmc color
-    color = color_pmc.'color'()
+    component = colors['r']
+    color += component
 
     .local pmc font_surface_struct
-    font_surface_struct = RenderText_Solid( font, text, color )
+    font_surface_struct = RenderUTF8_Solid( font, text, color )
     font_surface.'wrap_surface'( font_surface_struct )
 
     .return( font_surface )


More information about the parrot-commits mailing list