Mercurial > mplayer.hg
comparison libvo/vo_gl.c @ 26842:c675462d66d9
Render everything as early as possible, doing as little as possible in
flip_page. Can improve A-V sync when playing a video that uses little
CPU with GPU filtering that is very slow.
author | reimar |
---|---|
date | Sun, 25 May 2008 11:26:09 +0000 |
parents | 3822def2c61d |
children | 2a7fb43a9976 |
comparison
equal
deleted
inserted
replaced
26841:3822def2c61d | 26842:c675462d66d9 |
---|---|
115 static int vo_flipped; | 115 static int vo_flipped; |
116 static int ass_border_x, ass_border_y; | 116 static int ass_border_x, ass_border_y; |
117 | 117 |
118 static unsigned int slice_height = 1; | 118 static unsigned int slice_height = 1; |
119 | 119 |
120 static void redraw(void); | |
121 | |
120 static void resize(int x,int y){ | 122 static void resize(int x,int y){ |
121 mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); | 123 mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); |
122 if (WinID >= 0) { | 124 if (WinID >= 0) { |
123 int top = 0, left = 0, w = x, h = y; | 125 int top = 0, left = 0, w = x, h = y; |
124 geometry(&top, &left, &w, &h, vo_screenwidth, vo_screenheight); | 126 geometry(&top, &left, &w, &h, vo_screenwidth, vo_screenheight); |
152 force_load_font = 1; | 154 force_load_font = 1; |
153 #endif | 155 #endif |
154 vo_osd_changed(OSDTYPE_OSD); | 156 vo_osd_changed(OSDTYPE_OSD); |
155 } | 157 } |
156 glClear(GL_COLOR_BUFFER_BIT); | 158 glClear(GL_COLOR_BUFFER_BIT); |
157 flip_page(); | 159 redraw(); |
158 } | 160 } |
159 | 161 |
160 static void texSize(int w, int h, int *texw, int *texh) { | 162 static void texSize(int w, int h, int *texw, int *texh) { |
161 if (use_rectangle) { | 163 if (use_rectangle) { |
162 *texw = w; *texh = h; | 164 *texw = w; *texh = h; |
503 | 505 |
504 static void check_events(void) | 506 static void check_events(void) |
505 { | 507 { |
506 int e=vo_check_events(); | 508 int e=vo_check_events(); |
507 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight); | 509 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight); |
508 if(e&VO_EVENT_EXPOSE && int_pause) flip_page(); | 510 if(e&VO_EVENT_EXPOSE && int_pause) redraw(); |
509 } | 511 } |
510 | 512 |
511 /** | 513 /** |
512 * Creates the textures and the display list needed for displaying | 514 * Creates the textures and the display list needed for displaying |
513 * an OSD part. | 515 * an OSD part. |
575 glEndList(); | 577 glEndList(); |
576 | 578 |
577 osdtexCnt++; | 579 osdtexCnt++; |
578 } | 580 } |
579 | 581 |
582 static void do_render_osd(void); | |
583 | |
580 static void draw_osd(void) | 584 static void draw_osd(void) |
581 { | 585 { |
582 if (!use_osd) return; | 586 if (!use_osd) return; |
583 if (vo_osd_changed(0)) { | 587 if (vo_osd_changed(0)) { |
584 int osd_h, osd_w; | 588 int osd_h, osd_w; |
585 clearOSD(); | 589 clearOSD(); |
586 osd_w = (scaled_osd) ? image_width : vo_dwidth; | 590 osd_w = (scaled_osd) ? image_width : vo_dwidth; |
587 osd_h = (scaled_osd) ? image_height : vo_dheight; | 591 osd_h = (scaled_osd) ? image_height : vo_dheight; |
588 vo_draw_text(osd_w, osd_h, create_osd_texture); | 592 vo_draw_text(osd_w, osd_h, create_osd_texture); |
589 } | 593 } |
594 if (vo_doublebuffering) do_render_osd(); | |
590 } | 595 } |
591 | 596 |
592 static void do_render(void) { | 597 static void do_render(void) { |
593 // glEnable(GL_TEXTURE_2D); | 598 // glEnable(GL_TEXTURE_2D); |
594 // glBindTexture(GL_TEXTURE_2D, texture_id); | 599 // glBindTexture(GL_TEXTURE_2D, texture_id); |
601 texture_width, texture_height, | 606 texture_width, texture_height, |
602 use_rectangle == 1, image_format == IMGFMT_YV12, | 607 use_rectangle == 1, image_format == IMGFMT_YV12, |
603 mpi_flipped ^ vo_flipped); | 608 mpi_flipped ^ vo_flipped); |
604 if (image_format == IMGFMT_YV12) | 609 if (image_format == IMGFMT_YV12) |
605 glDisableYUVConversion(gl_target, yuvconvtype); | 610 glDisableYUVConversion(gl_target, yuvconvtype); |
606 | 611 } |
612 | |
613 static void do_render_osd(void) { | |
607 if (osdtexCnt > 0 || eosdDispList) { | 614 if (osdtexCnt > 0 || eosdDispList) { |
608 // set special rendering parameters | 615 // set special rendering parameters |
609 if (!scaled_osd) { | 616 if (!scaled_osd) { |
610 glMatrixMode(GL_PROJECTION); | 617 glMatrixMode(GL_PROJECTION); |
611 glPushMatrix(); | 618 glPushMatrix(); |
634 BindTexture(gl_target, 0); | 641 BindTexture(gl_target, 0); |
635 } | 642 } |
636 } | 643 } |
637 | 644 |
638 static void flip_page(void) { | 645 static void flip_page(void) { |
639 do_render(); | |
640 if (vo_doublebuffering) { | 646 if (vo_doublebuffering) { |
641 if (use_glFinish) glFinish(); | 647 if (use_glFinish) glFinish(); |
642 swapGlBuffers(); | 648 swapGlBuffers(); |
643 if (vo_fs && use_aspect) | 649 if (vo_fs && use_aspect) |
644 glClear(GL_COLOR_BUFFER_BIT); | 650 glClear(GL_COLOR_BUFFER_BIT); |
645 } else { | 651 } else { |
652 do_render(); | |
653 do_render_osd(); | |
646 if (use_glFinish) glFinish(); | 654 if (use_glFinish) glFinish(); |
647 else glFlush(); | 655 else glFlush(); |
648 } | 656 } |
657 } | |
658 | |
659 static void redraw(void) { | |
660 if (vo_doublebuffering) { do_render(); do_render_osd(); } | |
661 flip_page(); | |
649 } | 662 } |
650 | 663 |
651 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num) | 664 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num) |
652 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) | 665 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) |
653 { | 666 { |
714 int slice = slice_height; | 727 int slice = slice_height; |
715 int stride[3]; | 728 int stride[3]; |
716 unsigned char *planes[3]; | 729 unsigned char *planes[3]; |
717 mp_image_t mpi2 = *mpi; | 730 mp_image_t mpi2 = *mpi; |
718 if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) | 731 if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) |
719 return VO_TRUE; | 732 goto skip_upload; |
720 mpi2.flags = 0; mpi2.type = MP_IMGTYPE_TEMP; | 733 mpi2.flags = 0; mpi2.type = MP_IMGTYPE_TEMP; |
721 mpi2.width = mpi2.w; mpi2.height = mpi2.h; | 734 mpi2.width = mpi2.w; mpi2.height = mpi2.h; |
722 if (force_pbo && !(mpi->flags & MP_IMGFLAG_DIRECT) && !gl_bufferptr && get_image(&mpi2) == VO_TRUE) { | 735 if (force_pbo && !(mpi->flags & MP_IMGFLAG_DIRECT) && !gl_bufferptr && get_image(&mpi2) == VO_TRUE) { |
723 int bpp = mpi->imgfmt == IMGFMT_YV12 ? 1 : mpi->bpp; | 736 int bpp = mpi->imgfmt == IMGFMT_YV12 ? 1 : mpi->bpp; |
724 memcpy_pic(mpi2.planes[0], mpi->planes[0], mpi->w * bpp, mpi->h, mpi2.stride[0], mpi->stride[0]); | 737 memcpy_pic(mpi2.planes[0], mpi->planes[0], mpi->w * bpp, mpi->h, mpi2.stride[0], mpi->stride[0]); |
754 mpi->x / 2, mpi->y / 2, mpi->w / 2, mpi->h / 2, slice); | 767 mpi->x / 2, mpi->y / 2, mpi->w / 2, mpi->h / 2, slice); |
755 ActiveTexture(GL_TEXTURE0); | 768 ActiveTexture(GL_TEXTURE0); |
756 } | 769 } |
757 if (mpi->flags & MP_IMGFLAG_DIRECT) | 770 if (mpi->flags & MP_IMGFLAG_DIRECT) |
758 BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); | 771 BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); |
772 skip_upload: | |
773 if (vo_doublebuffering) do_render(); | |
759 return VO_TRUE; | 774 return VO_TRUE; |
760 } | 775 } |
761 | 776 |
762 static int | 777 static int |
763 draw_frame(uint8_t *src[]) | 778 draw_frame(uint8_t *src[]) |