Esempio n. 1
0
        protected override void OnEnable()
        {
            base.OnEnable();

            if (_renderPerf == null || !_renderPerf.Name.EndsWith(name))
            {
                _renderPerf = new PerfWatcher("Render " + name);
            }

            if (_hasSource)
            {
                Assert.IsNotNull(_renderAtom, "renderAtom == null");
                _renderAtom.Update();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Takes an Image and tries to load it into MP' graphics memory
        /// If the sFileName was already in memory, it will not be reloaded (basically it caches)
        /// </summary>
        /// <param name="image">The System.Drawing.Bitmap to be loaded</param>
        /// <param name="identifier">A unique identifier for the image so it can be retrieved later on</param>
        /// <returns>memory identifier</returns>
        public static string buildMemoryImage(Image image, string identifier, System.Drawing.Size size, bool buildIdentifier)
        {
            string name = buildIdentifier ? ImageAllocator.buildIdentifier(identifier) : identifier;

            try
            {
                // we don't have to try first, if name already exists mp will not do anything with the image
                if (size.Height > 0 && (size.Height != image.Size.Height || size.Width != image.Size.Width)) //resize
                {
                    image = Resize(image, size);
                }
                PerfWatcher.GetNamedWatch("add to TextureManager").Start();
                //MPTVSeriesLog.WriteMultiLine("AsyncImageResource LoadFromMemory - " + Environment.StackTrace, MPTVSeriesLog.LogLevel.Debug);
                GUITextureManager.LoadFromMemory(image, name, 0, size.Width, size.Height);
                PerfWatcher.GetNamedWatch("add to TextureManager").Stop();
            }
            catch (Exception)
            {
                MPTVSeriesLog.Write("Unable to add to MP's Graphics memory: " + identifier);
                return(string.Empty);
            }
            return(name);
        }