Ticket #101: xvmcosd-6.diff
File xvmcosd-6.diff, 57.1 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.cpp
1878 1878 dispx, dispy, dispw, disph); 1879 1879 1880 1880 if (kCodec_NORMAL_END < decoder->GetVideoCodecID() && 1881 kCodec_S PECIAL_END > decoder->GetVideoCodecID() &&1881 kCodec_STD_XVMC_END > decoder->GetVideoCodecID() && 1882 1882 (600 < video_height)) 1883 1883 { 1884 1884 osd->DisableFade(); -
libs/libmythtv/osd.h
121 121 OSDGenericTree *treeToShow); 122 122 123 123 void DisableFade(void); 124 bool HasPalette() { return hasPalette; } 125 const QValueList<QColor>& Palette() { return surfPalette; } 124 126 125 127 private: 126 128 void SetDefaults(); … … 149 151 void parsePositionImage(OSDSet *container, QDomElement &element); 150 152 void parseListTree(OSDSet *container, QDomElement &element); 151 153 154 void parsePalette(QDomElement &element); 155 152 156 int vid_width; 153 157 int vid_height; 154 158 int frameint; … … 178 182 OSDTypeImage *editarrowright; 179 183 QRect editarrowRect; 180 184 185 QString surftype; 186 QValueList<QColor> surfPalette; 187 bool hasPalette; 188 181 189 OSDSurface *drawSurface; 182 190 bool changed; 183 191 -
libs/libmythtv/osdtypes.cpp
14 14 15 15 #include "mythcontext.h" 16 16 17 #include <sys/time.h> 18 19 #ifdef TIMING 20 #include "timer.h" 21 22 int Timer::indent = 0; 23 Timer::Timer(const QString &title) 24 { 25 name = title; 26 gettimeofday(&start,NULL); 27 28 int i; 29 for (i=0;i<indent;i++) 30 cout << " "; 31 indent ++; 32 cout << name << " timing.." << endl; 33 } 34 35 Timer::~Timer() 36 { 37 struct timeval dur; 38 gettimeofday(&end,NULL); 39 40 timersub(&end, &start, &dur); 41 42 indent--; 43 int i; 44 for (i=0;i<indent;i++) 45 cout << " "; 46 47 cout << name << " time " << dur.tv_usec << endl; 48 } 49 50 void Timer::check(const QString &tag) 51 { 52 struct timeval dur,now; 53 gettimeofday(&now,NULL); 54 55 timersub(&now, &start, &dur); 56 57 int i; 58 for (i=0;i<indent;i++) 59 cout << " "; 60 cout << tag << " time " << dur.tv_usec << endl; 61 } 62 #endif 63 17 64 OSDSet::OSDSet(const QString &name, bool cache, int screenwidth, 18 65 int screenheight, float wmult, float hmult, int frint) 19 66 : QObject() … … 361 408 362 409 void OSDSet::Draw(OSDSurface *surface, bool actuallydraw) 363 410 { 411 #ifdef TIMING 412 Timer t("OSDSet::Draw"); 413 #endif 414 364 415 if (actuallydraw) 365 416 { 366 417 vector<OSDType *>::iterator i = allTypes->begin(); … … 437 488 438 489 OSDTypeText::OSDTypeText(const QString &name, TTFFont *font, 439 490 const QString &text, QRect displayrect) 440 : OSDType(name) 491 : OSDType(name),m_raster(0) 441 492 { 442 493 m_message = text; 443 494 m_default_msg = text; … … 457 508 m_scrollinit = false; 458 509 459 510 m_linespacing = 1.5; 511 512 m_message.replace(QRegExp("%BR%"), "\n"); 513 m_message.replace(QRegExp("\n")," \n "); 514 460 515 } 461 516 462 517 OSDTypeText::OSDTypeText(const OSDTypeText &other) 463 : OSDType(other.m_name) 518 : OSDType(other.m_name),m_raster(0) 464 519 { 465 520 m_displaysize = other.m_displaysize; 466 521 m_screensize = other.m_screensize; … … 480 535 481 536 OSDTypeText::~OSDTypeText() 482 537 { 538 if (m_raster) 539 { 540 TTFFont::destroy_font_raster(m_raster); 541 m_raster=0; 542 } 483 543 } 484 544 485 545 void OSDTypeText::SetAltFont(TTFFont *font) … … 489 549 490 550 void OSDTypeText::SetText(const QString &text) 491 551 { 552 if (m_raster) 553 { 554 TTFFont::destroy_font_raster(m_raster); 555 m_raster=0; 556 } 557 492 558 m_message = text; 493 559 m_scrollinit = false; 560 561 m_message.replace(QRegExp("%BR%"), "\n"); 562 m_message.replace(QRegExp("\n")," \n "); 494 563 } 495 564 496 565 void OSDTypeText::SetDefaultText(const QString &text) 497 566 { 567 if (m_raster) 568 { 569 TTFFont::destroy_font_raster(m_raster); 570 m_raster=0; 571 } 572 498 573 m_message = text; 499 574 m_default_msg = text; 500 575 m_scrollinit = false; 576 577 m_message.replace(QRegExp("%BR%"), "\n"); 578 m_message.replace(QRegExp("\n")," \n "); 501 579 } 502 580 503 581 void OSDTypeText::Reinit(float wchange, float hchange) 504 582 { 583 if (m_raster) 584 { 585 TTFFont::destroy_font_raster(m_raster); 586 m_raster=0; 587 } 588 505 589 int width = (int)(m_screensize.width() * wchange); 506 590 int height = (int)(m_screensize.height() * hchange); 507 591 int x = (int)(m_screensize.x() * wchange); … … 513 597 void OSDTypeText::Draw(OSDSurface *surface, int fade, int maxfade, int xoff, 514 598 int yoff) 515 599 { 600 #ifdef TIMING 601 Timer t("OSDTypeText::Draw"); 602 #endif 516 603 int textlength = 0; 517 604 518 605 if (m_message == QString::null) … … 524 611 if (m_scroller) 525 612 m_parent->SetDrawEveryFrame(true); 526 613 527 m_font->CalcWidth(m_message, &textlength);614 // m_font->CalcWidth(m_message, &textlength); 528 615 529 616 int maxlength = m_displaysize.width(); 530 617 531 618 if (m_multiline) 532 619 { 533 QString tmp_msg = m_message;534 tmp_msg.replace(QRegExp("%BR%"), "\n");535 tmp_msg.replace(QRegExp("\n")," \n ");620 // QString tmp_msg = m_message; 621 // tmp_msg.replace(QRegExp("%BR%"), "\n"); 622 // tmp_msg.replace(QRegExp("\n")," \n "); 536 623 537 QStringList wordlist = QStringList::split(" ", tmp_msg);624 QStringList wordlist = QStringList::split(" ", m_message); 538 625 int length = 0; 539 626 int lines = 0; 540 627 … … 652 739 const QString &text, int fade, int maxfade, 653 740 int xoff, int yoff) 654 741 { 742 #ifdef TIMING 743 Timer t("OSDTypeText::DrawString"); 744 #endif 745 655 746 if (m_centered || m_right) 656 747 { 657 748 int textlength = 0; … … 707 798 m_isvalid = false; 708 799 m_imagesize = QRect(0, 0, 0, 0); 709 800 801 m_i44 = NULL; 802 710 803 m_scalew = scalew; 711 804 m_scaleh = scaleh; 712 805 … … 728 821 m_scaleh = other.m_scaleh; 729 822 730 823 m_alpha = m_yuv = NULL; 824 m_i44 = NULL; 825 731 826 if (m_isvalid) 732 827 { 733 828 int size = m_imagesize.width() * m_imagesize.height() * 3 / 2; … … 743 838 m_ubuffer = m_yuv + (m_imagesize.width() * m_imagesize.height()); 744 839 m_vbuffer = m_yuv + (m_imagesize.width() * m_imagesize.height() * 745 840 5 / 4); 746 } 841 842 //I44 843 m_i44 = new unsigned char[size]; 844 memcpy(m_i44, other.m_i44, size); 845 } 747 846 } 748 847 749 848 OSDTypeImage::OSDTypeImage(const QString &name) … … 761 860 m_vbuffer = NULL; 762 861 m_isvalid = false; 763 862 m_filename = ""; 863 864 m_i44 = NULL; 764 865 } 765 866 766 867 OSDTypeImage::OSDTypeImage(void) … … 779 880 m_vbuffer = NULL; 780 881 m_isvalid = false; 781 882 m_filename = ""; 883 884 m_i44 = NULL; 782 885 } 783 886 784 887 OSDTypeImage::~OSDTypeImage() … … 787 890 delete [] m_yuv; 788 891 if (m_alpha) 789 892 delete [] m_alpha; 893 894 if (m_i44) 895 delete [] m_i44; 790 896 } 791 897 792 898 void OSDTypeImage::SetName(const QString &name) … … 805 911 LoadImage(m_filename, wmult, hmult, m_scalew, m_scaleh); 806 912 } 807 913 914 void rgb32_to_i44(unsigned char*i44, unsigned char*rgb, int width, int height, int srcwidth) 915 { 916 int wrap, wrap4, x, y; 917 unsigned char *p; 918 unsigned char ch,r,g,b; 919 920 printf("rgb32_to_i44\n"); 921 922 p = rgb; 923 924 for (y=0; y<height; y++) 925 { 926 unsigned char *pstart=p; 927 928 for (x=0; x<width; x++) 929 { 930 931 // 0 0 0 0 . . . . // alpha 932 // . . . . 0 x x x // greys 933 // . . . . 1 0 0 0 // 934 // . . . . 1 0 0 1 // red 935 // . . . . 1 0 1 0 // green 936 // . . . . 1 0 1 1 // yellow 937 // . . . . 1 1 0 0 // blue 938 // . . . . 1 1 0 1 // magen 939 // . . . . 1 1 1 0 // cyan 940 // . . . . 1 1 1 1 // 941 942 ch = (p[3] >> 4) & 0x0f; //trunc alpha 943 r=p[2]; g=p[1]; b=p[0]; 944 945 if ((r == g) && (g == b)) //lets have 8 greys 946 { 947 ch |= ((r>>1) & 0x70); 948 // ch |= 0x0b; 949 } 950 else // ok now try and grab colours 951 { // trivial func for now. 952 ch |= 0x80; 953 if (r>128) ch |= 0x10; 954 if (g>128) ch |= 0x20; 955 if (b>128) ch |= 0x40; 956 } 957 958 *(i44+x+y*width) = ch; 959 960 p+=4; 961 } 962 963 p=pstart+srcwidth*4; 964 965 } 966 } 967 808 968 void OSDTypeImage::LoadImage(const QString &filename, float wmult, float hmult, 809 969 int scalew, int scaleh) 810 970 { … … 815 975 if (m_alpha) 816 976 delete [] m_alpha; 817 977 978 if (m_i44) 979 delete [] m_i44; 980 818 981 m_isvalid = false; 819 982 m_yuv = NULL; 820 983 m_alpha = NULL; 984 985 m_i44 = NULL; 821 986 } 822 987 823 988 if (filename.length() < 2) … … 856 1021 857 1022 m_alpha = new unsigned char[imwidth * imheight]; 858 1023 1024 m_i44 = new unsigned char[imwidth*imheight]; 1025 1026 printf("yuv convert\n"); 1027 859 1028 rgb32_to_yuv420p(m_ybuffer, m_ubuffer, m_vbuffer, m_alpha, tmp2.bits(), 860 1029 imwidth, imheight, tmp2.width()); 861 1030 1031 rgb32_to_i44(m_i44, tmp2.bits(), imwidth, imheight, tmp2.width()); 1032 862 1033 m_imagesize = QRect(0, 0, imwidth, imheight); 863 1034 } 864 1035 … … 871 1042 if (m_alpha) 872 1043 delete [] m_alpha; 873 1044 1045 if (m_i44) 1046 delete[] m_i44; 1047 874 1048 m_isvalid = false; 875 1049 m_yuv = NULL; 876 1050 m_alpha = NULL; 1051 m_i44 = NULL; 877 1052 } 878 1053 879 1054 m_isvalid = true; … … 888 1063 889 1064 m_alpha = new unsigned char[imwidth * imheight]; 890 1065 1066 m_i44 = new unsigned char[imwidth*imheight]; 1067 891 1068 rgb32_to_yuv420p(m_ybuffer, m_ubuffer, m_vbuffer, m_alpha, img.bits(), 892 1069 imwidth, imheight, img.width()); 893 1070 1071 rgb32_to_i44(m_i44, img.bits(), imwidth, imheight, img.width()); 894 1072 m_imagesize = QRect(0, 0, imwidth, imheight); 895 1073 } 896 1074 897 void OSDTypeImage::Draw(OSDSurface *surface, int fade, int maxfade, int xoff, 1075 void OSDTypeImage::Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff) 1076 { 1077 #ifdef TIMING 1078 Timer t("OSDTypeImage::Draw"); 1079 #endif 1080 1081 if (surface->SurfaceType()==OSDSurface::SURF_YUV) 1082 Draw((YUVSurface*)surface,fade,maxfade,xoff,yoff); 1083 else if (surface->SurfaceType()==OSDSurface::SURF_I44) 1084 Draw((I44Surface*)surface,fade,maxfade,xoff,yoff); 1085 } 1086 1087 void OSDTypeImage::Draw(I44Surface *surface, int fade, int maxfade, int xoff, 898 1088 int yoff) 899 1089 { 900 1090 if (!m_isvalid) … … 902 1092 903 1093 unsigned char *dest, *destalpha, *src, *srcalpha; 904 1094 unsigned char *udest, *vdest, *usrc, *vsrc; 1095 int alpha, iwidth, width; 1096 1097 iwidth = width = m_imagesize.width(); 1098 int height = m_imagesize.height(); 1099 1100 if (m_drawwidth >= 0) 1101 width = m_drawwidth; 1102 1103 int ystart = m_displaypos.y(); 1104 int xstart = m_displaypos.x(); 1105 1106 xstart += xoff; 1107 ystart += yoff; 1108 1109 ystart = (ystart / 2) * 2; 1110 xstart = ((xstart + 1) / 2) * 2; 1111 1112 int startline = 0; 1113 int startcol = 0; 1114 1115 if (ystart < 0) 1116 { 1117 startline = 0 - ystart; 1118 ystart = 0; 1119 } 1120 1121 if (xstart < 0) 1122 { 1123 startcol = 0 - xstart; 1124 xstart = 0; 1125 } 1126 1127 if (height + ystart > surface->height) 1128 height = surface->height - ystart - 1; 1129 if (width + xstart > surface->width) 1130 width = surface->width - xstart - 1; 1131 1132 if (width == 0 || height == 0) 1133 { 1134 printf("zeros\n"); 1135 return; 1136 } 1137 1138 1139 QRect destRect = QRect(xstart, ystart, width, height); 1140 bool needblend = false; 1141 1142 if (m_onlyusefirst || surface->IntersectsDrawn(destRect)) 1143 needblend = true; 1144 surface->AddRect(destRect); 1145 1146 int ysrcwidth; 1147 int ydestwidth; 1148 1149 int uvsrcwidth; 1150 int uvdestwidth; 1151 1152 int alphamod = 0xf; 1153 1154 1155 if (maxfade > 0 && fade >= 0) 1156 alphamod = (int)((((float)(fade) / maxfade) * 16.0) + 0.5); 1157 1158 unsigned char almap[256]; 1159 { 1160 for (int i=0; i<256; i++) 1161 { 1162 almap[i] = ( i & 0xf0)|((((i & 0xf) * alphamod)>>4)&0xf); 1163 } 1164 } 1165 unsigned char *dst; 1166 1167 src = m_i44; 1168 dst = surface->i44buffer + xstart + (ystart)*surface->width; 1169 1170 unsigned long *ldst = (unsigned long*)dst; 1171 1172 { 1173 for (int y = startline; y < height; y++) 1174 { 1175 unsigned long *lsrc = (unsigned long*)(src+(y*iwidth)); 1176 for (int x = startcol/4; x < width/4; x++) 1177 { 1178 unsigned long sch = lsrc[x]; 1179 unsigned long dsh = 1180 almap[sch>>24]<<24 | 1181 almap[sch>>16 & 0xff] << 16 | 1182 almap[sch>>8 & 0xff] << 8 | 1183 almap[sch&0xff]; 1184 1185 ldst[x] = (ldst[x] & 0x0f0f0f0f) | dsh; 1186 1187 /* unsigned char ch = (alphamod & 0xf0) | (*(m_ubuffer+(x/2)+ysrcwidth) & 0x0f) ; 1188 *(surface->i44buffer + x +xstart+ ydestwidth) = ch; 1189 */ 1190 } 1191 ldst+=surface->width/4; 1192 } 1193 } 1194 return; 1195 1196 } 1197 void OSDTypeImage::Draw(YUVSurface *surface, int fade, int maxfade, int xoff, 1198 int yoff) 1199 { 1200 if (!m_isvalid) 1201 return; 1202 1203 unsigned char *dest, *destalpha, *src, *srcalpha; 1204 unsigned char *udest, *vdest, *usrc, *vsrc; 905 1205 int alpha, iwidth, drawwidth; 906 1206 907 1207 iwidth = drawwidth = m_imagesize.width(); … … 1282 1582 1283 1583 void OSDTypeEditSlider::Draw(OSDSurface *surface, int fade, int maxfade, 1284 1584 int xoff, int yoff) 1585 { 1586 if (surface->SurfaceType()==OSDSurface::SURF_YUV) 1587 Draw((YUVSurface*)surface,fade,maxfade,xoff,yoff); 1588 // else if (surface->SurfaceType()==OSDSurface::SURF_I44) 1589 // Draw((I44Surface*)surface,fade,maxfade,xoff,yoff); 1590 } 1591 void OSDTypeEditSlider::Draw(YUVSurface *surface, int fade, int maxfade, 1592 int xoff, int yoff) 1285 1593 { 1286 1594 if (!m_isvalid || !m_risvalid) 1287 1595 return; … … 1405 1713 void OSDTypeBox::Draw(OSDSurface *surface, int fade, int maxfade, int xoff, 1406 1714 int yoff) 1407 1715 { 1716 #ifdef TIMING 1717 Timer t("OSDTypeBox::Draw"); 1718 #endif 1719 1720 if (surface->SurfaceType()==OSDSurface::SURF_YUV) 1721 Draw((YUVSurface*)surface,fade,maxfade,xoff,yoff); 1722 else if (surface->SurfaceType()==OSDSurface::SURF_I44) 1723 Draw((I44Surface*)surface,fade,maxfade,xoff,yoff); 1724 } 1725 1726 void OSDTypeBox::Draw(I44Surface *surface, int fade, int maxfade, int xoff, 1727 int yoff) 1728 { 1408 1729 unsigned char *dest, *destalpha; 1409 1730 unsigned char alpha = 192; 1731 unsigned char targ; 1410 1732 1411 1733 QRect disprect = size; 1412 1734 disprect.moveBy(xoff, yoff); … … 1427 1749 1428 1750 int height = yend - ystart + 1, width = xend - xstart + 1; 1429 1751 1752 QRect destRect = QRect(xstart, ystart, width, height); 1753 bool needblend = false; 1754 1755 if (surface->IntersectsDrawn(destRect)) 1756 needblend = true; 1757 surface->AddRect(destRect); 1758 1759 int alphamod = 255; 1760 if (maxfade > 0 && fade >= 0) 1761 alphamod = (int)((((float)(fade) / maxfade) * 16.0) + 0.5); 1762 1763 int ydestwidth; 1764 1765 alpha = ((alpha * alphamod) + 0x8); 1766 1767 targ = 0 | (alpha & 0xf); //black 1768 //targ=0xf3; 1769 1770 for (int y = ystart; y < yend; y++) 1771 { 1772 ydestwidth = y * surface->width; 1773 memset(surface->i44buffer + xstart + ydestwidth, targ , width); 1774 } 1775 } 1776 1777 void OSDTypeBox::Draw(YUVSurface *surface, int fade, int maxfade, int xoff, 1778 int yoff) 1779 { 1780 unsigned char *dest, *destalpha; 1781 unsigned char alpha = 192; 1782 1783 QRect disprect = size; 1784 disprect.moveBy(xoff, yoff); 1785 1786 int ystart = disprect.top(); 1787 int yend = disprect.bottom(); 1788 int xstart = disprect.left(); 1789 int xend = disprect.right(); 1790 1791 if (xstart < 0) 1792 xstart = 0; 1793 if (xend > surface->width) 1794 xend = surface->width; 1795 if (ystart < 0) 1796 ystart = 0; 1797 if (yend > surface->height) 1798 yend = surface->height; 1799 1800 int height = yend - ystart + 1, width = xend - xstart + 1; 1801 1430 1802 QRect destRect = QRect(xstart, ystart, width, height); 1431 1803 bool needblend = false; 1432 1804 … … 1549 1921 positions.push_back(rect); 1550 1922 m_numpositions++; 1551 1923 } 1552 1553 1924 void OSDTypePositionRectangle::Draw(OSDSurface *surface, int fade, int maxfade, 1554 1925 int xoff, int yoff) 1555 1926 { 1927 #ifdef TIMING 1928 Timer t("OSDTypePositionRectangle::Draw"); 1929 #endif 1930 1931 if (surface->SurfaceType()==OSDSurface::SURF_YUV) 1932 Draw((YUVSurface*)surface,fade,maxfade,xoff,yoff); 1933 else if (surface->SurfaceType()==OSDSurface::SURF_I44) 1934 Draw((I44Surface*)surface,fade,maxfade,xoff,yoff); 1935 } 1936 1937 void OSDTypePositionRectangle::Draw(YUVSurface *surface, int fade, int maxfade, 1938 int xoff, int yoff) 1939 { 1556 1940 fade = fade; 1557 1941 maxfade = maxfade; 1558 1942 xoff = xoff; … … 1622 2006 } 1623 2007 } 1624 2008 2009 2010 void OSDTypePositionRectangle::Draw(I44Surface *surface, int fade, int maxfade, 2011 int xoff, int yoff) 2012 { 2013 fade = fade; 2014 maxfade = maxfade; 2015 xoff = xoff; 2016 yoff = yoff; 2017 2018 if (m_curposition < 0 || m_curposition >= m_numpositions) 2019 return; 2020 2021 QRect rect = positions[m_curposition]; 2022 2023 unsigned char *src; 2024 int ystart = rect.top(); 2025 int yend = rect.bottom(); 2026 int xstart = rect.left(); 2027 int xend = rect.right(); 2028 2029 int height = yend - ystart + 1, width = xend - xstart + 1; 2030 2031 QRect destRect = QRect(xstart, ystart, width, height); 2032 surface->AddRect(destRect); 2033 2034 2035 for (int y = ystart; y < yend; y++) 2036 { 2037 if (y < 0 || y >= surface->height) 2038 continue; 2039 2040 for (int x = xstart; x < xstart + 2; x++) 2041 { 2042 if (x < 0 || x >= surface->width) 2043 continue; 2044 2045 src = surface->i44buffer + x + y * surface->width; 2046 *src = 0xaa; //white 2047 } 2048 2049 for (int x = xend - 2; x < xend; x++) 2050 { 2051 if (x < 0 || x >= surface->width) 2052 continue; 2053 2054 src = surface->i44buffer + x + y * surface->width; 2055 *src = 0xaa; //white 2056 } 2057 } 2058 2059 for (int x = xstart; x < xend; x++) 2060 { 2061 if (x < 0 || x >= surface->width) 2062 continue; 2063 2064 for (int y = ystart; y < ystart + 2; y++) 2065 { 2066 if (y < 0 || y >= surface->height) 2067 continue; 2068 2069 src = surface->i44buffer + x + y * surface->width; 2070 *src = 0xaa; 2071 } 2072 for (int y = yend - 2; y < yend; y++) 2073 { 2074 if (y < 0 || y >= surface->height) 2075 continue; 2076 2077 src = surface->i44buffer + x + y * surface->width; 2078 *src = 0xaa; 2079 } 2080 } 2081 } 2082 1625 2083 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1626 2084 1627 2085 OSDTypePositionImage::OSDTypePositionImage(const QString &name) -
libs/libmythtv/videooutbase.cpp
1105 1105 if (!osd) 1106 1106 return -1; 1107 1107 1108 OSDSurface * surface= osd->Display();1109 if (! surface)1108 OSDSurface *osdsurf = osd->Display(); 1109 if (!osdsurf) 1110 1110 return -1; 1111 1111 1112 1112 bool changed = (-1 == revision) ? 1113 surface->Changed() : (surface->GetRevision()!=revision);1113 osdsurf->Changed() : (osdsurf->GetRevision()!=revision); 1114 1114 1115 if (osdsurf->SurfaceType() == OSDSurface::SURF_YUV) 1116 { 1117 YUVSurface *surface = (YUVSurface*)osdsurf; 1118 1115 1119 switch (frame->codec) 1116 1120 { 1117 1121 case FMT_YV12: … … 1146 1150 default: 1147 1151 break; 1148 1152 } 1153 } 1154 else if (osdsurf->SurfaceType() == OSDSurface::SURF_I44) 1155 { 1156 I44Surface* surface=(I44Surface*)osdsurf; 1157 1158 if (changed) 1159 surface->BlendToI44( frame->buf, false, stride, XJ_height); 1160 } 1161 1149 1162 return (changed) ? 1 : 0; 1150 1163 } 1151 1164 -
libs/libmythtv/osdtypes.h
14 14 class TTFFont; 15 15 class OSDType; 16 16 class OSDSurface; 17 class YUVSurface; 18 class I44Surface; 17 19 class TV; 18 20 21 struct Raster_Map; 22 19 23 class OSDSet : public QObject 20 24 { 21 25 Q_OBJECT … … 212 216 bool m_scrollinit; 213 217 214 218 float m_linespacing; 219 220 Raster_Map *m_raster; 215 221 }; 216 222 217 223 class OSDTypeImage : public OSDType … … 245 251 246 252 virtual void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, 247 253 int yoff); 254 void Draw(YUVSurface *surface, int fade, int maxfade, int xoff, 255 int yoff); 256 void Draw(I44Surface *surface, int fade, int maxfade, int xoff, 257 int yoff); 248 258 249 259 protected: 250 260 QRect m_imagesize; … … 261 271 262 272 unsigned char *m_alpha; 263 273 274 unsigned char *m_i44; 275 264 276 int m_scalew, m_scaleh; 277 float m_wmult, m_hmult; 265 278 266 279 int m_drawwidth; 267 280 bool m_onlyusefirst; … … 331 344 void SetRange(int start, int end); 332 345 333 346 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff); 347 void Draw(YUVSurface *surface, int fade, int maxfade, int xoff, int yoff); 348 void Draw(I44Surface *surface, int fade, int maxfade, int xoff, int yoff); 334 349 335 350 private: 336 351 QRect m_displayrect; … … 363 378 void SetRect(QRect newrect) { size = newrect; } 364 379 365 380 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff); 381 void Draw(YUVSurface *surface, int fade, int maxfade, int xoff, int yoff); 382 void Draw(I44Surface *surface, int fade, int maxfade, int xoff, int yoff); 366 383 367 384 private: 368 385 QRect size; … … 403 420 void Reinit(float wchange, float hchange); 404 421 405 422 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff); 423 void Draw(YUVSurface *surface, int fade, int maxfade, int xoff, int yoff); 424 void Draw(I44Surface *surface, int fade, int maxfade, int xoff, int yoff); 406 425 407 426 private: 408 427 vector<QRect> positions; -
libs/libmythtv/videoout_xv.cpp
2415 2415 XvMCOSD* xvmc_osd = GetAvailableOSD(); 2416 2416 if (osd && xvmc_osd->IsValid()) 2417 2417 { 2418 if (osd->HasPalette() && 2419 !xvmc_osd->CustomPalette()) 2420 { 2421 VERBOSE(VB_IMPORTANT, "Setting palette"); 2422 xvmc_osd->SetPalette(osd->Palette()); 2423 } 2424 2418 2425 VideoFrame *osdframe = NULL; 2419 2426 int ret = DisplayOSD(xvmc_osd->OSDFrame(), osd, -1, 2420 2427 xvmc_osd->GetRevision()); -
libs/libmythtv/osdxvmc.h
28 28 void DeleteBuffer(); 29 29 void CompositeOSD(VideoFrame* frame, VideoFrame* osdframe=NULL); 30 30 31 void SetPalette( const QValueList<QColor> &palette ); 32 bool CustomPalette() { return custompalette; } 33 31 34 VideoFrame *OSDFrame() 32 35 { 33 36 tmpframe.codec = … … 55 58 int osd_subpict_clear_color; 56 59 bool osd_subpict_alloc; 57 60 61 bool custompalette; 58 62 VideoFrame tmpframe; 59 63 int revision; 60 64 }; -
libs/libmythtv/osdxvmc.cpp
25 25 : XJ_disp(disp), XJ_width(0), XJ_height(0), 26 26 xv_port(port), osd_palette(NULL), osd_xv_image(NULL), 27 27 osd_subpict_mode(NO_SUBPICTURE), osd_subpict_clear_color(0), 28 osd_subpict_alloc(false) 28 osd_subpict_alloc(false), 29 custompalette(false) 29 30 { 30 31 // subpicture init 31 32 int num = 0; … … 50 51 51 52 void XvMCOSD::CreateBuffer(XvMCContext &xvmc_ctx, int width, int height) 52 53 { 54 VERBOSE(VB_IMPORTANT, "XvMCOSD::CreateBuffer"); 55 53 56 if (NO_SUBPICTURE == osd_subpict_mode) 54 57 { 55 58 VERBOSE(VB_IMPORTANT, "XvMCOSD::CreateBuffer() failed because " … … 131 134 osd_subpict_alloc = true; 132 135 } 133 136 137 void XvMCOSD::SetPalette( const QValueList<QColor> &palette ) 138 { 139 int i; 140 custompalette=true; 141 int entries = palette.count(); 142 143 VERBOSE(VB_PLAYBACK, QString("SetPalette entries %1").arg(entries)); 144 145 if (entries > osd_subpict.num_palette_entries) 146 entries = osd_subpict.num_palette_entries; 147 int seb = osd_subpict.entry_bytes; 148 149 for (i=0; i<entries; i++) 150 { 151 int r=palette[i].red(); 152 int g=palette[i].green(); 153 int b=palette[i].blue(); 154 155 int Y = (int)((0.257*r)+(0.504*g)+(0.098*b)+16); 156 int U = (int)(-(0.148*r)-(0.291*g)+(0.439*b)+128); 157 int V = (int)((0.439*r)-(0.368*g)-(0.071*b)+128); 158 159 VERBOSE(VB_PLAYBACK, 160 QString("Colour: Y=%1 U=%1 V=%1" ).arg(Y).arg(U).arg(V)); 161 162 for (int j = 0; j < seb; j++) 163 { 164 switch (osd_subpict.component_order[j]) 165 { 166 case 'U': osd_palette[i * seb + j] = U; break; 167 case 'V': osd_palette[i * seb + j] = V; break; 168 case 'Y': 169 default: osd_palette[i * seb + j] = Y; break; 170 } 171 } 172 } 173 174 X11S(XvMCSetSubpicturePalette(XJ_disp, &osd_subpict, osd_palette)); 175 } 176 134 177 void XvMCOSD::DeleteBuffer() 135 178 { 136 179 if (!osd_subpict_alloc) -
libs/libmythtv/osdsurface.cpp
150 150 151 151 OSDSurface::OSDSurface(int w, int h) 152 152 { 153 width = w; 154 height = h; 155 156 size = width * height; 157 158 Clear(); 159 } 160 161 OSDSurface::~OSDSurface() 162 { 163 } 164 165 void OSDSurface::Clear(void) 166 { 167 usedRegions = QRegion(); 168 } 169 170 void OSDSurface::ClearUsed(void) 171 { 172 } 173 174 bool OSDSurface::IntersectsDrawn(QRect &newrect) 175 { 176 QMemArray<QRect> rects = usedRegions.rects(); 177 QMemArray<QRect>::Iterator it = rects.begin(); 178 for (; it != rects.end(); ++it) 179 if (newrect.intersects(*it)) 180 return true; 181 return false; 182 } 183 184 void OSDSurface::AddRect(QRect &newrect) 185 { 186 usedRegions = usedRegions.unite(newrect); 187 } 188 189 YUVSurface::YUVSurface(int w, int h) : OSDSurface(w,h) 190 { 153 191 yuvbuffer = new unsigned char[w * h * 3 / 2]; 154 192 y = yuvbuffer; 155 193 u = yuvbuffer + w * h; 156 194 v = u + w * h / 4; 157 195 alpha = new unsigned char[w * h]; 158 196 159 width = w;160 height = h;161 162 size = width * height;163 164 197 for (int i = 0; i < 256; i++) 165 198 { 166 199 for (int j = 0; j < 256; j++) … … 209 242 revision = 0; 210 243 } 211 244 212 OSDSurface::~OSDSurface()245 YUVSurface::~YUVSurface() 213 246 { 214 247 delete [] yuvbuffer; 215 248 delete [] alpha; 216 249 } 217 250 218 void OSDSurface::Clear(void)251 void YUVSurface::Clear(void) 219 252 { 220 253 memset(y, 0, size); 221 254 memset(u, 127, size / 4); 222 255 memset(v, 127, size / 4); 223 256 memset(alpha, 0, size); 224 usedRegions = QRegion(); 257 258 OSDSurface::Clear(); 225 259 } 226 260 227 void OSDSurface::ClearUsed(void)261 void YUVSurface::ClearUsed(void) 228 262 { 229 263 QMemArray<QRect> rects = usedRegions.rects(); 230 264 QMemArray<QRect>::Iterator it = rects.begin(); … … 259 293 } 260 294 261 295 usedRegions = QRegion(); 296 297 OSDSurface::Clear(); 262 298 } 263 299 264 bool OSDSurface::IntersectsDrawn(QRect &newrect)265 {266 QMemArray<QRect> rects = usedRegions.rects();267 QMemArray<QRect>::Iterator it = rects.begin();268 for (; it != rects.end(); ++it)269 if (newrect.intersects(*it))270 return true;271 return false;272 }273 300 274 void OSDSurface::AddRect(QRect &newrect)275 {276 usedRegions = usedRegions.unite(newrect);277 }278 279 301 /////////////////////////////////////////////////////////////////////////// 280 302 // Helper functions 281 303 /////////////////////////////////////////////////////////////////////////// … … 383 405 } 384 406 #endif 385 407 386 blendtoyv12_8_fun blendtoyv12_8_init(const OSDSurface *surface)408 blendtoyv12_8_fun blendtoyv12_8_init(const YUVSurface *surface) 387 409 { 388 410 (void)surface; 389 411 #ifdef MMX … … 393 415 return blendalpha8_c; 394 416 } 395 417 396 static inline void blendtoargb_8_c(const OSDSurface *surf, unsigned char *src,418 static inline void blendtoargb_8_c(const YUVSurface *surf, unsigned char *src, 397 419 unsigned char *usrc, unsigned char *vsrc, 398 420 unsigned char *alpha, unsigned char *dest) 399 421 { … … 415 437 416 438 #ifdef MMX 417 439 #define movntq(src, dest) movq_r2m(src, dest); 418 static inline void blendtoargb_8_mmx( const OSDSurface * /*surf*/, unsigned char *src,440 static inline void blendtoargb_8_mmx(YUVSurface * /*surf*/, unsigned char *src, 419 441 unsigned char *usrc, unsigned char *vsrc, 420 442 unsigned char *alpha, unsigned char *dest) 421 443 { … … 510 532 } 511 533 #endif 512 534 513 blendtoargb_8_fun blendtoargb_8_init(const OSDSurface *surface)535 blendtoargb_8_fun blendtoargb_8_init(const YUVSurface *surface) 514 536 { 515 537 (void)surface; 516 538 #ifdef MMX … … 626 648 } 627 649 #endif 628 650 629 dithertoia44_8_fun dithertoia44_8_init(const OSDSurface* /*surface*/)651 dithertoia44_8_fun dithertoia44_8_init(const YUVSurface* /*surface*/) 630 652 { 631 653 #ifdef MMX 632 654 // mmx version seems to be about the same speed, no reason to use it. … … 675 697 delete context; 676 698 } 677 699 678 /** \fn OSDSurface::BlendToYV12(unsigned char *) const679 * \brief Alpha blends OSDSurface to yuv buffer of the same size.700 /** \fn YUVSurface::BlendToYV12(unsigned char *) const 701 * \brief Alpha blends YUVSurface to yuv buffer of the same size. 680 702 * \param yuvptr Pointer to YUV buffer to blend OSD to. 681 703 */ 682 void OSDSurface::BlendToYV12(unsigned char *yuvptr) const704 void YUVSurface::BlendToYV12(unsigned char *yuvptr) const 683 705 { 684 const OSDSurface *surface = this;706 const YUVSurface *surface = this; 685 707 blendtoyv12_8_fun blender = blendtoyv12_8_init(surface); 686 708 687 709 unsigned char *uptrdest = yuvptr + surface->width * surface->height; … … 790 812 } 791 813 } 792 814 793 /** \fn OSDSurface::BlendToARGB(unsigned char *,uint,uint,bool) const794 * \brief Alpha blends OSDSurface to ARGB buffer.815 /** \fn YUVSurface::BlendToARGB(unsigned char *,uint,uint,bool) const 816 * \brief Alpha blends YUVSurface to ARGB buffer. 795 817 * 796 818 * \todo Currently blend_to_black is implemented as a post process 797 819 * on the whole frame, it would make sense to make this more … … 801 823 * \param height Number of lines in output buffer 802 824 * \param blend_to_black Uses Alpha to blend buffer to black 803 825 */ 804 void OSDSurface::BlendToARGB(unsigned char *argbptr, uint stride, uint height,826 void YUVSurface::BlendToARGB(unsigned char *argbptr, uint stride, uint height, 805 827 bool blend_to_black) const 806 828 { 807 const OSDSurface *surface = this;829 const YUVSurface *surface = this; 808 830 blendtoargb_8_fun blender = blendtoargb_8_init(surface); 809 831 const unsigned char *cm = surface->cm; 810 832 … … 876 898 BlendToBlack(argbptr, stride>>2, height); 877 899 } 878 900 879 /** \fn OSDSurface::DitherToI44(unsigned char*,bool,uint,uint) const880 * \brief Copies and converts OSDSurface to either a greyscale901 /** \fn YUVSurface::DitherToI44(unsigned char*,bool,uint,uint) const 902 * \brief Copies and converts YUVSurface to either a greyscale 881 903 * IA44 or AI44 buffer. 882 904 * \sa DitherToIA44(unsigned char*,uint,uint) const, 883 905 * DitherToAI44(unsigned char*,uint,uint) const. … … 887 909 * \param stride Length of each line in output buffer in bytes 888 910 * \param height Number of lines in output buffer 889 911 */ 890 void OSDSurface::DitherToI44(unsigned char *outbuf, bool ifirst,912 void YUVSurface::DitherToI44(unsigned char *outbuf, bool ifirst, 891 913 uint stride, uint height) const 892 914 { 893 const OSDSurface *surface = this;915 const YUVSurface *surface = this; 894 916 int ashift = ifirst ? 0 : 4; 895 917 int amask = ifirst ? 0x0f : 0xf0; 896 918 … … 970 992 delete_dithertoia44_8_context(dcontext); 971 993 } 972 994 973 /** \fn OSDSurface::DitherToIA44(unsigned char*,uint,uint) const974 * \brief Copies and converts OSDSurface to a greyscale IA44 buffer.995 /** \fn YUVSurface::DitherToIA44(unsigned char*,uint,uint) const 996 * \brief Copies and converts YUVSurface to a greyscale IA44 buffer. 975 997 * 976 998 * \param outbuf Output buffer 977 999 * \param stride Length of each line in output buffer in bytes … … 979 1001 * \sa DitherToI44(unsigned char*,bool,uint,uint) const, 980 1002 * DitherToAI44(unsigned char*,uint,uint) const. 981 1003 */ 982 void OSDSurface::DitherToIA44(unsigned char* outbuf,1004 void YUVSurface::DitherToIA44(unsigned char* outbuf, 983 1005 uint stride, uint height) const 984 1006 { 985 1007 DitherToI44(outbuf, false, stride, height); 986 1008 } 987 1009 988 /** \fn OSDSurface::DitherToAI44(unsigned char*,bool,uint,uint) const989 * \brief Copies and converts OSDSurface to a greyscale AI44 buffer.1010 /** \fn YUVSurface::DitherToAI44(unsigned char*,bool,uint,uint) const 1011 * \brief Copies and converts YUVSurface to a greyscale AI44 buffer. 990 1012 * 991 1013 * \param outbuf Output buffer 992 1014 * \param stride Length of each line in output buffer in bytes … … 994 1016 * \sa DitherToI44(unsigned char*,bool,uint,uint) const, 995 1017 * DitherToIA44(unsigned char*,uint,uint) const. 996 1018 */ 997 void OSDSurface::DitherToAI44(unsigned char* outbuf,1019 void YUVSurface::DitherToAI44(unsigned char* outbuf, 998 1020 uint stride, uint height) const 999 1021 { 1000 1022 DitherToI44(outbuf, true, stride, height); 1001 1023 } 1024 1025 1026 I44Surface::I44Surface(int w, int h): OSDSurface(w,h) 1027 { 1028 printf("I44Surface - %d, %d\n",w,h); 1029 i44buffer = new unsigned char [w*h]; 1030 Clear(); 1031 } 1032 1033 I44Surface::~I44Surface() 1034 { 1035 delete [] i44buffer; 1036 } 1037 1038 void I44Surface::Clear(void) 1039 { 1040 memset(i44buffer, 0, size); 1041 1042 OSDSurface::Clear(); 1043 } 1044 1045 void I44Surface::ClearUsed(void) 1046 { 1047 memset(i44buffer, 0, size); 1048 OSDSurface::Clear(); 1049 } 1050 1051 void I44Surface::BlendToI44( unsigned char *i44ptr, bool ifirst, uint stride, uint height) const 1052 { 1053 printf("BlendToI44 %d\n", size); 1054 memcpy(i44ptr, i44buffer, size);//stride * XJ_height); 1055 } -
libs/libmythtv/ttfont.cpp
31 31 #include "osdtypes.h" 32 32 #include "osdsurface.h" 33 33 34 #include <sys/time.h> 35 36 #ifdef TIMING 37 #include "timer.h" 38 #endif 39 34 40 static int have_library = 0; 35 41 static FT_Library the_library; 36 42 37 43 #define FT_VALID(handle) ((handle) && (handle)->clazz != NULL) 38 44 45 /* 39 46 struct Raster_Map 40 47 { 41 48 int width; … … 44 51 int size; 45 52 unsigned char *bitmap; 46 53 }; 54 */ 47 55 48 56 void TTFFont::setColor(int color) 49 57 { 50 58 color %= 256; 59 m_color_normal = color; 51 60 m_color_normal_y = color; 52 61 m_color_normal_u = m_color_normal_v = 128; 53 62 … … 80 89 m_color_normal_y = (uint8_t)(y); 81 90 m_color_normal_u = (uint8_t)(127 + u); 82 91 m_color_normal_v = (uint8_t)(127 + v); 92 m_color_normal = k; 83 93 break; 84 94 85 95 case kTTF_Outline: 86 96 m_color_outline_y = (uint8_t)(y); 87 97 m_color_outline_u = (uint8_t)(127 + u); 88 98 m_color_outline_v = (uint8_t)(127 + v); 99 m_color_outline = k; 89 100 break; 90 101 91 102 case kTTF_Shadow: 92 103 m_color_shadow_y = (uint8_t)(y); 93 104 m_color_shadow_u = (uint8_t)(127 + u); 94 105 m_color_shadow_v = (uint8_t)(127 + v); 106 m_color_shadow = k; 95 107 break; 96 108 } 97 109 } … … 103 115 rmap = new Raster_Map; 104 116 rmap->width = (width + 3) & -4; 105 117 rmap->rows = height; 106 rmap->cols = rmap->width; 107 rmap->size = rmap->rows * rmap->width; 118 119 if (m_mono) 120 rmap->cols = (rmap->width+7) >> 3; 121 else 122 rmap->cols = rmap->width; 123 124 rmap->size = rmap->rows * rmap->cols; 108 125 if (rmap->size <= 0) 109 126 { 110 127 delete rmap; … … 202 219 void TTFFont::render_text(Raster_Map *rmap, Raster_Map *rchr, 203 220 const QString &text, int *xorblah, int *yor) 204 221 { 222 #ifdef TIMING 223 Timer t("render_text"); 224 #endif 225 205 226 FT_F26Dot6 x, y, xmin, ymin, xmax, ymax; 206 227 FT_BBox bbox; 207 228 unsigned int i, ioff, iread; … … 248 269 origin.x = 0; 249 270 origin.y = 0; 250 271 251 FT_Glyph_To_Bitmap(&glyphs[j], ft_render_mode_normal, &origin, 1);272 FT_Glyph_To_Bitmap(&glyphs[j], m_mono ? ft_render_mode_mono : ft_render_mode_normal, &origin, 1); 252 273 bmap = (FT_BitmapGlyph)(glyphs[j]); 253 274 254 275 glyphs_cached[j] = duplicate_raster(bmap); … … 311 332 if (ymax >= rmap->rows) 312 333 ymax = rmap->rows - 1; 313 334 335 int x_ioff = 0, x_iread=0; 336 314 337 if (xmin < 0) 315 338 { 316 iread -= xmin; 339 // iread -= xmin; 340 x_iread = -xmin; 317 341 xmin = 0; 318 342 } 319 343 else 320 ioff += xmin; 344 { 345 x_ioff = xmin; 346 // ioff += xmin; 347 } 321 348 322 349 if (xmax >= rmap->width) 323 350 xmax = rmap->width - 1; … … 327 354 _read = (char *)rtmp->bitmap + iread; 328 355 _off = (char *)rmap->bitmap + ioff; 329 356 357 //printf("rows %d ymin %d cols %d\n", rmap->rows, ymin, rmap->cols); 358 359 //printf(" i %d, j '%c' xmin %d, xmax %d, x_iread %d, x_ioff %d iread %d ioff %d\n", 360 // i, j,xmin, xmax, x_iread, x_ioff, iread, ioff); 361 362 int len = xmax - xmin; 363 int bytes = len >> 3; 364 int rem = len & 7; 365 366 int x_read = x_iread; 367 int x_off = x_ioff; 368 369 unsigned char last=0, next=0; 370 unsigned char lmask,nmask=255; 371 372 int bit_off = x_off&7; 373 374 nmask = nmask >> bit_off; 375 lmask = 255 ^ nmask; 376 377 // printf(" nmask %02x, lmask %02x, bit_off %d, len %d, bytes %d, rem %d\n", 378 // nmask, lmask, bit_off, len, bytes, rem); 379 330 380 for (y = ymin; y <= ymax; y++) 331 381 { 332 382 read = _read; 333 383 off = _off; 334 384 335 for (x = xmin; x <= xmax; x++)385 if (m_mono) 336 386 { 337 *off = *read; 338 off++; 339 read++; 387 388 off += (x_off>>3); 389 390 int i; 391 last = *off; 392 for (i=0; i<=bytes; i++) 393 { 394 __asm__ __volatile__ ("movb %b1, %b0; rorb %b2,%b0" 395 : "=a"(next):"g"(*read++),"c"(bit_off)); 396 397 *off++ = (last & lmask)|(next & nmask); 398 399 last=next; 400 } 401 if (bit_off) 402 *off |= last & lmask; 403 404 /* 405 for (x = xmin; x <= xmax; x++) 406 { 407 408 int r = x_iread + (x-xmin); 409 int w = x_ioff + (x-xmin); 410 411 bool bit = read[r>>3] & mask[r&7]; 412 413 if (bit) 414 off[w>>3] |= mask[w&7]; 415 } 416 */ 417 418 // i 16, j 't' xmin 180, xmax 186, x_iread 0, x_ioff 180 iread 34 ioff 594 419 // i 17, j 'c' xmin 188, xmax 197, x_iread 0, x_ioff 188 iread 24 ioff 594 420 // i 18, j 'h' xmin 201, xmax 210, x_iread 0, x_ioff 201 iread 34 ioff 594 340 421 } 422 else 423 { 424 read += x_iread; 425 off += x_ioff; 426 427 for (x = xmin; x <= xmax; x++) 428 { 429 *off = *read; 430 off++; 431 read++; 432 } 433 } 341 434 _read -= rtmp->cols; 342 435 _off -= rmap->cols; 343 436 } … … 349 442 } 350 443 } 351 444 352 void TTFFont::merge_text( OSDSurface *surface, Raster_Map * rmap, int offset_x,445 void TTFFont::merge_text(I44Surface *surface, Raster_Map * rmap, int offset_x, 353 446 int offset_y, int xstart, int ystart, int width, 354 447 int height, int alphamod, kTTF_Color k) 355 448 { 449 #ifdef TIMING 450 Timer t("merge_text i44"); 451 #endif 452 356 453 unsigned char * asrc, * ydst, * udst, * vdst, * adst; 357 454 uint8_t color_y = 0, color_u = 0, color_v = 0; 455 if (xstart < 0) 456 { 457 width += xstart; 458 offset_x -= xstart; 459 xstart = 0; 460 } 358 461 462 if (ystart < 0) 463 { 464 height += ystart; 465 offset_y -= ystart; 466 ystart = 0; 467 } 468 469 if (height + ystart > surface->height) 470 height = surface->height - ystart; 471 472 if (width + xstart > surface->width) 473 width = surface->width - xstart; 474 475 QRect drawRect(xstart, ystart, width, height); 476 surface->AddRect(drawRect); 477 478 int b,x,y; 479 char ch; 480 481 asrc=rmap->bitmap; 482 adst=surface->i44buffer; 483 484 asrc += rmap->cols*offset_y+(offset_x>>3); 485 adst += xstart+ystart*surface->width; 486 487 unsigned long* ldst=(unsigned long*)adst; 488 489 unsigned char chmap[16]; 490 491 unsigned long col; 492 switch(k) 493 { 494 case kTTF_Normal: 495 col=(m_color_normal&0xf)<<4; 496 break; 497 case kTTF_Outline: 498 col=(m_color_outline&0xf)<<4; 499 break; 500 case kTTF_Shadow: 501 col=(m_color_shadow&0xf)<<4; 502 break; 503 } 504 505 if (alphamod>255) 506 alphamod=255; 507 col |= alphamod>>4; 508 509 for (y=0; y<height;y++) 510 { 511 char ch; 512 int j=0; 513 514 for (x=0; x<width;x++) 515 { 516 if ((x&7) == 0) 517 { 518 ch = asrc[j++]; 519 } 520 else 521 { 522 ch = ch<<1; 523 } 524 525 if (ch & 0x80) 526 adst[x] = col;// | 0x0f; 527 } 528 asrc += rmap->cols; 529 adst += surface->width; 530 } 531 } 532 533 void TTFFont::merge_text(YUVSurface *surface, Raster_Map * rmap, int offset_x, 534 int offset_y, int xstart, int ystart, int width, 535 int height, int alphamod, kTTF_Color k) 536 { 537 unsigned char * asrc, * ydst, * udst, * vdst, * adst; 538 uint8_t color_y = 0, color_u = 0, color_v = 0; 539 359 540 if (xstart < 0) 360 541 { 361 542 width += xstart; … … 411 592 surface->pow_lut); 412 593 } 413 594 414 void TTFFont::DrawString(OSDSurface *surface, int x, int y, 415 const QString &text, int maxx, int maxy, 416 int alphamod) 595 Raster_Map* TTFFont::Prerender(const QString &text) 417 596 { 418 int width, height, w, h, inx, iny, clipx, clipy; 419 Raster_Map *rmap, *rtmp; 420 char is_pixmap = 0; 597 #ifdef TIMING 598 Timer t("Prerender"); 599 #endif 600 int inx, iny, w, h; 601 Raster_Map *rmap, *rtmp; 602 char is_pixmap = 0; 421 603 422 604 if (text.length() < 1) 423 return ;605 return 0; 424 606 425 607 inx = 0; 426 608 iny = 0; … … 429 611 if (w <= 0 || h <= 0) 430 612 { 431 613 destroy_font_raster(rtmp); 432 return ;614 return 0; 433 615 } 434 616 rmap = create_font_raster(w, h); 435 617 … … 437 619 438 620 is_pixmap = 1; 439 621 622 rmap->m_w = w; 623 rmap->m_h = h; 624 rmap->m_inx = inx; 625 rmap->m_iny = iny; 626 627 return rmap; 628 } 629 630 void TTFFont::DrawString(OSDSurface *surface, int x, int y, 631 const QString &text, int maxx, int maxy, 632 int alphamod ) 633 { 634 #ifdef TIMING 635 Timer t("DrawString"); 636 #endif 637 Raster_Map *rmap; 638 639 int width, height, w, h, inx, iny, clipx, clipy; 640 641 if (rasters.contains(text)) 642 { 643 rmap = rasters[text]; 644 } 645 else 646 { 647 rmap = Prerender(text); 648 rasters[text] = rmap; 649 } 650 651 if (!rmap) 652 return; 653 654 w = rmap->m_w; 655 h = rmap->m_h; 656 inx = rmap->m_inx; 657 iny = rmap->m_iny; 658 440 659 y += loadedfontsize; 441 660 442 661 width = maxx; … … 470 689 } 471 690 if ((width <= 0) || (height <= 0)) 472 691 { 473 destroy_font_raster(rmap); 474 destroy_font_raster(rtmp); 475 return; 692 return; 476 693 } 477 694 478 695 if (m_shadowxoff > 0 || m_shadowyoff > 0) 479 696 { 480 merge_text(surface, rmap, clipx, clipy, x + m_shadowxoff, 697 if (surface->SurfaceType() == OSDSurface::SURF_YUV) 698 { 699 merge_text((YUVSurface*)surface, rmap, clipx, clipy, x + m_shadowxoff, 481 700 y + m_shadowyoff, width, height, alphamod, kTTF_Shadow); 701 } 702 else if (surface->SurfaceType() == OSDSurface::SURF_I44) 703 { 704 merge_text((I44Surface*)surface, rmap, clipx, clipy, x + m_shadowxoff, 705 y + m_shadowyoff, width, height, alphamod, kTTF_Shadow); 706 } 482 707 } 483 708 484 709 if (m_outline) 485 710 { 486 merge_text(surface, rmap, clipx, clipy, x - 1, y - 1, width, height, 711 if (surface->SurfaceType() == OSDSurface::SURF_YUV) 712 { 713 merge_text((YUVSurface*)surface, rmap, clipx, clipy, x - 1, y - 1, width, height, 487 714 alphamod, kTTF_Outline); 488 merge_text( surface, rmap, clipx, clipy, x + 1, y - 1, width, height,715 merge_text((YUVSurface*)surface, rmap, clipx, clipy, x + 1, y - 1, width, height, 489 716 alphamod, kTTF_Outline); 490 merge_text( surface, rmap, clipx, clipy, x - 1, y + 1, width, height,717 merge_text((YUVSurface*)surface, rmap, clipx, clipy, x - 1, y + 1, width, height, 491 718 alphamod, kTTF_Outline); 492 merge_text( surface, rmap, clipx, clipy, x + 1, y + 1, width, height,719 merge_text((YUVSurface*)surface, rmap, clipx, clipy, x + 1, y + 1, width, height, 493 720 alphamod, kTTF_Outline); 721 } 722 else if (surface->SurfaceType() == OSDSurface::SURF_I44) 723 { 724 merge_text((I44Surface*)surface, rmap, clipx, clipy, x - 1, y - 1, width, height, 725 alphamod, kTTF_Outline); 726 merge_text((I44Surface*)surface, rmap, clipx, clipy, x + 1, y - 1, width, height, 727 alphamod, kTTF_Outline); 728 merge_text((I44Surface*)surface, rmap, clipx, clipy, x - 1, y + 1, width, height, 729 alphamod, kTTF_Outline); 730 merge_text((I44Surface*)surface, rmap, clipx, clipy, x + 1, y + 1, width, height, 731 alphamod, kTTF_Outline); 732 733 } 734 494 735 } 495 736 496 merge_text(surface, rmap, clipx, clipy, x, y, width, height, alphamod); 497 498 destroy_font_raster(rmap); 499 destroy_font_raster(rtmp); 737 if (surface->SurfaceType() == OSDSurface::SURF_YUV) 738 { 739 merge_text((YUVSurface*)surface, rmap, clipx, clipy, x, y, width, height, alphamod); 740 } 741 else if (surface->SurfaceType() == OSDSurface::SURF_I44) 742 { 743 merge_text((I44Surface*)surface, rmap, clipx, clipy, x, y, width, height, alphamod); 744 } 500 745 } 501 746 502 747 TTFFont::~TTFFont() 503 748 { 749 QMap<QString,Raster_Map*>::Iterator it; 750 for (it=rasters.begin(); it!= rasters.end(); ++it) 751 { 752 destroy_font_raster(*it); 753 } 754 504 755 if (!valid) 505 756 return; 506 757 … … 526 777 } 527 778 528 779 TTFFont::TTFFont(char *file, int size, int video_width, int video_height, 529 float hmult )780 float hmult, bool mono) 530 781 { 782 531 783 FT_Error error; 532 784 533 785 valid = false; 534 786 m_size = size; 535 787 spacewidth = 0; 536 788 789 m_mono = mono; 790 537 791 m_outline = false; 538 792 m_shadowxoff = 0; 539 793 m_shadowyoff = 0; 540 794 541 795 m_color_normal_y = 255; 796 m_color_normal = 255; 542 797 m_color_normal_u = m_color_normal_v = 128; 543 798 544 799 m_color_outline_y = 0x40; 800 m_color_outline = 0x40; 545 801 m_color_outline_u = m_color_outline_v = 128; 546 802 547 803 m_color_shadow_y = 0x20; 804 m_color_shadow = 0x20; 548 805 m_color_shadow_u = m_color_shadow_v = 128; 549 806 550 807 if (!have_library) … … 597 854 598 855 void TTFFont::Init(void) 599 856 { 857 600 858 FT_Error error; 601 859 FT_CharMap char_map; 602 860 int xdpi = 96, ydpi = 96; … … 663 921 664 922 void TTFFont::CalcWidth(const QString &text, int *width_return) 665 923 { 924 666 925 unsigned int i, pw; 667 926 668 927 pw = 0; -
libs/libmythtv/osd.cpp
30 30 int dispx, int dispy, int dispw, int disph) 31 31 : QObject() 32 32 { 33 hasPalette=false; 33 34 changed = false; 34 35 vid_width = width; 35 36 vid_height = height; … … 74 75 75 76 SetDefaults(); 76 77 77 drawSurface = new OSDSurface(width, height); 78 79 if (surftype == "I44") 80 { 81 drawSurface = new I44Surface(width,height); 82 } 83 else //default to normal YUV 84 { 85 drawSurface = new YUVSurface(width, height); 86 } 78 87 } 79 88 80 89 OSD::~OSD(void) … … 234 243 } 235 244 236 245 delete drawSurface; 237 drawSurface = new OSDSurface(width, height); 246 247 if (surftype == "I44") 248 { 249 drawSurface = new I44Surface(width,height); 250 } 251 else //default to normal YUV 252 { 253 drawSurface = new YUVSurface(width, height); 254 } 238 255 239 256 osdlock.unlock(); 240 257 } … … 263 280 TTFFont *OSD::LoadFont(QString name, int size) 264 281 { 265 282 QString fullname = MythContext::GetConfDir() + "/" + name; 283 284 bool mono = (surftype == "I44") ? true:false; 285 286 printf("Load font %s\n", mono?"mono":"nonmono"); 287 266 288 TTFFont *font = new TTFFont((char *)fullname.ascii(), size, vid_width, 267 vid_height, hmult );289 vid_height, hmult,mono); 268 290 269 291 if (font->isValid()) 270 292 return font; … … 273 295 fullname = gContext->GetShareDir() + name; 274 296 275 297 font = new TTFFont((char *)fullname.ascii(), size, vid_width, 276 vid_height, hmult );298 vid_height, hmult,mono); 277 299 278 300 if (font->isValid()) 279 301 return font; … … 283 305 { 284 306 fullname = themepath + "/" + name; 285 307 font = new TTFFont((char *)fullname.ascii(), size, vid_width, 286 vid_height, hmult );308 vid_height, hmult,mono); 287 309 if (font->isValid()) 288 310 return font; 289 311 } … … 292 314 293 315 fullname = name; 294 316 font = new TTFFont((char *)fullname.ascii(), size, vid_width, vid_height, 295 hmult );317 hmult,mono); 296 318 297 319 if (font->isValid()) 298 320 return font; … … 316 338 return ""; 317 339 } 318 340 341 void OSD::parsePalette(QDomElement &element) 342 { 343 int index=0; 344 hasPalette = true; 345 346 for (QDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) 347 { 348 QDomElement node = child.toElement(); 349 if (!node.isNull()) 350 { 351 if (node.tagName() == "rgb") 352 { 353 int r,g,b; 354 QString text = getFirstText(node); 355 356 if (sscanf(text.data(), "%d,%d,%d", &r, &g, &b) == 3) 357 { 358 surfPalette.append(QColor(r,g,b)); 359 } 360 } 361 else 362 { 363 cerr << "Unknown tag " << node.tagName() << " in colour\n"; 364 continue; 365 } 366 index ++; 367 } 368 } 369 } 370 319 371 void OSD::parseFont(QDomElement &element) 320 372 { 321 373 QString name; … … 1166 1218 { 1167 1219 parseContainer(e); 1168 1220 } 1221 else if (e.tagName() == "surface") 1222 { 1223 surftype = getFirstText(e); 1224 } 1225 else if (e.tagName() == "palette") 1226 { 1227 parsePalette(e); 1228 } 1229 1169 1230 else 1170 1231 { 1171 1232 cerr << "Unknown element: " << e.tagName() << endl; -
libs/libmythtv/osdsurface.h
18 18 class OSDSurface 19 19 { 20 20 public: 21 enum SURFTYPE{ 22 SURF_YUV, 23 SURF_I44 24 }; 25 21 26 OSDSurface(int w, int h); 22 ~OSDSurface();27 virtual ~OSDSurface(); 23 28 24 v oid Clear(void);25 v oid ClearUsed(void);29 virtual void Clear(void); 30 virtual void ClearUsed(void); 26 31 27 32 bool IntersectsDrawn(QRect &newrect); 28 33 void AddRect(QRect &newrect); … … 35 40 ++revision; 36 41 } 37 42 int GetRevision() { return revision; } 43 int revision; 38 44 45 virtual SURFTYPE SurfaceType() = 0; 46 47 int width; 48 int height; 49 int size; 50 51 QRegion usedRegions; 52 bool changed; 53 }; 54 55 class I44Surface : public OSDSurface 56 { 57 public: 58 I44Surface(int w, int h); 59 ~I44Surface(); 60 61 virtual void Clear(void); 62 virtual void ClearUsed(void); 63 64 SURFTYPE SurfaceType() { return SURF_I44; } 65 66 unsigned char *i44buffer; 67 68 void BlendToI44(unsigned char* outbuf, bool ifirst, uint stride, uint height) const; 69 private: 70 }; 71 72 73 class YUVSurface : public OSDSurface 74 { 75 public: 76 YUVSurface(int w, int h); 77 ~YUVSurface(); 78 79 SURFTYPE SurfaceType() { return SURF_YUV; } 80 81 virtual void Clear(void); 82 virtual void ClearUsed(void); 83 84 39 85 void BlendToYV12(unsigned char *yuvptr) const; 40 86 void BlendToARGB(unsigned char *argbptr, 41 87 uint stride, uint height, bool blendtoblack=false) const; … … 44 90 void DitherToIA44(unsigned char* outbuf, uint stride, uint height) const; 45 91 void DitherToAI44(unsigned char* outbuf, uint stride, uint height) const; 46 92 47 int revision;48 49 93 unsigned char *yuvbuffer; 50 94 51 95 // just pointers into yuvbuffer … … 55 99 56 100 unsigned char *alpha; 57 101 58 int width;59 int height;60 int size;61 62 QRegion usedRegions;63 64 102 #ifdef MMX 65 103 short int rec_lut[256]; 66 104 #else … … 74 112 blendcolor_ptr blendcolorfunc; 75 113 blendconst_ptr blendconstfunc; 76 114 77 bool changed;78 79 115 bool usemmx; 80 116 81 117 unsigned char cropTbl[256 + 2 * MAX_NEG_CROP]; … … 85 121 typedef void (*blendtoyv12_8_fun)(unsigned char *src, unsigned char *dest, 86 122 unsigned char *alpha, bool uvplane); 87 123 88 blendtoyv12_8_fun blendtoyv12_8_init(const OSDSurface *surface);124 blendtoyv12_8_fun blendtoyv12_8_init(const YUVSurface *surface); 89 125 90 typedef void (*blendtoargb_8_fun)(const OSDSurface *surf, unsigned char *src,126 typedef void (*blendtoargb_8_fun)(const YUVSurface *surf, unsigned char *src, 91 127 unsigned char *usrc, unsigned char *vsrc, 92 128 unsigned char *alpha, unsigned char *dest); 93 129 94 blendtoargb_8_fun blendtoargb_8_init(const OSDSurface *surface);130 blendtoargb_8_fun blendtoargb_8_init(const YUVSurface *surface); 95 131 96 132 97 133 struct dither8_context; … … 101 137 const unsigned char *dmp, int xpos, 102 138 dither8_context *context); 103 139 104 dithertoia44_8_fun dithertoia44_8_init(const OSDSurface *surface);140 dithertoia44_8_fun dithertoia44_8_init(const YUVSurface *surface); 105 141 dither8_context *init_dithertoia44_8_context(bool first); 106 142 void delete_dithertoia44_8_context(dither8_context *context); 107 143 -
libs/libmythtv/ttfont.h
12 12 13 13 struct Raster_Map; 14 14 class OSDSurface; 15 class YUVSurface; 16 class I44Surface; 15 17 16 18 enum kTTF_Color { 17 19 kTTF_Normal = 0, … … 19 21 kTTF_Shadow, 20 22 }; 21 23 24 struct Raster_Map 25 { 26 int width; 27 int rows; 28 int cols; 29 int size; 30 unsigned char *bitmap; 31 int m_w; 32 int m_h; 33 int m_inx; 34 int m_iny; 35 }; 36 22 37 class TTFFont 23 38 { 24 39 public: 25 40 TTFFont(char *file, int size, int video_width, int video_height, 26 float hmult );41 float hmult, bool mono); 27 42 ~TTFFont(); 28 43 29 44 // Actually greyscale, keep for compat. … … 36 51 37 52 bool isValid(void) { return valid; } 38 53 54 Raster_Map* Prerender(const QString &text ); 39 55 void DrawString(OSDSurface *surface, int x, int y, const QString &text, 40 56 int maxx, int maxy, int alphamod = 255); 41 57 void CalcWidth(const QString &text, int *width_return); … … 45 61 46 62 void Reinit(int width, int height, float hmult); 47 63 64 static void destroy_font_raster(Raster_Map *rmap); 65 48 66 private: 49 67 void KillFace(void); 50 68 void Init(void); … … 52 70 Raster_Map *create_font_raster(int width, int height); 53 71 Raster_Map *duplicate_raster(FT_BitmapGlyph bmap); 54 72 void clear_raster(Raster_Map *rmap); 55 void destroy_font_raster(Raster_Map *rmap);56 73 Raster_Map *calc_size(int *width, int *height, const QString &text); 57 74 void render_text(Raster_Map *rmap, Raster_Map *rchr, const QString &text, 58 int *xorblah, int *yor );59 void merge_text( OSDSurface *surface, Raster_Map *rmap, int offset_x,75 int *xorblah, int *yor ); 76 void merge_text(YUVSurface *surface, Raster_Map *rmap, int offset_x, 60 77 int offset_y, int xstart, int ystart, int width, 61 78 int height, int alphamod, kTTF_Color k = kTTF_Normal); 79 void merge_text(I44Surface *surface, Raster_Map *rmap, int offset_x, 80 int offset_y, int xstart, int ystart, int width, 81 int height, int alphamod, kTTF_Color k = kTTF_Normal); 62 82 bool cache_glyph(unsigned short c); 63 83 64 84 bool valid; … … 83 103 uint8_t m_color_normal_y; 84 104 uint8_t m_color_normal_u; 85 105 uint8_t m_color_normal_v; 106 uint8_t m_color_normal; 86 107 87 108 uint8_t m_color_outline_y; 88 109 uint8_t m_color_outline_u; 89 110 uint8_t m_color_outline_v; 111 uint8_t m_color_outline; 90 112 91 113 uint8_t m_color_shadow_y; 92 114 uint8_t m_color_shadow_u; 93 115 uint8_t m_color_shadow_v; 116 uint8_t m_color_shadow; 94 117 95 118 QString m_file; 96 119 97 120 int loadedfontsize; 98 121 float m_hmult; 122 123 bool m_mono; 124 125 QMap<QString, Raster_Map *> rasters; 126 99 127 }; 100 128 101 129 #endif