Esempio n. 1
0
        public List <int> update(List <Window> requested, int lastsynthesizedlevel)
        {
            SynthWindows synthwins = new SynthWindows(requested, m_iBorderL, m_iBorderR, m_iBorderT, m_iBorderB, m_iPrefetchBorder);

            if (synthwins.m_iNbLevels != m_iNbLevels)
            {
                throw new Exception("SynthWindows::update - can only update if the number of requested levels is the same !");
            }
            return(update(synthwins, lastsynthesizedlevel));
        }
Esempio n. 2
0
        void computeNewRegions(int l, SynthWindows synthwins)
        {
            // compute update regions
            // -> common synthesized part, express in new window coords, to be copied
            Window absSynthCached = bufferrgn(l);
            Window absSynthNew    = synthwins.bufferrgn(l);
            Window absOverlap     = absSynthCached.overlap(absSynthNew);

            Window absValidCached  = valid(l).absoluteFrom(bufferrgn(l));
            Window absValidNew     = synthwins.valid(l).absoluteFrom(synthwins.bufferrgn(l));
            Window absValidOverlap = absValidCached.overlap(absValidNew);

            Pair <Window, Window> rgn = computeUpdateRegions(absValidNew, absValidOverlap);

            m_UpdVert[l]    = rgn.first.relativeTo(synthwins.bufferrgn(l));
            m_UpdHorz[l]    = rgn.second.relativeTo(synthwins.bufferrgn(l));
            m_UpdCopySrc[l] = absValidOverlap.relativeTo(bufferrgn(l));
            m_UpdCopyDst[l] = absValidOverlap.relativeTo(synthwins.bufferrgn(l));

            m_BufferRgn[l] = synthwins.bufferrgn(l);
            m_Valid[l]     = synthwins.valid(l);
            m_Requested[l] = synthwins.requested(l);
            m_Cached[l]    = synthwins.m_Cached[l];
        }
Esempio n. 3
0
 public void updateSynthWindow()
 {
     m_Windows = new SynthWindows(Window.LTWH((int)mWindowMinX, (int)mWindowMinY, mWindowWidth, mWindowHeight), Globals.cNumLevels,
                                  Globals.SYNTH_SUB1234_BORDER_L, Globals.SYNTH_SUB1234_BORDER_R, Globals.SYNTH_SUB1234_BORDER_T, Globals.SYNTH_SUB1234_BORDER_B, Globals.SYNTH_PREFETCH_BORDER);
 }
Esempio n. 4
0
        public List <int> update(Window target)
        {
            SynthWindows synthwins = new SynthWindows(target, m_iNbLevels, m_iBorderL, m_iBorderR, m_iBorderT, m_iBorderB, m_iPrefetchBorder);

            return(update(synthwins, 0));
        }
Esempio n. 5
0
        // TODO : get rid of 'contains' => O(n) !!!!

        List <int> update(SynthWindows synthwins, int lastsynthesizedlevel)
        {
            List <int> tobeupdated = new List <int>();
            int        nbearly     = 0;

            // STEP 1
            // reuse some coarse levels ?
            for (int l = m_iNbLevels - 1; l >= lastsynthesizedlevel; l--)
            {
                // is new requested window included in current valid window ?
                // -> request window in absolute coords.
                Window absreq = synthwins.absRequested(l);
                // -> current valid in absolute coord.
                Window absval = absValid(l);
                // -> if current valid area does not include requested area, level cannot be reused
                if (!absval.includes(absreq))
                {
                    tobeupdated.Insert(0, l);
                }
            }

            // STEP 2
            // -> Early Update: if finest level request is closest than half prefetch, regen !
            if (tobeupdated.Count < 1)
            {
                for (int l = m_iNbLevels - 1; l >= lastsynthesizedlevel; l--)
                {
                    if (!contains(ref tobeupdated, l))
                    {
                        if (nbearly < 1)
                        {
                            Window absreq = synthwins.absRequested(l);
                            int    dist   = absreq.nestedBorderDistance(m_Cached[l]);
                            int    thres  = m_iPrefetchBorder / 2;
                            //      cerr << l << " - thres " << thres << " - dist " << dist << endl;
                            if (dist < thres)
                            {
                                nbearly++;
                                tobeupdated.Insert(0, l);
                            }
                        }
                    }
                }
            }

            // STEP 3
            // -> from finest to coarsest
            // update regions and check parents hold enough data
            //      skip finest
            for (int l = lastsynthesizedlevel; l < m_iNbLevels; l++)
            {
                bool lpresent = contains(ref tobeupdated, l);
                bool ladded   = false;

                if (l > 0 && !lpresent)
                {
                    if (contains(ref tobeupdated, l - 1))
                    {
                        Globals.Assert(bufferrgn(l - 1).equals(synthwins.bufferrgn(l - 1)));

                        Window needed = windowCoarserLevel(bufferrgn(l - 1));
                        if (!(absValid(l).includes(needed)))
                        {
                            tobeupdated.Add(l);
                            ladded = true;
                        }
                    }
                }

                if (lpresent || ladded)
                {
                    computeNewRegions(l, synthwins);
                }
            }

            for (int l = 0; l < m_iNbLevels; l++)
            {
                if (l < lastsynthesizedlevel)
                {
                    m_HasChanged[l] = false;
                }
                else if (!contains(ref tobeupdated, l))
                {
                    Window absreq = synthwins.absRequested(l);
                    if (absreq.equals(absRequested(l)))
                    {
                        m_HasChanged[l] = false;
                    }
                    else
                    {
                        m_Requested[l]  = absreq.relativeTo(bufferrgn(l));
                        m_UpdCopySrc[l] = new Window();
                        m_UpdCopyDst[l] = new Window();
                        m_UpdHorz[l]    = new Window();
                        m_UpdVert[l]    = new Window();
                        m_HasChanged[l] = true;
                    }
                }
                else
                {
                    m_HasChanged[l] = true;
                }
            }

            // sort list

            sort(ref tobeupdated);

            // sanity check

            // -> check enough data in levels
            for (int k = 0; k < tobeupdated.Count; k++)
            {
                if (tobeupdated[k] < m_iNbLevels - 1)
                {
                    Window coarser_needed = windowCoarserLevel(bufferrgn(tobeupdated[k]));
                    Window coarser_valid  = absValid(tobeupdated[k] + 1);
                    if (!coarser_valid.includes(coarser_needed))
                    {
                        // make sure parent also in regen
                        // cerr << "failed(" << (*R) << ") ";
                        MessageBox.Show("(SynthWindows::update) Sanity check failed !");
                    }
                }
            }
            // cerr << endl;

            // -> check list is sorted
            int last = -1;

            for (int k = 0; k < tobeupdated.Count; k++)
            {
                if (!(last == -1 || last > (tobeupdated[k])))
                {
                    MessageBox.Show("(SynthWindows::update) List not sorted !");
                }
                last = tobeupdated[k];
            }

            return(tobeupdated);
        }