trunk/src/osd/sdl/drawsdl.c
| r243333 | r243334 | |
| 64 | 64 | #endif |
| 65 | 65 | m_yuv_lookup(NULL), |
| 66 | 66 | m_yuv_bitmap(NULL), |
| 67 | | m_hw_scale_width(0), |
| 68 | | m_hw_scale_height(0), |
| 67 | //m_hw_scale_width(0), |
| 68 | //m_hw_scale_height(0), |
| 69 | 69 | m_last_hofs(0), |
| 70 | 70 | m_last_vofs(0), |
| 71 | 71 | m_old_blitwidth(0), |
| r243333 | r243334 | |
| 114 | 114 | // if we leave scaling to SDL and the underlying driver, this |
| 115 | 115 | // is the render_target_width/height to use |
| 116 | 116 | |
| 117 | | int m_hw_scale_width; |
| 118 | | int m_hw_scale_height; |
| 119 | 117 | int m_last_hofs; |
| 120 | 118 | int m_last_vofs; |
| 121 | 119 | int m_old_blitwidth; |
| r243333 | r243334 | |
| 135 | 133 | const char *sdl_scale_mode; /* what to use as a hint ? */ |
| 136 | 134 | #endif |
| 137 | 135 | int pixel_format; /* Pixel/Overlay format */ |
| 138 | | void (*yuv_blit)(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch); |
| 136 | void (*yuv_blit)(const UINT16 *bitmap, UINT8 *ptr, const int pitch, const UINT32 *lookup, const int width, const int height); |
| 139 | 137 | }; |
| 140 | 138 | |
| 141 | 139 | //============================================================ |
| r243333 | r243334 | |
| 151 | 149 | |
| 152 | 150 | // YUV overlays |
| 153 | 151 | |
| 154 | | static void yuv_RGB_to_YV12(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch); |
| 155 | | static void yuv_RGB_to_YV12X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch); |
| 156 | | static void yuv_RGB_to_YUY2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch); |
| 157 | | static void yuv_RGB_to_YUY2X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch); |
| 152 | static void yuv_RGB_to_YV12(const UINT16 *bitmap, UINT8 *ptr, const int pitch, \ |
| 153 | const UINT32 *lookup, const int width, const int height); |
| 154 | static void yuv_RGB_to_YV12X2(const UINT16 *bitmap, UINT8 *ptr, const int pitch, \ |
| 155 | const UINT32 *lookup, const int width, const int height); |
| 156 | static void yuv_RGB_to_YUY2(const UINT16 *bitmap, UINT8 *ptr, const int pitch, \ |
| 157 | const UINT32 *lookup, const int width, const int height); |
| 158 | static void yuv_RGB_to_YUY2X2(const UINT16 *bitmap, UINT8 *ptr, const int pitch, \ |
| 159 | const UINT32 *lookup, const int width, const int height); |
| 158 | 160 | |
| 159 | 161 | // Static declarations |
| 160 | 162 | |
| r243333 | r243334 | |
| 163 | 165 | |
| 164 | 166 | static const sdl_scale_mode scale_modes[] = |
| 165 | 167 | { |
| 166 | | { "none", 0, 0, 0, 0, SDL_DOUBLEBUF, 0, 0 }, |
| 167 | | { "async", 0, 0, 0, 0, SDL_DOUBLEBUF | SDL_ASYNCBLIT, 0, 0 }, |
| 168 | { "none", 0, 0, 1, 1, SDL_DOUBLEBUF, 0, 0 }, |
| 169 | { "async", 0, 0, 1, 1, SDL_DOUBLEBUF | SDL_ASYNCBLIT, 0, 0 }, |
| 168 | 170 | { "yv12", 1, 1, 1, 1, 0, SDL_YV12_OVERLAY, yuv_RGB_to_YV12 }, |
| 169 | 171 | { "yv12x2", 1, 1, 2, 2, 0, SDL_YV12_OVERLAY, yuv_RGB_to_YV12X2 }, |
| 170 | 172 | { "yuy2", 1, 1, 1, 1, 0, SDL_YUY2_OVERLAY, yuv_RGB_to_YUY2 }, |
| r243333 | r243334 | |
| 174 | 176 | #else |
| 175 | 177 | static const sdl_scale_mode scale_modes[] = |
| 176 | 178 | { |
| 177 | | { "none", 0, 0, 0, 0, DRAW2_SCALEMODE_NEAREST, 0, 0 }, |
| 179 | { "none", 0, 0, 1, 1, DRAW2_SCALEMODE_NEAREST, 0, 0 }, |
| 178 | 180 | { "hwblit", 1, 0, 1, 1, DRAW2_SCALEMODE_LINEAR, 0, 0 }, |
| 179 | 181 | { "hwbest", 1, 0, 1, 1, DRAW2_SCALEMODE_BEST, 0, 0 }, |
| 180 | 182 | { "yv12", 1, 1, 1, 1, DRAW2_SCALEMODE_NEAREST, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12 }, |
| r243333 | r243334 | |
| 280 | 282 | m_yuv_bitmap = NULL; |
| 281 | 283 | } |
| 282 | 284 | |
| 285 | fmt = (sdl_sm->pixel_format ? sdl_sm->pixel_format : mode.format); |
| 286 | |
| 283 | 287 | if (sdl_sm->is_scale) |
| 284 | 288 | { |
| 289 | int m_hw_scale_width =0; |
| 290 | int m_hw_scale_height = 0; |
| 291 | |
| 285 | 292 | window().m_target->compute_minimum_size(m_hw_scale_width, m_hw_scale_height); |
| 286 | 293 | if (video_config.prescale) |
| 287 | 294 | { |
| r243333 | r243334 | |
| 291 | 298 | /* This must be a multiple of 2 */ |
| 292 | 299 | m_hw_scale_width = (m_hw_scale_width + 1) & ~1; |
| 293 | 300 | } |
| 294 | | } |
| 301 | if (sdl_sm->is_yuv) |
| 302 | m_yuv_bitmap = global_alloc_array(UINT16, m_hw_scale_width * m_hw_scale_height); |
| 295 | 303 | |
| 296 | | if (sdl_sm->is_yuv) |
| 297 | | m_yuv_bitmap = global_alloc_array(UINT16, m_hw_scale_width * m_hw_scale_height); |
| 298 | | |
| 299 | | fmt = (sdl_sm->pixel_format ? sdl_sm->pixel_format : mode.format); |
| 300 | | |
| 301 | | if (sdl_sm->is_scale) |
| 302 | | { |
| 303 | 304 | int w = m_hw_scale_width * sdl_sm->mult_w; |
| 304 | 305 | int h = m_hw_scale_height * sdl_sm->mult_h; |
| 305 | 306 | |
| r243333 | r243334 | |
| 355 | 356 | //return 1; |
| 356 | 357 | } |
| 357 | 358 | |
| 358 | | m_hw_scale_width = minimum_width; |
| 359 | | m_hw_scale_height = minimum_height; |
| 360 | | |
| 361 | 359 | if (!shown_video_info) |
| 362 | 360 | { |
| 363 | 361 | osd_printf_verbose("YUV Mode : %s\n", sdl_sm->name); |
| r243333 | r243334 | |
| 546 | 544 | |
| 547 | 545 | if (!m_sdlsurf) |
| 548 | 546 | return 1; |
| 549 | | |
| 550 | 547 | window().m_width = m_sdlsurf->w; |
| 551 | 548 | window().m_height = m_sdlsurf->h; |
| 552 | | |
| 553 | 549 | if (sm->is_yuv) |
| 554 | 550 | yuv_overlay_init(); |
| 555 | 551 | |
| r243333 | r243334 | |
| 589 | 585 | |
| 590 | 586 | m_sdlsurf = SDL_SetVideoMode(width, height, 0, |
| 591 | 587 | SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags); |
| 588 | |
| 592 | 589 | window().m_width = m_sdlsurf->w; |
| 593 | 590 | window().m_height = m_sdlsurf->h; |
| 594 | 591 | |
| 595 | | if (sdl_sm->is_yuv) |
| 592 | if (sdl_sm->is_yuv) |
| 596 | 593 | { |
| 597 | 594 | yuv_overlay_init(); |
| 598 | 595 | } |
| r243333 | r243334 | |
| 670 | 667 | return 0; |
| 671 | 668 | if (*yt<0 || *xt >= window().m_blitheight) |
| 672 | 669 | return 0; |
| 673 | | if (!sm->is_scale) |
| 674 | | { |
| 675 | | return 1; |
| 676 | | } |
| 677 | | /* Rescale */ |
| 678 | | *xt = (*xt * m_hw_scale_width) / window().m_blitwidth; |
| 679 | | *yt = (*yt * m_hw_scale_height) / window().m_blitheight; |
| 680 | 670 | return 1; |
| 681 | 671 | } |
| 682 | 672 | |
| r243333 | r243334 | |
| 686 | 676 | |
| 687 | 677 | void sdl_info::set_target_bounds() |
| 688 | 678 | { |
| 689 | | const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; |
| 690 | | |
| 691 | | if (!sm->is_scale) |
| 692 | | window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect()); |
| 693 | | else |
| 694 | | window().m_target->set_bounds(m_hw_scale_width, m_hw_scale_height); |
| 679 | window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect()); |
| 695 | 680 | } |
| 696 | 681 | |
| 697 | 682 | //============================================================ |
| r243333 | r243334 | |
| 703 | 688 | const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; |
| 704 | 689 | UINT8 *surfptr; |
| 705 | 690 | INT32 pitch; |
| 706 | | int bpp; |
| 707 | 691 | Uint32 rmask, gmask, bmask; |
| 708 | 692 | #if (SDLMAME_SDL2) |
| 709 | 693 | Uint32 amask; |
| 710 | 694 | #endif |
| 711 | 695 | INT32 vofs, hofs, blitwidth, blitheight, ch, cw; |
| 696 | int bpp; |
| 712 | 697 | |
| 713 | 698 | if (video_config.novideo) |
| 714 | 699 | { |
| r243333 | r243334 | |
| 750 | 735 | SDL_LockYUVOverlay(m_yuvsurf); |
| 751 | 736 | surfptr = m_yuvsurf->pixels[0]; // (UINT8 *) m_yuv_bitmap; |
| 752 | 737 | pitch = m_yuvsurf->pitches[0]; // (UINT8 *) m_yuv_bitmap; |
| 738 | #if 0 |
| 739 | printf("abcd %d\n", m_yuvsurf->h); |
| 740 | printf("abcd %d %d %d\n", m_yuvsurf->pitches[0], m_yuvsurf->pitches[1], m_yuvsurf->pitches[2]); |
| 741 | printf("abcd %p %p %p\n", m_yuvsurf->pixels[0], m_yuvsurf->pixels[1], m_yuvsurf->pixels[2]); |
| 742 | printf("abcd %ld %ld\n", m_yuvsurf->pixels[1] - m_yuvsurf->pixels[0], m_yuvsurf->pixels[2] - m_yuvsurf->pixels[1]); |
| 743 | #endif |
| 753 | 744 | } |
| 754 | 745 | else |
| 755 | 746 | surfptr = (UINT8 *)m_sdlsurf->pixels; |
| r243333 | r243334 | |
| 832 | 823 | |
| 833 | 824 | window().m_primlist->acquire_lock(); |
| 834 | 825 | |
| 835 | | // render to it |
| 836 | | if (!sm->is_yuv) |
| 837 | | { |
| 838 | | int mamewidth, mameheight; |
| 826 | int mamewidth, mameheight; |
| 839 | 827 | |
| 840 | | if (!sm->is_scale) |
| 828 | #if !SDLMAME_SDL2 |
| 829 | if (!sm->is_yuv) |
| 841 | 830 | { |
| 842 | | mamewidth = blitwidth; |
| 843 | | mameheight = blitheight; |
| 844 | | #if !SDLMAME_SDL2 |
| 845 | 831 | surfptr += ((vofs * pitch) + (hofs * bpp)); |
| 846 | | #endif |
| 832 | mamewidth = blitwidth; //m_sdlsurf->w; |
| 833 | mameheight = blitheight; //m_sdlsurf->h; |
| 847 | 834 | } |
| 848 | 835 | else |
| 849 | 836 | { |
| 850 | | mamewidth = m_hw_scale_width; |
| 851 | | mameheight = m_hw_scale_height; |
| 837 | mamewidth = m_yuvsurf->w / sm->mult_w; |
| 838 | mameheight = m_yuvsurf->h / sm->mult_h; |
| 852 | 839 | } |
| 840 | #else |
| 841 | Uint32 fmt = 0; |
| 842 | int access = 0; |
| 843 | SDL_QueryTexture(m_texture_id, &fmt, &access, &mamewidth, &mameheight); |
| 844 | mamewidth /= sm->mult_w; |
| 845 | mameheight /= sm->mult_h; |
| 846 | #endif |
| 847 | //printf("w h %d %d %d %d\n", mamewidth, mameheight, blitwidth, blitheight); |
| 848 | |
| 849 | // rescale bounds |
| 850 | float fw = (float) mamewidth / (float) blitwidth; |
| 851 | float fh = (float) mameheight / (float) blitheight; |
| 852 | |
| 853 | // FIXME: this could be a lot easier if we get the primlist here! |
| 854 | // Bounds would be set fit for purpose and done! |
| 855 | |
| 856 | for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next()) |
| 857 | { |
| 858 | prim->bounds.x0 *= fw; |
| 859 | prim->bounds.x1 *= fw; |
| 860 | prim->bounds.y0 *= fh; |
| 861 | prim->bounds.y1 *= fh; |
| 862 | } |
| 863 | |
| 864 | // render to it |
| 865 | if (!sm->is_yuv) |
| 866 | { |
| 853 | 867 | switch (rmask) |
| 854 | 868 | { |
| 855 | 869 | case 0x0000ff00: |
| r243333 | r243334 | |
| 881 | 895 | { |
| 882 | 896 | assert (m_yuv_bitmap != NULL); |
| 883 | 897 | assert (surfptr != NULL); |
| 884 | | software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window().m_primlist, m_yuv_bitmap, m_hw_scale_width, m_hw_scale_height, m_hw_scale_width); |
| 885 | | sm->yuv_blit((UINT16 *)m_yuv_bitmap, this, surfptr, pitch); |
| 898 | software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window().m_primlist, m_yuv_bitmap, mamewidth, mameheight, mamewidth); |
| 899 | sm->yuv_blit((UINT16 *)m_yuv_bitmap, surfptr, pitch, m_yuv_lookup, mamewidth, mameheight); |
| 886 | 900 | } |
| 887 | 901 | |
| 888 | 902 | window().m_primlist->release_lock(); |
| r243333 | r243334 | |
| 992 | 1006 | } |
| 993 | 1007 | } |
| 994 | 1008 | |
| 995 | | static void yuv_RGB_to_YV12(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch) |
| 1009 | //UINT32 *lookup = sdl->m_yuv_lookup; |
| 1010 | |
| 1011 | static void yuv_RGB_to_YV12(const UINT16 *bitmap, UINT8 *ptr, const int pitch, \ |
| 1012 | const UINT32 *lookup, const int width, const int height) |
| 996 | 1013 | { |
| 997 | 1014 | int x, y; |
| 998 | | UINT8 *dest_y; |
| 999 | | UINT8 *dest_u; |
| 1000 | | UINT8 *dest_v; |
| 1001 | | UINT16 *src; |
| 1002 | | UINT16 *src2; |
| 1003 | | UINT32 *lookup = sdl->m_yuv_lookup; |
| 1004 | 1015 | UINT8 *pixels[3]; |
| 1005 | 1016 | int u1,v1,y1,u2,v2,y2,u3,v3,y3,u4,v4,y4; /* 12 */ |
| 1006 | 1017 | |
| 1007 | 1018 | pixels[0] = ptr; |
| 1008 | | pixels[1] = ptr + pitch * sdl->m_hw_scale_height; |
| 1009 | | pixels[2] = pixels[1] + pitch * sdl->m_hw_scale_height / 4; |
| 1019 | pixels[1] = ptr + pitch * height; |
| 1020 | pixels[2] = pixels[1] + pitch * height / 4; |
| 1010 | 1021 | |
| 1011 | | for(y=0;y<sdl->m_hw_scale_height;y+=2) |
| 1022 | for(y=0;y<height;y+=2) |
| 1012 | 1023 | { |
| 1013 | | src=bitmap + (y * sdl->m_hw_scale_width) ; |
| 1014 | | src2=src + sdl->m_hw_scale_width; |
| 1024 | const UINT16 *src=bitmap + (y * width) ; |
| 1025 | const UINT16 *src2=src + width; |
| 1015 | 1026 | |
| 1016 | | dest_y = pixels[0] + y * pitch; |
| 1017 | | dest_v = pixels[1] + (y>>1) * pitch / 2; |
| 1018 | | dest_u = pixels[2] + (y>>1) * pitch / 2; |
| 1027 | UINT8 *dest_y = pixels[0] + y * pitch; |
| 1028 | UINT8 *dest_v = pixels[1] + (y>>1) * pitch / 2; |
| 1029 | UINT8 *dest_u = pixels[2] + (y>>1) * pitch / 2; |
| 1019 | 1030 | |
| 1020 | | for(x=0;x<sdl->m_hw_scale_width;x+=2) |
| 1031 | for(x=0;x<width;x+=2) |
| 1021 | 1032 | { |
| 1022 | 1033 | v1 = lookup[src[x]]; |
| 1023 | 1034 | y1 = (v1>>Y1SHIFT) & 0xff; |
| r243333 | r243334 | |
| 1051 | 1062 | } |
| 1052 | 1063 | } |
| 1053 | 1064 | |
| 1054 | | static void yuv_RGB_to_YV12X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch) |
| 1065 | static void yuv_RGB_to_YV12X2(const UINT16 *bitmap, UINT8 *ptr, const int pitch, \ |
| 1066 | const UINT32 *lookup, const int width, const int height) |
| 1055 | 1067 | { |
| 1056 | 1068 | /* this one is used when scale==2 */ |
| 1057 | 1069 | unsigned int x,y; |
| 1058 | | UINT16 *dest_y; |
| 1059 | | UINT8 *dest_u; |
| 1060 | | UINT8 *dest_v; |
| 1061 | | UINT16 *src; |
| 1062 | 1070 | int u1,v1,y1; |
| 1063 | 1071 | UINT8 *pixels[3]; |
| 1064 | 1072 | |
| 1065 | 1073 | pixels[0] = ptr; |
| 1066 | | pixels[1] = ptr + pitch * sdl->m_hw_scale_height * 2; |
| 1067 | | pixels[2] = pixels[1] + pitch * sdl->m_hw_scale_height / 2; |
| 1074 | pixels[1] = ptr + pitch * height * 2; |
| 1075 | #if (SDLMAME_SDL2) |
| 1076 | int p2 = (pitch >> 1); |
| 1077 | #else |
| 1078 | int p2 = (pitch + 7) & ~ 7;; |
| 1079 | p2 = (p2 >> 1); |
| 1080 | #endif |
| 1081 | pixels[2] = pixels[1] + p2 * height; |
| 1068 | 1082 | |
| 1069 | | for(y=0;y<sdl->m_hw_scale_height;y++) |
| 1083 | for(y=0;y<height;y++) |
| 1070 | 1084 | { |
| 1071 | | src = bitmap + (y * sdl->m_hw_scale_width) ; |
| 1085 | const UINT16 *src = bitmap + (y * width) ; |
| 1072 | 1086 | |
| 1073 | | dest_y = (UINT16 *)(pixels[0] + 2 * y * pitch); |
| 1074 | | dest_v = pixels[1] + y * pitch / 2; |
| 1075 | | dest_u = pixels[2] + y * pitch / 2; |
| 1076 | | for(x=0;x<sdl->m_hw_scale_width;x++) |
| 1087 | UINT16 *dest_y = (UINT16 *)(pixels[0] + 2 * y * pitch); |
| 1088 | UINT8 *dest_v = pixels[1] + y * p2; |
| 1089 | UINT8 *dest_u = pixels[2] + y * p2; |
| 1090 | for(x=0;x<width;x++) |
| 1077 | 1091 | { |
| 1078 | | v1 = sdl->m_yuv_lookup[src[x]]; |
| 1092 | v1 = lookup[src[x]]; |
| 1079 | 1093 | y1 = (v1 >> Y1SHIFT) & 0xff; |
| 1080 | 1094 | u1 = (v1 >> USHIFT) & 0xff; |
| 1081 | 1095 | v1 = (v1 >> VSHIFT) & 0xff; |
| r243333 | r243334 | |
| 1088 | 1102 | } |
| 1089 | 1103 | } |
| 1090 | 1104 | |
| 1091 | | static void yuv_RGB_to_YUY2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch) |
| 1105 | static void yuv_RGB_to_YUY2(const UINT16 *bitmap, UINT8 *ptr, const int pitch, \ |
| 1106 | const UINT32 *lookup, const int width, const int height) |
| 1092 | 1107 | { |
| 1093 | 1108 | /* this one is used when scale==2 */ |
| 1094 | 1109 | unsigned int y; |
| 1095 | | UINT32 *dest; |
| 1096 | | UINT16 *src; |
| 1097 | | UINT16 *end; |
| 1098 | 1110 | UINT32 p1,p2,uv; |
| 1099 | | UINT32 *lookup = sdl->m_yuv_lookup; |
| 1100 | | int yuv_pitch = pitch/4; |
| 1111 | const int yuv_pitch = pitch/4; |
| 1101 | 1112 | |
| 1102 | | for(y=0;y<sdl->m_hw_scale_height;y++) |
| 1113 | for(y=0;y<height;y++) |
| 1103 | 1114 | { |
| 1104 | | src=bitmap + (y * sdl->m_hw_scale_width) ; |
| 1105 | | end=src+sdl->m_hw_scale_width; |
| 1115 | const UINT16 *src=bitmap + (y * width) ; |
| 1116 | const UINT16 *end=src+width; |
| 1106 | 1117 | |
| 1107 | | dest = (UINT32 *) ptr; |
| 1118 | UINT32 *dest = (UINT32 *) ptr; |
| 1108 | 1119 | dest += y * yuv_pitch; |
| 1109 | 1120 | for(; src<end; src+=2) |
| 1110 | 1121 | { |
| r243333 | r243334 | |
| 1117 | 1128 | } |
| 1118 | 1129 | } |
| 1119 | 1130 | |
| 1120 | | static void yuv_RGB_to_YUY2X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch) |
| 1131 | static void yuv_RGB_to_YUY2X2(const UINT16 *bitmap, UINT8 *ptr, const int pitch, \ |
| 1132 | const UINT32 *lookup, const int width, const int height) |
| 1121 | 1133 | { |
| 1122 | 1134 | /* this one is used when scale==2 */ |
| 1123 | 1135 | unsigned int y; |
| 1124 | | UINT32 *dest; |
| 1125 | | UINT16 *src; |
| 1126 | | UINT16 *end; |
| 1127 | | UINT32 *lookup = sdl->m_yuv_lookup; |
| 1128 | 1136 | int yuv_pitch = pitch / 4; |
| 1129 | 1137 | |
| 1130 | | for(y=0;y<sdl->m_hw_scale_height;y++) |
| 1138 | for(y=0;y<height;y++) |
| 1131 | 1139 | { |
| 1132 | | src=bitmap + (y * sdl->m_hw_scale_width) ; |
| 1133 | | end=src+sdl->m_hw_scale_width; |
| 1140 | const UINT16 *src=bitmap + (y * width) ; |
| 1141 | const UINT16 *end=src+width; |
| 1134 | 1142 | |
| 1135 | | dest = (UINT32 *) ptr; |
| 1143 | UINT32 *dest = (UINT32 *) ptr; |
| 1136 | 1144 | dest += (y * yuv_pitch); |
| 1137 | 1145 | for(; src<end; src++) |
| 1138 | 1146 | { |
trunk/src/osd/sdl/window.c
| r243333 | r243334 | |
| 55 | 55 | #define ASSERT_WINDOW_THREAD() ASSERT_USE(window_threadid) |
| 56 | 56 | #define ASSERT_MAIN_THREAD() ASSERT_USE(main_threadid) |
| 57 | 57 | |
| 58 | | #define OSDWORK_CALLBACK(name) void *name(void *param, ATTR_UNUSED int threadid) |
| 59 | | |
| 60 | 58 | // minimum window dimension |
| 61 | 59 | #define MIN_WINDOW_DIM 200 |
| 62 | 60 | |
| r243333 | r243334 | |
| 141 | 139 | // PROTOTYPES |
| 142 | 140 | //============================================================ |
| 143 | 141 | |
| 144 | | static OSDWORK_CALLBACK( draw_video_contents_wt ); |
| 145 | | static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ); |
| 146 | | static OSDWORK_CALLBACK( sdlwindow_resize_wt ); |
| 147 | | static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ); |
| 148 | 142 | static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window); |
| 149 | 143 | static void sdlwindow_sync(void); |
| 150 | 144 | |
| 151 | | static void *complete_create_wt(void *param, int threadid); |
| 152 | 145 | static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view); |
| 153 | 146 | |
| 154 | 147 | //============================================================ |
| r243333 | r243334 | |
| 483 | 476 | // (main thread) |
| 484 | 477 | //============================================================ |
| 485 | 478 | |
| 486 | | static OSDWORK_CALLBACK( sdlwindow_resize_wt ) |
| 479 | OSDWORK_CALLBACK( sdl_window_info::sdlwindow_resize_wt ) |
| 487 | 480 | { |
| 488 | 481 | worker_param * wp = (worker_param *) param; |
| 489 | 482 | sdl_window_info * window = wp->window(); |
| r243333 | r243334 | |
| 517 | 510 | // (window thread) |
| 518 | 511 | //============================================================ |
| 519 | 512 | |
| 520 | | static OSDWORK_CALLBACK( sdlwindow_clear_surface_wt ) |
| 513 | OSDWORK_CALLBACK( sdl_window_info::sdlwindow_clear_surface_wt ) |
| 521 | 514 | { |
| 522 | 515 | worker_param *wp = (worker_param *) param; |
| 523 | 516 | sdl_window_info *window = wp->window(); |
| r243333 | r243334 | |
| 547 | 540 | // (main thread) |
| 548 | 541 | //============================================================ |
| 549 | 542 | |
| 550 | | static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ) |
| 543 | OSDWORK_CALLBACK( sdl_window_info::sdlwindow_toggle_full_screen_wt ) |
| 551 | 544 | { |
| 552 | 545 | worker_param *wp = (worker_param *) param; |
| 553 | 546 | sdl_window_info *window = wp->window(); |
| r243333 | r243334 | |
| 583 | 576 | execute_async_wait(&sdlwindow_toggle_full_screen_wt, worker_param(machine, this)); |
| 584 | 577 | } |
| 585 | 578 | |
| 586 | | static OSDWORK_CALLBACK( destroy_all_textures_wt ) |
| 579 | OSDWORK_CALLBACK( sdl_window_info::destroy_all_textures_wt ) |
| 587 | 580 | { |
| 588 | 581 | worker_param *wp = (worker_param *) param; |
| 589 | 582 | |
| r243333 | r243334 | |
| 703 | 696 | return NULL; |
| 704 | 697 | } |
| 705 | 698 | |
| 699 | int sdl_window_info::xy_to_render_target(int x, int y, int *xt, int *yt) |
| 700 | { |
| 701 | return renderer().xy_to_render_target(x, y, xt, yt); |
| 702 | } |
| 706 | 703 | |
| 707 | 704 | //============================================================ |
| 708 | 705 | // sdlwindow_video_window_create |
| r243333 | r243334 | |
| 753 | 750 | { |
| 754 | 751 | osd_work_item *wi; |
| 755 | 752 | |
| 756 | | wi = osd_work_item_queue(work_queue, &complete_create_wt, (void *) wp, 0); |
| 753 | wi = osd_work_item_queue(work_queue, &sdl_window_info::complete_create_wt, (void *) wp, 0); |
| 757 | 754 | sdlwindow_sync(); |
| 758 | 755 | result = *((int *) (osd_work_item_result)(wi)); |
| 759 | 756 | osd_work_item_release(wi); |
| 760 | 757 | } |
| 761 | 758 | else |
| 762 | | result = *((int *) complete_create_wt((void *) wp, 0)); |
| 759 | result = *((int *) sdl_window_info::complete_create_wt((void *) wp, 0)); |
| 763 | 760 | |
| 764 | 761 | // handle error conditions |
| 765 | 762 | if (result == 1) |
| r243333 | r243334 | |
| 780 | 777 | // (main thread) |
| 781 | 778 | //============================================================ |
| 782 | 779 | |
| 783 | | static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ) |
| 780 | OSDWORK_CALLBACK( sdl_window_info::sdlwindow_video_window_destroy_wt ) |
| 784 | 781 | { |
| 785 | 782 | worker_param * wp = (worker_param *) param; |
| 786 | 783 | sdl_window_info * window = wp->window(); |
| r243333 | r243334 | |
| 1075 | 1072 | // (window thread) |
| 1076 | 1073 | //============================================================ |
| 1077 | 1074 | |
| 1078 | | static OSDWORK_CALLBACK( complete_create_wt ) |
| 1075 | OSDWORK_CALLBACK( sdl_window_info::complete_create_wt ) |
| 1079 | 1076 | { |
| 1080 | 1077 | worker_param * wp = (worker_param *) param; |
| 1081 | 1078 | sdl_window_info * window = wp->window(); |
| r243333 | r243334 | |
| 1139 | 1136 | // (window thread) |
| 1140 | 1137 | //============================================================ |
| 1141 | 1138 | |
| 1142 | | static void measure_fps(sdl_window_info *window, UINT32 dc, int update) |
| 1139 | void sdl_window_info::measure_fps(UINT32 dc, int update) |
| 1143 | 1140 | { |
| 1144 | 1141 | const unsigned long frames_skip4fps = 100; |
| 1145 | 1142 | static int64_t lastTime=0, sumdt=0, startTime=0; |
| r243333 | r243334 | |
| 1154 | 1151 | |
| 1155 | 1152 | t0 = osd_ticks(); |
| 1156 | 1153 | |
| 1157 | | window->renderer().draw(dc, update); |
| 1154 | renderer().draw(dc, update); |
| 1158 | 1155 | |
| 1159 | 1156 | frames++; |
| 1160 | 1157 | currentTime = osd_ticks(); |
| r243333 | r243334 | |
| 1181 | 1178 | } |
| 1182 | 1179 | } |
| 1183 | 1180 | |
| 1184 | | static OSDWORK_CALLBACK( draw_video_contents_wt ) |
| 1181 | OSDWORK_CALLBACK( sdl_window_info::draw_video_contents_wt ) |
| 1185 | 1182 | { |
| 1186 | 1183 | UINT32 dc = 0; |
| 1187 | 1184 | int update = 1; |
| r243333 | r243334 | |
| 1203 | 1200 | else |
| 1204 | 1201 | { |
| 1205 | 1202 | if( video_config.perftest ) |
| 1206 | | measure_fps(window, dc, update); |
| 1203 | window->measure_fps(dc, update); |
| 1207 | 1204 | else |
| 1208 | 1205 | window->renderer().draw(dc, update); |
| 1209 | 1206 | } |