private void LoadAlphaNumeric(SegmentWeight weight)
        {
            var prefix           = "LibDmd.Output.Virtual.AlphaNumeric.alphanum_" + weight.ToString().ToLower() + ".";
            var segmentFileNames = new[] {
                $"{prefix}00-top.svg",
                $"{prefix}01-top-right.svg",
                $"{prefix}02-bottom-right.svg",
                $"{prefix}03-bottom.svg",
                $"{prefix}04-bottom-left.svg",
                $"{prefix}05-top-left.svg",
                $"{prefix}06-middle-left.svg",
                $"{prefix}07-comma.svg",
                $"{prefix}08-diag-top-left.svg",
                $"{prefix}09-center-top.svg",
                $"{prefix}10-diag-top-right.svg",
                $"{prefix}11-middle-right.svg",
                $"{prefix}12-diag-bottom-right.svg",
                $"{prefix}13-center-bottom.svg",
                $"{prefix}14-diag-bottom-left.svg",
                $"{prefix}15-dot.svg",
            };

            Logger.Info("Loading alphanumeric SVGs...");
            Load(segmentFileNames, $"{prefix}full.svg", SegmentType.Alphanumeric, weight);
        }
 public RasterCacheKey(int display, RasterizeLayer layer, SegmentType type, SegmentWeight weight, int segment)
 {
     Display = display;
     Layer   = layer;
     Type    = type;
     Weight  = weight;
     Segment = segment;
 }
        private void Load(string[] fileNames, string pathToFull, SegmentType type, SegmentWeight weight)
        {
            for (var i = 0; i < fileNames.Length; i++)
            {
                var svg = new SKSvg();
                svg.Load(_assembly.GetManifestResourceStream(fileNames[i]));
                _svgs[type][weight].Add(i, svg);
            }
            var full = new SKSvg();

            full.Load(_assembly.GetManifestResourceStream(pathToFull));
            _svgs[type][weight].Add(FullSegment, full);
            Loaded[type][weight].OnNext(Unit.Default);
            Loaded[type][weight] = new BehaviorSubject <Unit>(Unit.Default);
        }
        private void LoadNumeric8(SegmentWeight weight)
        {
            var prefix           = "LibDmd.Output.Virtual.AlphaNumeric.numeric_" + weight.ToString().ToLower() + ".";
            var segmentFileNames = new[] {
                $"{prefix}00-top.svg",
                $"{prefix}01-top-right.svg",
                $"{prefix}02-bottom-right.svg",
                $"{prefix}03-bottom.svg",
                $"{prefix}04-bottom-left.svg",
                $"{prefix}05-top-left.svg",
                $"{prefix}06-middle.svg",
                $"{prefix}07-comma.svg",
            };

            Logger.Info("Loading numeric (8) SVGs...");
            Load(segmentFileNames, $"{prefix}full.svg", SegmentType.Numeric8, weight);
        }
 /// <summary>
 /// Returns the size of the SVG of a given segment type.
 /// </summary>
 /// <param name="type">Segment type</param>
 /// <param name="weight">Segment weight</param>
 /// <returns>Size of the SVG</returns>
 public SKRect GetSvgSize(SegmentType type, SegmentWeight weight)
 {
     return(_svgs[type][weight][FullSegment].Picture.CullRect);
 }
        /// <summary>
        /// Returns a surface of a segment that was previously generated.
        /// </summary>
        ///
        /// <remarks>
        /// Note that in order to avoid multiple rasterization for each display
        /// on startup, we initially use only one cache. Then, when displays
        /// get individually resized, each display has its own cache.
        /// </remarks>
        /// <param name="display">Display number</param>
        /// <param name="layer">Which layer</param>
        /// <param name="type">Which segment type</param>
        /// <param name="weight">SegmentWeight</param>
        /// <param name="segment">Which segment</param>
        /// <returns>Rasterized surface of null if rasterization is unavailable</returns>
        public SKSurface GetRasterized(int display, RasterizeLayer layer, SegmentType type, SegmentWeight weight, int segment)
        {
            // do we have an individual cache for that display already?
            var displayKey = new RasterCacheKey(display, layer, type, weight, segment);

            if (_rasterCache.ContainsKey(displayKey))
            {
                return(_rasterCache[displayKey]);
            }

            // fallback on initial cache
            var initialKey = new RasterCacheKey(InitialCache, layer, type, weight, segment);

            if (_rasterCache.ContainsKey(initialKey))
            {
                return(_rasterCache[initialKey]);
            }
            return(null);
        }