Ticket #7525: mythui_pulse_optimize_v2.patch

File mythui_pulse_optimize_v2.patch, 9.1 KB (added by Jim Stichnoth <stichnot@…>, 14 years ago)
  • libs/libmythui/mythuitype.cpp

     
    4545    m_XYSpeed = QPoint(0, 0);
    4646    m_deferload = false;
    4747
     48    m_NextPulse = (1 << animNUMTYPES) - 1; // all bits set
     49    m_NextChildPulse = 0;
     50
    4851    m_Parent = NULL;
    4952    if (parent)
    5053    {
     
    7073 */
    7174void MythUIType::Reset()
    7275{
     76    SetNextPulse(true);
    7377    // Reset all children
    7478    QMutableListIterator<MythUIType *> it(m_ChildrenList);
    7579    while (it.hasNext())
     
    8993        return;
    9094
    9195    m_ChildrenList.push_back(child);
     96    FixupNextChildPulse();
    9297}
    9398
    9499static QObject *qChildHelper(const char *objName, const char *inheritsClass,
     
    150155        {
    151156            type->deleteLater();
    152157            it.remove();
     158            FixupNextChildPulse();
    153159            return;
    154160        }
    155161    }
     
    172178        {
    173179            type->deleteLater();
    174180            it.remove();
     181            FixupNextChildPulse();
    175182            child = NULL;
    176183            return;
    177184        }
     
    198205    }
    199206
    200207    m_ChildrenList.clear();
     208    FixupNextChildPulse();
    201209}
    202210
    203211/** \brief Return the first MythUIType which accepts focus found at the given
     
    325333void MythUIType::HandleMovementPulse(void)
    326334{
    327335    if (!GetMythPainter()->SupportsAnimation())
     336    {
     337        SetNextPulse(animMovement, false);
    328338        return;
     339    }
    329340
    330341    if (!m_Moving)
     342    {
     343        SetNextPulse(animMovement, false);
    331344        return;
     345    }
    332346
    333347    QPoint curXY = m_Area.topLeft().toQPoint();
    334348    m_DirtyRegion = m_Area.toQRect();
     
    362376    }
    363377
    364378    m_Area.moveTopLeft(curXY);
     379    SetNextPulse(animMovement, m_Moving);
    365380}
    366381
    367382/**
     
    373388{
    374389    if (!GetMythPainter()->SupportsAlpha() ||
    375390        !GetMythPainter()->SupportsAnimation())
     391    {
     392        SetNextPulse(animAlpha, false);
    376393        return;
     394    }
    377395
    378396    if (m_AlphaChangeMode == 0)
     397    {
     398        SetNextPulse(animAlpha, false);
    379399        return;
     400    }
    380401
    381402    m_Alpha += m_AlphaChange;
    382403
     
    400421    }
    401422
    402423    SetRedraw();
     424    SetNextPulse(animAlpha, (m_AlphaChangeMode != 0));
    403425}
    404426
    405427/**
     
    413435    if (!m_Visible)
    414436        return;
    415437
    416     HandleMovementPulse();
    417     HandleAlphaPulse();
     438    if (m_NextPulse & (1 << animMovement))
     439        HandleMovementPulse();
     440    if (m_NextPulse & (1 << animAlpha))
     441        HandleAlphaPulse();
    418442
    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);
    422450}
    423451
    424452int MythUIType::CalcAlpha(int alphamod)
     
    663691                             int maxalpha)
    664692{
    665693    if (!GetMythPainter()->SupportsAlpha())
     694    {
     695        SetNextPulse(animAlpha, false);
    666696        return;
     697    }
    667698
    668699    m_AlphaChangeMode = mode;
    669700    m_AlphaChange = alphachange;
     
    674705        m_Alpha = m_AlphaMax;
    675706    if (m_Alpha < m_AlphaMin)
    676707        m_Alpha = m_AlphaMin;
     708    SetNextPulse(animAlpha, (m_AlphaChangeMode != 0));
    677709}
    678710
    679711void MythUIType::SetAlpha(int newalpha)
     
    757789        emit Showing();
    758790    else
    759791        emit Hiding();
     792    FixupNextChildPulse();
    760793}
    761794
    762795void MythUIType::SetEnabled(bool enable)
     
    824857    m_XYSpeed = base->m_XYSpeed;
    825858    m_deferload = base->m_deferload;
    826859
     860    m_NextPulse = m_Visible ? (1 << animNUMTYPES) - 1 : 0;
     861    FixupNextChildPulse();
     862
    827863    QList<MythUIType *>::Iterator it;
    828864    for (it = base->m_ChildrenList.begin(); it != base->m_ChildrenList.end();
    829865         ++it)
     
    10091045    return false;
    10101046}
    10111047
     1048// Recompute m_NextChildPulse, and if anything has changed, continue
     1049// up the tree.
     1050void 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
     1088void 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
     1099void MythUIType::SetNextPulse(bool flag)
     1100{
     1101    for (unsigned i=0; i<animNUMTYPES; i++)
     1102        SetNextPulse((AnimationType)i, flag);
     1103}
  • libs/libmythui/mythuitype.h

     
    121121
    122122    bool ContainsPoint(const QPoint &point) const;
    123123
     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
    124134  protected:
    125135    virtual void customEvent(QEvent *);
    126136
     
    190200    QPoint m_XYDestination;
    191201    QPoint m_XYSpeed;
    192202
     203    unsigned m_NextPulse;
     204    unsigned m_NextChildPulse;
     205
    193206    FontMap *m_Fonts;
    194207
    195208    MythUIType *m_Parent;
  • libs/libmythui/mythuiimage.cpp

     
    284284    m_Delay = delayms;
    285285    m_LastDisplay = QTime::currentTime();
    286286    m_CurPos = 0;
     287    SetNextPulse(animPulse, (m_Delay > 0));
    287288}
    288289
    289290/**
     
    302303    m_Filename = img->GetFileName();
    303304    Clear();
    304305    m_Delay = -1;
     306    SetNextPulse(animPulse, false);
    305307
    306308    img->UpRef();
    307309
     
    853855    }
    854856
    855857    MythUIType::Pulse();
     858    SetNextPulse(animPulse, (m_Delay > 0));
    856859}
    857860
    858861/**
     
    9991002    else if (element.tagName() == "crop")
    10001003        m_cropRect = parseRect(element);
    10011004    else if (element.tagName() == "delay")
     1005    {
    10021006        m_Delay = getFirstText(element).toInt();
     1007        SetNextPulse(animPulse, (m_Delay > 0));
     1008    }
    10031009    else if (element.tagName() == "reflection")
    10041010    {
    10051011        m_isReflected = true;
  • libs/libmythui/mythuitext.cpp

     
    453453    //
    454454
    455455    MythUIType::Pulse();
     456    SetNextPulse(animPulse, (m_colorCycling || m_scrolling));
    456457
    457458    if (m_colorCycling)
    458459    {
  • libs/libmythui/mythuiwebbrowser.cpp

     
    621621    }
    622622
    623623    MythUIType::Pulse();
     624    SetNextPulse(animPulse, (m_updateInterval != 0));
    624625}
    625626
    626627/**
  • libs/libmythui/mythuitextedit.cpp

     
    7878void MythUITextEdit::Pulse(void)
    7979{
    8080    if (!m_cursorImage)
     81    {
     82        SetNextPulse(animPulse, false);
    8183        return;
     84    }
    8285
    8386    if (m_HasFocus)
    8487    {
     
    102105        m_cursorImage->SetVisible(false);
    103106
    104107    MythUIType::Pulse();
     108    SetNextPulse(animPulse, true);
    105109}
    106110
    107111bool MythUITextEdit::ParseElement(
  • libs/libmythui/mythuiclock.cpp

     
    6464    }
    6565
    6666    MythUIText::Pulse();
     67    SetNextPulse(animPulse, true);
    6768}
    6869
    6970/**