Example #1
0
void spVisitor::VisitAll( spContext& atContext,
                          bool sortContent
                        )
{
    mSiblingSkipped = false;
    mChildSkipped   = false;
    mContextMask    = SP_CTX_ANY; // FIXME:: should be an arg.

    if ( sortContent && !atContext.IsSorted() )

        atContext.SortMembers();

    mpCurCxt = &atContext; // FIXME:: this is dirty, restoring it each time

    if ( atContext.GetContextType() & mContextMask )

        atContext.AcceptVisitor( *this );

    MMemberListT& members = atContext.GetMembers();

    for( size_t i = 0; i != members.size(); ++i )
    {
        if ( mSiblingSkipped )

            return;

        if ( !mChildSkipped )
        {
            size_t prevSz = members.size();

            // visit members of the context recursivelly
            VisitAll( *members[i], sortContent );

            if ( members.size() != prevSz )

                --i; // current member was removed!

            mChildSkipped = 0;
        }
    }
}
Example #2
0
void QuadTreeNode::Visit(const QueryRect& rect, const NormRect& normalized_rect, int32_t count, VisitorQueue& visitor)
{
    size_t size = visitor.size();
    //if the visitor is full check to see if any points ranked below here are useful
    if (size >= count)
    {
        int current_rank =  visitor.top().m_Rank;
        if(current_rank < m_Best)
        {
            return;
        }
    }

    if (normalized_rect.IntersectsRect(m_Bounds.m_LX, m_Bounds.m_LY, m_Bounds.m_HX, m_Bounds.m_HY))
    {
        //If this node is completly contained visit every child node
        if(normalized_rect.ContainsRect(m_Bounds.m_LX, m_Bounds.m_LY, m_Bounds.m_HX, m_Bounds.m_HY))
        {
            VisitAll(rect, normalized_rect, count, visitor);
        }
        else
        {
            //Search children if this node is split
            if (m_IsSplit)
            {
                if(m_NA != nullptr)
                    m_NA->Visit(rect, normalized_rect, count, visitor);
                if(m_NB != nullptr)
                    m_NB->Visit(rect, normalized_rect, count, visitor);
                if(m_NC != nullptr)
                    m_NC->Visit(rect, normalized_rect, count, visitor);
                if(m_ND != nullptr)
                    m_ND->Visit(rect, normalized_rect, count, visitor);
            }
            else
            {
                int32_t highestRank = (1<<30);
                bool is_full = false;
                //If we have a full list we can set the highest rank we are searching for
                if(size >= count)
                {
                    is_full = true;
                    highestRank =  visitor.top().m_Rank;
                }
                for (std::vector<const QueryPoint>::iterator it = m_QueryPoints.begin(); it != m_QueryPoints.end(); ++it)
                {
                    //Are we past the lowest ranked point that is useable?
                    if (it->m_Rank < highestRank)
                    {
                        if(rect.ContainsPoint(it->m_X, it->m_Y))
                        {
                            visitor.push((*it));
                            size++;
                            //Check to see if visitor just became full if so get the highest ranked point
                            if(is_full)
                            {
                                visitor.pop();
                                highestRank =  visitor.top().m_Rank;
                            }
                            else if (size == count)
                            {
                                highestRank =  visitor.top().m_Rank;
                                is_full = true;
                            }
                        }
                    }
                    else //There are no more lower ranked points in this list
                    {
                        break;
                    }
                }
            }
        }
    }
}
Example #3
0
void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
    // Since resource could be backed by malloc or discardable, the cache always dumps detailed
    // stats to be accurate.
    VisitAll(sk_trace_dump_visitor, dump);
}
Example #4
0
void SkResourceCache::TestDumpMemoryStatistics() {
    VisitAll(dump_visitor, nullptr);
}
Example #5
0
void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
    VisitAll(sk_trace_dump_visitor, dump);
}