trunk/src/mame/drivers/aleck64.c
| r242698 | r242699 | |
| 881 | 881 | PIF_BOOTROM |
| 882 | 882 | |
| 883 | 883 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 884 | | ROM_LOAD16_WORD_SWAP( "nus-zhaj.u3", 0x000000, 0x0800000, BAD_DUMP CRC(95258ba2) SHA1(0299b8fb9a8b1b24428d0f340f6bf1cfaf99c672) ) |
| 884 | ROM_LOAD16_WORD_SWAP( "nus-zhaj.u3", 0x000000, 0x0800000, CRC(95258ba2) SHA1(0299b8fb9a8b1b24428d0f340f6bf1cfaf99c672) ) |
| 885 | 885 | |
| 886 | 886 | ROM_REGION16_BE( 0x80, "normpoint", 0 ) |
| 887 | 887 | ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) ) |
| r242698 | r242699 | |
| 895 | 895 | PIF_BOOTROM |
| 896 | 896 | |
| 897 | 897 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 898 | | ROM_LOAD16_WORD_SWAP( "nus-zcaj.u4", 0x000000, 0x1000000, CRC(ec4563fc) SHA1(4d5a30873a5850cf4cd1c0bdbe24e1934f163cd0) ) |
| 898 | ROM_LOAD16_WORD_SWAP( "nus-zcaj.u4", 0x000000, 0x1000000, CRC(ec4563fc) SHA1(4d5a30873a5850cf4cd1c0bdbe24e1934f163cd0) ) |
| 899 | 899 | |
| 900 | 900 | ROM_REGION32_BE( 0x100000, "user3", 0 ) |
| 901 | | ROM_LOAD ( "tet-01m.u5", 0x000000, 0x100000, CRC(f78f859b) SHA1(b07c85e0453869fe43792f42081f64a5327e58e6) ) |
| 901 | ROM_LOAD ( "tet-01m.u5", 0x000000, 0x100000, CRC(f78f859b) SHA1(b07c85e0453869fe43792f42081f64a5327e58e6) ) |
| 902 | 902 | |
| 903 | 903 | ROM_REGION32_BE( 0x80, "user4", 0 ) |
| 904 | | ROM_LOAD ( "at24c01.u34", 0x000000, 0x80, CRC(ba7e503f) SHA1(454aa4fdde7d8694d1affaf25cd750fa678686bb) ) |
| 904 | ROM_LOAD ( "at24c01.u34", 0x000000, 0x80, CRC(ba7e503f) SHA1(454aa4fdde7d8694d1affaf25cd750fa678686bb) ) |
| 905 | 905 | |
| 906 | 906 | ROM_REGION16_BE( 0x80, "normpoint", 0 ) |
| 907 | 907 | ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) ) |
| r242698 | r242699 | |
| 924 | 924 | PIF_BOOTROM |
| 925 | 925 | |
| 926 | 926 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 927 | | ROM_LOAD16_WORD_SWAP( "nus-zhbj-0.u3", 0x000000, 0xc00000, CRC(a4edac93) SHA1(3794606c008fb69f5d16dcccece94d03da23bf8a) ) |
| 927 | ROM_LOAD16_WORD_SWAP( "nus-zhbj-0.u3", 0x000000, 0xc00000, CRC(a4edac93) SHA1(3794606c008fb69f5d16dcccece94d03da23bf8a) ) |
| 928 | 928 | |
| 929 | 929 | ROM_REGION16_BE( 0x80, "normpoint", 0 ) |
| 930 | 930 | ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) ) |
| r242698 | r242699 | |
| 939 | 939 | PIF_BOOTROM |
| 940 | 940 | |
| 941 | 941 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 942 | | ROM_LOAD16_WORD_SWAP( "nus-zsej-0.u2", 0x000000, 0x2000000, CRC(44f40102) SHA1(a78de955f2fcd99dda14e782984368b320eb5415) ) |
| 942 | ROM_LOAD16_WORD_SWAP( "nus-zsej-0.u2", 0x000000, 0x2000000, CRC(44f40102) SHA1(a78de955f2fcd99dda14e782984368b320eb5415) ) |
| 943 | 943 | |
| 944 | 944 | ROM_REGION16_BE( 0x80, "normpoint", 0 ) |
| 945 | 945 | ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) ) |
| r242698 | r242699 | |
| 963 | 963 | PIF_BOOTROM |
| 964 | 964 | |
| 965 | 965 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 966 | | ROM_LOAD16_WORD_SWAP( "nus-zsaj-0.u3", 0x000000, 0x800000, CRC(f3220e29) SHA1(06d8b808cc19378b046803f4dc75c7d791b7767f) ) |
| 966 | ROM_LOAD16_WORD_SWAP( "nus-zsaj-0.u3", 0x000000, 0x800000, CRC(f3220e29) SHA1(06d8b808cc19378b046803f4dc75c7d791b7767f) ) |
| 967 | 967 | |
| 968 | 968 | ROM_REGION16_BE( 0x80, "normpoint", 0 ) |
| 969 | 969 | ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) ) |
| r242698 | r242699 | |
| 991 | 991 | PIF_BOOTROM |
| 992 | 992 | |
| 993 | 993 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 994 | | ROM_LOAD16_WORD_SWAP( "ua3012--all02.u3", 0x000000, 0x1000000, CRC(904a91a7) SHA1(7dfa3447d2c489c0448c4004dc12d3037c05a0f3) ) |
| 994 | ROM_LOAD16_WORD_SWAP( "ua3012--all02.u3", 0x000000, 0x1000000, CRC(904a91a7) SHA1(7dfa3447d2c489c0448c4004dc12d3037c05a0f3) ) |
| 995 | 995 | |
| 996 | 996 | ROM_REGION32_BE( 0x800000, "user3", 0 ) |
| 997 | | ROM_LOAD16_WORD_SWAP( "nus-zsij-0.u1", 0x000000, 0x800000, CRC(2389576f) SHA1(dc22b2eab4d7a02cb918827a62e6c120b3a84e6c) ) |
| 997 | ROM_LOAD16_WORD_SWAP( "nus-zsij-0.u1", 0x000000, 0x800000, CRC(2389576f) SHA1(dc22b2eab4d7a02cb918827a62e6c120b3a84e6c) ) |
| 998 | 998 | |
| 999 | 999 | ROM_REGION16_BE( 0x80, "normpoint", 0 ) |
| 1000 | 1000 | ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) ) |
| r242698 | r242699 | |
| 1009 | 1009 | PIF_BOOTROM |
| 1010 | 1010 | |
| 1011 | 1011 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 1012 | | ROM_LOAD16_WORD_SWAP( "ua2011-all02.u3", 0x0000000, 0x1000000, CRC(eb4b96d0) SHA1(e909ea5b71b81087da07821c4f57244576363678) ) |
| 1013 | | ROM_LOAD16_WORD_SWAP( "ua2011-alh02.u4", 0x1000000, 0x1000000, CRC(b8e35ddf) SHA1(7c3e59f6520dc3f0aa592e682fa82e30ffd1f4d0) ) |
| 1012 | ROM_LOAD16_WORD_SWAP( "ua2011-all02.u3", 0x0000000, 0x1000000, CRC(eb4b96d0) SHA1(e909ea5b71b81087da07821c4f57244576363678) ) |
| 1013 | ROM_LOAD16_WORD_SWAP( "ua2011-alh02.u4", 0x1000000, 0x1000000, CRC(b8e35ddf) SHA1(7c3e59f6520dc3f0aa592e682fa82e30ffd1f4d0) ) |
| 1014 | 1014 | |
| 1015 | 1015 | ROM_REGION32_BE( 0x800000, "user3", 0 ) |
| 1016 | | ROM_LOAD16_WORD_SWAP( "nus-nsij-0.u1", 0x000000, 0x800000, CRC(94cf9f8d) SHA1(cd624d1f5de2be3bec3ece06556a2e39bef66d77) ) |
| 1016 | ROM_LOAD16_WORD_SWAP( "nus-nsij-0.u1", 0x000000, 0x800000, CRC(94cf9f8d) SHA1(cd624d1f5de2be3bec3ece06556a2e39bef66d77) ) |
| 1017 | 1017 | |
| 1018 | 1018 | ROM_REGION16_BE( 0x80, "normpoint", 0 ) |
| 1019 | 1019 | ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) ) |
| r242698 | r242699 | |
| 1028 | 1028 | PIF_BOOTROM |
| 1029 | 1029 | |
| 1030 | 1030 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 1031 | | ROM_LOAD16_WORD_SWAP( "ua3088-all01.u3", 0x0000000, 0x1000000, CRC(00db4dbc) SHA1(824fdce01fffdfcbcc9b1fbda4ab389a10b2b418) ) |
| 1032 | | ROM_LOAD16_WORD_SWAP( "ua3088-alh04.u4", 0x1000000, 0x1000000, CRC(c96bc7c0) SHA1(2b6ca1a769dee74e112c2b287dacd0bf46dda091) ) |
| 1031 | ROM_LOAD16_WORD_SWAP( "ua3088-all01.u3", 0x0000000, 0x1000000, CRC(00db4dbc) SHA1(824fdce01fffdfcbcc9b1fbda4ab389a10b2b418) ) |
| 1032 | ROM_LOAD16_WORD_SWAP( "ua3088-alh04.u4", 0x1000000, 0x1000000, CRC(c96bc7c0) SHA1(2b6ca1a769dee74e112c2b287dacd0bf46dda091) ) |
| 1033 | 1033 | |
| 1034 | 1034 | ROM_REGION32_BE( 0x800000, "user3", 0 ) |
| 1035 | | ROM_LOAD16_WORD_SWAP( "nus-zsij-0.u1", 0x000000, 0x800000, CRC(2389576f) SHA1(dc22b2eab4d7a02cb918827a62e6c120b3a84e6c) ) // same as tower & shaft |
| 1035 | ROM_LOAD16_WORD_SWAP( "nus-zsij-0.u1", 0x000000, 0x800000, CRC(2389576f) SHA1(dc22b2eab4d7a02cb918827a62e6c120b3a84e6c) ) // same as tower & shaft |
| 1036 | 1036 | |
| 1037 | 1037 | ROM_REGION16_BE( 0x80, "normpoint", 0 ) |
| 1038 | 1038 | ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) ) |
| r242698 | r242699 | |
| 1046 | 1046 | PIF_BOOTROM |
| 1047 | 1047 | |
| 1048 | 1048 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 1049 | | ROM_LOAD16_WORD_SWAP( "ua3003-all01.u3", 0x0000000, 0x1000000, CRC(f362fa82) SHA1(4f41ee23edc18110be1218ba333d1c58376ab175) ) |
| 1050 | | ROM_LOAD16_WORD_SWAP( "ua3003-alh01.u4", 0x1000000, 0x1000000, CRC(47c56387) SHA1(c8cc6c0a456b593aef711d0a75b2342ba2f8203f) ) |
| 1049 | ROM_LOAD16_WORD_SWAP( "ua3003-all01.u3", 0x0000000, 0x1000000, CRC(f362fa82) SHA1(4f41ee23edc18110be1218ba333d1c58376ab175) ) |
| 1050 | ROM_LOAD16_WORD_SWAP( "ua3003-alh01.u4", 0x1000000, 0x1000000, CRC(47c56387) SHA1(c8cc6c0a456b593aef711d0a75b2342ba2f8203f) ) |
| 1051 | 1051 | |
| 1052 | 1052 | ROM_REGION32_BE( 0x800000, "user3", 0 ) |
| 1053 | 1053 | ROM_LOAD16_WORD_SWAP( "nus-zsij-0.u1", 0x000000, 0x800000, CRC(547d8122) SHA1(347f0785767265acb0f0c21646e06cbe6f561821) ) |
| r242698 | r242699 | |
| 1065 | 1065 | PIF_BOOTROM |
| 1066 | 1066 | |
| 1067 | 1067 | ROM_REGION32_BE( 0x4000000, "user2", 0 ) |
| 1068 | | ROM_LOAD16_WORD_SWAP( "nus-zscj.u3", 0x000000, 0x800000, CRC(8b36eb91) SHA1(179745625c16c6813d5f8d29bfd7628783d55806) ) |
| 1068 | ROM_LOAD16_WORD_SWAP( "nus-zscj.u3", 0x000000, 0x800000, CRC(8b36eb91) SHA1(179745625c16c6813d5f8d29bfd7628783d55806) ) |
| 1069 | 1069 | |
| 1070 | 1070 | ROM_REGION16_BE( 0x80, "normpoint", 0 ) |
| 1071 | 1071 | ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) ) |
| r242698 | r242699 | |
| 1079 | 1079 | |
| 1080 | 1080 | |
| 1081 | 1081 | // BIOS |
| 1082 | | GAME( 1998, aleck64, 0, aleck64, aleck64, aleck64_state, aleck64, ROT0, "Nintendo / Seta", "Aleck64 PIF BIOS", GAME_IS_BIOS_ROOT) |
| 1082 | GAME( 1998, aleck64, 0, aleck64, aleck64, aleck64_state, aleck64, ROT0, "Nintendo / Seta", "Aleck64 PIF BIOS", GAME_IS_BIOS_ROOT) |
| 1083 | 1083 | |
| 1084 | 1084 | // games |
| 1085 | 1085 | GAME( 1998, 11beat, aleck64, aleck64, 11beat, aleck64_state, aleck64, ROT0, "Hudson", "Eleven Beat", GAME_NOT_WORKING|GAME_NO_SOUND ) |
trunk/src/osd/sdl/draw13.c
| r242698 | r242699 | |
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | //============================================================ |
| 46 | | // Inline functions |
| 46 | // MACROS |
| 47 | 47 | //============================================================ |
| 48 | 48 | |
| 49 | | static inline bool is_opaque(const float &a) |
| 50 | | { |
| 51 | | return (a >= 1.0f); |
| 52 | | } |
| 49 | #define IS_OPAQUE(a) (a >= 1.0f) |
| 50 | #define IS_TRANSPARENT(a) (a < 0.0001f) |
| 53 | 51 | |
| 54 | | static inline bool is_transparent(const float &a) |
| 55 | | { |
| 56 | | return (a < 0.0001f); |
| 57 | | } |
| 52 | #define MAX4(a, b, c, d) MAX(a, MAX(b, MAX(c, d))) |
| 53 | #define MIN4(a, b, c, d) MIN(a, MIN(b, MIN(c, d))) |
| 58 | 54 | |
| 55 | |
| 59 | 56 | //============================================================ |
| 60 | 57 | // TYPES |
| 61 | 58 | //============================================================ |
| r242698 | r242699 | |
| 67 | 64 | : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0), |
| 68 | 65 | rotwidth(0), rotheight(0) |
| 69 | 66 | {} |
| 70 | | void compute(const render_primitive &prim); |
| 71 | | |
| 72 | 67 | INT32 dudx, dvdx, dudy, dvdy; |
| 73 | 68 | INT32 startu, startv; |
| 74 | 69 | INT32 rotwidth, rotheight; |
| 75 | 70 | }; |
| 76 | 71 | |
| 77 | | class texture_info; |
| 72 | struct texture_info; |
| 78 | 73 | |
| 79 | | typedef void (*texture_copy_func)(const texture_info *texture, const render_texinfo *texsource); |
| 74 | typedef void (*texture_copy_func)(texture_info *texture, const render_texinfo *texsource); |
| 80 | 75 | |
| 81 | | struct copy_info_t { |
| 76 | struct copy_info { |
| 82 | 77 | int src_fmt; |
| 83 | 78 | Uint32 dst_fmt; |
| 84 | 79 | int dst_bpp; |
| r242698 | r242699 | |
| 93 | 88 | int samples; |
| 94 | 89 | int perf; |
| 95 | 90 | /* list */ |
| 96 | | copy_info_t *next; |
| 91 | copy_info *next; |
| 97 | 92 | }; |
| 98 | 93 | |
| 99 | | //============================================================ |
| 100 | | // Textures |
| 101 | | //============================================================ |
| 102 | | |
| 103 | | struct sdl_info; |
| 104 | | |
| 105 | 94 | /* texture_info holds information about a texture */ |
| 106 | | class texture_info |
| 95 | struct texture_info |
| 107 | 96 | { |
| 108 | | friend class simple_list<texture_info>; |
| 109 | | public: |
| 110 | | texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags); |
| 111 | | ~texture_info(); |
| 97 | texture_info() |
| 98 | : next(NULL), hash(0), flags(0), rawwidth(0), rawheight(0), format(0), |
| 99 | pixels(NULL), pitch(0), pixels_own(0), texture_id(NULL), copyinfo(NULL), |
| 100 | sdl_access(0), sdl_blendmode(SDL_BLENDMODE_NONE), is_rotated(0), last_access(0) |
| 101 | { |
| 102 | } |
| 103 | texture_info * next; // next texture in the list |
| 112 | 104 | |
| 113 | | void set_data(const render_texinfo &texsource, const UINT32 flags); |
| 114 | | void render_quad(const render_primitive *prim, const int x, const int y); |
| 115 | | bool matches(const render_primitive &prim, const quad_setup_data &setup); |
| 105 | HashT hash; // hash value for the texture (must be >= pointer size) |
| 106 | UINT32 flags; // rendering flags |
| 107 | render_texinfo texinfo; // copy of the texture info |
| 116 | 108 | |
| 117 | | copy_info_t *compute_size_type(); |
| 109 | int rawwidth, rawheight;// raw width/height of the texture |
| 118 | 110 | |
| 119 | | void *m_pixels; // pixels for the texture |
| 120 | | int m_pitch; |
| 111 | int format; // texture format |
| 112 | void *pixels; // pixels for the texture |
| 113 | int pitch; |
| 114 | int pixels_own; // do we own / allocated it ? |
| 121 | 115 | |
| 122 | | copy_info_t *m_copyinfo; |
| 123 | | quad_setup_data m_setup; |
| 116 | SDL_Texture *texture_id; |
| 124 | 117 | |
| 125 | | osd_ticks_t m_last_access; |
| 118 | copy_info *copyinfo; |
| 119 | Uint32 sdl_access; |
| 120 | SDL_BlendMode sdl_blendmode; |
| 121 | quad_setup_data setup; |
| 122 | int is_rotated; |
| 126 | 123 | |
| 127 | | int raw_width() const { return m_texinfo.width; } |
| 128 | | int raw_height() const { return m_texinfo.height; } |
| 129 | | |
| 130 | | texture_info *next() { return m_next; } |
| 131 | | const render_texinfo &texinfo() const { return m_texinfo; } |
| 132 | | render_texinfo &texinfo() { return m_texinfo; } |
| 133 | | |
| 134 | | const HashT hash() const { return m_hash; } |
| 135 | | const UINT32 flags() const { return m_flags; } |
| 136 | | const bool is_pixels_owned() const { // do we own / allocated it ? |
| 137 | | return m_sdl_access == SDL_TEXTUREACCESS_STATIC |
| 138 | | && m_copyinfo->func != NULL ; |
| 139 | | } |
| 140 | | |
| 141 | | private: |
| 142 | | SDL_Renderer * m_renderer; |
| 143 | | render_texinfo m_texinfo; // copy of the texture info |
| 144 | | HashT m_hash; // hash value for the texture (must be >= pointer size) |
| 145 | | UINT32 m_flags; // rendering flags |
| 146 | | |
| 147 | | SDL_Texture * m_texture_id; |
| 148 | | int m_is_rotated; |
| 149 | | |
| 150 | | int m_format; // texture format |
| 151 | | SDL_BlendMode m_sdl_blendmode; |
| 152 | | Uint32 m_sdl_access; |
| 153 | | |
| 154 | | texture_info * m_next; // next texture in the list |
| 124 | osd_ticks_t last_access; |
| 155 | 125 | }; |
| 156 | 126 | |
| 157 | 127 | /* sdl_info is the information about SDL for the current screen */ |
| 158 | 128 | struct sdl_info |
| 159 | 129 | { |
| 160 | 130 | sdl_info() |
| 161 | | : m_blittimer(0), m_renderer(NULL), |
| 162 | | m_hofs(0), m_vofs(0), |
| 163 | | m_resize_pending(0), m_resize_width(0), m_resize_height(0), |
| 164 | | m_last_blit_time(0), m_last_blit_pixels(0) |
| 131 | : blittimer(0), extra_flags(0), sdl_renderer(NULL), texlist(NULL), |
| 132 | texture_max_width(0), texture_max_height(0), last_hofs(0), last_vofs(0), |
| 133 | resize_pending(0), resize_width(0), resize_height(0), |
| 134 | last_blit_time(0), last_blit_pixels(0) |
| 165 | 135 | {} |
| 136 | INT32 blittimer; |
| 137 | UINT32 extra_flags; |
| 166 | 138 | |
| 167 | | void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y); |
| 139 | SDL_Renderer *sdl_renderer; |
| 140 | texture_info * texlist; // list of active textures |
| 141 | INT32 texture_max_width; // texture maximum width |
| 142 | INT32 texture_max_height; // texture maximum height |
| 168 | 143 | |
| 169 | | texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup); |
| 170 | | texture_info *texture_update(const render_primitive &prim); |
| 144 | float last_hofs; |
| 145 | float last_vofs; |
| 171 | 146 | |
| 172 | | INT32 m_blittimer; |
| 173 | | |
| 174 | | SDL_Renderer * m_renderer; |
| 175 | | simple_list<texture_info> m_texlist; // list of active textures |
| 176 | | |
| 177 | | float m_hofs; |
| 178 | | float m_vofs; |
| 179 | | |
| 180 | 147 | // resize information |
| 181 | 148 | |
| 182 | | UINT8 m_resize_pending; |
| 183 | | UINT32 m_resize_width; |
| 184 | | UINT32 m_resize_height; |
| 149 | UINT8 resize_pending; |
| 150 | UINT32 resize_width; |
| 151 | UINT32 resize_height; |
| 185 | 152 | |
| 186 | 153 | // Stats |
| 187 | | INT64 m_last_blit_time; |
| 188 | | INT64 m_last_blit_pixels; |
| 154 | INT64 last_blit_time; |
| 155 | INT64 last_blit_pixels; |
| 189 | 156 | }; |
| 190 | 157 | |
| 191 | 158 | //============================================================ |
| r242698 | r242699 | |
| 200 | 167 | static void drawsdl2_window_resize(sdl_window_info *window, int width, int height); |
| 201 | 168 | static void drawsdl2_window_destroy(sdl_window_info *window); |
| 202 | 169 | static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update); |
| 203 | | static void drawsdl2_set_target_bounds(sdl_window_info *window); |
| 170 | static render_primitive_list &drawsdl2_window_get_primitives(sdl_window_info *window); |
| 204 | 171 | static void drawsdl2_destroy_all_textures(sdl_window_info *window); |
| 205 | 172 | static void drawsdl2_window_clear(sdl_window_info *window); |
| 206 | 173 | static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt); |
| 174 | static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture); |
| 207 | 175 | |
| 208 | 176 | //============================================================ |
| 177 | // Textures |
| 178 | //============================================================ |
| 179 | |
| 180 | static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_texinfo *texsource, UINT32 flags); |
| 181 | static texture_info *texture_create(sdl_window_info *window, const render_texinfo *texsource, quad_setup_data *setup, UINT32 flags); |
| 182 | static texture_info *texture_find(sdl_info *sdl, const render_primitive *prim, quad_setup_data *setup); |
| 183 | static texture_info * texture_update(sdl_window_info *window, const render_primitive *prim); |
| 184 | |
| 185 | |
| 186 | //============================================================ |
| 209 | 187 | // TEXCOPY FUNCS |
| 210 | 188 | //============================================================ |
| 211 | 189 | |
| r242698 | r242699 | |
| 224 | 202 | #define ENTRY_BM(a,b,c,d,f,bm) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, bm, #a, #b, 0, 0, 0, 0} |
| 225 | 203 | #define ENTRY_LR(a,b,c,d,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, -1} |
| 226 | 204 | |
| 227 | | static copy_info_t blit_info_default[] = |
| 205 | static copy_info blit_info_default[] = |
| 228 | 206 | { |
| 229 | 207 | /* no rotation */ |
| 230 | 208 | ENTRY(ARGB32, ARGB8888, 4, 0, NULL), |
| 231 | 209 | ENTRY_LR(ARGB32, RGB888, 4, 0, argb32_rgb32), |
| 232 | | /* Entry primarily for directfb */ |
| 210 | /* Entry for primarily for directfb */ |
| 233 | 211 | ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_ADD), |
| 234 | 212 | ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_MOD), |
| 235 | 213 | ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_NONE), |
| r242698 | r242699 | |
| 269 | 247 | /* rotation */ |
| 270 | 248 | ENTRY(ARGB32, ARGB8888, 4, 1, rot_argb32_argb32), |
| 271 | 249 | ENTRY_LR(ARGB32, RGB888, 4, 1, rot_argb32_rgb32), |
| 272 | | /* Entry primarily for directfb */ |
| 250 | /* Entry for primarily for directfb */ |
| 273 | 251 | ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_ADD), |
| 274 | 252 | ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_MOD), |
| 275 | 253 | ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_NONE), |
| r242698 | r242699 | |
| 303 | 281 | { -1 }, |
| 304 | 282 | }; |
| 305 | 283 | |
| 306 | | static copy_info_t *blit_info[SDL_TEXFORMAT_LAST+1]; |
| 284 | static copy_info *blit_info[SDL_TEXFORMAT_LAST+1]; |
| 307 | 285 | |
| 308 | 286 | static struct |
| 309 | 287 | { |
| r242698 | r242699 | |
| 322 | 300 | return floor(f + 0.5f); |
| 323 | 301 | } |
| 324 | 302 | |
| 325 | | INLINE HashT texture_compute_hash(const render_texinfo &texture, const UINT32 flags) |
| 303 | INLINE HashT texture_compute_hash(const render_texinfo *texture, UINT32 flags) |
| 326 | 304 | { |
| 327 | | return (HashT)texture.base ^ (flags & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)); |
| 305 | return (HashT)texture->base ^ (flags & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)); |
| 328 | 306 | } |
| 329 | 307 | |
| 330 | | INLINE SDL_BlendMode map_blendmode(const int blendmode) |
| 308 | INLINE SDL_BlendMode map_blendmode(int blendmode) |
| 331 | 309 | { |
| 332 | 310 | switch (blendmode) |
| 333 | 311 | { |
| r242698 | r242699 | |
| 353 | 331 | UINT32 sa = (UINT32)(255.0f * color->a); |
| 354 | 332 | |
| 355 | 333 | |
| 356 | | if (color->r >= 1.0f && color->g >= 1.0f && color->b >= 1.0f && is_opaque(color->a)) |
| 334 | if (color->r >= 1.0f && color->g >= 1.0f && color->b >= 1.0f && IS_OPAQUE(color->a)) |
| 357 | 335 | { |
| 358 | 336 | SDL_SetTextureColorMod(texture_id, 0xFF, 0xFF, 0xFF); |
| 359 | 337 | SDL_SetTextureAlphaMod(texture_id, 0xFF); |
| 360 | 338 | } |
| 361 | 339 | /* coloring-only case */ |
| 362 | | else if (is_opaque(color->a)) |
| 340 | else if (IS_OPAQUE(color->a)) |
| 363 | 341 | { |
| 364 | 342 | SDL_SetTextureColorMod(texture_id, sr, sg, sb); |
| 365 | 343 | SDL_SetTextureAlphaMod(texture_id, 0xFF); |
| 366 | 344 | } |
| 367 | 345 | /* alpha and/or coloring case */ |
| 368 | | else if (!is_transparent(color->a)) |
| 346 | else if (!IS_TRANSPARENT(color->a)) |
| 369 | 347 | { |
| 370 | 348 | SDL_SetTextureColorMod(texture_id, sr, sg, sb); |
| 371 | 349 | SDL_SetTextureAlphaMod(texture_id, sa); |
| r242698 | r242699 | |
| 377 | 355 | } |
| 378 | 356 | } |
| 379 | 357 | |
| 380 | | void texture_info::render_quad(const render_primitive *prim, const int x, const int y) |
| 358 | INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive *prim, int x, int y) |
| 381 | 359 | { |
| 360 | SDL_Texture *texture_id; |
| 382 | 361 | SDL_Rect target_rect; |
| 383 | 362 | |
| 384 | 363 | target_rect.x = x; |
| r242698 | r242699 | |
| 386 | 365 | target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0); |
| 387 | 366 | target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0); |
| 388 | 367 | |
| 368 | if (texture) |
| 369 | { |
| 370 | texture_id = texture->texture_id; |
| 371 | |
| 372 | texture->copyinfo->time -= osd_ticks(); |
| 389 | 373 | #if 0 |
| 390 | | // no longer supported in SDL2 |
| 391 | | if ((PRIMFLAG_GET_SCREENTEX(prim->m_flags)) && video_config.filter) |
| 392 | | { |
| 393 | | SDL_SetTextureScaleMode(texture->m_texture_id, DRAW2_SCALEMODE_BEST); |
| 394 | | } |
| 395 | | else |
| 396 | | { |
| 397 | | SDL_SetTextureScaleMode(texture->m_texture_id, DRAW2_SCALEMODE_NEAREST); |
| 398 | | } |
| 374 | if ((PRIMFLAG_GET_SCREENTEX(prim->flags)) && video_config.filter) |
| 375 | { |
| 376 | SDL_SetTextureScaleMode(texture->texture_id, DRAW2_SCALEMODE_BEST); |
| 377 | } |
| 378 | else |
| 379 | { |
| 380 | SDL_SetTextureScaleMode(texture->texture_id, DRAW2_SCALEMODE_NEAREST); |
| 381 | } |
| 399 | 382 | #endif |
| 400 | | SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode); |
| 401 | | set_coloralphamode(m_texture_id, &prim->color); |
| 402 | | SDL_RenderCopy(m_renderer, m_texture_id, NULL, &target_rect); |
| 383 | SDL_SetTextureBlendMode(texture_id, texture->sdl_blendmode); |
| 384 | set_coloralphamode(texture_id, &prim->color); |
| 385 | SDL_RenderCopy(sdl->sdl_renderer, texture_id, NULL, &target_rect); |
| 386 | texture->copyinfo->time += osd_ticks(); |
| 387 | |
| 388 | texture->copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->rawwidth * texture->rawheight)); |
| 389 | if (sdl->last_blit_pixels) |
| 390 | { |
| 391 | texture->copyinfo->time += (sdl->last_blit_time * (INT64) (texture->rawwidth * texture->rawheight)) / (INT64) sdl->last_blit_pixels; |
| 392 | } |
| 393 | texture->copyinfo->samples++; |
| 394 | texture->copyinfo->perf = ( texture->copyinfo->pixel_count * (osd_ticks_per_second()/1000)) / texture->copyinfo->time; |
| 395 | } |
| 396 | else |
| 397 | { |
| 398 | UINT32 sr = (UINT32)(255.0f * prim->color.r); |
| 399 | UINT32 sg = (UINT32)(255.0f * prim->color.g); |
| 400 | UINT32 sb = (UINT32)(255.0f * prim->color.b); |
| 401 | UINT32 sa = (UINT32)(255.0f * prim->color.a); |
| 402 | |
| 403 | SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 404 | SDL_SetRenderDrawColor(sdl->sdl_renderer, sr, sg, sb, sa); |
| 405 | SDL_RenderFillRect(sdl->sdl_renderer, &target_rect); |
| 406 | } |
| 403 | 407 | } |
| 404 | 408 | |
| 405 | | void sdl_info::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y) |
| 409 | #if 0 |
| 410 | static int RendererSupportsFormat(Uint32 format, Uint32 access, const char *sformat) |
| 406 | 411 | { |
| 407 | | SDL_Rect target_rect; |
| 412 | struct SDL_RendererInfo render_info; |
| 413 | int i; |
| 408 | 414 | |
| 409 | | target_rect.x = x; |
| 410 | | target_rect.y = y; |
| 411 | | target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0); |
| 412 | | target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0); |
| 415 | SDL_GetRendererInfo(&render_info); |
| 413 | 416 | |
| 414 | | if (texture) |
| 415 | | { |
| 416 | | copy_info_t *copyinfo = texture->m_copyinfo; |
| 417 | | copyinfo->time -= osd_ticks(); |
| 418 | | texture->render_quad(prim, x, y); |
| 419 | | copyinfo->time += osd_ticks(); |
| 420 | | |
| 421 | | copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height())); |
| 422 | | if (m_last_blit_pixels) |
| 423 | | { |
| 424 | | copyinfo->time += (m_last_blit_time * (INT64) (texture->raw_width() * texture->raw_height())) / (INT64) m_last_blit_pixels; |
| 425 | | } |
| 426 | | copyinfo->samples++; |
| 427 | | copyinfo->perf = ( texture->m_copyinfo->pixel_count * (osd_ticks_per_second()/1000)) / texture->m_copyinfo->time; |
| 428 | | } |
| 429 | | else |
| 430 | | { |
| 431 | | UINT32 sr = (UINT32)(255.0f * prim->color.r); |
| 432 | | UINT32 sg = (UINT32)(255.0f * prim->color.g); |
| 433 | | UINT32 sb = (UINT32)(255.0f * prim->color.b); |
| 434 | | UINT32 sa = (UINT32)(255.0f * prim->color.a); |
| 435 | | |
| 436 | | SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 437 | | SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa); |
| 438 | | SDL_RenderFillRect(m_renderer, &target_rect); |
| 439 | | } |
| 417 | for (i=0; i < render_info.num_texture_formats; i++) |
| 418 | { |
| 419 | if (format == render_info.texture_formats[i]) |
| 420 | return 1; |
| 421 | } |
| 422 | osd_printf_verbose("Pixelformat <%s> not supported\n", sformat); |
| 423 | return 0; |
| 440 | 424 | } |
| 441 | | |
| 425 | #else |
| 442 | 426 | static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32 access, const char *sformat) |
| 443 | 427 | { |
| 444 | 428 | int i; |
| r242698 | r242699 | |
| 465 | 449 | fmt_support[i].status = 0; |
| 466 | 450 | return 0; |
| 467 | 451 | } |
| 452 | #endif |
| 468 | 453 | |
| 469 | 454 | //============================================================ |
| 470 | 455 | // drawsdl2_init |
| 471 | 456 | //============================================================ |
| 472 | 457 | |
| 473 | | static void add_list(copy_info_t **head, copy_info_t *element, Uint32 bm) |
| 458 | static void add_list(copy_info **head, copy_info *element, Uint32 bm) |
| 474 | 459 | { |
| 475 | | copy_info_t *newci = global_alloc(copy_info_t); |
| 460 | copy_info *newci = global_alloc(copy_info); |
| 476 | 461 | *newci = *element; |
| 477 | 462 | |
| 478 | 463 | newci->bm_mask = bm; |
| r242698 | r242699 | |
| 480 | 465 | *head = newci; |
| 481 | 466 | } |
| 482 | 467 | |
| 483 | | static void expand_copy_info(copy_info_t *list) |
| 468 | static void expand_copy_info(copy_info *list) |
| 484 | 469 | { |
| 485 | | copy_info_t *bi; |
| 470 | copy_info *bi; |
| 486 | 471 | |
| 487 | 472 | for (bi = list; bi->src_fmt != -1; bi++) |
| 488 | 473 | { |
| r242698 | r242699 | |
| 521 | 506 | |
| 522 | 507 | // No fatalerror here since not all video drivers support GL ! |
| 523 | 508 | if (SDL_GL_LoadLibrary(stemp) != 0) // Load library (default for e==NULL |
| 524 | | osd_printf_warning("Warning: Unable to load opengl library: %s\n", stemp ? stemp : "<default>"); |
| 509 | osd_printf_verbose("Warning: Unable to load opengl library: %s\n", stemp ? stemp : "<default>"); |
| 525 | 510 | else |
| 526 | 511 | osd_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>"); |
| 527 | 512 | |
| r242698 | r242699 | |
| 536 | 521 | static void drawsdl2_exit(void) |
| 537 | 522 | { |
| 538 | 523 | int i; |
| 539 | | copy_info_t *bi, *freeme; |
| 524 | copy_info *bi, *freeme; |
| 540 | 525 | for (i = 0; i <= SDL_TEXFORMAT_LAST; i++) |
| 541 | 526 | for (bi = blit_info[i]; bi != NULL; ) |
| 542 | 527 | { |
| r242698 | r242699 | |
| 559 | 544 | // fill in the callbacks |
| 560 | 545 | window->create = drawsdl2_window_create; |
| 561 | 546 | window->resize = drawsdl2_window_resize; |
| 562 | | window->set_target_bounds = drawsdl2_set_target_bounds; |
| 547 | window->get_primitives = drawsdl2_window_get_primitives; |
| 563 | 548 | window->draw = drawsdl2_window_draw; |
| 564 | 549 | window->destroy = drawsdl2_window_destroy; |
| 565 | 550 | window->destroy_all_textures = drawsdl2_destroy_all_textures; |
| r242698 | r242699 | |
| 580 | 565 | |
| 581 | 566 | window->dxdata = sdl; |
| 582 | 567 | |
| 583 | | UINT32 extra_flags = (window->fullscreen() ? |
| 568 | sdl->extra_flags = (window->fullscreen() ? |
| 584 | 569 | SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE); |
| 585 | 570 | |
| 586 | 571 | // create the SDL window |
| 587 | 572 | window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0, |
| 588 | | width, height, extra_flags); |
| 573 | width, height, sdl->extra_flags); |
| 589 | 574 | |
| 590 | 575 | if (window->fullscreen() && video_config.switchres) |
| 591 | 576 | { |
| r242698 | r242699 | |
| 623 | 608 | // create renderer |
| 624 | 609 | |
| 625 | 610 | if (video_config.waitvsync) |
| 626 | | sdl->m_renderer = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); |
| 611 | sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); |
| 627 | 612 | else |
| 628 | | sdl->m_renderer = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_ACCELERATED); |
| 613 | sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_ACCELERATED); |
| 629 | 614 | |
| 630 | | if (!sdl->m_renderer) |
| 615 | if (!sdl->sdl_renderer) |
| 631 | 616 | { |
| 632 | 617 | fatalerror("Error on creating renderer: %s\n", SDL_GetError()); |
| 633 | 618 | } |
| r242698 | r242699 | |
| 640 | 625 | SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); |
| 641 | 626 | |
| 642 | 627 | |
| 643 | | sdl->m_blittimer = 3; |
| 628 | sdl->blittimer = 3; |
| 644 | 629 | |
| 645 | | SDL_RenderPresent(sdl->m_renderer); |
| 630 | // in case any textures try to come up before these are validated, |
| 631 | // OpenGL guarantees all implementations can handle something this size. |
| 632 | sdl->texture_max_width = 64; |
| 633 | sdl->texture_max_height = 64; |
| 634 | |
| 635 | SDL_RenderPresent(sdl->sdl_renderer); |
| 646 | 636 | osd_printf_verbose("Leave drawsdl2_window_create\n"); |
| 647 | 637 | return 0; |
| 648 | 638 | } |
| r242698 | r242699 | |
| 655 | 645 | { |
| 656 | 646 | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 657 | 647 | |
| 658 | | sdl->m_resize_pending = 1; |
| 659 | | sdl->m_resize_height = height; |
| 660 | | sdl->m_resize_width = width; |
| 648 | sdl->resize_pending = 1; |
| 649 | sdl->resize_height = height; |
| 650 | sdl->resize_width = width; |
| 661 | 651 | |
| 662 | 652 | window->width = width; |
| 663 | 653 | window->height = height; |
| 664 | 654 | |
| 665 | | sdl->m_blittimer = 3; |
| 655 | sdl->blittimer = 3; |
| 666 | 656 | |
| 667 | 657 | } |
| 668 | 658 | |
| r242698 | r242699 | |
| 674 | 664 | { |
| 675 | 665 | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 676 | 666 | |
| 677 | | *xt = x - sdl->m_hofs; |
| 678 | | *yt = y - sdl->m_vofs; |
| 667 | *xt = x - sdl->last_hofs; |
| 668 | *yt = y - sdl->last_vofs; |
| 679 | 669 | if (*xt<0 || *xt >= window->blitwidth) |
| 680 | 670 | return 0; |
| 681 | 671 | if (*yt<0 || *yt >= window->blitheight) |
| r242698 | r242699 | |
| 687 | 677 | // drawsdl2_window_get_primitives |
| 688 | 678 | //============================================================ |
| 689 | 679 | |
| 690 | | static void drawsdl2_set_target_bounds(sdl_window_info *window) |
| 680 | static render_primitive_list &drawsdl2_window_get_primitives(sdl_window_info *window) |
| 691 | 681 | { |
| 682 | if ((!window->fullscreen()) || (video_config.switchres)) |
| 683 | { |
| 684 | window->blit_surface_size(window->width, window->height); |
| 685 | } |
| 686 | else |
| 687 | { |
| 688 | window->blit_surface_size(window->monitor()->center_width, window->monitor()->center_height); |
| 689 | } |
| 692 | 690 | window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor())); |
| 691 | return window->target->get_primitives(); |
| 693 | 692 | } |
| 694 | 693 | |
| 695 | 694 | //============================================================ |
| r242698 | r242699 | |
| 709 | 708 | return 0; |
| 710 | 709 | } |
| 711 | 710 | |
| 712 | | if (sdl->m_resize_pending) |
| 711 | if (sdl->resize_pending) |
| 713 | 712 | { |
| 714 | | SDL_SetWindowSize(window->sdl_window, sdl->m_resize_width, sdl->m_resize_height); |
| 713 | SDL_SetWindowSize(window->sdl_window, sdl->resize_width, sdl->resize_height); |
| 715 | 714 | SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); |
| 716 | | sdl->m_resize_pending = 0; |
| 717 | | SDL_RenderSetViewport(sdl->m_renderer, NULL); |
| 715 | sdl->resize_pending = 0; |
| 716 | SDL_RenderSetViewport(sdl->sdl_renderer, NULL); |
| 718 | 717 | } |
| 719 | 718 | |
| 720 | 719 | //SDL_SelectRenderer(window->sdl_window); |
| 721 | 720 | |
| 722 | | if (sdl->m_blittimer > 0) |
| 721 | if (sdl->blittimer > 0) |
| 723 | 722 | { |
| 724 | 723 | /* SDL Underlays need alpha = 0 ! */ |
| 725 | | SDL_SetRenderDrawBlendMode(sdl->m_renderer, SDL_BLENDMODE_NONE); |
| 724 | SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, SDL_BLENDMODE_NONE); |
| 726 | 725 | //SDL_SetRenderDrawColor(0,0,0,255); |
| 727 | | SDL_SetRenderDrawColor(sdl->m_renderer, 0,0,0,0); |
| 728 | | SDL_RenderFillRect(sdl->m_renderer, NULL); |
| 729 | | sdl->m_blittimer--; |
| 726 | SDL_SetRenderDrawColor(sdl->sdl_renderer, 0,0,0,0); |
| 727 | SDL_RenderFillRect(sdl->sdl_renderer, NULL); |
| 728 | sdl->blittimer--; |
| 730 | 729 | } |
| 731 | 730 | |
| 732 | 731 | // compute centering parameters |
| r242698 | r242699 | |
| 757 | 756 | } |
| 758 | 757 | } |
| 759 | 758 | |
| 760 | | sdl->m_hofs = hofs; |
| 761 | | sdl->m_vofs = vofs; |
| 759 | sdl->last_hofs = hofs; |
| 760 | sdl->last_vofs = vofs; |
| 762 | 761 | |
| 763 | 762 | window->primlist->acquire_lock(); |
| 764 | 763 | |
| r242698 | r242699 | |
| 775 | 774 | sb = (int)(255.0f * prim->color.b); |
| 776 | 775 | sa = (int)(255.0f * prim->color.a); |
| 777 | 776 | |
| 778 | | SDL_SetRenderDrawBlendMode(sdl->m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 779 | | SDL_SetRenderDrawColor(sdl->m_renderer, sr, sg, sb, sa); |
| 780 | | SDL_RenderDrawLine(sdl->m_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs, |
| 777 | SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); |
| 778 | SDL_SetRenderDrawColor(sdl->sdl_renderer, sr, sg, sb, sa); |
| 779 | SDL_RenderDrawLine(sdl->sdl_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs, |
| 781 | 780 | prim->bounds.x1 + hofs, prim->bounds.y1 + vofs); |
| 782 | 781 | break; |
| 783 | 782 | case render_primitive::QUAD: |
| 784 | | texture = sdl->texture_update(*prim); |
| 783 | texture = texture_update(window, prim); |
| 785 | 784 | if (texture) |
| 786 | | blit_pixels += (texture->raw_height() * texture->raw_width()); |
| 787 | | sdl->render_quad(texture, prim, |
| 785 | blit_pixels += (texture->rawheight * texture->rawwidth); |
| 786 | render_quad(sdl, texture, prim, |
| 788 | 787 | round_nearest(hofs + prim->bounds.x0), |
| 789 | 788 | round_nearest(vofs + prim->bounds.y0)); |
| 790 | 789 | break; |
| r242698 | r242699 | |
| 795 | 794 | |
| 796 | 795 | window->primlist->release_lock(); |
| 797 | 796 | |
| 798 | | sdl->m_last_blit_pixels = blit_pixels; |
| 799 | | sdl->m_last_blit_time = -osd_ticks(); |
| 800 | | SDL_RenderPresent(sdl->m_renderer); |
| 801 | | sdl->m_last_blit_time += osd_ticks(); |
| 797 | sdl->last_blit_pixels = blit_pixels; |
| 798 | sdl->last_blit_time = -osd_ticks(); |
| 799 | SDL_RenderPresent(sdl->sdl_renderer); |
| 800 | sdl->last_blit_time += osd_ticks(); |
| 802 | 801 | |
| 803 | 802 | return 0; |
| 804 | 803 | } |
| r242698 | r242699 | |
| 812 | 811 | { |
| 813 | 812 | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 814 | 813 | |
| 815 | | sdl->m_blittimer = 2; |
| 814 | sdl->blittimer = 2; |
| 816 | 815 | } |
| 817 | 816 | |
| 818 | 817 | |
| r242698 | r242699 | |
| 846 | 845 | // texture_compute_size and type |
| 847 | 846 | //============================================================ |
| 848 | 847 | |
| 849 | | copy_info_t *texture_info::compute_size_type() |
| 848 | static copy_info *texture_compute_size_type(SDL_Renderer *renderer, const render_texinfo *texsource, texture_info *texture, UINT32 flags) |
| 850 | 849 | { |
| 851 | | copy_info_t *bi; |
| 852 | | copy_info_t *result = NULL; |
| 850 | copy_info *bi; |
| 851 | copy_info *result = NULL; |
| 853 | 852 | int maxperf = 0; |
| 853 | //int bm = PRIMFLAG_GET_BLENDMODE(flags); |
| 854 | 854 | |
| 855 | | for (bi = blit_info[m_format]; bi != NULL; bi = bi->next) |
| 855 | for (bi = blit_info[texture->format]; bi != NULL; bi = bi->next) |
| 856 | 856 | { |
| 857 | | if ((m_is_rotated == bi->rotate) |
| 858 | | && (m_sdl_blendmode == bi->bm_mask)) |
| 857 | if ((texture->is_rotated == bi->rotate) |
| 858 | && (texture->sdl_blendmode == bi->bm_mask)) |
| 859 | 859 | { |
| 860 | | if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 860 | if (RendererSupportsFormat(renderer, bi->dst_fmt, texture->sdl_access, bi->dstname)) |
| 861 | 861 | { |
| 862 | | int perf = bi->perf; |
| 863 | | if (perf == 0) |
| 862 | if (bi->perf == 0) |
| 864 | 863 | return bi; |
| 865 | | else if (perf > (maxperf * 102) / 100) |
| 864 | else if (bi->perf > (maxperf * 102) / 100) |
| 866 | 865 | { |
| 867 | 866 | result = bi; |
| 868 | | maxperf = perf; |
| 867 | maxperf = bi->perf; |
| 869 | 868 | } |
| 870 | 869 | } |
| 871 | 870 | } |
| r242698 | r242699 | |
| 873 | 872 | if (result) |
| 874 | 873 | return result; |
| 875 | 874 | /* try last resort handlers */ |
| 876 | | for (bi = blit_info[m_format]; bi != NULL; bi = bi->next) |
| 875 | for (bi = blit_info[texture->format]; bi != NULL; bi = bi->next) |
| 877 | 876 | { |
| 878 | | if ((m_is_rotated == bi->rotate) |
| 879 | | && (m_sdl_blendmode == bi->bm_mask)) |
| 880 | | if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 877 | if ((texture->is_rotated == bi->rotate) |
| 878 | && (texture->sdl_blendmode == bi->bm_mask)) |
| 879 | if (RendererSupportsFormat(renderer, bi->dst_fmt, texture->sdl_access, bi->dstname)) |
| 881 | 880 | return bi; |
| 882 | 881 | } |
| 883 | 882 | //FIXME: crash implement a -do nothing handler */ |
| r242698 | r242699 | |
| 885 | 884 | } |
| 886 | 885 | |
| 887 | 886 | //============================================================ |
| 888 | | // texture_info::matches |
| 887 | // texture_create |
| 889 | 888 | //============================================================ |
| 890 | 889 | |
| 891 | | bool texture_info::matches(const render_primitive &prim, const quad_setup_data &setup) |
| 890 | static texture_info *texture_create(sdl_window_info *window, const render_texinfo *texsource, quad_setup_data *setup, UINT32 flags) |
| 892 | 891 | { |
| 893 | | return texinfo().base == prim.texture.base && |
| 894 | | texinfo().width == prim.texture.width && |
| 895 | | texinfo().height == prim.texture.height && |
| 896 | | texinfo().rowpixels == prim.texture.rowpixels && |
| 897 | | m_setup.dudx == setup.dudx && |
| 898 | | m_setup.dvdx == setup.dvdx && |
| 899 | | m_setup.dudy == setup.dudy && |
| 900 | | m_setup.dvdy == setup.dvdy && |
| 901 | | ((flags() ^ prim.flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0; |
| 902 | | } |
| 892 | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 893 | texture_info *texture; |
| 903 | 894 | |
| 904 | | //============================================================ |
| 905 | | // texture_create |
| 906 | | //============================================================ |
| 895 | // allocate a new texture |
| 896 | texture = global_alloc(texture_info); |
| 907 | 897 | |
| 908 | | texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags) |
| 909 | | { |
| 910 | | |
| 911 | 898 | // fill in the core data |
| 912 | | m_renderer = renderer; |
| 913 | | m_hash = texture_compute_hash(texsource, flags); |
| 914 | | m_flags = flags; |
| 915 | | m_texinfo = texsource; |
| 916 | | m_texinfo.seqid = -1; // force set data |
| 917 | | m_is_rotated = FALSE; |
| 918 | | m_setup = setup; |
| 919 | | m_sdl_blendmode = map_blendmode(PRIMFLAG_GET_BLENDMODE(flags)); |
| 920 | | m_pitch = 0; |
| 899 | texture->hash = texture_compute_hash(texsource, flags); |
| 900 | texture->flags = flags; |
| 901 | texture->texinfo = *texsource; |
| 902 | texture->texinfo.seqid = -1; // force set data |
| 903 | texture->is_rotated = FALSE; |
| 904 | texture->setup = *setup; |
| 905 | texture->sdl_blendmode = map_blendmode(PRIMFLAG_GET_BLENDMODE(flags)); |
| 921 | 906 | |
| 922 | 907 | switch (PRIMFLAG_GET_TEXFORMAT(flags)) |
| 923 | 908 | { |
| 924 | 909 | case TEXFORMAT_ARGB32: |
| 925 | | m_format = SDL_TEXFORMAT_ARGB32; |
| 910 | texture->format = SDL_TEXFORMAT_ARGB32; |
| 926 | 911 | break; |
| 927 | 912 | case TEXFORMAT_RGB32: |
| 928 | | m_format = texsource.palette() ? SDL_TEXFORMAT_RGB32_PALETTED : SDL_TEXFORMAT_RGB32; |
| 913 | texture->format = texsource->palette() ? SDL_TEXFORMAT_RGB32_PALETTED : SDL_TEXFORMAT_RGB32; |
| 929 | 914 | break; |
| 930 | 915 | case TEXFORMAT_PALETTE16: |
| 931 | | m_format = SDL_TEXFORMAT_PALETTE16; |
| 916 | texture->format = SDL_TEXFORMAT_PALETTE16; |
| 932 | 917 | break; |
| 933 | 918 | case TEXFORMAT_PALETTEA16: |
| 934 | | m_format = SDL_TEXFORMAT_PALETTE16A; |
| 919 | texture->format = SDL_TEXFORMAT_PALETTE16A; |
| 935 | 920 | break; |
| 936 | 921 | case TEXFORMAT_YUY16: |
| 937 | | m_format = texsource.palette() ? SDL_TEXFORMAT_YUY16_PALETTED : SDL_TEXFORMAT_YUY16; |
| 922 | texture->format = texsource->palette() ? SDL_TEXFORMAT_YUY16_PALETTED : SDL_TEXFORMAT_YUY16; |
| 938 | 923 | break; |
| 939 | 924 | |
| 940 | 925 | default: |
| 941 | 926 | osd_printf_error("Unknown textureformat %d\n", PRIMFLAG_GET_TEXFORMAT(flags)); |
| 942 | 927 | } |
| 943 | 928 | |
| 944 | | if (setup.rotwidth != m_texinfo.width || setup.rotheight != m_texinfo.height |
| 945 | | || setup.dudx < 0 || setup.dvdy < 0) |
| 946 | | m_is_rotated = TRUE; |
| 929 | texture->rawwidth = texsource->width; |
| 930 | texture->rawheight = texsource->height; |
| 931 | if (setup->rotwidth != texture->rawwidth || setup->rotheight != texture->rawheight |
| 932 | || setup->dudx < 0 ) |
| 933 | texture->is_rotated = TRUE; |
| 947 | 934 | else |
| 948 | | m_is_rotated = FALSE; |
| 935 | texture->is_rotated = FALSE; |
| 949 | 936 | |
| 950 | | //m_sdl_access = SDL_TEXTUREACCESS_STATIC; |
| 951 | | m_sdl_access = SDL_TEXTUREACCESS_STREAMING; |
| 937 | //texture->sdl_access = SDL_TEXTUREACCESS_STATIC; |
| 938 | texture->sdl_access = SDL_TEXTUREACCESS_STREAMING; |
| 952 | 939 | |
| 953 | 940 | // Watch out for 0x0 textures ... |
| 954 | | if (!m_setup.rotwidth || !m_setup.rotheight) |
| 941 | if (!texture->setup.rotwidth || !texture->setup.rotheight) |
| 955 | 942 | osd_printf_warning("Trying to create texture with zero dim\n"); |
| 956 | 943 | |
| 957 | | // set copy_info |
| 944 | // compute the size |
| 945 | texture->copyinfo = texture_compute_size_type(sdl->sdl_renderer, texsource, texture, flags); |
| 958 | 946 | |
| 959 | | m_copyinfo = compute_size_type(); |
| 947 | texture->texture_id = SDL_CreateTexture(sdl->sdl_renderer, texture->copyinfo->dst_fmt, texture->sdl_access, |
| 948 | texture->setup.rotwidth, texture->setup.rotheight); |
| 960 | 949 | |
| 961 | | m_texture_id = SDL_CreateTexture(m_renderer, m_copyinfo->dst_fmt, m_sdl_access, |
| 962 | | m_setup.rotwidth, m_setup.rotheight); |
| 950 | if (!texture->texture_id) |
| 951 | osd_printf_error("Error creating texture: %d x %d, pixelformat %s error: %s\n", texture->setup.rotwidth, texture->setup.rotheight, |
| 952 | texture->copyinfo->dstname, SDL_GetError()); |
| 963 | 953 | |
| 964 | | if (!m_texture_id) |
| 965 | | osd_printf_error("Error creating texture: %d x %d, pixelformat %s error: %s\n", m_setup.rotwidth, m_setup.rotheight, |
| 966 | | m_copyinfo->dstname, SDL_GetError()); |
| 967 | | |
| 968 | | if (m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 954 | if ( (texture->copyinfo->func != NULL) && (texture->sdl_access == SDL_TEXTUREACCESS_STATIC)) |
| 969 | 955 | { |
| 970 | | if (m_copyinfo->func != NULL) |
| 971 | | m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp); |
| 972 | | else |
| 973 | | m_pixels = NULL; |
| 956 | texture->pixels = malloc(texture->setup.rotwidth * texture->setup.rotheight * texture->copyinfo->dst_bpp); |
| 957 | texture->pixels_own=TRUE; |
| 974 | 958 | } |
| 975 | | m_last_access = osd_ticks(); |
| 959 | /* add us to the texture list */ |
| 960 | texture->next = sdl->texlist; |
| 961 | sdl->texlist = texture; |
| 976 | 962 | |
| 977 | | } |
| 963 | texture->last_access = osd_ticks(); |
| 978 | 964 | |
| 979 | | texture_info::~texture_info() |
| 980 | | { |
| 981 | | SDL_DestroyTexture(m_texture_id); |
| 982 | | if ( is_pixels_owned() && m_pixels != NULL ) |
| 983 | | free(m_pixels); |
| 965 | return texture; |
| 984 | 966 | } |
| 985 | 967 | |
| 986 | 968 | //============================================================ |
| 987 | 969 | // texture_set_data |
| 988 | 970 | //============================================================ |
| 989 | 971 | |
| 990 | | void texture_info::set_data(const render_texinfo &texsource, const UINT32 flags) |
| 972 | static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_texinfo *texsource, UINT32 flags) |
| 991 | 973 | { |
| 992 | | m_copyinfo->time -= osd_ticks(); |
| 993 | | if (m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 974 | texture->copyinfo->time -= osd_ticks(); |
| 975 | if (texture->sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 994 | 976 | { |
| 995 | | if ( m_copyinfo->func ) |
| 977 | if ( texture->copyinfo->func ) |
| 996 | 978 | { |
| 997 | | m_pitch = m_setup.rotwidth * m_copyinfo->dst_bpp; |
| 998 | | m_copyinfo->func(this, &texsource); |
| 979 | texture->pitch = texture->setup.rotwidth * texture->copyinfo->dst_bpp; |
| 980 | texture->copyinfo->func(texture, texsource); |
| 999 | 981 | } |
| 1000 | 982 | else |
| 1001 | 983 | { |
| 1002 | | m_pixels = texsource.base; |
| 1003 | | m_pitch = m_texinfo.rowpixels * m_copyinfo->dst_bpp; |
| 984 | texture->pixels = texsource->base; |
| 985 | texture->pitch = texture->texinfo.rowpixels * texture->copyinfo->dst_bpp; |
| 1004 | 986 | } |
| 1005 | | SDL_UpdateTexture(m_texture_id, NULL, m_pixels, m_pitch); |
| 987 | SDL_UpdateTexture(texture->texture_id, NULL, texture->pixels, texture->pitch); |
| 1006 | 988 | } |
| 1007 | 989 | else |
| 1008 | 990 | { |
| 1009 | | SDL_LockTexture(m_texture_id, NULL, (void **) &m_pixels, &m_pitch); |
| 1010 | | if ( m_copyinfo->func ) |
| 1011 | | m_copyinfo->func(this, &texsource); |
| 991 | SDL_LockTexture(texture->texture_id, NULL, (void **) &texture->pixels, &texture->pitch); |
| 992 | if ( texture->copyinfo->func ) |
| 993 | texture->copyinfo->func(texture, texsource); |
| 1012 | 994 | else |
| 1013 | 995 | { |
| 1014 | | UINT8 *src = (UINT8 *) texsource.base; |
| 1015 | | UINT8 *dst = (UINT8 *) m_pixels; |
| 1016 | | int spitch = texsource.rowpixels * m_copyinfo->dst_bpp; |
| 1017 | | int num = texsource.width * m_copyinfo->dst_bpp; |
| 1018 | | int h = texsource.height; |
| 996 | UINT8 *src = (UINT8 *) texsource->base; |
| 997 | UINT8 *dst = (UINT8 *) texture->pixels; |
| 998 | int spitch = texsource->rowpixels * texture->copyinfo->dst_bpp; |
| 999 | int num = texsource->width * texture->copyinfo->dst_bpp; |
| 1000 | int h = texsource->height; |
| 1019 | 1001 | while (h--) { |
| 1020 | 1002 | memcpy(dst, src, num); |
| 1021 | 1003 | src += spitch; |
| 1022 | | dst += m_pitch; |
| 1004 | dst += texture->pitch; |
| 1023 | 1005 | } |
| 1024 | 1006 | } |
| 1025 | | SDL_UnlockTexture(m_texture_id); |
| 1007 | SDL_UnlockTexture(texture->texture_id); |
| 1026 | 1008 | } |
| 1027 | | m_copyinfo->time += osd_ticks(); |
| 1009 | texture->copyinfo->time += osd_ticks(); |
| 1028 | 1010 | } |
| 1029 | 1011 | |
| 1030 | 1012 | //============================================================ |
| 1031 | 1013 | // compute rotation setup |
| 1032 | 1014 | //============================================================ |
| 1033 | 1015 | |
| 1034 | | void quad_setup_data::compute(const render_primitive &prim) |
| 1016 | static void compute_setup(sdl_info *sdl, const render_primitive *prim, quad_setup_data *setup, int flags) |
| 1035 | 1017 | { |
| 1036 | | const render_quad_texuv *texcoords = &prim.texcoords; |
| 1037 | | int texwidth = prim.texture.width; |
| 1038 | | int texheight = prim.texture.height; |
| 1018 | const render_quad_texuv *texcoords = &prim->texcoords; |
| 1019 | int texwidth = prim->texture.width; |
| 1020 | int texheight = prim->texture.height; |
| 1039 | 1021 | float fdudx, fdvdx, fdudy, fdvdy; |
| 1040 | 1022 | float width, height; |
| 1041 | 1023 | float fscale; |
| 1042 | 1024 | /* determine U/V deltas */ |
| 1043 | | if ((PRIMFLAG_GET_SCREENTEX(prim.flags))) |
| 1025 | if ((PRIMFLAG_GET_SCREENTEX(flags))) |
| 1044 | 1026 | fscale = (float) video_config.prescale; |
| 1045 | 1027 | else |
| 1046 | 1028 | fscale = 1.0f; |
| r242698 | r242699 | |
| 1050 | 1032 | fdudy = (texcoords->bl.u - texcoords->tl.u) / fscale; // b a12 |
| 1051 | 1033 | fdvdy = (texcoords->bl.v - texcoords->tl.v) / fscale; // d a22 |
| 1052 | 1034 | |
| 1053 | | #if 0 |
| 1054 | | printf("tl.u %f tl.v %f\n", texcoords->tl.u, texcoords->tl.v); |
| 1055 | | printf("tr.u %f tr.v %f\n", texcoords->tr.u, texcoords->tr.v); |
| 1056 | | printf("bl.u %f bl.v %f\n", texcoords->bl.u, texcoords->bl.v); |
| 1057 | | printf("br.u %f br.v %f\n", texcoords->br.u, texcoords->br.v); |
| 1058 | 1035 | /* compute start and delta U,V coordinates now */ |
| 1059 | | #endif |
| 1060 | 1036 | |
| 1061 | | dudx = round_nearest(65536.0f * fdudx); |
| 1062 | | dvdx = round_nearest(65536.0f * fdvdx); |
| 1063 | | dudy = round_nearest(65536.0f * fdudy); |
| 1064 | | dvdy = round_nearest(65536.0f * fdvdy); |
| 1065 | | startu = round_nearest(65536.0f * (float) texwidth * texcoords->tl.u); |
| 1066 | | startv = round_nearest(65536.0f * (float) texheight * texcoords->tl.v); |
| 1037 | setup->dudx = round_nearest(65536.0f * fdudx); |
| 1038 | setup->dvdx = round_nearest(65536.0f * fdvdx); |
| 1039 | setup->dudy = round_nearest(65536.0f * fdudy); |
| 1040 | setup->dvdy = round_nearest(65536.0f * fdvdy); |
| 1041 | setup->startu = round_nearest(65536.0f * (float) texwidth * texcoords->tl.u); |
| 1042 | setup->startv = round_nearest(65536.0f * (float) texheight * texcoords->tl.v); |
| 1067 | 1043 | |
| 1068 | 1044 | /* clamp to integers */ |
| 1069 | 1045 | |
| 1070 | 1046 | width = fabs((fdudx * (float) (texwidth) + fdvdx * (float) (texheight)) * fscale * fscale); |
| 1071 | 1047 | height = fabs((fdudy * (float)(texwidth) + fdvdy * (float) (texheight)) * fscale * fscale); |
| 1072 | 1048 | |
| 1073 | | rotwidth = width; |
| 1074 | | rotheight = height; |
| 1049 | setup->rotwidth = width; |
| 1050 | setup->rotheight = height; |
| 1075 | 1051 | |
| 1076 | | startu += (dudx + dudy) / 2; |
| 1077 | | startv += (dvdx + dvdy) / 2; |
| 1052 | setup->startu += (setup->dudx + setup->dudy) / 2; |
| 1053 | setup->startv += (setup->dvdx + setup->dvdy) / 2; |
| 1078 | 1054 | |
| 1079 | 1055 | } |
| 1080 | 1056 | |
| r242698 | r242699 | |
| 1082 | 1058 | // texture_find |
| 1083 | 1059 | //============================================================ |
| 1084 | 1060 | |
| 1085 | | texture_info *sdl_info::texture_find(const render_primitive &prim, const quad_setup_data &setup) |
| 1061 | static texture_info *texture_find(sdl_info *sdl, const render_primitive *prim, quad_setup_data *setup) |
| 1086 | 1062 | { |
| 1087 | | HashT texhash = texture_compute_hash(prim.texture, prim.flags); |
| 1063 | HashT texhash = texture_compute_hash(&prim->texture, prim->flags); |
| 1088 | 1064 | texture_info *texture; |
| 1089 | 1065 | osd_ticks_t now = osd_ticks(); |
| 1090 | 1066 | |
| 1091 | 1067 | // find a match |
| 1092 | | for (texture = m_texlist.first(); texture != NULL; ) |
| 1093 | | if (texture->hash() == texhash && |
| 1094 | | texture->matches(prim, setup)) |
| 1068 | for (texture = sdl->texlist; texture != NULL; ) |
| 1069 | if (texture->hash == texhash && |
| 1070 | texture->texinfo.base == prim->texture.base && |
| 1071 | texture->texinfo.width == prim->texture.width && |
| 1072 | texture->texinfo.height == prim->texture.height && |
| 1073 | texture->texinfo.rowpixels == prim->texture.rowpixels && |
| 1074 | texture->setup.dudx == setup->dudx && |
| 1075 | texture->setup.dvdx == setup->dvdx && |
| 1076 | texture->setup.dudy == setup->dudy && |
| 1077 | texture->setup.dvdy == setup->dvdy && |
| 1078 | ((texture->flags ^ prim->flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0) |
| 1095 | 1079 | { |
| 1096 | | /* would we choose another blitter based on performance ? */ |
| 1097 | | if ((texture->m_copyinfo->samples & 0x7f) == 0x7f) |
| 1080 | /* would we choose another blitter ? */ |
| 1081 | if ((texture->copyinfo->samples & 0x1f) == 0x1f) |
| 1098 | 1082 | { |
| 1099 | | if (texture->m_copyinfo != texture->compute_size_type()) |
| 1083 | if (texture->copyinfo != texture_compute_size_type(sdl->sdl_renderer, &texture->texinfo, texture, prim->flags)) |
| 1100 | 1084 | return NULL; |
| 1085 | #if 0 |
| 1086 | else |
| 1087 | { |
| 1088 | /* reset stats */ |
| 1089 | texture->copyinfo->samples = 0; |
| 1090 | texture->copyinfo->time = 0; |
| 1091 | texture->copyinfo->pixel_count = 0; |
| 1092 | } |
| 1093 | #endif |
| 1101 | 1094 | } |
| 1102 | | texture->m_last_access = now; |
| 1095 | texture->last_access = now; |
| 1103 | 1096 | return texture; |
| 1104 | 1097 | } |
| 1105 | 1098 | else |
| 1106 | 1099 | { |
| 1107 | 1100 | /* free resources not needed any longer? */ |
| 1108 | 1101 | texture_info *expire = texture; |
| 1109 | | texture = texture->next(); |
| 1110 | | if (now - expire->m_last_access > osd_ticks_per_second()) |
| 1111 | | m_texlist.remove(*expire); |
| 1102 | texture = texture->next; |
| 1103 | if (now - expire->last_access > osd_ticks_per_second()) |
| 1104 | drawsdl2_destroy_texture(sdl, expire); |
| 1112 | 1105 | } |
| 1113 | 1106 | |
| 1114 | 1107 | // nothing found |
| r242698 | r242699 | |
| 1119 | 1112 | // texture_update |
| 1120 | 1113 | //============================================================ |
| 1121 | 1114 | |
| 1122 | | texture_info * sdl_info::texture_update(const render_primitive &prim) |
| 1115 | static texture_info * texture_update(sdl_window_info *window, const render_primitive *prim) |
| 1123 | 1116 | { |
| 1117 | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 1124 | 1118 | quad_setup_data setup; |
| 1125 | 1119 | texture_info *texture; |
| 1126 | 1120 | |
| 1127 | | setup.compute(prim); |
| 1121 | compute_setup(sdl, prim, &setup, prim->flags); |
| 1128 | 1122 | |
| 1129 | | texture = texture_find(prim, setup); |
| 1123 | texture = texture_find(sdl, prim, &setup); |
| 1130 | 1124 | |
| 1131 | 1125 | // if we didn't find one, create a new texture |
| 1132 | | if (texture == NULL && prim.texture.base != NULL) |
| 1126 | if (texture == NULL && prim->texture.base != NULL) |
| 1133 | 1127 | { |
| 1134 | | texture = global_alloc(texture_info(m_renderer, prim.texture, setup, prim.flags)); |
| 1135 | | /* add us to the texture list */ |
| 1136 | | m_texlist.prepend(*texture); |
| 1137 | | |
| 1128 | texture = texture_create(window, &prim->texture, &setup, prim->flags); |
| 1138 | 1129 | } |
| 1139 | 1130 | |
| 1140 | 1131 | if (texture != NULL) |
| 1141 | 1132 | { |
| 1142 | | if (prim.texture.base != NULL && texture->texinfo().seqid != prim.texture.seqid) |
| 1133 | if (prim->texture.base != NULL && texture->texinfo.seqid != prim->texture.seqid) |
| 1143 | 1134 | { |
| 1144 | | texture->texinfo().seqid = prim.texture.seqid; |
| 1135 | texture->texinfo.seqid = prim->texture.seqid; |
| 1145 | 1136 | // if we found it, but with a different seqid, copy the data |
| 1146 | | texture->set_data(prim.texture, prim.flags); |
| 1137 | texture_set_data(sdl, texture, &prim->texture, prim->flags); |
| 1147 | 1138 | } |
| 1148 | 1139 | |
| 1149 | 1140 | } |
| 1150 | 1141 | return texture; |
| 1151 | 1142 | } |
| 1152 | 1143 | |
| 1144 | static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture) |
| 1145 | { |
| 1146 | texture_info *p; |
| 1153 | 1147 | |
| 1148 | SDL_DestroyTexture(texture->texture_id); |
| 1149 | if ( texture->pixels_own ) |
| 1150 | { |
| 1151 | free(texture->pixels); |
| 1152 | texture->pixels=NULL; |
| 1153 | texture->pixels_own=FALSE; |
| 1154 | } |
| 1155 | |
| 1156 | for (p=sdl->texlist; p != NULL; p = p->next) |
| 1157 | if (p->next == texture) |
| 1158 | break; |
| 1159 | if (p == NULL) |
| 1160 | sdl->texlist = NULL; |
| 1161 | else |
| 1162 | p->next = texture->next; |
| 1163 | global_free(texture); |
| 1164 | } |
| 1165 | |
| 1154 | 1166 | static void drawsdl2_destroy_all_textures(sdl_window_info *window) |
| 1155 | 1167 | { |
| 1156 | 1168 | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 1169 | texture_info *next_texture=NULL, *texture = NULL; |
| 1170 | int lock=FALSE; |
| 1157 | 1171 | |
| 1158 | 1172 | if (sdl == NULL) |
| 1159 | 1173 | return; |
| 1160 | 1174 | |
| 1161 | 1175 | if(window->primlist) |
| 1162 | 1176 | { |
| 1177 | lock=TRUE; |
| 1163 | 1178 | window->primlist->acquire_lock(); |
| 1164 | | sdl->m_texlist.reset(); |
| 1165 | | window->primlist->release_lock(); |
| 1166 | 1179 | } |
| 1167 | | else |
| 1168 | | sdl->m_texlist.reset(); |
| 1180 | |
| 1181 | texture = sdl->texlist; |
| 1182 | |
| 1183 | while (texture) |
| 1184 | { |
| 1185 | next_texture = texture->next; |
| 1186 | drawsdl2_destroy_texture(sdl, texture); |
| 1187 | texture = next_texture; |
| 1188 | } |
| 1189 | |
| 1190 | if (lock) |
| 1191 | window->primlist->release_lock(); |
| 1169 | 1192 | } |