Ticket #1899: 1899-v1.patch
File 1899-v1.patch, 28.7 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/osdtypeteletext.h
96 96 class TeletextMagazine 97 97 { 98 98 public: 99 QMutex lock;99 mutable QMutex lock; 100 100 int current_page; 101 101 int current_subpage; 102 102 std::map<int, TeletextPage> pages; … … 112 112 : OSDType(other.m_name), TeletextViewer() {} 113 113 virtual ~OSDTypeTeletext() {} 114 114 115 116 115 void Reinit(float wmult, float hmult); 117 116 117 // Teletext Drawing methods 118 118 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff); 119 void DrawBackground(OSDSurface *surface, int x, int y) const; 120 void DrawRect(OSDSurface *surface, const QRect) const; 121 void DrawCharacter(OSDSurface *surface, int x, int y, 122 QChar ch, int doubleheight = 0) const; 123 void DrawMosaic(OSDSurface *surface, int x, int y, 124 int code, int doubleheight) const; 125 void DrawLine(OSDSurface *surface, const uint8_t *page, 126 uint row, int lang) const; 127 void DrawHeader(OSDSurface *surface, const uint8_t *page, int lang) const; 128 void DrawStatus(OSDSurface *surface) const; 129 void DrawPage(OSDSurface *surface) const; 119 130 120 void SetForegroundColor(int color); 121 void SetBackgroundColor(int color); 122 123 void DrawBackground(int x, int y); 124 void DrawRect(int x, int y, int dx, int dy); 125 void DrawCharacter(int x, int y, QChar ch, int doubleheight = 0); 126 void DrawMosaic(int x, int y, int code, int doubleheight); 127 128 void DrawLine(const uint8_t* page, uint row, int lang); 129 void DrawHeader(const uint8_t* page, int lang); 130 void DrawPage(void); 131 132 void NewsFlash(void) {}; 133 134 void PageUpdated(int page, int subpage); 135 void HeaderUpdated(uint8_t* page, int lang); 136 void StatusUpdated(void); 137 138 // Teletext Viewer methods 131 // TeletextViewer interface methods 139 132 void KeyPress(uint key); 140 133 void SetPage(int page, int subpage); 141 134 void SetDisplaying(bool display) { m_displaying = display; }; … … 146 139 void AddTeletextData(int magazine, int row, 147 140 const uint8_t* buf, int vbimode); 148 141 142 static const QColor kColorBlack; 143 static const QColor kColorRed; 144 static const QColor kColorGreen; 145 static const QColor kColorYellow; 146 static const QColor kColorBlue; 147 static const QColor kColorMagenta; 148 static const QColor kColorCyan; 149 static const QColor kColorWhite; 150 static const int kTeletextColumns; 151 static const int kTeletextRows; 152 149 153 private: 150 char CharConversion(char ch, int lang);151 TeletextSubPage *FindSubPage(int page, int subpage, int direction = 0);152 TeletextPage *FindPage(int page, int direction = 0);154 // Internal Teletext Sets 155 void SetForegroundColor(int color) const; 156 void SetBackgroundColor(int color) const; 153 157 158 // Internal Teletext Commands 159 void NewsFlash(void) {}; 160 void PageUpdated(int page, int subpage); 161 void HeaderUpdated(uint8_t *page, int lang); 162 163 const TeletextSubPage *FindSubPage(int page,int subpage,int dir = 0) const; 164 const TeletextPage *FindPage(int page, int direction = 0) const; 165 166 TeletextSubPage *FindSubPage(int page, int subpage, int direction = 0) 167 { return (TeletextSubPage*) FindSubPage(page, subpage, direction); } 168 TeletextPage *FindPage(int page, int direction = 0) 169 { return (TeletextPage*) FindPage(page, direction); } 170 154 171 private: 155 172 QMutex m_lock; 156 173 QRect m_displayrect; 157 174 QRect m_unbiasedrect; 158 175 159 TTFFont *m_font;160 OSDSurface *m_surface;161 176 OSDTypeBox *m_box; 162 177 163 178 int m_tt_colspace; 164 179 int m_tt_rowspace; 165 180 166 uint8_t m_bgcolor_y;167 uint8_t m_bgcolor_u;168 uint8_t m_bgcolor_v;169 uint8_t m_bgcolor_a;170 171 181 // last fetched page 172 182 int m_fetchpage; 173 183 int m_fetchsubpage; 174 184 185 // needs to mutable so we can change color character by character. 186 mutable TTFFont *m_font; 187 188 // current character background 189 mutable uint8_t m_bgcolor_y; 190 mutable uint8_t m_bgcolor_u; 191 mutable uint8_t m_bgcolor_v; 192 mutable uint8_t m_bgcolor_a; 193 175 194 // currently displayed page: 176 int m_curpage; 177 int m_cursubpage; 195 mutable int m_curpage; 196 mutable int m_cursubpage; 197 mutable bool m_curpage_showheader; 198 mutable bool m_curpage_issubtitle; 199 178 200 int m_pageinput[3]; 179 bool m_curpage_showheader;180 bool m_curpage_issubtitle;181 201 182 202 bool m_transparent; 183 203 bool m_revealHidden; … … 186 206 187 207 TeletextMagazine m_magazines[8]; 188 208 unsigned char bitswap[256]; 189 190 static const QColor kColorBlack;191 static const QColor kColorRed;192 static const QColor kColorGreen;193 static const QColor kColorYellow;194 static const QColor kColorBlue;195 static const QColor kColorMagenta;196 static const QColor kColorCyan;197 static const QColor kColorWhite;198 static const int kTeletextColumns;199 static const int kTeletextRows;200 209 }; 201 210 202 211 #endif -
libs/libmythtv/osdtypeteletext.cpp
50 50 QRect displayrect, float wmult, float hmult) 51 51 : OSDType(name), 52 52 m_displayrect(displayrect), m_unbiasedrect(0,0,0,0), 53 m_font(font), m_surface(NULL),54 53 m_box(NULL), 55 54 56 55 m_tt_colspace(m_displayrect.width() / kTeletextColumns), 57 56 m_tt_rowspace(m_displayrect.height() / kTeletextRows), 58 57 59 m_bgcolor_y(0), m_bgcolor_u(0),60 m_bgcolor_v(0), m_bgcolor_a(0),61 58 // last fetched page 62 59 m_fetchpage(0), m_fetchsubpage(0), 63 // currently displayed page: 60 61 // current font 62 m_font(font), 63 64 // current character background 65 m_bgcolor_y(0), m_bgcolor_u(0), 66 m_bgcolor_v(0), m_bgcolor_a(0), 67 68 // currently displayed page 64 69 m_curpage(0x100), m_cursubpage(-1), 65 70 m_curpage_showheader(true), m_curpage_issubtitle(false), 66 71 … … 115 120 m_pageinput[2] = '0'; 116 121 } 117 122 118 /** \fn OSDTypeTeletext::CharConversion(char, int)119 * \brief converts the given character to the given language120 */121 char OSDTypeTeletext::CharConversion(char ch, int lang)122 {123 int c = 0;124 for (int j = 0; j < 14; j++)125 {126 c = ch & 0x7F;127 if (c == lang_chars[0][j])128 ch = lang_chars[lang + 1][j];129 }130 return ch;131 }132 133 123 /** \fn OSDTypeTeletext::AddPageHeader(int,int,const unsigned char*,int,int,int) 134 124 * \brief Adds a new page header 135 125 * (page=0 if none) … … 298 288 } 299 289 } 300 290 301 /** \fn OSDTypeTeletext::PageUpdated(int )291 /** \fn OSDTypeTeletext::PageUpdated(int,int) 302 292 * \brief Updates the page, if given pagenumber is the same 303 293 * as the current shown page 304 294 */ … … 313 303 if (subpage != m_cursubpage && m_cursubpage != -1) 314 304 return; 315 305 316 317 if (m_surface != NULL) 306 #if 1 307 #warning TODO PageUpdated() may need to schedule redraw.... 308 #else 309 if (surface != NULL) 318 310 { 319 m_surface->SetChanged(true);320 m_surface->ClearUsed();321 DrawPage( );311 surface->SetChanged(true); 312 surface->ClearUsed(); 313 DrawPage(surface); 322 314 } 315 #endif 323 316 } 324 317 325 318 /** \fn OSDTypeTeletext::HeaderUpdated(unsigned char*,int) … … 340 333 if (m_curpage_showheader == false) 341 334 return; 342 335 343 if (m_surface != NULL) 344 DrawHeader(page, lang); 336 #if 1 337 #warning TODO HeaderUpdated() may need to schedule redraw.... 338 (void) lang; 339 #else 340 if (surface != NULL) 341 DrawHeader(surface, page, lang); 342 #endif 345 343 } 346 344 347 345 /** \fn OSDTypeTeletext::FindPage(int, int) … … 351 349 * \param direction find page before or after the given page 352 350 * \return TeletextPage (NULL if not found) 353 351 */ 354 TeletextPage* OSDTypeTeletext::FindPage(int page, int direction) 352 const TeletextPage *OSDTypeTeletext::FindPage(int page, int direction) const 355 353 { 356 TeletextPage *res = NULL;357 354 int mag = MAGAZINE(page); 358 355 359 356 if (mag > 8 || mag < 1) … … 361 358 362 359 QMutexLocker lock(&m_magazines[mag - 1].lock); 363 360 364 std::map<int, TeletextPage>:: iterator pageIter;361 std::map<int, TeletextPage>::const_iterator pageIter; 365 362 pageIter = m_magazines[mag - 1].pages.find(page); 366 363 if (pageIter == m_magazines[mag - 1].pages.end()) 367 364 return NULL; 368 365 369 res = &pageIter->second;366 const TeletextPage *res = &pageIter->second; 370 367 if (direction == -1) 371 368 { 372 369 --pageIter; 373 370 if (pageIter == m_magazines[mag - 1].pages.end()) 374 371 { 375 std::map<int, TeletextPage>:: reverse_iterator iter;372 std::map<int, TeletextPage>::const_reverse_iterator iter; 376 373 iter = m_magazines[mag - 1].pages.rbegin(); 377 374 res = &iter->second; 378 375 } … … 395 392 return res; 396 393 } 397 394 398 /** \fn OSDTypeTeletext::FindSubPage(int, int, int) 395 /** \fn OSDTypeTeletext::FindSubPage(int, int, int) const 399 396 * \brief Finds the given page 400 397 * 401 398 * \param page Page number … … 404 401 * (only if Subpage is not -1) 405 402 * \return TeletextSubPage (NULL if not found) 406 403 */ 407 TeletextSubPage* OSDTypeTeletext::FindSubPage(int page, int subpage, int direction) 404 const TeletextSubPage *OSDTypeTeletext::FindSubPage(int page, int subpage, 405 int direction) const 408 406 { 409 TeletextSubPage *res = NULL;410 407 int mag = MAGAZINE(page); 411 408 412 409 if (mag > 8 || mag < 1) … … 414 411 415 412 QMutexLocker lock(&m_magazines[mag - 1].lock); 416 413 417 if (subpage == -1) 418 { 419 // return the first subpage found 420 std::map<int, TeletextPage>::iterator pageIter; 421 pageIter = m_magazines[mag - 1].pages.find(page); 422 if (pageIter == m_magazines[mag - 1].pages.end()) 423 return NULL; 414 std::map<int, TeletextPage>::const_iterator pageIter; 415 pageIter = m_magazines[mag - 1].pages.find(page); 416 if (pageIter == m_magazines[mag - 1].pages.end()) 417 return NULL; 424 418 425 TeletextPage *page = &pageIter->second; 426 std::map<int, TeletextSubPage>::iterator subpageIter; 427 subpageIter = page->subpages.begin(); 428 if (subpageIter == page->subpages.end()) 429 return NULL; 419 const TeletextPage *ttpage = &(pageIter->second); 420 std::map<int, TeletextSubPage>::const_iterator subpageIter = 421 ttpage->subpages.begin(); 430 422 431 return &subpageIter->second; 432 } 433 else 434 { 435 // try to find the subpage given 436 std::map<int, TeletextPage>::iterator pageIter; 437 pageIter = m_magazines[mag - 1].pages.find(page); 438 if (pageIter == m_magazines[mag - 1].pages.end()) 439 return NULL; 423 // try to find the subpage given, or first if subpage == -1 424 if (subpage != -1) 425 subpageIter = ttpage->subpages.find(subpage); 440 426 441 TeletextPage *page = &pageIter->second; 442 std::map<int, TeletextSubPage>::iterator subpageIter; 443 subpageIter = page->subpages.find(subpage); 444 if (subpageIter == page->subpages.end()) 445 return NULL; 427 if (subpageIter == ttpage->subpages.end()) 428 return NULL; 446 429 447 res = &subpageIter->second; 448 if (direction == -1) 449 { 450 --subpageIter; 451 if (subpageIter == page->subpages.end()) 452 { 453 std::map<int, TeletextSubPage>::reverse_iterator iter; 454 iter = page->subpages.rbegin(); 455 res = &iter->second; 456 } 457 else 458 res = &subpageIter->second; 459 } 430 if (subpage == -1) 431 return &(subpageIter->second); 460 432 461 if (direction == 1) 433 const TeletextSubPage *res = &(subpageIter->second); 434 if (direction == -1) 435 { 436 --subpageIter; 437 if (subpageIter == ttpage->subpages.end()) 462 438 { 463 ++subpageIter; 464 if (subpageIter == page->subpages.end()) 465 { 466 subpageIter = page->subpages.begin(); 467 res = &subpageIter->second; 468 } 469 else 470 res = &subpageIter->second; 439 std::map<int, TeletextSubPage>::const_reverse_iterator iter = 440 ttpage->subpages.rbegin(); 441 res = &(iter->second); 471 442 } 443 else 444 res = &(subpageIter->second); 472 445 } 473 446 447 if (direction == 1) 448 { 449 ++subpageIter; 450 if (subpageIter == ttpage->subpages.end()) 451 subpageIter = ttpage->subpages.begin(); 452 453 res = &(subpageIter->second); 454 } 455 474 456 return res; 475 457 } 476 458 … … 677 659 PageUpdated(m_curpage, m_cursubpage); 678 660 } 679 661 680 /** \fn OSDTypeTeletext::SetForegroundColor(int) 662 QColor color_tt2qt(int ttcolor) 663 { 664 QColor color; 665 666 switch (ttcolor & ~TTColor::TRANSPARENT) 667 { 668 case TTColor::BLACK: color = OSDTypeTeletext::kColorBlack; break; 669 case TTColor::RED: color = OSDTypeTeletext::kColorRed; break; 670 case TTColor::GREEN: color = OSDTypeTeletext::kColorGreen; break; 671 case TTColor::YELLOW: color = OSDTypeTeletext::kColorYellow; break; 672 case TTColor::BLUE: color = OSDTypeTeletext::kColorBlue; break; 673 case TTColor::MAGENTA: color = OSDTypeTeletext::kColorMagenta; break; 674 case TTColor::CYAN: color = OSDTypeTeletext::kColorCyan; break; 675 case TTColor::WHITE: color = OSDTypeTeletext::kColorWhite; break; 676 } 677 678 return color; 679 } 680 681 /** \fn OSDTypeTeletext::SetForegroundColor(int) const 681 682 * \brief Set the font color to the given color. 682 683 * 683 684 * NOTE: TTColor::TRANSPARENT does not do anything! 684 685 * \sa TTColor 685 686 */ 686 void OSDTypeTeletext::SetForegroundColor(int color)687 void OSDTypeTeletext::SetForegroundColor(int ttcolor) const 687 688 { 688 switch (color & ~TTColor::TRANSPARENT) 689 { 690 case TTColor::BLACK: m_font->setColor(kColorBlack); break; 691 case TTColor::RED: m_font->setColor(kColorRed); break; 692 case TTColor::GREEN: m_font->setColor(kColorGreen); break; 693 case TTColor::YELLOW: m_font->setColor(kColorYellow); break; 694 case TTColor::BLUE: m_font->setColor(kColorBlue); break; 695 case TTColor::MAGENTA: m_font->setColor(kColorMagenta); break; 696 case TTColor::CYAN: m_font->setColor(kColorCyan); break; 697 case TTColor::WHITE: m_font->setColor(kColorWhite); break; 698 } 699 689 m_font->setColor(color_tt2qt(ttcolor)); 700 690 m_font->setShadow(0,0); 701 691 m_font->setOutline(0); 702 692 } 703 693 704 /** \fn OSDTypeTeletext:SetBackgroundColor(int) 694 /** \fn OSDTypeTeletext:SetBackgroundColor(int) const 705 695 * \brief Set the background color to the given color 706 696 * 707 697 * \sa TTColor 708 698 */ 709 void OSDTypeTeletext::SetBackgroundColor(int ttcolor) 699 void OSDTypeTeletext::SetBackgroundColor(int ttcolor) const 710 700 { 711 QColor color;701 const QColor color = color_tt2qt(ttcolor); 712 702 713 switch (ttcolor & ~TTColor::TRANSPARENT) 714 { 715 case TTColor::BLACK: color = kColorBlack; break; 716 case TTColor::RED: color = kColorRed; break; 717 case TTColor::GREEN: color = kColorGreen; break; 718 case TTColor::YELLOW: color = kColorYellow; break; 719 case TTColor::BLUE: color = kColorBlue; break; 720 case TTColor::MAGENTA: color = kColorMagenta; break; 721 case TTColor::CYAN: color = kColorCyan; break; 722 case TTColor::WHITE: color = kColorWhite; break; 723 } 703 const int r = color.red(); 704 const int g = color.green(); 705 const int b = color.blue(); 724 706 725 int r = color.red();726 int g = color.green();727 int b = color.blue();707 const float y = (0.299*r) + (0.587*g) + (0.114*b); 708 const float u = (0.564*(b - y)); // = -0.169R-0.331G+0.500B 709 const float v = (0.713*(r - y)); // = 0.500R-0.419G-0.081B 728 710 729 float y = (0.299*r) + (0.587*g) + (0.114*b);730 float u = (0.564*(b - y)); // = -0.169R-0.331G+0.500B731 float v = (0.713*(r - y)); // = 0.500R-0.419G-0.081B732 733 711 m_bgcolor_y = (uint8_t)(y); 734 712 m_bgcolor_u = (uint8_t)(127 + u); 735 713 m_bgcolor_v = (uint8_t)(127 + v); 714 736 715 m_bgcolor_a = (ttcolor & TTColor::TRANSPARENT) ? 0x00 : 0xff; 737 716 } 738 717 739 /** \fn OSDTypeTeletext::DrawBackground( int, int)740 * \brief draws background in the color set in setBackgroundColor718 /** \fn OSDTypeTeletext::DrawBackground(OSDSurface*,int,int) const 719 * \brief draws background in the color set in SetBackgroundColor(). 741 720 * 742 721 * \param x X position (40 cols) 743 722 * \param y Y position (25 rows) 744 723 */ 745 void OSDTypeTeletext::DrawBackground( int x, int y)724 void OSDTypeTeletext::DrawBackground(OSDSurface *surface, int x, int y) const 746 725 { 747 726 x *= m_tt_colspace; 748 727 x += m_displayrect.left(); … … 750 729 y *= m_tt_rowspace; 751 730 y += m_displayrect.top(); 752 731 753 DrawRect( x, y, m_tt_colspace, m_tt_rowspace);732 DrawRect(surface, QRect(x, y, m_tt_colspace, m_tt_rowspace)); 754 733 } 755 734 756 /** \fn OSDTypeteletext::drawRect(int, int, int, int) 757 * \brief draws a Rectangle at position x and y (width dx, height dy) 758 * with the color set in setBackgroundColor 759 * 760 * \param x X position at the screen 761 * \param y Y position at the screen 762 * \param dx width 763 * \param dy height 735 /** \fn OSDTypeteletext::DrawRect(OSDSurface*,const QRect) const 736 * \brief Draws a Rectangle with the color set in SetBackgroundColor(). 764 737 */ 765 void OSDTypeTeletext::DrawRect( int x, int y, int dx, int dy)738 void OSDTypeTeletext::DrawRect(OSDSurface *surface, const QRect rect) const 766 739 { 767 QRect all(x, y, dx, dy);768 m_surface->AddRect(all);740 QRect tmp = rect; 741 surface->AddRect(tmp); 769 742 770 int luma_stride = m_surface->width; 771 int chroma_stride = m_surface->width >> 1; 772 int ye = y + dy; 743 const int luma_stride = surface->width; 744 const int chroma_stride = surface->width >> 1; 745 const int y = rect.top(), x = rect.left(); 746 const int dy = rect.height(), dx = rect.width(); 747 const int ye = y + dy; 773 748 774 unsigned char *buf_y = m_surface->y + (luma_stride * y) + x;775 unsigned char *buf_u = m_surface->u + (chroma_stride * (y>>1)) + (x>>1);776 unsigned char *buf_v = m_surface->v + (chroma_stride * (y>>1)) + (x>>1);777 unsigned char *buf_a = m_surface->alpha + (luma_stride * y) + x;749 unsigned char *buf_y = surface->y + (luma_stride * y) + x; 750 unsigned char *buf_u = surface->u + (chroma_stride * (y>>1)) + (x>>1); 751 unsigned char *buf_v = surface->v + (chroma_stride * (y>>1)) + (x>>1); 752 unsigned char *buf_a = surface->alpha + (luma_stride * y) + x; 778 753 779 for ( ; y<ye; ++y)754 for (int j = y; j < ye; j++) 780 755 { 781 for (int i =0; i<dx; ++i)756 for (int i = 0; i < dx; i++) 782 757 { 783 758 buf_y[i] = m_bgcolor_y; 784 759 buf_a[i] = m_bgcolor_a; 785 760 } 786 761 787 if ( (y & 1) == 0)762 if (!(y & 1)) 788 763 { 789 for (int i=0; i<dx; ++i)764 for (int k = 0; k < dx; k++) 790 765 { 791 buf_u[ i>>1] = m_bgcolor_u;792 buf_v[ i>>1] = m_bgcolor_v;766 buf_u[k>>1] = m_bgcolor_u; 767 buf_v[k>>1] = m_bgcolor_v; 793 768 } 794 769 795 770 buf_u += chroma_stride; … … 801 776 } 802 777 } 803 778 804 /** \fn OSDTypeTeletext::DrawCharacter( int, int, QChar, int)779 /** \fn OSDTypeTeletext::DrawCharacter(OSDSurface*,int,int,QChar,int) const 805 780 * \brief Draws a character at posistion x, y 806 781 * 807 782 * \param x X position (40 cols) … … 809 784 * \param ch Character 810 785 * \param doubleheight if different to 0, draw doubleheighted character 811 786 */ 812 void OSDTypeTeletext::DrawCharacter(int x, int y, QChar ch, int doubleheight) 787 void OSDTypeTeletext::DrawCharacter(OSDSurface *surface, 788 int x, int y, 789 QChar ch, int doubleheight) const 813 790 { 814 791 if (!m_font) 815 792 return; … … 822 799 y *= m_tt_rowspace; 823 800 y += m_displayrect.top(); 824 801 825 m_font->DrawString( m_surface, x, y, line,826 m_surface->width, m_surface->height,802 m_font->DrawString(surface, x, y, line, 803 surface->width, surface->height, 827 804 255, doubleheight); 828 805 } 829 806 … … 833 810 * \param x X position (40 cols) 834 811 * \param y Y position (25 rows) 835 812 * \param code Code 836 * \param doubleheight if different to 0, draw doubleheighted mosaic) 813 * \param doubleheight if different to 0, draw doubleheighted mosaic) const 837 814 */ 838 void OSDTypeTeletext::DrawMosaic(int x, int y, int code, int doubleheight) 815 void OSDTypeTeletext::DrawMosaic(OSDSurface *surface, int x, int y, 816 int code, int doubleheight) const 839 817 { 840 (void)x;841 (void)y;842 (void)code;843 844 818 x *= m_tt_colspace; 845 819 x += m_displayrect.left(); 846 820 847 821 y *= m_tt_rowspace; 848 822 y += m_displayrect.top(); 849 823 850 int dx = (int)round(m_tt_colspace / 2)+1; 851 int dy = (int)round(m_tt_rowspace / 3)+1; 824 int dx = (int)round(m_tt_colspace / 2) + 1; 825 int dy = (int)round(m_tt_rowspace / 3) + 1; 826 dy = (doubleheight) ? (2 * dy) : dy; 852 827 853 if (doubleheight != 0) 854 dy *= 2; 828 if (code & 0x10) 829 DrawRect(surface, QRect(x, y + 2*dy, dx, dy)); 830 if (code & 0x40) 831 DrawRect(surface, QRect(x + dx, y + 2*dy, dx, dy)); 832 if (code & 0x01) 833 DrawRect(surface, QRect(x, y, dx, dy)); 834 if (code & 0x02) 835 DrawRect(surface, QRect(x + dx, y, dx, dy)); 836 if (code & 0x04) 837 DrawRect(surface, QRect(x, y + dy, dx, dy)); 838 if (code & 0x08) 839 DrawRect(surface, QRect(x + dx, y + dy, dx, dy)); 840 } 855 841 856 if (code & 0x10) DrawRect(x, y + 2*dy, dx, dy); 857 if (code & 0x40) DrawRect(x + dx, y + 2*dy, dx, dy); 858 if (code & 0x01) DrawRect(x, y, dx, dy); 859 if (code & 0x02) DrawRect(x + dx, y, dx, dy); 860 if (code & 0x04) DrawRect(x, y + dy, dx, dy); 861 if (code & 0x08) DrawRect(x + dx, y + dy, dx, dy); 842 /** \fn cvt_char(char,int) 843 * \brief converts the given character to the given language 844 */ 845 static char cvt_char(char ch, int lang) 846 { 847 int c = 0; 848 for (int j = 0; j < 14; j++) 849 { 850 c = ch & 0x7F; 851 if (c == lang_chars[0][j]) 852 ch = lang_chars[lang + 1][j]; 853 } 854 return ch; 862 855 } 863 856 864 void OSDTypeTeletext::DrawLine(const unsigned char* page, uint row, int lang) 857 void OSDTypeTeletext::DrawLine(OSDSurface *surface, const unsigned char *page, 858 uint row, int lang) const 865 859 { 866 860 bool mosaic; 867 861 bool conceal; … … 903 897 if (row == 1) 904 898 { 905 899 for (uint x = 0; x < 8; x++) 906 DrawBackground( x, 1);900 DrawBackground(surface, x, 1); 907 901 } 908 902 909 903 for (uint x = (row == 1 ? 8 : 0); x < (uint)kTeletextColumns; ++x) … … 1006 1000 if (m_transparent) 1007 1001 SetBackgroundColor(TTColor::TRANSPARENT); 1008 1002 1009 DrawBackground( x, row);1003 DrawBackground(surface, x, row); 1010 1004 if (doubleheight && row < (uint)kTeletextRows) 1011 DrawBackground( x, row + 1);1005 DrawBackground(surface, x, row + 1); 1012 1006 1013 1007 if ((mosaic) && (ch < 0x40 || ch > 0x5F)) 1014 1008 { 1015 1009 SetBackgroundColor(newfgcolor); 1016 DrawMosaic( x, row, ch, doubleheight);1010 DrawMosaic(surface, x, row, ch, doubleheight); 1017 1011 } 1018 1012 else 1019 1013 { 1020 char c2 = CharConversion(ch, lang);1014 char c2 = cvt_char(ch, lang); 1021 1015 bool dh = doubleheight && row < (uint)kTeletextRows; 1022 1016 int rw = (dh) ? row + 1 : row; 1023 DrawCharacter( x, rw, c2, dh);1017 DrawCharacter(surface, x, rw, c2, dh); 1024 1018 } 1025 1019 } 1026 1020 } 1027 1021 } 1028 1022 1029 void OSDTypeTeletext::DrawHeader(const unsigned char* page, int lang) 1023 void OSDTypeTeletext::DrawHeader(OSDSurface *surface, 1024 const unsigned char* page, int lang) const 1030 1025 { 1031 1026 if (!m_displaying) 1032 1027 return; 1033 1028 1034 1029 if (page != NULL) 1035 DrawLine( page, 1, lang);1036 1037 StatusUpdated();1030 DrawLine(surface, page, 1, lang); 1031 1032 DrawStatus(surface); 1038 1033 } 1039 1034 1040 void OSDTypeTeletext::DrawPage( void)1035 void OSDTypeTeletext::DrawPage(OSDSurface *surface) const 1041 1036 { 1042 1037 if (!m_displaying) 1043 1038 return; 1044 1039 1045 TeletextSubPage *ttpage = FindSubPage(m_curpage, m_cursubpage);1040 const TeletextSubPage *ttpage = FindSubPage(m_curpage, m_cursubpage); 1046 1041 1047 if ( ttpage == NULL)1042 if (!ttpage) 1048 1043 { 1049 DrawHeader( NULL,0);1044 DrawHeader(surface, NULL, 0); 1050 1045 return; 1051 1046 } 1052 1047 1053 1048 m_cursubpage = ttpage->subpagenum; 1054 1049 1055 1050 int a = 0; 1056 if ((ttpage->subtitle) || (ttpage->flags &1057 (TP_SUPPRESS_HEADER + TP_NEWSFLASH +TP_SUBTITLE)))1051 if ((ttpage->subtitle) || 1052 (ttpage->flags & (TP_SUPPRESS_HEADER | TP_NEWSFLASH | TP_SUBTITLE))) 1058 1053 { 1059 1054 a = 1; 1060 1055 m_curpage_showheader = false; … … 1064 1059 { 1065 1060 m_curpage_issubtitle = false; 1066 1061 m_curpage_showheader = true; 1067 DrawHeader( ttpage->data[0], ttpage->lang);1062 DrawHeader(surface, ttpage->data[0], ttpage->lang); 1068 1063 } 1069 1064 1070 for (int y = kTeletextRows -a; y >= 2; y--)1071 DrawLine( ttpage->data[y-1], y, ttpage->lang);1065 for (int y = kTeletextRows - a; y >= 2; y--) 1066 DrawLine(surface, ttpage->data[y-1], y, ttpage->lang); 1072 1067 } 1073 1068 1074 1069 void OSDTypeTeletext::Reinit(float wmult, float hmult) … … 1078 1073 m_tt_rowspace = m_displayrect.height() / kTeletextRows; 1079 1074 } 1080 1075 1081 void OSDTypeTeletext::Draw(OSDSurface *surface, int fade, int maxfade, 1082 int xoff, int yoff) 1076 void OSDTypeTeletext::Draw(OSDSurface *surface, 1077 int /*fade*/, int /*maxfade*/, 1078 int /*xoff*/, int /*yoff*/) 1083 1079 { 1084 (void)surface; 1085 (void)fade; 1086 (void)maxfade; 1087 (void)xoff; 1088 (void)yoff; 1089 1090 m_surface = surface; 1091 DrawPage(); 1080 DrawPage(surface); 1092 1081 } 1093 1082 1094 void OSDTypeTeletext:: StatusUpdated(void)1083 void OSDTypeTeletext::DrawStatus(OSDSurface *surface) const 1095 1084 { 1096 1085 SetForegroundColor(TTColor::WHITE); 1097 1086 SetBackgroundColor(TTColor::BLACK); 1098 1087 1099 1088 if (!m_transparent) 1100 1089 for (int i = 0; i < 40; ++i) 1101 DrawBackground( i, 0);1090 DrawBackground(surface, i, 0); 1102 1091 1103 DrawCharacter( 1, 0, 'P', 0);1104 DrawCharacter( 2, 0, m_pageinput[0], 0);1105 DrawCharacter( 3, 0, m_pageinput[1], 0);1106 DrawCharacter( 4, 0, m_pageinput[2], 0);1092 DrawCharacter(surface, 1, 0, 'P', 0); 1093 DrawCharacter(surface, 2, 0, m_pageinput[0], 0); 1094 DrawCharacter(surface, 3, 0, m_pageinput[1], 0); 1095 DrawCharacter(surface, 4, 0, m_pageinput[2], 0); 1107 1096 1108 TeletextSubPage *ttpage = FindSubPage(m_curpage, m_cursubpage);1097 const TeletextSubPage *ttpage = FindSubPage(m_curpage, m_cursubpage); 1109 1098 1110 1099 if (!ttpage) 1111 1100 { … … 1114 1103 1115 1104 if (!m_transparent) 1116 1105 for (int i = 7; i < 40; i++) 1117 DrawBackground( i, 0);1106 DrawBackground(surface, i, 0); 1118 1107 1119 1108 char *str = "Page Not Available"; 1120 1109 for (unsigned int i = 0; i < strlen(str); ++i) 1121 DrawCharacter( i+10, 0, str[i], 0);1110 DrawCharacter(surface, i+10, 0, str[i], 0); 1122 1111 1123 1112 return; 1124 1113 } … … 1126 1115 // get list of available sub pages 1127 1116 QString str = ""; 1128 1117 int count = 1, selected = 0; 1129 TeletextPage *page = FindPage(m_curpage);1118 const TeletextPage *page = FindPage(m_curpage); 1130 1119 if (page) 1131 1120 { 1132 std::map<int, TeletextSubPage>:: iterator subpageIter;1121 std::map<int, TeletextSubPage>::const_iterator subpageIter; 1133 1122 subpageIter = page->subpages.begin(); 1134 1123 while (subpageIter != page->subpages.end()) 1135 1124 { 1136 TeletextSubPage *subpage = &subpageIter->second;1125 const TeletextSubPage *subpage = &subpageIter->second; 1137 1126 1138 1127 if (subpage->subpagenum == m_cursubpage) 1139 1128 { … … 1180 1169 else 1181 1170 SetBackgroundColor(TTColor::BLACK); 1182 1171 1183 DrawBackground( x * 3 + 7, 0);1172 DrawBackground(surface, x * 3 + 7, 0); 1184 1173 1185 1174 if (str[x * 3] == '*') 1186 1175 { … … 1188 1177 SetBackgroundColor(TTColor::RED); 1189 1178 } 1190 1179 1191 DrawBackground( x * 3 + 8, 0);1192 DrawBackground( x * 3 + 9, 0);1180 DrawBackground(surface, x * 3 + 8, 0); 1181 DrawBackground(surface, x * 3 + 9, 0); 1193 1182 1194 DrawCharacter( x * 3 + 7, 0, str[x * 3], 0);1195 DrawCharacter( x * 3 + 8, 0, str[x * 3 + 1], 0);1196 DrawCharacter( x * 3 + 9, 0, str[x * 3 + 2], 0);1183 DrawCharacter(surface, x * 3 + 7, 0, str[x * 3], 0); 1184 DrawCharacter(surface, x * 3 + 8, 0, str[x * 3 + 1], 0); 1185 DrawCharacter(surface, x * 3 + 9, 0, str[x * 3 + 2], 0); 1197 1186 } 1198 1187 } 1199 1188