Ticket #7525: mythui_pulse_optimize_v3.patch
File mythui_pulse_optimize_v3.patch, 10.5 KB (added by , 14 years ago) |
---|
-
libs/libmythui/mythuitype.cpp
45 45 m_XYSpeed = QPoint(0, 0); 46 46 m_deferload = false; 47 47 48 m_NextPulse = (1 << animNUMTYPES) - 1; // all bits set 49 m_NextChildPulse = 0; 50 48 51 m_Parent = NULL; 49 52 if (parent) 50 53 { … … 70 73 */ 71 74 void MythUIType::Reset() 72 75 { 76 SetNextPulse(true); 73 77 // Reset all children 74 78 QMutableListIterator<MythUIType *> it(m_ChildrenList); 75 79 while (it.hasNext()) … … 89 93 return; 90 94 91 95 m_ChildrenList.push_back(child); 96 FixupNextChildPulse(); 92 97 } 93 98 94 99 static QObject *qChildHelper(const char *objName, const char *inheritsClass, … … 150 155 { 151 156 delete type; 152 157 it.remove(); 158 FixupNextChildPulse(); 153 159 return; 154 160 } 155 161 } … … 172 178 { 173 179 delete type; 174 180 it.remove(); 181 FixupNextChildPulse(); 175 182 child = NULL; 176 183 return; 177 184 } … … 196 203 delete *it; 197 204 198 205 m_ChildrenList.clear(); 206 FixupNextChildPulse(); 199 207 } 200 208 201 209 /** \brief Return the first MythUIType which accepts focus found at the given … … 323 331 void MythUIType::HandleMovementPulse(void) 324 332 { 325 333 if (!GetMythPainter()->SupportsAnimation()) 334 { 335 SetNextPulse(animMovement, false); 326 336 return; 337 } 327 338 328 339 if (!m_Moving) 340 { 341 SetNextPulse(animMovement, false); 329 342 return; 343 } 330 344 331 345 QPoint curXY = m_Area.topLeft().toQPoint(); 332 346 m_DirtyRegion = m_Area.toQRect(); … … 360 374 } 361 375 362 376 m_Area.moveTopLeft(curXY); 377 SetNextPulse(animMovement, m_Moving); 363 378 } 364 379 365 380 /** … … 371 386 { 372 387 if (!GetMythPainter()->SupportsAlpha() || 373 388 !GetMythPainter()->SupportsAnimation()) 389 { 390 SetNextPulse(animAlpha, false); 374 391 return; 392 } 375 393 376 394 if (m_AlphaChangeMode == 0) 395 { 396 SetNextPulse(animAlpha, false); 377 397 return; 398 } 378 399 379 400 m_Alpha += m_AlphaChange; 380 401 … … 398 419 } 399 420 400 421 SetRedraw(); 422 SetNextPulse(animAlpha, (m_AlphaChangeMode != 0)); 401 423 } 402 424 403 425 /** … … 411 433 if (!m_Visible) 412 434 return; 413 435 414 HandleMovementPulse(); 415 HandleAlphaPulse(); 436 if (m_NextPulse & (1 << animMovement)) 437 HandleMovementPulse(); 438 if (m_NextPulse & (1 << animAlpha)) 439 HandleAlphaPulse(); 416 440 417 QList<MythUIType *>::Iterator it; 418 for (it = m_ChildrenList.begin(); it != m_ChildrenList.end(); ++it) 419 (*it)->Pulse(); 441 if (m_NextChildPulse) 442 { 443 QList<MythUIType *>::Iterator it; 444 for (it = m_ChildrenList.begin(); it != m_ChildrenList.end(); ++it) 445 (*it)->Pulse(); 446 } 447 SetNextPulse(animPulse, false); 420 448 } 421 449 422 450 int MythUIType::CalcAlpha(int alphamod) … … 661 689 int maxalpha) 662 690 { 663 691 if (!GetMythPainter()->SupportsAlpha()) 692 { 693 SetNextPulse(animAlpha, false); 664 694 return; 695 } 665 696 666 697 m_AlphaChangeMode = mode; 667 698 m_AlphaChange = alphachange; … … 672 703 m_Alpha = m_AlphaMax; 673 704 if (m_Alpha < m_AlphaMin) 674 705 m_Alpha = m_AlphaMin; 706 SetNextPulse(animAlpha, (m_AlphaChangeMode != 0)); 675 707 } 676 708 677 709 void MythUIType::SetAlpha(int newalpha) … … 755 787 emit Showing(); 756 788 else 757 789 emit Hiding(); 790 FixupNextChildPulse(); 758 791 } 759 792 760 793 void MythUIType::SetEnabled(bool enable) … … 822 855 m_XYSpeed = base->m_XYSpeed; 823 856 m_deferload = base->m_deferload; 824 857 858 m_NextPulse = m_Visible ? (1 << animNUMTYPES) - 1 : 0; 859 FixupNextChildPulse(); 860 825 861 QList<MythUIType *>::Iterator it; 826 862 for (it = base->m_ChildrenList.begin(); it != base->m_ChildrenList.end(); 827 863 ++it) … … 1007 1043 return false; 1008 1044 } 1009 1045 1046 // Recompute m_NextChildPulse, and if anything has changed, continue 1047 // up the tree. 1048 void MythUIType::FixupNextChildPulse(bool recomputeChildren) 1049 { 1050 for (MythUIType *current=this; current; current=current->m_Parent) 1051 { 1052 unsigned oldNextPulse = current->m_NextPulse; 1053 unsigned oldNextChildPulse = current->m_NextChildPulse; 1054 1055 if (current->m_Visible) 1056 { 1057 // If necessary, recompute m_NextChildPulse as the min of 1058 // m_NextPulse and m_NextChildPulse across all children. 1059 if (recomputeChildren) 1060 { 1061 current->m_NextChildPulse = 0; 1062 QList<MythUIType*>::iterator it; 1063 for (it = current->m_ChildrenList.begin(); it != current->m_ChildrenList.end(); ++it) 1064 { 1065 current->m_NextChildPulse |= (*it)->m_NextPulse; 1066 current->m_NextChildPulse |= (*it)->m_NextChildPulse; 1067 } 1068 } 1069 1070 } else { 1071 current->m_NextPulse = 0; 1072 current->m_NextChildPulse = 0; 1073 } 1074 1075 // If anything changed, continue up the tree. Also continue 1076 // if current=this, since the method might have been called as 1077 // a result of m_NextPulse changing. 1078 unsigned oldmin = oldNextPulse | oldNextChildPulse; 1079 unsigned newmin = current->m_NextPulse | current->m_NextChildPulse; 1080 if (oldmin == newmin && current != this) 1081 break; 1082 recomputeChildren = true; 1083 } 1084 } 1085 1086 void MythUIType::SetNextPulse(AnimationType type, bool flag) 1087 { 1088 unsigned oldMask = m_NextPulse; 1089 if (flag) 1090 m_NextPulse |= (1 << type); 1091 else 1092 m_NextPulse &= ~(1 << type); 1093 if (m_NextPulse != oldMask) 1094 FixupNextChildPulse(false); 1095 } 1096 1097 void MythUIType::SetNextPulse(bool flag) 1098 { 1099 for (unsigned i=0; i<animNUMTYPES; i++) 1100 SetNextPulse((AnimationType)i, flag); 1101 } -
libs/libmythui/mythuitype.h
121 121 122 122 bool ContainsPoint(const QPoint &point) const; 123 123 124 enum AnimationType { 125 animMovement=0, 126 animAlpha, 127 animPulse, 128 animNUMTYPES 129 }; 130 void SetNextPulse(AnimationType type, bool flag); // true=asap, false=never 131 void SetNextPulse(bool flag); // true=asap, false=never 132 void FixupNextChildPulse(bool recomputeChildren=true); 133 124 134 protected: 125 135 virtual void customEvent(QEvent *); 126 136 … … 190 200 QPoint m_XYDestination; 191 201 QPoint m_XYSpeed; 192 202 203 unsigned m_NextPulse; 204 unsigned m_NextChildPulse; 205 193 206 FontMap *m_Fonts; 194 207 195 208 MythUIType *m_Parent; -
libs/libmythui/mythuiimage.cpp
287 287 m_Delay = delayms; 288 288 m_LastDisplay = QTime::currentTime(); 289 289 m_CurPos = 0; 290 SetNextPulse(animPulse, (m_Delay > 0)); 290 291 } 291 292 292 293 /** … … 305 306 m_Filename = img->GetFileName(); 306 307 Clear(); 307 308 m_Delay = -1; 309 SetNextPulse(animPulse, false); 308 310 309 311 img->UpRef(); 310 312 … … 856 858 } 857 859 858 860 MythUIType::Pulse(); 861 SetNextPulse(animPulse, (m_Delay > 0)); 859 862 } 860 863 861 864 /** … … 1002 1005 else if (element.tagName() == "crop") 1003 1006 m_cropRect = parseRect(element); 1004 1007 else if (element.tagName() == "delay") 1008 { 1005 1009 m_Delay = getFirstText(element).toInt(); 1010 SetNextPulse(animPulse, (m_Delay > 0)); 1011 } 1006 1012 else if (element.tagName() == "reflection") 1007 1013 { 1008 1014 m_isReflected = true; … … 1119 1125 //SetImages(im->m_Images); 1120 1126 1121 1127 MythUIType::CopyFrom(base); 1128 SetNextPulse(animPulse, (m_Delay > 0)); 1122 1129 1123 1130 m_NeedLoad = im->m_NeedLoad; 1124 1131 -
libs/libmythui/mythuitext.cpp
453 453 // 454 454 455 455 MythUIType::Pulse(); 456 SetNextPulse(animPulse, (m_colorCycling || m_scrolling)); 456 457 457 458 if (m_colorCycling) 458 459 { … … 524 525 incB = (endColor.blue() * 1.0 - curB) / m_numSteps; 525 526 526 527 m_colorCycling = true; 528 SetNextPulse(animPulse, true); 527 529 } 528 530 529 531 void MythUIText::StopCycling(void) … … 673 675 m_colorCycling = false; 674 676 675 677 m_colorCycling = parseBool(element.attribute("disable")); 678 SetNextPulse(animPulse, (m_colorCycling || m_scrolling)); 676 679 } 677 680 else if (element.tagName() == "scroll") 678 681 { … … 696 699 } 697 700 else 698 701 m_scrolling = false; 702 SetNextPulse(animPulse, (m_colorCycling || m_scrolling)); 699 703 } 700 704 else if (element.tagName() == "case") 701 705 { … … 769 773 m_textCase = text->m_textCase; 770 774 771 775 MythUIType::CopyFrom(base); 776 SetNextPulse(animPulse, (m_colorCycling || m_scrolling)); 772 777 } 773 778 774 779 void MythUIText::CreateCopy(MythUIType *parent) -
libs/libmythui/mythuiwebbrowser.cpp
621 621 } 622 622 623 623 MythUIType::Pulse(); 624 SetNextPulse(animPulse, (m_updateInterval != 0)); 624 625 } 625 626 626 627 /** … … 875 876 { 876 877 QString interval = getFirstText(element); 877 878 m_updateInterval = interval.toInt(); 879 SetNextPulse(animPulse, (m_updateInterval != 0)); 878 880 } 879 881 else if (element.tagName() == "background") 880 882 { … … 909 911 m_widgetUrl = browser->m_widgetUrl; 910 912 m_userCssFile = browser->m_userCssFile; 911 913 m_updateInterval = browser->m_updateInterval; 914 SetNextPulse(animPulse, (m_updateInterval != 0)); 912 915 913 916 Init(); 914 917 } -
libs/libmythui/mythuitextedit.cpp
78 78 void MythUITextEdit::Pulse(void) 79 79 { 80 80 if (!m_cursorImage) 81 { 82 SetNextPulse(animPulse, false); 81 83 return; 84 } 82 85 83 86 if (m_HasFocus) 84 87 { … … 102 105 m_cursorImage->SetVisible(false); 103 106 104 107 MythUIType::Pulse(); 108 SetNextPulse(animPulse, true); 105 109 } 106 110 107 111 bool MythUITextEdit::ParseElement( -
libs/libmythui/mythuiclock.cpp
64 64 } 65 65 66 66 MythUIText::Pulse(); 67 SetNextPulse(animPulse, true); 67 68 } 68 69 69 70 /**