Ticket #7525: mythui_pulse_optimize_v3.patch

File mythui_pulse_optimize_v3.patch, 10.5 KB (added by Jim Stichnoth <stichnot@…>, 9 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            delete type;
    152157            it.remove();
     158            FixupNextChildPulse();
    153159            return;
    154160        }
    155161    }
     
    172178        {
    173179            delete type;
    174180            it.remove();
     181            FixupNextChildPulse();
    175182            child = NULL;
    176183            return;
    177184        }
     
    196203        delete *it;
    197204
    198205    m_ChildrenList.clear();
     206    FixupNextChildPulse();
    199207}
    200208
    201209/** \brief Return the first MythUIType which accepts focus found at the given
     
    323331void MythUIType::HandleMovementPulse(void)
    324332{
    325333    if (!GetMythPainter()->SupportsAnimation())
     334    {
     335        SetNextPulse(animMovement, false);
    326336        return;
     337    }
    327338
    328339    if (!m_Moving)
     340    {
     341        SetNextPulse(animMovement, false);
    329342        return;
     343    }
    330344
    331345    QPoint curXY = m_Area.topLeft().toQPoint();
    332346    m_DirtyRegion = m_Area.toQRect();
     
    360374    }
    361375
    362376    m_Area.moveTopLeft(curXY);
     377    SetNextPulse(animMovement, m_Moving);
    363378}
    364379
    365380/**
     
    371386{
    372387    if (!GetMythPainter()->SupportsAlpha() ||
    373388        !GetMythPainter()->SupportsAnimation())
     389    {
     390        SetNextPulse(animAlpha, false);
    374391        return;
     392    }
    375393
    376394    if (m_AlphaChangeMode == 0)
     395    {
     396        SetNextPulse(animAlpha, false);
    377397        return;
     398    }
    378399
    379400    m_Alpha += m_AlphaChange;
    380401
     
    398419    }
    399420
    400421    SetRedraw();
     422    SetNextPulse(animAlpha, (m_AlphaChangeMode != 0));
    401423}
    402424
    403425/**
     
    411433    if (!m_Visible)
    412434        return;
    413435
    414     HandleMovementPulse();
    415     HandleAlphaPulse();
     436    if (m_NextPulse & (1 << animMovement))
     437        HandleMovementPulse();
     438    if (m_NextPulse & (1 << animAlpha))
     439        HandleAlphaPulse();
    416440
    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);
    420448}
    421449
    422450int MythUIType::CalcAlpha(int alphamod)
     
    661689                             int maxalpha)
    662690{
    663691    if (!GetMythPainter()->SupportsAlpha())
     692    {
     693        SetNextPulse(animAlpha, false);
    664694        return;
     695    }
    665696
    666697    m_AlphaChangeMode = mode;
    667698    m_AlphaChange = alphachange;
     
    672703        m_Alpha = m_AlphaMax;
    673704    if (m_Alpha < m_AlphaMin)
    674705        m_Alpha = m_AlphaMin;
     706    SetNextPulse(animAlpha, (m_AlphaChangeMode != 0));
    675707}
    676708
    677709void MythUIType::SetAlpha(int newalpha)
     
    755787        emit Showing();
    756788    else
    757789        emit Hiding();
     790    FixupNextChildPulse();
    758791}
    759792
    760793void MythUIType::SetEnabled(bool enable)
     
    822855    m_XYSpeed = base->m_XYSpeed;
    823856    m_deferload = base->m_deferload;
    824857
     858    m_NextPulse = m_Visible ? (1 << animNUMTYPES) - 1 : 0;
     859    FixupNextChildPulse();
     860
    825861    QList<MythUIType *>::Iterator it;
    826862    for (it = base->m_ChildrenList.begin(); it != base->m_ChildrenList.end();
    827863         ++it)
     
    10071043    return false;
    10081044}
    10091045
     1046// Recompute m_NextChildPulse, and if anything has changed, continue
     1047// up the tree.
     1048void 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
     1086void 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
     1097void MythUIType::SetNextPulse(bool flag)
     1098{
     1099    for (unsigned i=0; i<animNUMTYPES; i++)
     1100        SetNextPulse((AnimationType)i, flag);
     1101}
  • 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

     
    287287    m_Delay = delayms;
    288288    m_LastDisplay = QTime::currentTime();
    289289    m_CurPos = 0;
     290    SetNextPulse(animPulse, (m_Delay > 0));
    290291}
    291292
    292293/**
     
    305306    m_Filename = img->GetFileName();
    306307    Clear();
    307308    m_Delay = -1;
     309    SetNextPulse(animPulse, false);
    308310
    309311    img->UpRef();
    310312
     
    856858    }
    857859
    858860    MythUIType::Pulse();
     861    SetNextPulse(animPulse, (m_Delay > 0));
    859862}
    860863
    861864/**
     
    10021005    else if (element.tagName() == "crop")
    10031006        m_cropRect = parseRect(element);
    10041007    else if (element.tagName() == "delay")
     1008    {
    10051009        m_Delay = getFirstText(element).toInt();
     1010        SetNextPulse(animPulse, (m_Delay > 0));
     1011    }
    10061012    else if (element.tagName() == "reflection")
    10071013    {
    10081014        m_isReflected = true;
     
    11191125    //SetImages(im->m_Images);
    11201126
    11211127    MythUIType::CopyFrom(base);
     1128    SetNextPulse(animPulse, (m_Delay > 0));
    11221129
    11231130    m_NeedLoad = im->m_NeedLoad;
    11241131
  • libs/libmythui/mythuitext.cpp

     
    453453    //
    454454
    455455    MythUIType::Pulse();
     456    SetNextPulse(animPulse, (m_colorCycling || m_scrolling));
    456457
    457458    if (m_colorCycling)
    458459    {
     
    524525    incB = (endColor.blue() * 1.0 - curB) / m_numSteps;
    525526
    526527    m_colorCycling = true;
     528    SetNextPulse(animPulse, true);
    527529}
    528530
    529531void MythUIText::StopCycling(void)
     
    673675            m_colorCycling = false;
    674676
    675677        m_colorCycling = parseBool(element.attribute("disable"));
     678        SetNextPulse(animPulse, (m_colorCycling || m_scrolling));
    676679    }
    677680    else if (element.tagName() == "scroll")
    678681    {
     
    696699        }
    697700        else
    698701            m_scrolling = false;
     702        SetNextPulse(animPulse, (m_colorCycling || m_scrolling));
    699703    }
    700704    else if (element.tagName() == "case")
    701705    {
     
    769773    m_textCase = text->m_textCase;
    770774
    771775    MythUIType::CopyFrom(base);
     776    SetNextPulse(animPulse, (m_colorCycling || m_scrolling));
    772777}
    773778
    774779void MythUIText::CreateCopy(MythUIType *parent)
  • libs/libmythui/mythuiwebbrowser.cpp

     
    621621    }
    622622
    623623    MythUIType::Pulse();
     624    SetNextPulse(animPulse, (m_updateInterval != 0));
    624625}
    625626
    626627/**
     
    875876    {
    876877        QString interval = getFirstText(element);
    877878        m_updateInterval = interval.toInt();
     879        SetNextPulse(animPulse, (m_updateInterval != 0));
    878880    }
    879881    else if (element.tagName() == "background")
    880882    {
     
    909911    m_widgetUrl = browser->m_widgetUrl;
    910912    m_userCssFile = browser->m_userCssFile;
    911913    m_updateInterval = browser->m_updateInterval;
     914    SetNextPulse(animPulse, (m_updateInterval != 0));
    912915
    913916    Init();
    914917}
  • 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/**