Ticket #101: xvmcosd-cleanedup-v1.patch
| File xvmcosd-cleanedup-v1.patch, 66.9 KB (added by , 20 years ago) |
|---|
-
themes/themes.pro
9 9 !macx:QMAKE_COPY_DIR = sh ./cpsvndir 10 10 11 11 themes.path = $${PREFIX}/share/mythtv/themes/ 12 themes.files = blue defaultosd blueosd oldosd default G.A.N.T. classic DVR 12 themes.files = blue default G.A.N.T. classic DVR 13 themes.files += defaultosd blueosd oldosd xvmcosd 13 14 14 15 fonts.path = $${PREFIX}/share/mythtv 15 16 fonts.files = FreeSans.ttf FreeMono.ttf -
libs/libmythtv/NuppelVideoPlayer.cpp
1903 1903 visible.width(), visible.height()); 1904 1904 1905 1905 if (kCodec_NORMAL_END < GetDecoder()->GetVideoCodecID() && 1906 kCodec_S PECIAL_END > GetDecoder()->GetVideoCodecID() &&1906 kCodec_STD_XVMC_END > GetDecoder()->GetVideoCodecID() && 1907 1907 (600 < video_height)) 1908 1908 { 1909 1909 osd->DisableFade(); -
libs/libmythtv/osd.h
123 123 124 124 void DisableFade(void); 125 125 126 bool HasPalette(void) const { return hasPalette; } 127 128 // TODO using a QValueList here is NOT threadsafe -- dtk 129 QValueList<QColor> GetPalette(void) const 130 { return surfPalette; } 131 126 132 private: 127 133 void SetDefaults(); 128 134 TTFFont *LoadFont(QString name, int size); … … 149 155 void parsePositionRects(OSDSet *container, QDomElement &element); 150 156 void parsePositionImage(OSDSet *container, QDomElement &element); 151 157 void parseListTree(OSDSet *container, QDomElement &element); 158 void parsePalette(QDomElement &element); 152 159 153 160 int vid_width; 154 161 int vid_height; … … 184 191 185 192 OSDListTreeType *runningTreeMenu; 186 193 QString treeMenuContainer; 194 195 // variables to support restricted color palette 196 bool hasPalette; 197 QString surftype; 198 QValueList<QColor> surfPalette; 199 187 200 }; 188 201 189 202 #endif -
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 #endif 22 23 QValueList<QColor> OSDTypeImage::s_palette; 24 17 25 OSDSet::OSDSet(const QString &name, bool cache, int screenwidth, 18 26 int screenheight, float wmult, float hmult, int frint) 19 27 : QObject() … … 367 375 368 376 void OSDSet::Draw(OSDSurface *surface, bool actuallydraw) 369 377 { 378 #ifdef TIMING 379 Timer t("OSDSet::Draw"); 380 #endif 381 370 382 if (actuallydraw) 371 383 { 372 384 vector<OSDType *>::iterator i = allTypes->begin(); … … 443 455 444 456 OSDTypeText::OSDTypeText(const QString &name, TTFFont *font, 445 457 const QString &text, QRect displayrect) 446 : OSDType(name) 458 : OSDType(name), m_raster(0) 447 459 { 448 460 m_message = text; 449 461 m_default_msg = text; … … 463 475 m_scrollinit = false; 464 476 465 477 m_linespacing = 1.5; 478 479 m_message.replace(QRegExp("%BR%"), "\n"); 480 m_message.replace(QRegExp("\n")," \n "); 466 481 } 467 482 468 483 OSDTypeText::OSDTypeText(const OSDTypeText &other) 469 : OSDType(other.m_name) 484 : OSDType(other.m_name), m_raster(0) 470 485 { 471 486 m_displaysize = other.m_displaysize; 472 487 m_screensize = other.m_screensize; … … 486 501 487 502 OSDTypeText::~OSDTypeText() 488 503 { 504 if (m_raster) 505 { 506 TTFFont::destroy_font_raster(m_raster); 507 m_raster=0; 508 } 489 509 } 490 510 491 511 void OSDTypeText::SetAltFont(TTFFont *font) … … 495 515 496 516 void OSDTypeText::SetText(const QString &text) 497 517 { 518 if (m_raster) 519 { 520 TTFFont::destroy_font_raster(m_raster); 521 m_raster=0; 522 } 523 498 524 m_message = text; 499 525 m_scrollinit = false; 526 527 m_message.replace(QRegExp("%BR%"), "\n"); 528 m_message.replace(QRegExp("\n"), " \n "); 500 529 } 501 530 502 531 void OSDTypeText::SetDefaultText(const QString &text) 503 532 { 533 if (m_raster) 534 { 535 TTFFont::destroy_font_raster(m_raster); 536 m_raster=0; 537 } 538 504 539 m_message = text; 505 540 m_default_msg = text; 506 541 m_scrollinit = false; 542 543 m_message.replace(QRegExp("%BR%"), "\n"); 544 m_message.replace(QRegExp("\n"), " \n "); 507 545 } 508 546 509 547 void OSDTypeText::Reinit(float wchange, float hchange) 510 548 { 549 if (m_raster) 550 { 551 TTFFont::destroy_font_raster(m_raster); 552 m_raster=0; 553 } 554 511 555 int width = (int)(m_screensize.width() * wchange); 512 556 int height = (int)(m_screensize.height() * hchange); 513 557 int x = (int)(m_screensize.x() * wchange); … … 519 563 void OSDTypeText::Draw(OSDSurface *surface, int fade, int maxfade, int xoff, 520 564 int yoff) 521 565 { 566 #ifdef TIMING 567 Timer t("OSDTypeText::Draw"); 568 #endif 522 569 int textlength = 0; 523 570 524 571 if (m_message == QString::null) … … 530 577 if (m_scroller) 531 578 m_parent->SetDrawEveryFrame(true); 532 579 533 m_font->CalcWidth(m_message, &textlength);580 // m_font->CalcWidth(m_message, &textlength); 534 581 535 582 int maxlength = m_displaysize.width(); 536 583 537 584 if (m_multiline) 538 585 { 539 QString tmp_msg = m_message;540 tmp_msg.replace(QRegExp("%BR%"), "\n");541 tmp_msg.replace(QRegExp("\n")," \n ");586 // QString tmp_msg = m_message; 587 // tmp_msg.replace(QRegExp("%BR%"), "\n"); 588 // tmp_msg.replace(QRegExp("\n"), " \n "); 542 589 543 QStringList wordlist = QStringList::split(" ", tmp_msg);590 QStringList wordlist = QStringList::split(" ", m_message); 544 591 int length = 0; 545 592 int lines = 0; 546 593 … … 658 705 const QString &text, int fade, int maxfade, 659 706 int xoff, int yoff) 660 707 { 708 #ifdef TIMING 709 Timer t("OSDTypeText::DrawString"); 710 #endif 711 661 712 if (m_centered || m_right) 662 713 { 663 714 int textlength = 0; … … 713 764 m_isvalid = false; 714 765 m_imagesize = QRect(0, 0, 0, 0); 715 766 767 m_i44 = NULL; 768 716 769 m_scalew = scalew; 717 770 m_scaleh = scaleh; 718 771 … … 734 787 m_scaleh = other.m_scaleh; 735 788 736 789 m_alpha = m_yuv = NULL; 790 m_i44 = NULL; 791 737 792 if (m_isvalid) 738 793 { 739 794 int size = m_imagesize.width() * m_imagesize.height() * 3 / 2; … … 749 804 m_ubuffer = m_yuv + (m_imagesize.width() * m_imagesize.height()); 750 805 m_vbuffer = m_yuv + (m_imagesize.width() * m_imagesize.height() * 751 806 5 / 4); 752 } 807 808 //I44 809 m_i44 = new unsigned char[size]; 810 memcpy(m_i44, other.m_i44, size); 811 } 753 812 } 754 813 755 814 OSDTypeImage::OSDTypeImage(const QString &name) … … 767 826 m_vbuffer = NULL; 768 827 m_isvalid = false; 769 828 m_filename = ""; 829 830 m_i44 = NULL; 770 831 } 771 832 772 833 OSDTypeImage::OSDTypeImage(void) … … 785 846 m_vbuffer = NULL; 786 847 m_isvalid = false; 787 848 m_filename = ""; 849 850 m_i44 = NULL; 788 851 } 789 852 790 853 OSDTypeImage::~OSDTypeImage() … … 793 856 delete [] m_yuv; 794 857 if (m_alpha) 795 858 delete [] m_alpha; 859 if (m_i44) 860 delete [] m_i44; 796 861 } 797 862 798 863 void OSDTypeImage::SetName(const QString &name) … … 811 876 LoadImage(m_filename, wmult, hmult, m_scalew, m_scaleh); 812 877 } 813 878 814 void OSDTypeImage::LoadImage(const QString &filename, float wmult, float hmult, 879 void rgb32_to_i44(unsigned char*i44, unsigned char*rgb, int width, int height, int srcwidth, const QValueList<QColor> &palette ) 880 { 881 int wrap, wrap4, x, y; 882 unsigned char *p; 883 unsigned char ch, r, g, b; 884 885 printf("rgb32_to_i44 called, image size: %dx%d\n", width, height); 886 887 p = rgb; 888 889 for (y=0; y<height; y++) 890 { 891 unsigned char *pstart=p; 892 893 for (x=0; x<width; x++) 894 { 895 ch = (p[3] >> 4) & 0x0f; //trunc alpha 896 r=p[2]; g=p[1]; b=p[0]; 897 898 //Find nearest palette colour 899 long d1, d2=( 256*256 )*3; //black is white 900 int i, j; 901 for ( i=0;i<palette.count(); i++ ) 902 { 903 d1 = ( palette[i].red()-r ) * ( palette[i].red()-r ) + 904 ( palette[i].green()-g ) * ( palette[i].green()-g ) + 905 ( palette[i].blue()-b ) * ( palette[i].blue()-b ); 906 907 if ( d1==0 ) { //perfect match 908 j=i; 909 break; 910 } 911 if ( d1 < d2 ) { //nearer match 912 d2 = d1; 913 j=i; 914 } 915 } 916 917 ch |= ( j<<4 ); 918 919 *(i44+x+y*width) = ch; 920 921 p+=4; 922 } 923 924 p=pstart+srcwidth*4; 925 926 } 927 } 928 929 void OSDTypeImage::LoadImage(const QString &filename, 930 float wmult, float hmult, 815 931 int scalew, int scaleh) 816 932 { 817 933 if (m_isvalid) … … 820 936 delete [] m_yuv; 821 937 if (m_alpha) 822 938 delete [] m_alpha; 939 if (m_i44) 940 delete [] m_i44; 823 941 824 942 m_isvalid = false; 825 943 m_yuv = NULL; 826 944 m_alpha = NULL; 945 m_i44 = NULL; 827 946 } 828 947 829 948 if (filename.length() < 2) … … 862 981 863 982 m_alpha = new unsigned char[imwidth * imheight]; 864 983 865 rgb32_to_yuv420p(m_ybuffer, m_ubuffer, m_vbuffer, m_alpha, tmp2.bits(), 984 m_i44 = new unsigned char[imwidth*imheight]; 985 986 rgb32_to_yuv420p(m_ybuffer, m_ubuffer, m_vbuffer, m_alpha, tmp2.bits(), 866 987 imwidth, imheight, tmp2.width()); 867 988 989 rgb32_to_i44(m_i44, tmp2.bits(), imwidth, imheight, tmp2.width(), 990 GetPalette()); 991 868 992 m_imagesize = QRect(0, 0, imwidth, imheight); 869 993 } 870 994 … … 877 1001 if (m_alpha) 878 1002 delete [] m_alpha; 879 1003 1004 if (m_i44) 1005 delete[] m_i44; 1006 880 1007 m_isvalid = false; 881 1008 m_yuv = NULL; 882 1009 m_alpha = NULL; 1010 m_i44 = NULL; 883 1011 } 884 1012 885 1013 m_isvalid = true; … … 894 1022 895 1023 m_alpha = new unsigned char[imwidth * imheight]; 896 1024 897 rgb32_to_yuv420p(m_ybuffer, m_ubuffer, m_vbuffer, m_alpha, img.bits(), 1025 m_i44 = new unsigned char[imwidth*imheight]; 1026 1027 rgb32_to_yuv420p(m_ybuffer, m_ubuffer, m_vbuffer, m_alpha, img.bits(), 898 1028 img.width(), img.height(), img.bytesPerLine() / 4); 899 1029 1030 rgb32_to_i44(m_i44, img.bits(), imwidth, imheight, img.width(), 1031 GetPalette()); 900 1032 m_imagesize = QRect(0, 0, imwidth, imheight); 901 1033 } 902 1034 903 void OSDTypeImage::Draw(OSDSurface *surface, int fade, int maxfade, 904 int xoff, int yoff) 1035 void OSDTypeImage::Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff) 905 1036 { 1037 #ifdef TIMING 1038 Timer t("OSDTypeImage::Draw"); 1039 #endif 1040 1041 if (surface->SurfaceType()==OSDSurface::SURF_YUV) 1042 Draw((YUVSurface*)surface, fade, maxfade, xoff, yoff); 1043 else if (surface->SurfaceType()==OSDSurface::SURF_I44) 1044 Draw((I44Surface*)surface, fade, maxfade, xoff, yoff); 1045 } 1046 1047 void OSDTypeImage::Draw(I44Surface *surface, int fade, int maxfade, int xoff, 1048 int yoff) 1049 { 906 1050 if (!m_isvalid) 907 1051 return; 908 1052 1053 unsigned char *dest, *destalpha, *src, *srcalpha; 1054 unsigned char *udest, *vdest, *usrc, *vsrc; 1055 int alpha, iwidth, width; 1056 1057 iwidth = width = m_imagesize.width(); 1058 int height = m_imagesize.height(); 1059 1060 if (m_drawwidth >= 0) 1061 width = m_drawwidth; 1062 1063 int ystart = m_displaypos.y(); 1064 int xstart = m_displaypos.x(); 1065 1066 xstart += xoff; 1067 ystart += yoff; 1068 1069 ystart = (ystart / 2) * 2; 1070 xstart = ((xstart + 1) / 2) * 2; 1071 1072 int startline = 0; 1073 int startcol = 0; 1074 1075 if (ystart < 0) 1076 { 1077 startline = 0 - ystart; 1078 ystart = 0; 1079 } 1080 1081 if (xstart < 0) 1082 { 1083 startcol = 0 - xstart; 1084 xstart = 0; 1085 } 1086 1087 if (height + ystart > surface->height) 1088 height = surface->height - ystart - 1; 1089 if (width + xstart > surface->width) 1090 width = surface->width - xstart - 1; 1091 1092 if (width == 0 || height == 0) 1093 { 1094 printf("zeros\n"); 1095 return; 1096 } 1097 1098 1099 QRect destRect = QRect(xstart, ystart, width, height); 1100 bool needblend = false; 1101 1102 if (m_onlyusefirst || surface->IntersectsDrawn(destRect)) 1103 needblend = true; 1104 surface->AddRect(destRect); 1105 1106 int ysrcwidth; 1107 int ydestwidth; 1108 1109 int uvsrcwidth; 1110 int uvdestwidth; 1111 1112 int alphamod = 0xf; 1113 1114 1115 if (maxfade > 0 && fade >= 0) 1116 alphamod = (int)((((float)(fade) / maxfade) * 16.0) + 0.5); 1117 1118 unsigned char almap[256]; 1119 { 1120 for (int i=0; i<256; i++) 1121 { 1122 almap[i] = ( i & 0xf0)|((((i & 0xf) * alphamod)>>4)&0xf); 1123 } 1124 } 1125 unsigned char *dst; 1126 1127 src = m_i44; 1128 dst = surface->i44buffer + xstart + (ystart)*surface->width; 1129 1130 unsigned long *ldst = (unsigned long*)dst; 1131 1132 { 1133 for (int y = startline; y < height; y++) 1134 { 1135 unsigned long *lsrc = (unsigned long*)(src+(y*iwidth)); 1136 for (int x = startcol/4; x < width/4; x++) 1137 { 1138 unsigned long sch = lsrc[x]; 1139 unsigned long dsh = 1140 almap[sch>>24]<<24 | 1141 almap[sch>>16 & 0xff] << 16 | 1142 almap[sch>>8 & 0xff] << 8 | 1143 almap[sch&0xff]; 1144 1145 ldst[x] = (ldst[x] & 0x0f0f0f0f) | dsh; 1146 1147 /* unsigned char ch = (alphamod & 0xf0) | (*(m_ubuffer+(x/2)+ysrcwidth) & 0x0f) ; 1148 *(surface->i44buffer + x +xstart+ ydestwidth) = ch; 1149 */ 1150 } 1151 ldst+=surface->width/4; 1152 } 1153 } 1154 return; 1155 1156 } 1157 void OSDTypeImage::Draw(YUVSurface *surface, int fade, int maxfade, int xoff, 1158 int yoff) 1159 { 1160 if (!m_isvalid) 1161 return; 1162 909 1163 int xstart = ((m_displaypos.x() + xoff + 1) / 2) * 2; 910 1164 int ystart = ((m_displaypos.y() + yoff) / 2) * 2; 911 1165 … … 933 1187 934 1188 drawheight = (drawheight + ystart > surface->height) ? 935 1189 surface->height - ystart - 1 : drawheight; 936 1190 937 1191 if ((drawwidth <= 0) || (drawheight <= 0)) 938 1192 return; 939 1193 … … 941 1195 bool needblend = m_onlyusefirst || surface->IntersectsDrawn(destRect); 942 1196 943 1197 surface->AddRect(destRect); 944 1198 945 1199 int alphamod = 255; 946 1200 947 1201 if (maxfade > 0 && fade >= 0) … … 954 1208 int ysrcwidth = y * iwidth; 955 1209 int ydestwidth = (y + ystart - startline) * surface->width; 956 1210 957 memcpy(surface->y + xstart + ydestwidth, 1211 memcpy(surface->y + xstart + ydestwidth, 958 1212 m_ybuffer + startcol + ysrcwidth, drawwidth); 959 1213 960 1214 unsigned char *destalpha = surface->alpha + xstart + ydestwidth; … … 962 1216 for (int x = startcol; x < drawwidth; x++) 963 1217 { 964 1218 int alpha = *(m_alpha + x + ysrcwidth); 965 1219 966 1220 if (alpha == 0) 967 1221 *destalpha = 0; 968 1222 else … … 985 1239 int uvsrcwidth = y * iwidth; 986 1240 int uvdestwidth = (y + ystart - startline) * (surface->width / 2); 987 1241 988 memcpy(surface->u + xstart + uvdestwidth, 1242 memcpy(surface->u + xstart + uvdestwidth, 989 1243 m_ubuffer + startcol + uvsrcwidth, drawwidth); 990 memcpy(surface->v + xstart + uvdestwidth, 1244 memcpy(surface->v + xstart + uvdestwidth, 991 1245 m_vbuffer + startcol + uvsrcwidth, drawwidth); 992 1246 } 993 1247 … … 1012 1266 unsigned char *destalpha = surface->alpha + xstart + ydestwidth; 1013 1267 1014 1268 if (m_onlyusefirst) 1015 (surface->blendcolumnfunc) (src, usrc, vsrc, srcalpha, iwidth, dest, 1016 udest, vdest, destalpha, surface->width, 1269 (surface->blendcolumnfunc) (src, usrc, vsrc, srcalpha, iwidth, dest, 1270 udest, vdest, destalpha, surface->width, 1017 1271 drawwidth - startcol, 1018 drawheight - startline, 1019 alphamod, 1, surface->rec_lut, 1272 drawheight - startline, 1273 alphamod, 1, surface->rec_lut, 1020 1274 surface->pow_lut); 1021 1275 else 1022 (surface->blendregionfunc) (src, usrc, vsrc, srcalpha, iwidth, dest, 1023 udest, vdest, destalpha, surface->width, 1276 (surface->blendregionfunc) (src, usrc, vsrc, srcalpha, iwidth, dest, 1277 udest, vdest, destalpha, surface->width, 1024 1278 drawwidth - startcol, 1025 drawheight - startline, 1026 alphamod, 1, surface->rec_lut, 1279 drawheight - startline, 1280 alphamod, 1, surface->rec_lut, 1027 1281 surface->pow_lut); 1028 1282 } 1029 1283 1030 1284 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1031 1285 1032 OSDTypePosSlider::OSDTypePosSlider(const QString &name, 1033 const QString &filename, 1034 QRect displayrect, float wmult, 1286 OSDTypePosSlider::OSDTypePosSlider(const QString &name, 1287 const QString &filename, 1288 QRect displayrect, float wmult, 1035 1289 float hmult, int scalew, int scaleh) 1036 : OSDTypeImage(name, filename, displayrect.topLeft(), wmult, 1290 : OSDTypeImage(name, filename, displayrect.topLeft(), wmult, 1037 1291 hmult, scalew, scaleh) 1038 1292 { 1039 1293 m_maxval = 1000; … … 1045 1299 { 1046 1300 } 1047 1301 1048 void OSDTypePosSlider::Reinit(float wchange, float hchange, float wmult, 1302 void OSDTypePosSlider::Reinit(float wchange, float hchange, float wmult, 1049 1303 float hmult) 1050 1304 { 1051 1305 int width = (int)(m_displayrect.width() * wchange); … … 1077 1331 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1078 1332 1079 1333 OSDTypeFillSlider::OSDTypeFillSlider(const QString &name, 1080 const QString &filename, 1334 const QString &filename, 1081 1335 QRect displayrect, float wmult, 1082 1336 float hmult, int scalew, int scaleh) 1083 1337 : OSDTypeImage(name, filename, displayrect.topLeft(), wmult, … … 1094 1348 { 1095 1349 } 1096 1350 1097 void OSDTypeFillSlider::Reinit(float wchange, float hchange, float wmult, 1351 void OSDTypeFillSlider::Reinit(float wchange, float hchange, float wmult, 1098 1352 float hmult) 1099 1353 { 1100 1354 int width = (int)(m_displayrect.width() * wchange); … … 1129 1383 1130 1384 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1131 1385 1132 OSDTypeEditSlider::OSDTypeEditSlider(const QString &name, 1133 const QString &bluefilename, 1134 const QString &redfilename, 1135 QRect displayrect, float wmult, 1386 OSDTypeEditSlider::OSDTypeEditSlider(const QString &name, 1387 const QString &bluefilename, 1388 const QString &redfilename, 1389 QRect displayrect, float wmult, 1136 1390 float hmult, int scalew, int scaleh) 1137 1391 : OSDTypeImage(name) 1138 1392 { … … 1146 1400 m_drawMap[i] = 0; 1147 1401 1148 1402 m_displaypos = displayrect.topLeft(); 1149 1403 1150 1404 m_yuv = m_alpha = NULL; 1151 1405 m_isvalid = false; 1152 1406 … … 1187 1441 delete [] m_ralpha; 1188 1442 } 1189 1443 1190 void OSDTypeEditSlider::Reinit(float wchange, float hchange, float wmult, 1444 void OSDTypeEditSlider::Reinit(float wchange, float hchange, float wmult, 1191 1445 float hmult) 1192 1446 { 1193 1447 int width = (int)(m_displayrect.width() * wchange); … … 1199 1453 m_drawwidth = m_displayrect.width(); 1200 1454 1201 1455 delete [] m_drawMap; 1202 1456 1203 1457 m_drawMap = new unsigned char[m_drawwidth + 1]; 1204 1458 for (int i = 0; i < m_drawwidth; i++) 1205 1459 m_drawMap[i] = 0; … … 1242 1496 1243 1497 if (start < 0) 1244 1498 start = 0; 1245 if (start >= m_drawwidth) 1499 if (start >= m_drawwidth) 1246 1500 start = m_drawwidth - 1; 1247 1501 if (end < 0) 1248 1502 end = 0; … … 1260 1514 m_drawMap[i] = 1; 1261 1515 } 1262 1516 1263 void OSDTypeEditSlider::Draw(OSDSurface *surface, int fade, int maxfade, 1517 void OSDTypeEditSlider::Draw(OSDSurface *surface, int fade, int maxfade, 1264 1518 int xoff, int yoff) 1265 { 1519 { 1520 if (surface->SurfaceType()==OSDSurface::SURF_YUV) 1521 Draw((YUVSurface*)surface, fade, maxfade, xoff, yoff); 1522 // else if (surface->SurfaceType()==OSDSurface::SURF_I44) 1523 // Draw((I44Surface*)surface, fade, maxfade, xoff, yoff); 1524 } 1525 void OSDTypeEditSlider::Draw(YUVSurface *surface, int fade, int maxfade, 1526 int xoff, int yoff) 1527 { 1266 1528 if (!m_isvalid || !m_risvalid) 1267 1529 return; 1268 1530 1269 1531 unsigned char *dest, *destalpha, *src, *rsrc, *srcalpha, *rsrcalpha; 1270 1532 unsigned char *udest, *vdest, *usrc, *rusrc, *vsrc, *rvsrc; 1271 1533 1272 1534 int iwidth, riwidth, width; 1273 1535 iwidth = m_imagesize.width(); 1274 1536 riwidth = m_rimagesize.width(); … … 1277 1539 1278 1540 int ystart = m_displaypos.y(); 1279 1541 int xstart = m_displaypos.x(); 1280 1542 1281 1543 xstart += xoff; 1282 1544 ystart += yoff; 1283 1545 … … 1309 1571 1310 1572 QRect destRect = QRect(xstart, ystart, width, height); 1311 1573 surface->AddRect(destRect); 1312 1313 int ysrcwidth; 1574 1575 int ysrcwidth; 1314 1576 int rysrcwidth; 1315 1577 int ydestwidth; 1316 1578 1317 1579 int uvsrcwidth; 1318 1580 int ruvsrcwidth; 1319 1581 int uvdestwidth; 1320 1582 1321 1583 int alphamod = 255; 1322 1584 1323 1585 if (maxfade > 0 && fade >= 0) 1324 1586 alphamod = (int)((((float)(fade) / maxfade) * 256.0) + 0.5); 1325 1587 1326 ysrcwidth = startline * iwidth; 1588 ysrcwidth = startline * iwidth; 1327 1589 rysrcwidth = startline * riwidth; 1328 1590 ydestwidth = ystart * surface->width; 1329 1591 … … 1346 1608 vdest = surface->v + xstart / 2 + uvdestwidth; 1347 1609 vsrc = m_vbuffer + uvsrcwidth; 1348 1610 rvsrc = m_rvbuffer + ruvsrcwidth; 1349 (surface->blendcolumn2func) (rsrc, rusrc, rvsrc, rsrcalpha, riwidth, src, 1350 usrc, vsrc, srcalpha, iwidth, 1351 m_drawMap + startcol, dest, udest, vdest, 1352 destalpha, surface->width, width - startcol, 1353 height - startline, alphamod, 1, 1611 (surface->blendcolumn2func) (rsrc, rusrc, rvsrc, rsrcalpha, riwidth, src, 1612 usrc, vsrc, srcalpha, iwidth, 1613 m_drawMap + startcol, dest, udest, vdest, 1614 destalpha, surface->width, width - startcol, 1615 height - startline, alphamod, 1, 1354 1616 surface->rec_lut, surface->pow_lut); 1355 1617 } 1356 1618 1357 1619 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1358 1620 1359 OSDTypeBox::OSDTypeBox(const QString &name, QRect displayrect) 1621 OSDTypeBox::OSDTypeBox(const QString &name, QRect displayrect) 1360 1622 : OSDType(name) 1361 1623 { 1362 1624 size = displayrect; … … 1385 1647 void OSDTypeBox::Draw(OSDSurface *surface, int fade, int maxfade, int xoff, 1386 1648 int yoff) 1387 1649 { 1650 #ifdef TIMING 1651 Timer t("OSDTypeBox::Draw"); 1652 #endif 1653 1654 if (surface->SurfaceType()==OSDSurface::SURF_YUV) 1655 Draw((YUVSurface*)surface, fade, maxfade, xoff, yoff); 1656 else if (surface->SurfaceType()==OSDSurface::SURF_I44) 1657 Draw((I44Surface*)surface, fade, maxfade, xoff, yoff); 1658 } 1659 1660 void OSDTypeBox::Draw(I44Surface *surface, int fade, int maxfade, int xoff, 1661 int yoff) 1662 { 1388 1663 unsigned char *dest, *destalpha; 1389 1664 unsigned char alpha = 192; 1665 unsigned char targ; 1390 1666 1391 1667 QRect disprect = size; 1392 1668 disprect.moveBy(xoff, yoff); … … 1407 1683 1408 1684 int height = yend - ystart + 1, width = xend - xstart + 1; 1409 1685 1686 QRect destRect = QRect(xstart, ystart, width, height); 1687 bool needblend = false; 1688 1689 if (surface->IntersectsDrawn(destRect)) 1690 needblend = true; 1691 surface->AddRect(destRect); 1692 1693 int alphamod = 255; 1694 if (maxfade > 0 && fade >= 0) 1695 alphamod = (int)((((float)(fade) / maxfade) * 16.0) + 0.5); 1696 1697 int ydestwidth; 1698 1699 alpha = ((alpha * alphamod) + 0x8); 1700 1701 targ = 0 | (alpha & 0xf); //black 1702 //targ=0xf3; 1703 1704 for (int y = ystart; y < yend; y++) 1705 { 1706 ydestwidth = y * surface->width; 1707 memset(surface->i44buffer + xstart + ydestwidth, targ , width); 1708 } 1709 } 1710 1711 void OSDTypeBox::Draw(YUVSurface *surface, int fade, int maxfade, int xoff, 1712 int yoff) 1713 { 1714 unsigned char *dest, *destalpha; 1715 unsigned char alpha = 192; 1716 1717 QRect disprect = size; 1718 disprect.moveBy(xoff, yoff); 1719 1720 int ystart = disprect.top(); 1721 int yend = disprect.bottom(); 1722 int xstart = disprect.left(); 1723 int xend = disprect.right(); 1724 1725 if (xstart < 0) 1726 xstart = 0; 1727 if (xend > surface->width) 1728 xend = surface->width; 1729 if (ystart < 0) 1730 ystart = 0; 1731 if (yend > surface->height) 1732 yend = surface->height; 1733 1734 int height = yend - ystart + 1, width = xend - xstart + 1; 1735 1410 1736 QRect destRect = QRect(xstart, ystart, width, height); 1411 1737 bool needblend = false; 1412 1738 … … 1533 1859 void OSDTypePositionRectangle::Draw(OSDSurface *surface, int fade, int maxfade, 1534 1860 int xoff, int yoff) 1535 1861 { 1862 #ifdef TIMING 1863 Timer t("OSDTypePositionRectangle::Draw"); 1864 #endif 1865 1866 if (surface->SurfaceType()==OSDSurface::SURF_YUV) 1867 Draw((YUVSurface*)surface, fade, maxfade, xoff, yoff); 1868 else if (surface->SurfaceType()==OSDSurface::SURF_I44) 1869 Draw((I44Surface*)surface, fade, maxfade, xoff, yoff); 1870 } 1871 1872 void OSDTypePositionRectangle::Draw(YUVSurface *surface, int fade, int maxfade, 1873 int xoff, int yoff) 1874 { 1536 1875 fade = fade; 1537 1876 maxfade = maxfade; 1538 1877 xoff = xoff; … … 1611 1950 } 1612 1951 } 1613 1952 1953 1954 void OSDTypePositionRectangle::Draw(I44Surface *surface, int fade, int maxfade, 1955 int xoff, int yoff) 1956 { 1957 fade = fade; 1958 maxfade = maxfade; 1959 xoff = xoff; 1960 yoff = yoff; 1961 1962 if (m_curposition < 0 || m_curposition >= m_numpositions) 1963 return; 1964 1965 QRect rect = positions[m_curposition]; 1966 1967 unsigned char *src; 1968 int ystart = rect.top(); 1969 int yend = rect.bottom(); 1970 int xstart = rect.left(); 1971 int xend = rect.right(); 1972 1973 int height = yend - ystart + 1, width = xend - xstart + 1; 1974 1975 QRect destRect = QRect(xstart, ystart, width, height); 1976 surface->AddRect(destRect); 1977 1978 1979 for (int y = ystart; y < yend; y++) 1980 { 1981 if (y < 0 || y >= surface->height) 1982 continue; 1983 1984 for (int x = xstart; x < xstart + 2; x++) 1985 { 1986 if (x < 0 || x >= surface->width) 1987 continue; 1988 1989 src = surface->i44buffer + x + y * surface->width; 1990 *src = 0xaa; //white 1991 } 1992 1993 for (int x = xend - 2; x < xend; x++) 1994 { 1995 if (x < 0 || x >= surface->width) 1996 continue; 1997 1998 src = surface->i44buffer + x + y * surface->width; 1999 *src = 0xaa; //white 2000 } 2001 } 2002 2003 for (int x = xstart; x < xend; x++) 2004 { 2005 if (x < 0 || x >= surface->width) 2006 continue; 2007 2008 for (int y = ystart; y < ystart + 2; y++) 2009 { 2010 if (y < 0 || y >= surface->height) 2011 continue; 2012 2013 src = surface->i44buffer + x + y * surface->width; 2014 *src = 0xaa; 2015 } 2016 for (int y = yend - 2; y < yend; y++) 2017 { 2018 if (y < 0 || y >= surface->height) 2019 continue; 2020 2021 src = surface->i44buffer + x + y * surface->width; 2022 *src = 0xaa; 2023 } 2024 } 2025 } 2026 1614 2027 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1615 2028 1616 2029 OSDTypePositionImage::OSDTypePositionImage(const QString &name) -
libs/libmythtv/videooutbase.cpp
1172 1172 if (!osd) 1173 1173 return -1; 1174 1174 1175 OSDSurface * surface= osd->Display();1176 if (! surface)1175 OSDSurface *osdsurf = osd->Display(); 1176 if (!osdsurf) 1177 1177 return -1; 1178 1178 1179 1179 bool changed = (-1 == revision) ? 1180 surface->Changed() : (surface->GetRevision()!=revision);1180 osdsurf->Changed() : (osdsurf->GetRevision()!=revision); 1181 1181 1182 if (osdsurf->SurfaceType() == OSDSurface::SURF_YUV) 1183 { 1184 YUVSurface *surface = (YUVSurface*)osdsurf; 1185 1182 1186 switch (frame->codec) 1183 1187 { 1184 1188 case FMT_YV12: … … 1213 1217 default: 1214 1218 break; 1215 1219 } 1220 } 1221 else if (osdsurf->SurfaceType() == OSDSurface::SURF_I44) 1222 { 1223 I44Surface* surface=(I44Surface*)osdsurf; 1224 1225 if (changed) 1226 surface->BlendToI44( frame->buf, false, stride, XJ_height); 1227 } 1228 1216 1229 return (changed) ? 1 : 0; 1217 1230 } 1218 1231 -
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 … … 214 218 bool m_scrollinit; 215 219 216 220 float m_linespacing; 221 222 Raster_Map *m_raster; 217 223 }; 218 224 219 225 class OSDTypeImage : public OSDType … … 247 253 248 254 virtual void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, 249 255 int yoff); 256 void Draw(YUVSurface *surface, int fade, int maxfade, int xoff, 257 int yoff); 258 void Draw(I44Surface *surface, int fade, int maxfade, int xoff, 259 int yoff); 250 260 261 // TODO this should not be static -- dtk 262 static void SetPalette(const QValueList<QColor> &palette) 263 { s_palette = palette; } 264 // TODO this should not be static -- dtk 265 // TODO QValueList here is unsafe, QValueList is not threadsafe -- dtk 266 static QValueList<QColor> GetPalette(void) { return s_palette; } 267 251 268 protected: 252 269 QRect m_imagesize; 253 270 QPoint m_displaypos; … … 263 280 264 281 unsigned char *m_alpha; 265 282 283 unsigned char *m_i44; 284 266 285 int m_scalew, m_scaleh; 286 float m_wmult, m_hmult; 267 287 268 288 int m_drawwidth; 269 289 bool m_onlyusefirst; 290 291 // Cant think of a clean way to get this to all the osdtypes that need it. 292 // TODO this should not be static -- dtk 293 // TODO QValueList is not threadsafe -- dtk 294 static QValueList<QColor> s_palette; 270 295 }; 271 296 272 297 class OSDTypePosSlider : public OSDTypeImage … … 333 358 void SetRange(int start, int end); 334 359 335 360 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff); 361 void Draw(YUVSurface *surface, int fade, int maxfade, int xoff, int yoff); 362 void Draw(I44Surface *surface, int fade, int maxfade, int xoff, int yoff); 336 363 337 364 private: 338 365 QRect m_displayrect; … … 365 392 void SetRect(QRect newrect) { size = newrect; } 366 393 367 394 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff); 395 void Draw(YUVSurface *surface, int fade, int maxfade, int xoff, int yoff); 396 void Draw(I44Surface *surface, int fade, int maxfade, int xoff, int yoff); 368 397 369 398 private: 370 399 QRect size; … … 405 434 void Reinit(float wchange, float hchange); 406 435 407 436 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff); 437 void Draw(YUVSurface *surface, int fade, int maxfade, int xoff, int yoff); 438 void Draw(I44Surface *surface, int fade, int maxfade, int xoff, int yoff); 408 439 409 440 private: 410 441 vector<QRect> positions; -
libs/libmythtv/videoout_xv.cpp
2622 2622 XvMCOSD* xvmc_osd = GetAvailableOSD(); 2623 2623 if (osd && xvmc_osd->IsValid()) 2624 2624 { 2625 if (osd->HasPalette() && !xvmc_osd->CustomPalette()) 2626 { 2627 VERBOSE(VB_PLAYBACK, LOC + "Setting XvMC OSD palette"); 2628 xvmc_osd->SetPalette(osd->GetPalette()); 2629 } 2630 2625 2631 VideoFrame *osdframe = NULL; 2626 2632 int ret = DisplayOSD(xvmc_osd->OSDFrame(), osd, -1, 2627 2633 xvmc_osd->GetRevision()); … … 3359 3365 Reinit(next); 3360 3366 3361 3367 // then blend the OSD onto it 3362 unsigned char *buf = (unsigned char*) shm_infos[next].shmaddr; 3363 osdsurf->BlendToARGB(buf, img[next]->bytes_per_line, vf[next].height, 3364 false/*blend_to_black*/, 16); 3368 YUVSurface *yuvsurf = dynamic_cast<YUVSurface*>(osdsurf); 3369 if (yuvsurf) 3370 { 3371 unsigned char *buf = (unsigned char*) shm_infos[next].shmaddr; 3372 yuvsurf->BlendToARGB(buf, img[next]->bytes_per_line, vf[next].height, 3373 false/*blend_to_black*/, 16); 3374 } 3365 3375 3366 3376 // then set it as the current OSD image 3367 3377 revision = osdsurf->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; … … 131 132 osd_subpict_alloc = true; 132 133 } 133 134 135 void XvMCOSD::SetPalette(const QValueList<QColor> &palette) 136 { 137 int i; 138 custompalette = true; 139 int entries = palette.count(); 140 141 VERBOSE(VB_PLAYBACK, QString("SetPalette entries %1").arg(entries)); 142 143 if (entries > osd_subpict.num_palette_entries) 144 entries = osd_subpict.num_palette_entries; 145 int seb = osd_subpict.entry_bytes; 146 147 for (i=0; i<entries; i++) 148 { 149 int r = palette[i].red(); 150 int g = palette[i].green(); 151 int b = palette[i].blue(); 152 153 int Y = (int)((0.257*r)+(0.504*g)+(0.098*b)+16); 154 int U = (int)(-(0.148*r)-(0.291*g)+(0.439*b)+128); 155 int V = (int)((0.439*r)-(0.368*g)-(0.071*b)+128); 156 157 VERBOSE(VB_PLAYBACK, 158 QString("Colour: Y=%1 U=%1 V=%1" ).arg(Y).arg(U).arg(V)); 159 160 for (int j = 0; j < seb; j++) 161 { 162 switch (osd_subpict.component_order[j]) 163 { 164 case 'U': osd_palette[i * seb + j] = U; break; 165 case 'V': osd_palette[i * seb + j] = V; break; 166 case 'Y': 167 default: osd_palette[i * seb + j] = Y; break; 168 } 169 } 170 } 171 172 X11S(XvMCSetSubpicturePalette(XJ_disp, &osd_subpict, osd_palette)); 173 } 174 134 175 void XvMCOSD::DeleteBuffer() 135 176 { 136 177 if (!osd_subpict_alloc) -
libs/libmythtv/osdsurface.cpp
11 11 12 12 #endif 13 13 14 OSDSurface::OSDSurface(int w, int h) 14 OSDSurface::OSDSurface(int w, int h) : 15 width(std::max(w,0)), height(std::max(h,0)), size(width * height) 15 16 { 17 Clear(); 18 } 19 20 OSDSurface::~OSDSurface() 21 { 22 } 23 24 void OSDSurface::Clear(void) 25 { 26 usedRegions = QRegion(); 27 } 28 29 void OSDSurface::ClearUsed(void) 30 { 31 } 32 33 bool OSDSurface::IntersectsDrawn(QRect &newrect) 34 { 35 QMemArray<QRect> rects = usedRegions.rects(); 36 QMemArray<QRect>::Iterator it = rects.begin(); 37 38 for (; it != rects.end(); ++it) 39 { 40 if (newrect.intersects(*it)) 41 return true; 42 } 43 44 return false; 45 } 46 47 void OSDSurface::AddRect(QRect &newrect) 48 { 49 usedRegions = usedRegions.unite(newrect); 50 } 51 52 YUVSurface::YUVSurface(int w, int h) : 53 OSDSurface(w, h) 54 { 16 55 yuvbuffer = new unsigned char[w * (h + 2) * 3 / 2]; 17 56 y = yuvbuffer; 18 57 u = yuvbuffer + w * h; 19 58 v = u + w * h / 4; 20 59 alpha = new unsigned char[w * (h + 2)]; 21 60 22 width = w;23 height = h;24 25 size = width * height;26 27 61 for (int i = 0; i < 256; i++) 28 62 { 29 63 for (int j = 0; j < 256; j++) … … 72 106 revision = 0; 73 107 } 74 108 75 OSDSurface::~OSDSurface()109 YUVSurface::~YUVSurface() 76 110 { 77 111 delete [] yuvbuffer; 78 112 delete [] alpha; 79 113 } 80 114 81 void OSDSurface::Clear(void)115 void YUVSurface::Clear(void) 82 116 { 83 117 memset(y, 0, size); 84 118 memset(u, 127, size / 4); 85 119 memset(v, 127, size / 4); 86 120 memset(alpha, 0, size); 87 usedRegions = QRegion(); 121 122 OSDSurface::Clear(); 88 123 } 89 124 90 void OSDSurface::ClearUsed(void)125 void YUVSurface::ClearUsed(void) 91 126 { 92 127 QMemArray<QRect> rects = usedRegions.rects(); 93 128 QMemArray<QRect>::Iterator it = rects.begin(); … … 127 162 } 128 163 129 164 usedRegions = QRegion(); 165 166 OSDSurface::Clear(); 130 167 } 131 168 132 bool OSDSurface::IntersectsDrawn(QRect &newrect)133 {134 QMemArray<QRect> rects = usedRegions.rects();135 QMemArray<QRect>::Iterator it = rects.begin();136 for (; it != rects.end(); ++it)137 if (newrect.intersects(*it))138 return true;139 return false;140 }141 169 142 void OSDSurface::AddRect(QRect &newrect)143 {144 usedRegions = usedRegions.unite(newrect);145 }146 147 170 /////////////////////////////////////////////////////////////////////////// 148 171 // Helper functions 149 172 /////////////////////////////////////////////////////////////////////////// … … 251 274 } 252 275 #endif 253 276 254 blendtoyv12_8_fun blendtoyv12_8_init(const OSDSurface *surface)277 blendtoyv12_8_fun blendtoyv12_8_init(const YUVSurface *surface) 255 278 { 256 279 (void)surface; 257 280 #ifdef MMX … … 261 284 return blendalpha8_c; 262 285 } 263 286 264 static inline void blendtoargb_8_c(const OSDSurface *surf, unsigned char *src,287 static inline void blendtoargb_8_c(const YUVSurface *surf, unsigned char *src, 265 288 unsigned char *usrc, unsigned char *vsrc, 266 289 unsigned char *alpha, unsigned char *dest) 267 290 { … … 283 306 284 307 #ifdef MMX 285 308 #define movntq(src, dest) movq_r2m(src, dest); 286 static inline void blendtoargb_8_mmx(const OSDSurface * /*surf*/, unsigned char *src, 309 static inline void blendtoargb_8_mmx(const YUVSurface * /*surf*/, 310 unsigned char *src, 287 311 unsigned char *usrc, unsigned char *vsrc, 288 312 unsigned char *alpha, unsigned char *dest) 289 313 { … … 378 402 } 379 403 #endif 380 404 381 blendtoargb_8_fun blendtoargb_8_init(const OSDSurface *surface)405 blendtoargb_8_fun blendtoargb_8_init(const YUVSurface *surface) 382 406 { 383 407 (void)surface; 384 408 #ifdef MMX … … 494 518 } 495 519 #endif 496 520 497 dithertoia44_8_fun dithertoia44_8_init(const OSDSurface* /*surface*/)521 dithertoia44_8_fun dithertoia44_8_init(const YUVSurface* /*surface*/) 498 522 { 499 523 #ifdef MMX 500 524 // mmx version seems to be about the same speed, no reason to use it. … … 543 567 delete context; 544 568 } 545 569 546 /** \fn OSDSurface::BlendToYV12(unsigned char *) const547 * \brief Alpha blends OSDSurface to yuv buffer of the same size.570 /** \fn YUVSurface::BlendToYV12(unsigned char *) const 571 * \brief Alpha blends YUVSurface to yuv buffer of the same size. 548 572 * \param yuvptr Pointer to YUV buffer to blend OSD to. 549 573 */ 550 void OSDSurface::BlendToYV12(unsigned char *yuvptr) const574 void YUVSurface::BlendToYV12(unsigned char *yuvptr) const 551 575 { 552 const OSDSurface *surface = this;576 const YUVSurface *surface = this; 553 577 blendtoyv12_8_fun blender = blendtoyv12_8_init(surface); 554 578 555 579 unsigned char *uptrdest = yuvptr + surface->width * surface->height; … … 668 692 } 669 693 } 670 694 671 /** \fn OSDSurface::BlendToARGB(unsigned char *,uint,uint,bool) const672 * \brief Alpha blends OSDSurface to ARGB buffer.695 /** \fn YUVSurface::BlendToARGB(unsigned char *,uint,uint,bool) const 696 * \brief Alpha blends YUVSurface to ARGB buffer. 673 697 * 674 698 * \todo Currently blend_to_black is implemented as a post process 675 699 * on the whole frame, it would make sense to make this more … … 680 704 * \param blend_to_black Uses Alpha to blend buffer to black 681 705 * \param threshold Alpha threshold above which to perform blending 682 706 */ 683 void OSDSurface::BlendToARGB(unsigned char *argbptr, uint stride,707 void YUVSurface::BlendToARGB(unsigned char *argbptr, uint stride, 684 708 uint outheight, bool blend_to_black, 685 709 uint threshold) const 686 710 { 687 const OSDSurface *surface = this;711 const YUVSurface *surface = this; 688 712 blendtoargb_8_fun blender = blendtoargb_8_init(surface); 689 713 const unsigned char *cm = surface->cm; 690 714 … … 756 780 BlendToBlack(argbptr, stride>>2, outheight); 757 781 } 758 782 759 /** \fn OSDSurface::DitherToI44(unsigned char*,bool,uint,uint) const760 * \brief Copies and converts OSDSurface to either a greyscale783 /** \fn YUVSurface::DitherToI44(unsigned char*,bool,uint,uint) const 784 * \brief Copies and converts YUVSurface to either a greyscale 761 785 * IA44 or AI44 buffer. 762 786 * \sa DitherToIA44(unsigned char*,uint,uint) const, 763 787 * DitherToAI44(unsigned char*,uint,uint) const. … … 767 791 * \param stride Length of each line in output buffer in bytes 768 792 * \param outheight Number of lines in output buffer 769 793 */ 770 void OSDSurface::DitherToI44(unsigned char *outbuf, bool ifirst,794 void YUVSurface::DitherToI44(unsigned char *outbuf, bool ifirst, 771 795 uint stride, uint outheight) const 772 796 { 773 const OSDSurface *surface = this;797 const YUVSurface *surface = this; 774 798 int ashift = ifirst ? 0 : 4; 775 799 int amask = ifirst ? 0x0f : 0xf0; 776 800 … … 855 879 delete_dithertoia44_8_context(dcontext); 856 880 } 857 881 858 /** \fn OSDSurface::DitherToIA44(unsigned char*,uint,uint) const859 * \brief Copies and converts OSDSurface to a greyscale IA44 buffer.882 /** \fn YUVSurface::DitherToIA44(unsigned char*,uint,uint) const 883 * \brief Copies and converts YUVSurface to a greyscale IA44 buffer. 860 884 * 861 885 * \param outbuf Output buffer 862 886 * \param stride Length of each line in output buffer in bytes … … 864 888 * \sa DitherToI44(unsigned char*,bool,uint,uint) const, 865 889 * DitherToAI44(unsigned char*,uint,uint) const. 866 890 */ 867 void OSDSurface::DitherToIA44(unsigned char* outbuf,891 void YUVSurface::DitherToIA44(unsigned char* outbuf, 868 892 uint stride, uint outheight) const 869 893 { 870 894 DitherToI44(outbuf, false, stride, outheight); 871 895 } 872 896 873 /** \fn OSDSurface::DitherToAI44(unsigned char*,bool,uint,uint) const874 * \brief Copies and converts OSDSurface to a greyscale AI44 buffer.897 /** \fn YUVSurface::DitherToAI44(unsigned char*,bool,uint,uint) const 898 * \brief Copies and converts YUVSurface to a greyscale AI44 buffer. 875 899 * 876 900 * \param outbuf Output buffer 877 901 * \param stride Length of each line in output buffer in bytes … … 879 903 * \sa DitherToI44(unsigned char*,bool,uint,uint) const, 880 904 * DitherToIA44(unsigned char*,uint,uint) const. 881 905 */ 882 void OSDSurface::DitherToAI44(unsigned char* outbuf,906 void YUVSurface::DitherToAI44(unsigned char* outbuf, 883 907 uint stride, uint outheight) const 884 908 { 885 909 DitherToI44(outbuf, true, stride, outheight); 886 910 } 911 912 I44Surface::I44Surface(int w, int h) : 913 OSDSurface(w,h) 914 { 915 i44buffer = new unsigned char [size]; 916 Clear(); 917 } 918 919 I44Surface::~I44Surface() 920 { 921 delete [] i44buffer; 922 } 923 924 void I44Surface::Clear(void) 925 { 926 bzero(i44buffer, size); 927 OSDSurface::Clear(); 928 } 929 930 void I44Surface::ClearUsed(void) 931 { 932 bzero(i44buffer, size); 933 OSDSurface::Clear(); 934 } 935 936 void I44Surface::BlendToI44(unsigned char *i44ptr, bool /*ifirst*/, 937 uint /*stride*/, uint /*height*/) const 938 { 939 memcpy(i44ptr, i44buffer, size); 940 } -
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 #if 0 39 46 struct Raster_Map 40 47 { 41 48 int width; … … 44 51 int size; 45 52 unsigned char *bitmap; 46 53 }; 54 #endif 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 rmap->cols = (m_mono) ? (rmap->width+7) >> 3 : rmap->width; 119 rmap->size = rmap->rows * rmap->cols; 108 120 if (rmap->size <= 0) 109 121 { 110 122 delete rmap; … … 202 214 void TTFFont::render_text(Raster_Map *rmap, Raster_Map *rchr, 203 215 const QString &text, int *xorblah, int *yor) 204 216 { 217 #ifdef TIMING 218 Timer t("render_text"); 219 #endif 220 205 221 FT_F26Dot6 x, y, xmin, ymin, xmax, ymax; 206 222 FT_BBox bbox; 207 223 unsigned int i, ioff, iread; … … 248 264 origin.x = 0; 249 265 origin.y = 0; 250 266 251 FT_Glyph_To_Bitmap(&glyphs[j], ft_render_mode_normal, &origin, 1); 267 FT_Render_Mode rmode; 268 rmode = m_mono ? ft_render_mode_mono : ft_render_mode_normal; 269 FT_Glyph_To_Bitmap(&glyphs[j], rmode, &origin, 1); 252 270 bmap = (FT_BitmapGlyph)(glyphs[j]); 253 271 254 272 glyphs_cached[j] = duplicate_raster(bmap); … … 311 329 if (ymax >= rmap->rows) 312 330 ymax = rmap->rows - 1; 313 331 332 int x_ioff = 0, x_iread=0; 333 314 334 if (xmin < 0) 315 335 { 316 iread -=xmin;336 x_iread = -xmin; 317 337 xmin = 0; 318 338 } 319 339 else 320 ioff += xmin;340 x_ioff = xmin; 321 341 322 342 if (xmax >= rmap->width) 323 343 xmax = rmap->width - 1; … … 327 347 _read = (char *)rtmp->bitmap + iread; 328 348 _off = (char *)rmap->bitmap + ioff; 329 349 350 int len = xmax - xmin; 351 int bytes = len >> 3; 352 353 int x_off = x_ioff; 354 355 unsigned char last=0, next=0; 356 unsigned char lmask,nmask=255; 357 358 int bit_off = x_off&7; 359 360 nmask = nmask >> bit_off; 361 lmask = 255 ^ nmask; 362 330 363 for (y = ymin; y <= ymax; y++) 331 364 { 332 365 read = _read; 333 366 off = _off; 334 367 335 for (x = xmin; x <= xmax; x++)368 if (m_mono) 336 369 { 337 *off = *read; 338 off++; 339 read++; 370 off += (x_off>>3); 371 372 int i; 373 last = *off; 374 for (i=0; i<=bytes; i++) 375 { 376 __asm__ __volatile__ ( 377 "movb %b1, %b0; rorb %b2,%b0" 378 : "=a"(next):"g"(*read++),"c"(bit_off)); 379 380 *off++ = (last & lmask)|(next & nmask); 381 382 last=next; 383 } 384 if (bit_off) 385 *off |= last & lmask; 386 387 // i 16, j 't' xmin 180, xmax 186, x_iread 0, x_ioff 180 iread 34 ioff 594 388 // i 17, j 'c' xmin 188, xmax 197, x_iread 0, x_ioff 188 iread 24 ioff 594 389 // i 18, j 'h' xmin 201, xmax 210, x_iread 0, x_ioff 201 iread 34 ioff 594 340 390 } 391 else 392 { 393 read += x_iread; 394 off += x_ioff; 395 396 for (x = xmin; x <= xmax; x++) 397 { 398 *off = *read; 399 off++; 400 read++; 401 } 402 } 341 403 _read -= rtmp->cols; 342 404 _off -= rmap->cols; 343 405 } … … 349 411 } 350 412 } 351 413 352 void TTFFont::merge_text( OSDSurface *surface, Raster_Map * rmap, int offset_x,414 void TTFFont::merge_text(I44Surface *surface, Raster_Map * rmap, int offset_x, 353 415 int offset_y, int xstart, int ystart, int width, 354 416 int height, int alphamod, kTTF_Color k) 355 417 { 418 #ifdef TIMING 419 Timer t("merge_text i44"); 420 #endif 421 422 unsigned char *asrc, *adst; 423 if (xstart < 0) 424 { 425 width += xstart; 426 offset_x -= xstart; 427 xstart = 0; 428 } 429 430 if (ystart < 0) 431 { 432 height += ystart; 433 offset_y -= ystart; 434 ystart = 0; 435 } 436 437 if (height + ystart > surface->height) 438 height = surface->height - ystart; 439 440 if (width + xstart > surface->width) 441 width = surface->width - xstart; 442 443 QRect drawRect(xstart, ystart, width, height); 444 surface->AddRect(drawRect); 445 446 int x, y; 447 448 asrc = rmap->bitmap; 449 adst = surface->i44buffer; 450 451 asrc += rmap->cols*offset_y+(offset_x>>3); 452 adst += xstart+ystart*surface->width; 453 454 unsigned long col; 455 switch(k) 456 { 457 case kTTF_Normal: 458 col = (m_color_normal&0xf)<<4; 459 break; 460 case kTTF_Outline: 461 col = (m_color_outline&0xf)<<4; 462 break; 463 case kTTF_Shadow: 464 col = (m_color_shadow&0xf)<<4; 465 break; 466 } 467 468 if (alphamod>255) 469 alphamod = 255; 470 col |= alphamod>>4; 471 472 for (y = 0; y<height;y++) 473 { 474 char ch; 475 int j = 0; 476 477 for (x = 0; x<width;x++) 478 { 479 if ((x&7) == 0) 480 { 481 ch = asrc[j++]; 482 } 483 else 484 { 485 ch = ch<<1; 486 } 487 488 if (ch & 0x80) 489 adst[x] = col;// | 0x0f; 490 } 491 asrc += rmap->cols; 492 adst += surface->width; 493 } 494 } 495 496 void TTFFont::merge_text(YUVSurface *surface, Raster_Map * rmap, int offset_x, 497 int offset_y, int xstart, int ystart, int width, 498 int height, int alphamod, kTTF_Color k) 499 { 356 500 unsigned char * asrc, * ydst, * udst, * vdst, * adst; 357 501 uint8_t color_y = 0, color_u = 0, color_v = 0; 358 502 … … 411 555 surface->pow_lut); 412 556 } 413 557 414 void TTFFont::DrawString(OSDSurface *surface, int x, int y, 415 const QString &text, int maxx, int maxy, 416 int alphamod) 558 Raster_Map* TTFFont::Prerender(const QString &text) 417 559 { 418 int width, height, w, h, inx, iny, clipx, clipy; 419 Raster_Map *rmap, *rtmp; 420 char is_pixmap = 0; 560 #ifdef TIMING 561 Timer t("Prerender"); 562 #endif 563 int inx, iny, w, h; 564 Raster_Map *rmap, *rtmp; 565 char is_pixmap = 0; 421 566 422 567 if (text.length() < 1) 423 return ;568 return 0; 424 569 425 570 inx = 0; 426 571 iny = 0; … … 429 574 if (w <= 0 || h <= 0) 430 575 { 431 576 destroy_font_raster(rtmp); 432 return ;577 return 0; 433 578 } 434 579 rmap = create_font_raster(w, h); 435 580 … … 437 582 438 583 is_pixmap = 1; 439 584 585 rmap->m_w = w; 586 rmap->m_h = h; 587 rmap->m_inx = inx; 588 rmap->m_iny = iny; 589 590 return rmap; 591 } 592 593 void TTFFont::DrawString(OSDSurface *surface, int x, int y, 594 const QString &text, int maxx, int maxy, 595 int alphamod ) 596 { 597 #ifdef TIMING 598 Timer t("DrawString"); 599 #endif 600 Raster_Map *rmap; 601 602 int width, height, w, h, inx, iny, clipx, clipy; 603 604 if (rasters.contains(text)) 605 { 606 rmap = rasters[text]; 607 } 608 else 609 { 610 rmap = Prerender(text); 611 rasters[text] = rmap; 612 } 613 614 if (!rmap) 615 return; 616 617 w = rmap->m_w; 618 h = rmap->m_h; 619 inx = rmap->m_inx; 620 iny = rmap->m_iny; 621 440 622 y += loadedfontsize; 441 623 442 624 width = maxx; … … 470 652 } 471 653 if ((width <= 0) || (height <= 0)) 472 654 { 473 destroy_font_raster(rmap); 474 destroy_font_raster(rtmp); 475 return; 655 return; 476 656 } 477 657 478 658 if (m_shadowxoff > 0 || m_shadowyoff > 0) 479 659 { 480 merge_text(surface, rmap, clipx, clipy, x + m_shadowxoff, 481 y + m_shadowyoff, width, height, alphamod, kTTF_Shadow); 660 if (surface->SurfaceType() == OSDSurface::SURF_YUV) 661 { 662 merge_text((YUVSurface*)surface, rmap, clipx, clipy, 663 x + m_shadowxoff, y + m_shadowyoff, 664 width, height, alphamod, kTTF_Shadow); 665 } 666 else if (surface->SurfaceType() == OSDSurface::SURF_I44) 667 { 668 merge_text((I44Surface*)surface, rmap, clipx, clipy, 669 x + m_shadowxoff, y + m_shadowyoff, 670 width, height, alphamod, kTTF_Shadow); 671 } 482 672 } 483 673 484 674 if (m_outline) 485 675 { 486 merge_text(surface, rmap, clipx, clipy, x - 1, y - 1, width, height, 487 alphamod, kTTF_Outline); 488 merge_text(surface, rmap, clipx, clipy, x + 1, y - 1, width, height, 489 alphamod, kTTF_Outline); 490 merge_text(surface, rmap, clipx, clipy, x - 1, y + 1, width, height, 491 alphamod, kTTF_Outline); 492 merge_text(surface, rmap, clipx, clipy, x + 1, y + 1, width, height, 493 alphamod, kTTF_Outline); 676 if (surface->SurfaceType() == OSDSurface::SURF_YUV) 677 { 678 merge_text((YUVSurface*)surface, rmap, clipx, clipy, 679 x - 1, y - 1, width, height, 680 alphamod, kTTF_Outline); 681 merge_text((YUVSurface*)surface, rmap, clipx, clipy, 682 x + 1, y - 1, width, height, 683 alphamod, kTTF_Outline); 684 merge_text((YUVSurface*)surface, rmap, clipx, clipy, 685 x - 1, y + 1, width, height, 686 alphamod, kTTF_Outline); 687 merge_text((YUVSurface*)surface, rmap, clipx, clipy, 688 x + 1, y + 1, width, height, 689 alphamod, kTTF_Outline); 690 } 691 else if (surface->SurfaceType() == OSDSurface::SURF_I44) 692 { 693 merge_text((I44Surface*)surface, rmap, clipx, clipy, 694 x - 1, y - 1, width, height, 695 alphamod, kTTF_Outline); 696 merge_text((I44Surface*)surface, rmap, clipx, clipy, 697 x + 1, y - 1, width, height, 698 alphamod, kTTF_Outline); 699 merge_text((I44Surface*)surface, rmap, clipx, clipy, 700 x - 1, y + 1, width, height, 701 alphamod, kTTF_Outline); 702 merge_text((I44Surface*)surface, rmap, clipx, clipy, 703 x + 1, y + 1, width, height, 704 alphamod, kTTF_Outline); 705 706 } 494 707 } 495 708 496 merge_text(surface, rmap, clipx, clipy, x, y, width, height, alphamod); 497 498 destroy_font_raster(rmap); 499 destroy_font_raster(rtmp); 709 if (surface->SurfaceType() == OSDSurface::SURF_YUV) 710 { 711 merge_text((YUVSurface*)surface, rmap, clipx, clipy, 712 x, y, width, height, alphamod); 713 } 714 else if (surface->SurfaceType() == OSDSurface::SURF_I44) 715 { 716 merge_text((I44Surface*)surface, rmap, clipx, clipy, 717 x, y, width, height, alphamod); 718 } 500 719 } 501 720 502 721 TTFFont::~TTFFont() 503 722 { 504 if (!valid) 505 return; 723 QMap<QString,Raster_Map*>::Iterator it; 724 for (it = rasters.begin(); it != rasters.end(); ++it) 725 destroy_font_raster(*it); 506 726 507 KillFace(); 727 if (!valid) 728 return; 729 730 KillFace(); 508 731 } 509 732 510 733 void TTFFont::KillFace(void) … … 526 749 } 527 750 528 751 TTFFont::TTFFont(char *file, int size, int video_width, int video_height, 529 float hmult )752 float hmult, bool mono) 530 753 { 531 754 FT_Error error; 532 755 … … 534 757 m_size = size; 535 758 spacewidth = 0; 536 759 760 m_mono = mono; 537 761 m_outline = false; 538 762 m_shadowxoff = 0; 539 763 m_shadowyoff = 0; 540 764 541 765 m_color_normal_y = 255; 766 m_color_normal = 255; 542 767 m_color_normal_u = m_color_normal_v = 128; 543 768 544 769 m_color_outline_y = 0x40; 770 m_color_outline = 0x40; 545 771 m_color_outline_u = m_color_outline_v = 128; 546 772 547 773 m_color_shadow_y = 0x20; 774 m_color_shadow = 0x20; 548 775 m_color_shadow_u = m_color_shadow_v = 128; 549 776 550 777 if (!have_library) -
libs/libmythtv/osd.cpp
29 29 30 30 OSD::OSD(int width, int height, int frint, 31 31 int dispx, int dispy, int dispw, int disph) 32 : QObject( )32 : QObject(NULL, "osd") 33 33 { 34 hasPalette = false; 34 35 changed = false; 35 36 vid_width = width; 36 37 vid_height = height; … … 75 76 76 77 SetDefaults(); 77 78 78 drawSurface = new OSDSurface(width, height); 79 if (surftype == "I44") 80 drawSurface = new I44Surface(width, height); 81 else //default to normal YUV 82 drawSurface = new YUVSurface(width, height); 79 83 } 80 84 81 85 OSD::~OSD(void) … … 245 249 } 246 250 247 251 delete drawSurface; 248 drawSurface = new OSDSurface(width, height);249 252 253 if (surftype == "I44") 254 drawSurface = new I44Surface(width, height); 255 else //default to normal YUV 256 drawSurface = new YUVSurface(width, height); 257 250 258 osdlock.unlock(); 251 259 } 252 260 … … 274 282 TTFFont *OSD::LoadFont(QString name, int size) 275 283 { 276 284 QString fullname = MythContext::GetConfDir() + "/" + name; 285 bool mono = (surftype == "I44"); 277 286 TTFFont *font = new TTFFont((char *)fullname.ascii(), size, vid_width, 278 vid_height, hmult );287 vid_height, hmult, mono); 279 288 280 289 if (font->isValid()) 281 290 return font; … … 284 293 fullname = gContext->GetShareDir() + name; 285 294 286 295 font = new TTFFont((char *)fullname.ascii(), size, vid_width, 287 vid_height, hmult );296 vid_height, hmult, mono); 288 297 289 298 if (font->isValid()) 290 299 return font; … … 294 303 { 295 304 fullname = themepath + "/" + name; 296 305 font = new TTFFont((char *)fullname.ascii(), size, vid_width, 297 vid_height, hmult );306 vid_height, hmult, mono); 298 307 if (font->isValid()) 299 308 return font; 300 309 } … … 303 312 304 313 fullname = name; 305 314 font = new TTFFont((char *)fullname.ascii(), size, vid_width, vid_height, 306 hmult );315 hmult, mono); 307 316 308 317 if (font->isValid()) 309 318 return font; … … 327 336 return ""; 328 337 } 329 338 339 void OSD::parsePalette(QDomElement &element) 340 { 341 hasPalette = true; 342 343 for (QDomNode child = element.firstChild(); !child.isNull(); 344 child = child.nextSibling()) 345 { 346 QDomElement node = child.toElement(); 347 348 if (node.isNull()) 349 continue; 350 351 if (node.tagName() != "rgb") 352 { 353 VERBOSE(VB_IMPORTANT, QString("Unknown tag '%1' in colour node") 354 .arg(node.tagName())); 355 continue; 356 } 357 358 int r, g, b; 359 QString text = getFirstText(node); 360 if (sscanf(text.data(), "%d,%d,%d", &r, &g, &b) != 3) 361 { 362 VERBOSE(VB_IMPORTANT, QString("Badly formed rgb node '%1'") 363 .arg(text.data())); 364 continue; 365 } 366 367 // Success! Add new color to the palette. 368 surfPalette.append(QColor(r,g,b)); 369 } 370 } 371 330 372 void OSD::parseFont(QDomElement &element) 331 373 { 332 374 QString name; … … 1196 1238 { 1197 1239 parseContainer(e); 1198 1240 } 1241 else if (e.tagName() == "surface") 1242 { 1243 surftype = getFirstText(e); 1244 } 1245 else if (e.tagName() == "palette") 1246 { 1247 parsePalette(e); 1248 OSDTypeImage::SetPalette(surfPalette); 1249 } 1199 1250 else 1200 1251 { 1201 1252 VERBOSE(VB_IMPORTANT, "Unknown element: " << e.tagName()); -
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, … … 45 91 void DitherToIA44(unsigned char* outbuf, uint stride, uint height) const; 46 92 void DitherToAI44(unsigned char* outbuf, uint stride, uint height) const; 47 93 48 int revision;49 50 94 unsigned char *yuvbuffer; 51 95 52 96 // just pointers into yuvbuffer … … 56 100 57 101 unsigned char *alpha; 58 102 59 int width;60 int height;61 int size;62 63 QRegion usedRegions;64 65 103 #ifdef MMX 66 104 short int rec_lut[256]; 67 105 #else … … 75 113 blendcolor_ptr blendcolorfunc; 76 114 blendconst_ptr blendconstfunc; 77 115 78 bool changed;79 80 116 bool usemmx; 81 117 82 118 unsigned char cropTbl[256 + 2 * MAX_NEG_CROP]; … … 86 122 typedef void (*blendtoyv12_8_fun)(unsigned char *src, unsigned char *dest, 87 123 unsigned char *alpha, bool uvplane); 88 124 89 blendtoyv12_8_fun blendtoyv12_8_init(const OSDSurface *surface);125 blendtoyv12_8_fun blendtoyv12_8_init(const YUVSurface *surface); 90 126 91 typedef void (*blendtoargb_8_fun)(const OSDSurface *surf, unsigned char *src,127 typedef void (*blendtoargb_8_fun)(const YUVSurface *surf, unsigned char *src, 92 128 unsigned char *usrc, unsigned char *vsrc, 93 129 unsigned char *alpha, unsigned char *dest); 94 130 95 blendtoargb_8_fun blendtoargb_8_init(const OSDSurface *surface);131 blendtoargb_8_fun blendtoargb_8_init(const YUVSurface *surface); 96 132 97 133 98 134 struct dither8_context; … … 102 138 const unsigned char *dmp, int xpos, 103 139 dither8_context *context); 104 140 105 dithertoia44_8_fun dithertoia44_8_init(const OSDSurface *surface);141 dithertoia44_8_fun dithertoia44_8_init(const YUVSurface *surface); 106 142 dither8_context *init_dithertoia44_8_context(bool first); 107 143 void delete_dithertoia44_8_context(dither8_context *context); 108 144 -
libs/libmythtv/ttfont.h
17 17 18 18 struct Raster_Map; 19 19 class OSDSurface; 20 class YUVSurface; 21 class I44Surface; 20 22 21 23 enum kTTF_Color { 22 24 kTTF_Normal = 0, … … 24 26 kTTF_Shadow, 25 27 }; 26 28 29 struct Raster_Map 30 { 31 int width; 32 int rows; 33 int cols; 34 int size; 35 unsigned char *bitmap; 36 int m_w; 37 int m_h; 38 int m_inx; 39 int m_iny; 40 }; 41 27 42 class TTFFont 28 43 { 29 44 public: 30 45 TTFFont(char *file, int size, int video_width, int video_height, 31 float hmult );46 float hmult, bool mono); 32 47 ~TTFFont(); 33 48 34 49 // Actually greyscale, keep for compat. … … 41 56 42 57 bool isValid(void) { return valid; } 43 58 59 Raster_Map* Prerender(const QString &text ); 44 60 void DrawString(OSDSurface *surface, int x, int y, const QString &text, 45 61 int maxx, int maxy, int alphamod = 255); 46 62 void CalcWidth(const QString &text, int *width_return); … … 50 66 51 67 void Reinit(int width, int height, float hmult); 52 68 69 static void destroy_font_raster(Raster_Map *rmap); 70 53 71 private: 54 72 void KillFace(void); 55 73 void Init(void); … … 57 75 Raster_Map *create_font_raster(int width, int height); 58 76 Raster_Map *duplicate_raster(FT_BitmapGlyph bmap); 59 77 void clear_raster(Raster_Map *rmap); 60 void destroy_font_raster(Raster_Map *rmap);61 78 Raster_Map *calc_size(int *width, int *height, const QString &text); 62 79 void render_text(Raster_Map *rmap, Raster_Map *rchr, const QString &text, 63 int *xorblah, int *yor );64 void merge_text( OSDSurface *surface, Raster_Map *rmap, int offset_x,80 int *xorblah, int *yor ); 81 void merge_text(YUVSurface *surface, Raster_Map *rmap, int offset_x, 65 82 int offset_y, int xstart, int ystart, int width, 66 83 int height, int alphamod, kTTF_Color k = kTTF_Normal); 84 void merge_text(I44Surface *surface, Raster_Map *rmap, int offset_x, 85 int offset_y, int xstart, int ystart, int width, 86 int height, int alphamod, kTTF_Color k = kTTF_Normal); 67 87 bool cache_glyph(unsigned short c); 68 88 69 89 bool valid; … … 88 108 uint8_t m_color_normal_y; 89 109 uint8_t m_color_normal_u; 90 110 uint8_t m_color_normal_v; 111 uint8_t m_color_normal; 91 112 92 113 uint8_t m_color_outline_y; 93 114 uint8_t m_color_outline_u; 94 115 uint8_t m_color_outline_v; 116 uint8_t m_color_outline; 95 117 96 118 uint8_t m_color_shadow_y; 97 119 uint8_t m_color_shadow_u; 98 120 uint8_t m_color_shadow_v; 121 uint8_t m_color_shadow; 99 122 100 123 QString m_file; 101 124 102 125 int loadedfontsize; 103 126 float m_hmult; 127 128 bool m_mono; 129 130 QMap<QString, Raster_Map *> rasters; 131 104 132 }; 105 133 106 134 #endif
