@@ -1221,14 +1221,25 @@ smoothscale_init(struct _module_state *st)
12211221 return ;
12221222 }
12231223
1224- #ifdef SCALE_MMX_SUPPORT
1224+ #if !defined(__EMSCRIPTEN__ )
1225+ #if PG_ENABLE_SSE_NEON
12251226 if (SDL_HasSSE2 ()) {
12261227 st -> filter_type = "SSE2" ;
12271228 st -> filter_shrink_X = filter_shrink_X_SSE2 ;
12281229 st -> filter_shrink_Y = filter_shrink_Y_SSE2 ;
12291230 st -> filter_expand_X = filter_expand_X_SSE2 ;
12301231 st -> filter_expand_Y = filter_expand_Y_SSE2 ;
12311232 }
1233+ else if (SDL_HasNEON ()) {
1234+ st -> filter_type = "NEON" ;
1235+ st -> filter_shrink_X = filter_shrink_X_SSE2 ;
1236+ st -> filter_shrink_Y = filter_shrink_Y_SSE2 ;
1237+ st -> filter_expand_X = filter_expand_X_SSE2 ;
1238+ st -> filter_expand_Y = filter_expand_Y_SSE2 ;
1239+ }
1240+ #endif /* PG_ENABLE_SSE_NEON */
1241+ #endif /* !__EMSCRIPTEN__ */
1242+ #ifdef SCALE_MMX_SUPPORT
12321243 else if (SDL_HasSSE ()) {
12331244 st -> filter_type = "SSE" ;
12341245 st -> filter_shrink_X = filter_shrink_X_SSE ;
@@ -1563,14 +1574,14 @@ surf_set_smoothscale_backend(PyObject *self, PyObject *args, PyObject *kwargs)
15631574 if (!PyArg_ParseTupleAndKeywords (args , kwargs , "s" , keywords , & type ))
15641575 return NULL ;
15651576
1566- #if defined(SCALE_MMX_SUPPORT )
15671577 if (strcmp (type , "GENERIC" ) == 0 ) {
15681578 st -> filter_type = "GENERIC" ;
15691579 st -> filter_shrink_X = filter_shrink_X_ONLYC ;
15701580 st -> filter_shrink_Y = filter_shrink_Y_ONLYC ;
15711581 st -> filter_expand_X = filter_expand_X_ONLYC ;
15721582 st -> filter_expand_Y = filter_expand_Y_ONLYC ;
15731583 }
1584+ #if defined(SCALE_MMX_SUPPORT )
15741585 else if (strcmp (type , "MMX ") == 0 ) {
15751586 if (!SDL_HasMMX ()) {
15761587 return RAISE (PyExc_ValueError ,
@@ -1593,6 +1604,15 @@ surf_set_smoothscale_backend(PyObject *self, PyObject *args, PyObject *kwargs)
15931604 st -> filter_expand_X = filter_expand_X_SSE ;
15941605 st -> filter_expand_Y = filter_expand_Y_SSE ;
15951606 }
1607+ #else
1608+ else if (strcmp (st -> filter_type , "MMX ") == 0 ||
1609+ strcmp (st -> filter_type , "SSE ") == 0 ) {
1610+ return PyErr_Format (PyExc_ValueError ,
1611+ "%s not supported on this machine" , type );
1612+ }
1613+ #endif /* ~defined(SCALE_MMX_SUPPORT) */
1614+ #if !defined(__EMSCRIPTEN__ )
1615+ #if PG_ENABLE_SSE_NEON
15961616 else if (strcmp (type , "SSE2 ") == 0 ) {
15971617 if (!SDL_HasSSE2 ()) {
15981618 return RAISE (PyExc_ValueError ,
@@ -1604,22 +1624,24 @@ surf_set_smoothscale_backend(PyObject *self, PyObject *args, PyObject *kwargs)
16041624 st -> filter_expand_X = filter_expand_X_SSE2 ;
16051625 st -> filter_expand_Y = filter_expand_Y_SSE2 ;
16061626 }
1607- else {
1608- return PyErr_Format (PyExc_ValueError , "Unknown backend type %s" , type );
1609- }
1610- Py_RETURN_NONE ;
1611- #else /* Not an x86 processor */
1612- if (strcmp (type , "GENERIC" ) != 0 ) {
1613- if (strcmp (st -> filter_type , "MMX" ) == 0 ||
1614- strcmp (st -> filter_type , "SSE" ) == 0 ||
1615- strcmp (st -> filter_type , "SSE2" ) == 0 ) {
1616- return PyErr_Format (PyExc_ValueError ,
1617- "%s not supported on this machine" , type );
1627+
1628+ else if (strcmp (type , "NEON ") == 0 ) {
1629+ if (!SDL_HasNEON ()) {
1630+ return RAISE (PyExc_ValueError ,
1631+ "NEON not supported on this machine" );
16181632 }
1633+ st -> filter_type = "NEON" ;
1634+ st -> filter_shrink_X = filter_shrink_X_SSE2 ;
1635+ st -> filter_shrink_Y = filter_shrink_Y_SSE2 ;
1636+ st -> filter_expand_X = filter_expand_X_SSE2 ;
1637+ st -> filter_expand_Y = filter_expand_Y_SSE2 ;
1638+ }
1639+ #endif /* PG_ENABLE_SSE_NEON */
1640+ #endif /* !__EMSCRIPTEN__ */
1641+ else {
16191642 return PyErr_Format (PyExc_ValueError , "Unknown backend type %s" , type );
16201643 }
16211644 Py_RETURN_NONE ;
1622- #endif /* defined(SCALE_MMX_SUPPORT) */
16231645}
16241646
16251647/* _get_color_move_pixels is for iterating over pixels in a Surface.
0 commit comments