Ticket #7525: mythui_pulse_optimize_v2.patch
File mythui_pulse_optimize_v2.patch, 9.1 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 type->deleteLater(); 152 157 it.remove(); 158 FixupNextChildPulse(); 153 159 return; 154 160 } 155 161 } … … 172 178 { 173 179 type->deleteLater(); 174 180 it.remove(); 181 FixupNextChildPulse(); 175 182 child = NULL; 176 183 return; 177 184 } … … 198 205 } 199 206 200 207 m_ChildrenList.clear(); 208 FixupNextChildPulse(); 201 209 } 202 210 203 211 /** \brief Return the first MythUIType which accepts focus found at the given … … 325 333 void MythUIType::HandleMovementPulse(void) 326 334 { 327 335 if (!GetMythPainter()->SupportsAnimation()) 336 { 337 SetNextPulse(animMovement, false); 328 338 return; 339 } 329 340 330 341 if (!m_Moving) 342 { 343 SetNextPulse(animMovement, false); 331 344 return; 345 } 332 346 333 347 QPoint curXY = m_Area.topLeft().toQPoint(); 334 348 m_DirtyRegion = m_Area.toQRect(); … … 362 376 } 363 377 364 378 m_Area.moveTopLeft(curXY); 379 SetNextPulse(animMovement, m_Moving); 365 380 } 366 381 367 382 /** … … 373 388 { 374 389 if (!GetMythPainter()->SupportsAlpha() || 375 390 !GetMythPainter()->SupportsAnimation()) 391 { 392 SetNextPulse(animAlpha, false); 376 393 return; 394 } 377 395 378 396 if (m_AlphaChangeMode == 0) 397 { 398 SetNextPulse(animAlpha, false); 379 399 return; 400 } 380 401 381 402 m_Alpha += m_AlphaChange; 382 403 … … 400 421 } 401 422 402 423 SetRedraw(); 424 SetNextPulse(animAlpha, (m_AlphaChangeMode != 0)); 403 425 } 404 426 405 427 /** … … 413 435 if (!m_Visible) 414 436 return; 415 437 416 HandleMovementPulse(); 417 HandleAlphaPulse(); 438 if (m_NextPulse & (1 << animMovement)) 439 HandleMovementPulse(); 440 if (m_NextPulse & (1 << animAlpha)) 441 HandleAlphaPulse(); 418 442 419 QList<MythUIType *>::Iterator it; 420 for (it = m_ChildrenList.begin(); it != m_ChildrenList.end(); ++it) 421 (*it)->Pulse(); 443 if (m_NextChildPulse & (1 << animPulse)) 444 { 445 QList<MythUIType *>::Iterator it; 446 for (it = m_ChildrenList.begin(); it != m_ChildrenList.end(); ++it) 447 (*it)->Pulse(); 448 } 449 SetNextPulse(animPulse, false); 422 450 } 423 451 424 452 int MythUIType::CalcAlpha(int alphamod) … … 663 691 int maxalpha) 664 692 { 665 693 if (!GetMythPainter()->SupportsAlpha()) 694 { 695 SetNextPulse(animAlpha, false); 666 696 return; 697 } 667 698 668 699 m_AlphaChangeMode = mode; 669 700 m_AlphaChange = alphachange; … … 674 705 m_Alpha = m_AlphaMax; 675 706 if (m_Alpha < m_AlphaMin) 676 707 m_Alpha = m_AlphaMin; 708 SetNextPulse(animAlpha, (m_AlphaChangeMode != 0)); 677 709 } 678 710 679 711 void MythUIType::SetAlpha(int newalpha) … … 757 789 emit Showing(); 758 790 else 759 791 emit Hiding(); 792 FixupNextChildPulse(); 760 793 } 761 794 762 795 void MythUIType::SetEnabled(bool enable) … … 824 857 m_XYSpeed = base->m_XYSpeed; 825 858 m_deferload = base->m_deferload; 826 859 860 m_NextPulse = m_Visible ? (1 << animNUMTYPES) - 1 : 0; 861 FixupNextChildPulse(); 862 827 863 QList<MythUIType *>::Iterator it; 828 864 for (it = base->m_ChildrenList.begin(); it != base->m_ChildrenList.end(); 829 865 ++it) … … 1009 1045 return false; 1010 1046 } 1011 1047 1048 // Recompute m_NextChildPulse, and if anything has changed, continue 1049 // up the tree. 1050 void MythUIType::FixupNextChildPulse(bool recomputeChildren) 1051 { 1052 for (MythUIType *current=this; current; current=current->m_Parent) 1053 { 1054 unsigned oldNextPulse = current->m_NextPulse; 1055 unsigned oldNextChildPulse = current->m_NextChildPulse; 1056 1057 if (current->m_Visible) 1058 { 1059 // If necessary, recompute m_NextChildPulse as the min of 1060 // m_NextPulse and m_NextChildPulse across all children. 1061 if (recomputeChildren) 1062 { 1063 current->m_NextChildPulse = 0; 1064 QList<MythUIType*>::iterator it; 1065 for (it = current->m_ChildrenList.begin(); it != current->m_ChildrenList.end(); ++it) 1066 { 1067 current->m_NextChildPulse |= (*it)->m_NextPulse; 1068 current->m_NextChildPulse |= (*it)->m_NextChildPulse; 1069 } 1070 } 1071 1072 } else { 1073 current->m_NextPulse = 0; 1074 current->m_NextChildPulse = 0; 1075 } 1076 1077 // If anything changed, continue up the tree. Also continue 1078 // if current=this, since the method might have been called as 1079 // a result of m_NextPulse changing. 1080 unsigned oldmin = oldNextPulse | oldNextChildPulse; 1081 unsigned newmin = current->m_NextPulse | current->m_NextChildPulse; 1082 if (oldmin == newmin && current != this) 1083 break; 1084 recomputeChildren = true; 1085 } 1086 } 1087 1088 void MythUIType::SetNextPulse(AnimationType type, bool flag) 1089 { 1090 unsigned oldMask = m_NextPulse; 1091 if (flag) 1092 m_NextPulse |= (1 << type); 1093 else 1094 m_NextPulse &= ~(1 << type); 1095 if (m_NextPulse != oldMask) 1096 FixupNextChildPulse(false); 1097 } 1098 1099 void MythUIType::SetNextPulse(bool flag) 1100 { 1101 for (unsigned i=0; i<animNUMTYPES; i++) 1102 SetNextPulse((AnimationType)i, flag); 1103 } -
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
284 284 m_Delay = delayms; 285 285 m_LastDisplay = QTime::currentTime(); 286 286 m_CurPos = 0; 287 SetNextPulse(animPulse, (m_Delay > 0)); 287 288 } 288 289 289 290 /** … … 302 303 m_Filename = img->GetFileName(); 303 304 Clear(); 304 305 m_Delay = -1; 306 SetNextPulse(animPulse, false); 305 307 306 308 img->UpRef(); 307 309 … … 853 855 } 854 856 855 857 MythUIType::Pulse(); 858 SetNextPulse(animPulse, (m_Delay > 0)); 856 859 } 857 860 858 861 /** … … 999 1002 else if (element.tagName() == "crop") 1000 1003 m_cropRect = parseRect(element); 1001 1004 else if (element.tagName() == "delay") 1005 { 1002 1006 m_Delay = getFirstText(element).toInt(); 1007 SetNextPulse(animPulse, (m_Delay > 0)); 1008 } 1003 1009 else if (element.tagName() == "reflection") 1004 1010 { 1005 1011 m_isReflected = true; -
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 { -
libs/libmythui/mythuiwebbrowser.cpp
621 621 } 622 622 623 623 MythUIType::Pulse(); 624 SetNextPulse(animPulse, (m_updateInterval != 0)); 624 625 } 625 626 626 627 /** -
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 /**