Exemplo n.º 1
0
    public void PrefetchNextSlide(string prevPath, string currPath, string nextPath)
    {
        lock (_prefetchingThreadLock)
        {
            // assume that any incomplete prefetching is uneeded, abort
            if (_prefetchingThread != null)
            {
                _prefetchingThread.Abort();
                _prefetchingThread = null;
            }
        }

        lock (_slidesLock)
        {
            // shift slides and determine _neededSlideRelativeIndex
            if (NextSlide != null && NextSlide.FilePath == currPath)
            {
                PrevSlide                 = CurrentSlide;
                CurrentSlide              = NextSlide;
                _neededSlideFilePath      = nextPath;
                _neededSlideRelativeIndex = RelativeIndex.Next;
            }
            else if (PrevSlide != null && PrevSlide.FilePath == currPath)
            {
                NextSlide                 = CurrentSlide;
                CurrentSlide              = PrevSlide;
                _neededSlideFilePath      = prevPath;
                _neededSlideRelativeIndex = RelativeIndex.Prev;
            }
            else
            {
                // may need all 3, but just get next
                _neededSlideFilePath      = nextPath;
                _neededSlideRelativeIndex = RelativeIndex.Next;
            }
        }

        lock (_prefetchingThreadLock)
        {
            _prefetchingThread = new Thread(LoadNextSlideThread);
            _prefetchingThread.IsBackground = true;
            _prefetchingThread.Name         = "PicPrefetch";
            //string cacheString = String.Format("cache:{0}|{1}|{2} ",
            //  _slides[0] != null ? "1" : "0",
            //  _slides[1] != null ? "1" : "0",
            //  _slides[2] != null ? "1" : "0");
            //Trace.WriteLine(cacheString + String.Format("prefetching {0} slide {1}", _neededSlideRelativeIndex.ToString("G"), System.IO.Path.GetFileNameWithoutExtension(_neededSlideFilePath)));
            _prefetchingThread.Start();
        }
    }
Exemplo n.º 2
0
        color FragmentShader(VertexOut vertex, Field <BuildingDist> BuildingDistances, Field <building> Data, Field <unit> Unit, float blend, float radius, [Player.Vals] float player)
        {
            BuildingDist info = BuildingDistances[Here];

            if (info.dist > _15)
            {
                return(color.TransparentBlack);
            }

            vec2 subcell_pos = get_subcell_pos(vertex, BuildingDistances.Size);

            // Get the building data by following the offset
            vec2     offset = Float(info.diff - Pathfinding_ToSpecial.CenterOffset);
            var      index  = new RelativeIndex(offset.x, offset.y);
            building b      = Data[index];
            unit     u      = Unit[index];

            // Get the distance from here to the building center
            float l = length(255 * (info.diff - Pathfinding_ToSpecial.CenterOffset) - (subcell_pos - vec(.5f, .5f)));

            // Draw pixel
            if (fake_selected(b) && u.player == player)
            {
                if (l > .8f * radius && l < radius * 1.15f)
                {
                    color clr = SelectedUnitColor.Get(get_player(info)) * .75f;
                    clr.a = 1;
                    return(clr * blend);
                }

                if (l < radius)
                {
                    color clr = BuildingMarkerColors.Get(get_player(info), get_type(info)) * 1f;
                    clr.a = 1;
                    return(clr * blend);
                }
            }
            else
            {
                if (l < radius)
                {
                    color clr = BuildingMarkerColors.Get(get_player(info), get_type(info));
                    return(clr * blend);
                }
            }

            return(color.TransparentBlack);
        }
Exemplo n.º 3
0
        geo_info FragmentShader(VertexOut vertex, Field <geo> Geo, Field <geo_info> Info)
        {
            geo_info info_here = Info[Here];
            geo      here      = Geo[Here];

            if (here.dir == _0)
            {
                return(geo_info.Zero);
            }

            vec2          pos_here  = vertex.TexCoords * Geo.Size;
            vec2          start_pos = geo_pos_id(here);
            RelativeIndex GeoStart  = (RelativeIndex)(start_pos - pos_here);

            geo
                right = Geo[GeoStart + RightOne],
                up    = Geo[GeoStart + UpOne],
                left  = Geo[GeoStart + LeftOne],
                down  = Geo[GeoStart + DownOne];

            float circum = 0;

            if (right.pos_storage == here.pos_storage)
            {
                circum = max(circum, polar_dist(Info[GeoStart + RightOne]));
            }
            if (up.pos_storage == here.pos_storage)
            {
                circum = max(circum, polar_dist(Info[GeoStart + UpOne]));
            }
            if (left.pos_storage == here.pos_storage)
            {
                circum = max(circum, polar_dist(Info[GeoStart + LeftOne]));
            }
            if (down.pos_storage == here.pos_storage)
            {
                circum = max(circum, polar_dist(Info[GeoStart + DownOne]));
            }

            // Pack the polar circumference into 2-bytes
            set_circumference(ref info_here, circum);

            return(info_here);
        }
Exemplo n.º 4
0
  public void PrefetchNextSlide(string prevPath, string currPath, string nextPath)
  {
    lock (_prefetchingThreadLock)
    {
      // assume that any incomplete prefetching is uneeded, abort
      if (_prefetchingThread != null)
      {
        _prefetchingThread.Abort();
        _prefetchingThread = null;
      }
    }

    lock (_slidesLock)
    {
      // shift slides and determine _neededSlideRelativeIndex
      if (NextSlide != null && NextSlide.FilePath == currPath)
      {
        PrevSlide = CurrentSlide;
        CurrentSlide = NextSlide;
        _neededSlideFilePath = nextPath;
        _neededSlideRelativeIndex = RelativeIndex.Next;
      }
      else if (PrevSlide != null && PrevSlide.FilePath == currPath)
      {
        NextSlide = CurrentSlide;
        CurrentSlide = PrevSlide;
        _neededSlideFilePath = prevPath;
        _neededSlideRelativeIndex = RelativeIndex.Prev;
      }
      else
      {
        // may need all 3, but just get next
        _neededSlideFilePath = nextPath;
        _neededSlideRelativeIndex = RelativeIndex.Next;
      }
    }

    lock (_prefetchingThreadLock)
    {
      _prefetchingThread = new Thread(LoadNextSlideThread);
      _prefetchingThread.IsBackground = true;
      _prefetchingThread.Name = "PicPrefetch";
      //string cacheString = String.Format("cache:{0}|{1}|{2} ",
      //  _slides[0] != null ? "1" : "0",
      //  _slides[1] != null ? "1" : "0",
      //  _slides[2] != null ? "1" : "0");
      //Trace.WriteLine(cacheString + String.Format("prefetching {0} slide {1}", _neededSlideRelativeIndex.ToString("G"), System.IO.Path.GetFileNameWithoutExtension(_neededSlideFilePath)));
      _prefetchingThread.Start();
    }
  }