2 * Copyright (C) 2007-2008 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
24 #include "swfdec_utils.h"
29 #include "swfdec_as_internal.h"
30 #include "swfdec_as_object.h"
31 #include "swfdec_as_strings.h"
34 swfdec_str_case_equal (gconstpointer v1
, gconstpointer v2
)
39 return g_ascii_strcasecmp (s1
, s2
) == 0;
43 swfdec_str_case_hash (gconstpointer v
)
48 for (p
= v
; *p
!= '\0'; p
++)
49 h
= (h
<< 5) - h
+ (*p
& 0xDF);
55 swfdec_strcmp (guint version
, const char *s1
, const char *s2
)
57 g_return_val_if_fail (s1
!= NULL
, 0);
58 g_return_val_if_fail (s2
!= NULL
, 0);
61 return g_ascii_strcasecmp (s1
, s2
);
63 return strcmp (s1
, s2
);
68 swfdec_strncmp (guint version
, const char *s1
, const char *s2
, guint n
)
70 g_return_val_if_fail (s1
!= NULL
, 0);
71 g_return_val_if_fail (s2
!= NULL
, 0);
74 return g_ascii_strncasecmp (s1
, s2
, n
);
76 return strncmp (s1
, s2
, n
);
81 swfdec_matrix_from_as_object (cairo_matrix_t
*matrix
, SwfdecAsObject
*object
)
84 SwfdecAsContext
*cx
= object
->context
;
86 val
= swfdec_as_object_peek_variable (object
, SWFDEC_AS_STR_a
);
88 !isfinite (matrix
->xx
= swfdec_as_value_to_number (cx
, *val
)))
90 val
= swfdec_as_object_peek_variable (object
, SWFDEC_AS_STR_b
);
92 !isfinite (matrix
->yx
= swfdec_as_value_to_number (cx
, *val
)))
94 val
= swfdec_as_object_peek_variable (object
, SWFDEC_AS_STR_c
);
96 !isfinite (matrix
->xy
= swfdec_as_value_to_number (cx
, *val
)))
98 val
= swfdec_as_object_peek_variable (object
, SWFDEC_AS_STR_d
);
100 !isfinite (matrix
->yy
= swfdec_as_value_to_number (cx
, *val
)))
103 val
= swfdec_as_object_peek_variable (object
, SWFDEC_AS_STR_tx
);
106 matrix
->x0
= swfdec_as_value_to_number (cx
, *val
);
107 if (!isfinite (matrix
->x0
))
109 val
= swfdec_as_object_peek_variable (object
, SWFDEC_AS_STR_ty
);
112 matrix
->y0
= swfdec_as_value_to_number (cx
, *val
);
113 if (!isfinite (matrix
->y0
))