trunk/src/osd/modules/render/draw13.c
| r244710 | r244711 | |
| 136 | 136 | // TEXCOPY FUNCS |
| 137 | 137 | //============================================================ |
| 138 | 138 | |
| 139 | enum SDL_TEXFORMAT_E |
| 140 | { |
| 141 | SDL_TEXFORMAT_ARGB32 = 0, |
| 142 | SDL_TEXFORMAT_RGB32, |
| 143 | SDL_TEXFORMAT_RGB32_PALETTED, |
| 144 | SDL_TEXFORMAT_YUY16, |
| 145 | SDL_TEXFORMAT_YUY16_PALETTED, |
| 146 | SDL_TEXFORMAT_PALETTE16, |
| 147 | SDL_TEXFORMAT_RGB15, |
| 148 | SDL_TEXFORMAT_RGB15_PALETTED, |
| 149 | SDL_TEXFORMAT_PALETTE16A, |
| 150 | SDL_TEXFORMAT_PALETTE16_ARGB1555, |
| 151 | SDL_TEXFORMAT_RGB15_ARGB1555, |
| 152 | SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555, |
| 153 | SDL_TEXFORMAT_LAST = SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555 |
| 154 | }; |
| 155 | |
| 139 | 156 | #include "blit13.h" |
| 140 | 157 | |
| 141 | 158 | /* sdl_info is the information about SDL for the current screen */ |
| 142 | 159 | class sdl_info13 : public osd_renderer |
| 143 | 160 | { |
| 144 | 161 | public: |
| 145 | | sdl_info13(osd_window *w) |
| 146 | | : osd_renderer(w, FLAG_NONE), m_sdl_renderer(NULL), m_blittimer(0), |
| 162 | sdl_info13(osd_window *w, int extra_flags) |
| 163 | : osd_renderer(w, extra_flags), m_sdl_renderer(NULL), m_blittimer(0), |
| 147 | 164 | m_last_hofs(0), m_last_vofs(0), |
| 148 | 165 | m_width(0), m_height(0), |
| 149 | 166 | m_blit_dim(0,0), |
| r244710 | r244711 | |
| 242 | 259 | // STATIC VARIABLES |
| 243 | 260 | //============================================================ |
| 244 | 261 | |
| 245 | | #define SDL_TEXFORMAT_LAST SDL_TEXFORMAT_PALETTE16A |
| 246 | 262 | #define BM_ALL (-1) |
| 247 | 263 | //( SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD) |
| 248 | 264 | |
| r244710 | r244711 | |
| 329 | 345 | { -1 }, |
| 330 | 346 | }; |
| 331 | 347 | |
| 332 | | static copy_info_t *blit_info[SDL_TEXFORMAT_LAST+1]; |
| 348 | static copy_info_t *blit_info[SDL_TEXFORMAT_LAST+1] = { NULL }; |
| 349 | static bool blit_info_initialized = false; |
| 333 | 350 | |
| 334 | 351 | //============================================================ |
| 335 | 352 | // INLINES |
| r244710 | r244711 | |
| 512 | 529 | |
| 513 | 530 | static osd_renderer *drawsdl2_create(osd_window *window) |
| 514 | 531 | { |
| 515 | | return global_alloc(sdl_info13(window)); |
| 532 | if (!blit_info_initialized) |
| 533 | { |
| 534 | /* On OSX, calling this from drawsdl2_init will |
| 535 | * prohibit fullscreen toggling. It is than not possible |
| 536 | * to toggle from fullscreen to window mode. |
| 537 | */ |
| 538 | expand_copy_info(blit_info_default); |
| 539 | blit_info_initialized = true; |
| 540 | |
| 541 | } |
| 542 | return global_alloc(sdl_info13(window, osd_renderer::FLAG_NONE)); |
| 516 | 543 | } |
| 517 | 544 | |
| 518 | 545 | // FIXME: machine only used to access options. |
| 519 | 546 | int drawsdl2_init(running_machine &machine, osd_draw_callbacks *callbacks) |
| 520 | 547 | { |
| 521 | | const char *stemp; |
| 522 | | |
| 523 | 548 | // fill in the callbacks |
| 524 | 549 | callbacks->exit = drawsdl2_exit; |
| 525 | 550 | callbacks->create = drawsdl2_create; |
| 526 | 551 | |
| 527 | 552 | osd_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n"); |
| 528 | 553 | |
| 529 | | expand_copy_info(blit_info_default); |
| 530 | | |
| 531 | 554 | #if USE_OPENGL |
| 532 | 555 | // Load the GL library now - else MT will fail |
| 533 | | stemp = downcast<sdl_options &>(machine.options()).gl_lib(); |
| 556 | const char *stemp = downcast<sdl_options &>(machine.options()).gl_lib(); |
| 534 | 557 | #else |
| 535 | | stemp = NULL; |
| 558 | const char *stemp = NULL; |
| 536 | 559 | #endif |
| 537 | 560 | if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) == 0) |
| 538 | 561 | stemp = NULL; |
| r244710 | r244711 | |
| 555 | 578 | { |
| 556 | 579 | int i; |
| 557 | 580 | copy_info_t *bi, *freeme; |
| 558 | | for (i = 0; i <= SDL_TEXFORMAT_LAST; i++) |
| 581 | if (blit_info_initialized) |
| 559 | 582 | { |
| 560 | | for (bi = blit_info[i]; bi != NULL; ) |
| 583 | for (i = 0; i <= SDL_TEXFORMAT_LAST; i++) |
| 561 | 584 | { |
| 562 | | if (bi->pixel_count) |
| 563 | | osd_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname, |
| 564 | | bi->blitter->m_is_rot ? "rot" : "norot", bi->bm_mask, bi->samples, |
| 565 | | (int) bi->perf); |
| 566 | | freeme = bi; |
| 567 | | bi = bi->next; |
| 568 | | global_free(freeme); |
| 585 | for (bi = blit_info[i]; bi != NULL; ) |
| 586 | { |
| 587 | if (bi->pixel_count) |
| 588 | osd_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname, |
| 589 | bi->blitter->m_is_rot ? "rot" : "norot", bi->bm_mask, bi->samples, |
| 590 | (int) bi->perf); |
| 591 | freeme = bi; |
| 592 | bi = bi->next; |
| 593 | global_free(freeme); |
| 594 | } |
| 595 | blit_info[i] = NULL; |
| 569 | 596 | } |
| 570 | | blit_info[i] = NULL; |
| 597 | blit_info_initialized = false; |
| 571 | 598 | } |
| 572 | 599 | } |
| 573 | 600 | |
| r244710 | r244711 | |
| 601 | 628 | // a |
| 602 | 629 | //============================================================ |
| 603 | 630 | |
| 631 | static void drawsdl_show_info(struct SDL_RendererInfo *render_info) |
| 632 | { |
| 633 | #define RF_ENTRY(x) {x, #x } |
| 634 | static struct { |
| 635 | int flag; |
| 636 | const char *name; |
| 637 | } rflist[] = |
| 638 | { |
| 639 | #if 0 |
| 640 | RF_ENTRY(SDL_RENDERER_SINGLEBUFFER), |
| 641 | RF_ENTRY(SDL_RENDERER_PRESENTCOPY), |
| 642 | RF_ENTRY(SDL_RENDERER_PRESENTFLIP2), |
| 643 | RF_ENTRY(SDL_RENDERER_PRESENTFLIP3), |
| 644 | RF_ENTRY(SDL_RENDERER_PRESENTDISCARD), |
| 645 | #endif |
| 646 | RF_ENTRY(SDL_RENDERER_SOFTWARE), |
| 647 | RF_ENTRY(SDL_RENDERER_PRESENTVSYNC), |
| 648 | RF_ENTRY(SDL_RENDERER_ACCELERATED), |
| 649 | RF_ENTRY(SDL_RENDERER_TARGETTEXTURE), |
| 650 | {-1, NULL} |
| 651 | }; |
| 652 | int i; |
| 653 | |
| 654 | osd_printf_verbose("window: using renderer %s\n", render_info->name ? render_info->name : "<unknown>"); |
| 655 | for (i = 0; rflist[i].name != NULL; i++) |
| 656 | if (render_info->flags & rflist[i].flag) |
| 657 | osd_printf_verbose("renderer: flag %s\n", rflist[i].name); |
| 658 | } |
| 659 | |
| 660 | |
| 604 | 661 | int sdl_info13::create() |
| 605 | 662 | { |
| 606 | 663 | #if (SDLMAME_SDL2) |
| r244710 | r244711 | |
| 633 | 690 | |
| 634 | 691 | m_blittimer = 3; |
| 635 | 692 | |
| 636 | | SDL_RenderPresent(m_sdl_renderer); |
| 693 | //SDL_RenderPresent(m_sdl_renderer); |
| 637 | 694 | osd_printf_verbose("Leave sdl_info13::create\n"); |
| 638 | 695 | |
| 696 | struct SDL_RendererInfo render_info; |
| 697 | |
| 698 | SDL_GetRendererInfo(m_sdl_renderer, &render_info); |
| 699 | drawsdl_show_info(&render_info); |
| 700 | |
| 639 | 701 | #else |
| 640 | 702 | |
| 641 | 703 | #endif |
| r244710 | r244711 | |
| 651 | 713 | { |
| 652 | 714 | destroy_all_textures(); |
| 653 | 715 | SDL_DestroyRenderer(m_sdl_renderer); |
| 716 | m_sdl_renderer = NULL; |
| 654 | 717 | } |
| 655 | 718 | |
| 656 | 719 | |
| r244710 | r244711 | |
| 1108 | 1171 | texture = global_alloc(texture_info(this, prim.texture, setup, prim.flags)); |
| 1109 | 1172 | /* add us to the texture list */ |
| 1110 | 1173 | m_texlist.prepend(*texture); |
| 1111 | | |
| 1112 | 1174 | } |
| 1113 | 1175 | |
| 1114 | 1176 | if (texture != NULL) |