Inheritance: System.IDisposable
Exemplo n.º 1
0
 private void DisposeApplyImageTask(ApplyImageTask task)
 {
     task.mats.ForEach(material => {
         Destroy(material.mainTexture);
         material.mainTexture = null;
         Destroy(material);
         material = null;
     });
     task.Dispose();
 }
Exemplo n.º 2
0
 private void GCOldTasks()
 {
     foreach (object o in tasksToGCNext)
     {
         if (o is ApplyImageTask)
         {
             ApplyImageTask t = (ApplyImageTask)o;
             DisposeApplyImageTask(t);
         }
     }
     tasksToGCNext.Clear();
 }
Exemplo n.º 3
0
    /**
     * Renders the image progressively, using the small, medium and large URLs in succession
     */
    private IEnumerator ProcessTasks()
    {
        int i = 0;         // single coroutine HACK

        ctf = new Stopwatch();
        Stopwatch total = new Stopwatch();

        ctf.Start();
        total.Start();

        while (taskQueue.Count > 0)
        {
            object t = null;
            try {
                t = taskQueue[0];
                taskQueue.RemoveAt(0);
            } catch (System.Exception e) {
                analytics.LogException("Error pulling task: " + e.Message + "; " + e.StackTrace, true);
                continue;
            }

            if (t is ApplyImageTask)
            {
                ApplyImageTask task = (ApplyImageTask)t;
                yield return(StartCoroutine(ShowImage(task, i)));
            }
            else if (t is ShowTutorialTask)
            {
                ShowTutorial();
            }

            i++;
        }

        print("Done");
        total.Stop();
        analytics.LogEvent("Panorama", "AllImagesDone");
        analytics.LogTiming("Loading", total.ElapsedMilliseconds, "Flickr", "TotalTime");
    }
Exemplo n.º 4
0
    private IEnumerator ShowImage(ApplyImageTask task, int taskIndex)
    {
        Stopwatch s = new Stopwatch();

        analytics.LogEvent("Panorama", "DebugFetchFlickrImage");
        s.Start();

        WWW www;

        try {
            www = new WWW(task.url);
            networkConns.Add(www);
        } catch (System.Exception e) {
            analytics.LogException("Error fetching image url: " + e.Message + "; " + e.StackTrace, true);
            www = null;
            yield break;
        }
        print("Fetching image: " + task.url);
        yield return(www);

        if (!networkConns.Contains(www))            // connection was canceled
        {
            www = null;
            yield break;
        }

        s.Stop();
        analytics.LogEvent("Panorama", "DebugGotFlickrImage");
        analytics.LogTiming("Loading", s.ElapsedMilliseconds, "Flickr", "Image" + taskIndex + "Fetch");

        try {
            foreach (Material m in task.mats)
            {
                m.mainTexture = www.texture;
            }
        } catch (System.Exception e) {
            analytics.LogException("Error applying new texture: " + e.Message + "; " + e.StackTrace, true);
            www = null;
            yield break;
        }
        www = null;

        analytics.LogEvent("Panorama", "ImageRendered");
        if (renderMode == RenderMode.STEREO_PANORAMA)
        {
            statusMessage.text = "";
        }
        if (taskIndex == 0)
        {
            firstImageLoadTimeout = Time.time + IMAGE_VIEWING_TIMEOUT_DURATION;
            analytics.gav3.LogEvent("Panorama:" + analytics.sessionId, "RenderedBasicImage", "foo", 1);
            fetchAudio.Play();

            GCOldTasks();
        }
        else if (taskIndex == 2)
        {
            analytics.LogEvent("Panorama", "LargeImageRendered");
            ctf.Stop();
            analytics.LogTiming("Loading", ctf.ElapsedMilliseconds, "Flickr", "LargeImageCTCF");
        }

        tasksToGCNext.Add(task);
    }
    private IEnumerator ShowImage(ApplyImageTask task, int taskIndex)
    {
        Stopwatch s = new Stopwatch();
        analytics.LogEvent("Panorama", "DebugFetchFlickrImage");
        s.Start();

        WWW www;
        try {
            www = new WWW(task.url);
            networkConns.Add (www);
        } catch (System.Exception e) {
            analytics.LogException("Error fetching image url: " + e.Message + "; " + e.StackTrace, true);
            www = null;
            yield break;
        }
        print ("Fetching image: " + task.url);
        yield return www;

        if (!networkConns.Contains (www)) { // connection was canceled
            www = null;
            yield break;
        }

        s.Stop();
        analytics.LogEvent ("Panorama", "DebugGotFlickrImage");
        analytics.LogTiming("Loading", s.ElapsedMilliseconds, "Flickr", "Image" + taskIndex + "Fetch");

        try {
            foreach (Material m in task.mats) {
                m.mainTexture = www.texture;
            }
        } catch (System.Exception e) {
            analytics.LogException("Error applying new texture: " + e.Message + "; " + e.StackTrace, true);
            www = null;
            yield break;
        }
        www = null;

        analytics.LogEvent("Panorama", "ImageRendered");
        if (renderMode == RenderMode.STEREO_PANORAMA) statusMessage.text = "";
        if (taskIndex == 0) {
            firstImageLoadTimeout = Time.time + IMAGE_VIEWING_TIMEOUT_DURATION;
            analytics.gav3.LogEvent ("Panorama:" + analytics.sessionId, "RenderedBasicImage", "foo", 1);
            fetchAudio.Play();

            GCOldTasks();
        } else if (taskIndex == 2) {
            analytics.LogEvent("Panorama", "LargeImageRendered");
            ctf.Stop();
            analytics.LogTiming("Loading", ctf.ElapsedMilliseconds, "Flickr", "LargeImageCTCF");
        }

        tasksToGCNext.Add(task);
    }
 private void DisposeApplyImageTask(ApplyImageTask task)
 {
     task.mats.ForEach(material => {
         Destroy(material.mainTexture);
         material.mainTexture = null;
         Destroy (material);
         material = null;
     });
     task.Dispose ();
 }