Ticket #7525: mythui_pulse_optimize.patch
| File mythui_pulse_optimize.patch, 9.3 KB (added by , 17 years ago) |
|---|
-
libs/libmythui/mythuitype.h
115 115 116 116 bool ContainsPoint(const QPoint &point) const; 117 117 118 enum AnimationType { 119 animMovement=0, 120 animAlpha, 121 animPulse, 122 animNUMTYPES 123 }; 124 void SetNextPulse(AnimationType type, bool flag); // true=asap, false=never 125 void SetNextPulse(bool flag); // true=asap, false=never 126 void FixupNextChildPulse(bool recomputeChildren=true); 127 118 128 protected: 119 129 virtual void customEvent(QEvent *); 120 130 … … 181 191 QPoint m_XYDestination; 182 192 QPoint m_XYSpeed; 183 193 194 unsigned m_NextPulse; 195 unsigned m_NextChildPulse; 196 184 197 FontMap *m_Fonts; 185 198 186 199 MythUIType *m_Parent; -
libs/libmythui/mythuitype.cpp
44 44 m_XYSpeed = QPoint(0, 0); 45 45 m_deferload = false; 46 46 47 m_NextPulse = (1 << animNUMTYPES) - 1; // all bits set 48 m_NextChildPulse = 0; 49 47 50 m_Parent = NULL; 48 51 if (parent) 49 52 { … … 69 72 */ 70 73 void MythUIType::Reset() 71 74 { 75 SetNextPulse(true); 72 76 // Reset all children 73 77 QMutableListIterator<MythUIType *> it(m_ChildrenList); 74 78 while (it.hasNext()) … … 88 92 return; 89 93 90 94 m_ChildrenList.push_back(child); 95 FixupNextChildPulse(); 91 96 } 92 97 93 98 static QObject *qChildHelper(const char *objName, const char *inheritsClass, … … 149 154 { 150 155 type->deleteLater(); 151 156 it.remove(); 157 FixupNextChildPulse(); 152 158 return; 153 159 } 154 160 } … … 171 177 { 172 178 type->deleteLater(); 173 179 it.remove(); 180 FixupNextChildPulse(); 174 181 child = NULL; 175 182 return; 176 183 } … … 191 198 } 192 199 193 200 m_ChildrenList.clear(); 201 FixupNextChildPulse(); 194 202 } 195 203 196 204 /** \brief Return the first MythUIType which accepts focus found at the given … … 307 315 void MythUIType::HandleMovementPulse(void) 308 316 { 309 317 if (!GetMythPainter()->SupportsAnimation()) 318 { 319 SetNextPulse(animMovement, false); 310 320 return; 321 } 311 322 312 323 if (!m_Moving) 324 { 325 SetNextPulse(animMovement, false); 313 326 return; 327 } 314 328 315 329 QPoint curXY = m_Area.topLeft().toQPoint(); 316 330 m_DirtyRegion = m_Area.toQRect(); … … 344 358 } 345 359 346 360 m_Area.moveTopLeft(curXY); 361 SetNextPulse(animMovement, m_Moving); 347 362 } 348 363 349 364 void MythUIType::HandleAlphaPulse(void) 350 365 { 351 366 if (!GetMythPainter()->SupportsAlpha() || 352 367 !GetMythPainter()->SupportsAnimation()) 368 { 369 SetNextPulse(animAlpha, false); 353 370 return; 371 } 354 372 355 373 if (m_AlphaChangeMode == 0) 374 { 375 SetNextPulse(animAlpha, false); 356 376 return; 377 } 357 378 358 379 m_Alpha += m_AlphaChange; 359 380 … … 377 398 } 378 399 379 400 SetRedraw(); 401 SetNextPulse(animAlpha, (m_AlphaChangeMode != 0)); 380 402 } 381 403 382 404 void MythUIType::Pulse(void) … … 384 406 if (!m_Visible) 385 407 return; 386 408 387 HandleMovementPulse(); 388 HandleAlphaPulse(); 409 if (m_NextPulse & (1 << animMovement)) 410 HandleMovementPulse(); 411 if (m_NextPulse & (1 << animAlpha)) 412 HandleAlphaPulse(); 389 413 390 QList<MythUIType *>::Iterator it; 391 for (it = m_ChildrenList.begin(); it != m_ChildrenList.end(); ++it) 392 (*it)->Pulse(); 414 if (m_NextChildPulse & (1 << animPulse)) 415 { 416 QList<MythUIType *>::Iterator it; 417 for (it = m_ChildrenList.begin(); it != m_ChildrenList.end(); ++it) 418 (*it)->Pulse(); 419 } 420 SetNextPulse(animPulse, false); 393 421 } 394 422 395 423 int MythUIType::CalcAlpha(int alphamod) … … 532 560 int maxalpha) 533 561 { 534 562 if (!GetMythPainter()->SupportsAlpha()) 563 { 564 SetNextPulse(animAlpha, false); 535 565 return; 566 } 536 567 537 568 m_AlphaChangeMode = mode; 538 569 m_AlphaChange = alphachange; … … 543 574 m_Alpha = m_AlphaMax; 544 575 if (m_Alpha < m_AlphaMin) 545 576 m_Alpha = m_AlphaMin; 577 SetNextPulse(animAlpha, (m_AlphaChangeMode != 0)); 546 578 } 547 579 548 580 void MythUIType::SetAlpha(int newalpha) … … 615 647 emit Showing(); 616 648 else 617 649 emit Hiding(); 650 FixupNextChildPulse(); 618 651 } 619 652 620 653 void MythUIType::SetEnabled(bool enable) … … 677 710 m_XYSpeed = base->m_XYSpeed; 678 711 m_deferload = base->m_deferload; 679 712 713 m_NextPulse = m_Visible ? (1 << animNUMTYPES) - 1 : 0; 714 FixupNextChildPulse(); 715 680 716 QList<MythUIType *>::Iterator it; 681 717 for (it = base->m_ChildrenList.begin(); it != base->m_ChildrenList.end(); 682 718 ++it) … … 840 876 return false; 841 877 } 842 878 879 // Recompute m_NextChildPulse, and if anything has changed, continue 880 // up the tree. 881 void MythUIType::FixupNextChildPulse(bool recomputeChildren) 882 { 883 for (MythUIType *current=this; current; current=current->m_Parent) 884 { 885 unsigned oldNextPulse = current->m_NextPulse; 886 unsigned oldNextChildPulse = current->m_NextChildPulse; 887 888 if (current->m_Visible) 889 { 890 // If necessary, recompute m_NextChildPulse as the min of 891 // m_NextPulse and m_NextChildPulse across all children. 892 if (recomputeChildren) 893 { 894 current->m_NextChildPulse = 0; 895 QList<MythUIType*>::iterator it; 896 for (it = current->m_ChildrenList.begin(); it != current->m_ChildrenList.end(); ++it) 897 { 898 current->m_NextChildPulse |= (*it)->m_NextPulse; 899 current->m_NextChildPulse |= (*it)->m_NextChildPulse; 900 } 901 } 902 903 } else { 904 current->m_NextPulse = 0; 905 current->m_NextChildPulse = 0; 906 } 907 908 // If anything changed, continue up the tree. Also continue 909 // if current=this, since the method might have been called as 910 // a result of m_NextPulse changing. 911 unsigned oldmin = oldNextPulse | oldNextChildPulse; 912 unsigned newmin = current->m_NextPulse | current->m_NextChildPulse; 913 if (oldmin == newmin && current != this) 914 break; 915 recomputeChildren = true; 916 } 917 } 918 919 void MythUIType::SetNextPulse(AnimationType type, bool flag) 920 { 921 unsigned oldMask = m_NextPulse; 922 if (flag) 923 m_NextPulse |= (1 << type); 924 else 925 m_NextPulse &= ~(1 << type); 926 if (m_NextPulse != oldMask) 927 FixupNextChildPulse(false); 928 } 929 930 void MythUIType::SetNextPulse(bool flag) 931 { 932 for (unsigned i=0; i<animNUMTYPES; i++) 933 SetNextPulse((AnimationType)i, flag); 934 } -
libs/libmythui/mythuiimage.cpp
280 280 m_Delay = delayms; 281 281 m_LastDisplay = QTime::currentTime(); 282 282 m_CurPos = 0; 283 SetNextPulse(animPulse, (m_Delay > 0)); 283 284 } 284 285 285 286 /** … … 298 299 m_Filename = img->GetFileName(); 299 300 Clear(); 300 301 m_Delay = -1; 302 SetNextPulse(animPulse, false); 301 303 302 304 img->UpRef(); 303 305 … … 839 841 } 840 842 841 843 MythUIType::Pulse(); 844 SetNextPulse(animPulse, (m_Delay > 0)); 842 845 } 843 846 844 847 /** … … 982 985 else if (element.tagName() == "crop") 983 986 m_cropRect = parseRect(element); 984 987 else if (element.tagName() == "delay") 988 { 985 989 m_Delay = getFirstText(element).toInt(); 990 SetNextPulse(animPulse, (m_Delay > 0)); 991 } 986 992 else if (element.tagName() == "reflection") 987 993 { 988 994 m_isReflected = true; -
libs/libmythui/mythuitext.cpp
315 315 // 316 316 317 317 MythUIType::Pulse(); 318 SetNextPulse(animPulse, (m_colorCycling || m_scrolling)); 318 319 319 320 if (m_colorCycling) 320 321 { -
libs/libmythui/mythuiwebbrowser.cpp
534 534 } 535 535 536 536 MythUIType::Pulse(); 537 SetNextPulse(animPulse, (m_updateInterval != 0)); 537 538 } 538 539 539 540 void MythUIWebBrowser::DrawSelf(MythPainter *p, int xoffset, int yoffset, -
libs/libmythui/mythuitextedit.cpp
73 73 void MythUITextEdit::Pulse(void) 74 74 { 75 75 if (!m_cursorImage) 76 { 77 SetNextPulse(animPulse, false); 76 78 return; 79 } 77 80 78 81 if (m_HasFocus) 79 82 { … … 92 95 m_cursorImage->SetVisible(false); 93 96 94 97 MythUIType::Pulse(); 98 SetNextPulse(animPulse, true); 95 99 } 96 100 97 101 bool MythUITextEdit::ParseElement(QDomElement &element) -
libs/libmythui/mythuiclock.cpp
64 64 } 65 65 66 66 MythUIText::Pulse(); 67 SetNextPulse(animPulse, true); 67 68 } 68 69 69 70 bool MythUIClock::ParseElement(QDomElement &element)
