public void FreeNative(EntityManager man, Entity e, ref Image2DHTML imgHTML)
        {
            if (!imgHTML.externalOwner && imgHTML.imageIndex > 0)
            {
                ImageIOHTMLNativeCalls.JSFreeImage(imgHTML.imageIndex);
#if ENABLE_DOTSPLAYER_PROFILER
                int w = 0, h = 0;
                unsafe
                {
                    ImageIOHTMLNativeCalls.JSGetImageInfo(imgHTML.imageIndex, ref w, ref h);
                }
                if (w != 0 && h != 0)
                {
                    ProfilerStats.AccumStats.memTextureCount.Accumulate(-1);
                    long bytes = -w * h * 4;
                    ProfilerStats.AccumStats.memTexture.Accumulate(bytes);
                    ProfilerStats.AccumStats.memReservedGFX.Accumulate(bytes);
                    ProfilerStats.AccumStats.memUsedGFX.Accumulate(bytes);

                    // WebGL image loading doesn't use our unsafeutility heap allocator so we need to track our own stats
                    ProfilerStats.AccumStats.memReservedExternal.Accumulate(bytes);
                    ProfilerStats.AccumStats.memUsedExternal.Accumulate(bytes);
                }
#endif
            }
            if (imgHTML.imageIndex > 0)
            {
                var s = "Free HTML image at ";
                s += imgHTML.imageIndex.ToString();
                Console.WriteLine(s);
            }
            imgHTML.imageIndex    = 0;
            imgHTML.externalOwner = false;
        }
Exemple #2
0
 public void FreeNative(EntityManager man, Entity e, ref Image2DHTML imgHTML)
 {
     if (!imgHTML.externalOwner && imgHTML.imageIndex > 0)
     {
         ImageIOHTMLNativeCalls.JSFreeImage(imgHTML.imageIndex);
     }
     if (imgHTML.imageIndex > 0)
     {
         var s = "Free HTML image at ";
         s += imgHTML.imageIndex.ToString();
         Console.WriteLine(s);
     }
     imgHTML.imageIndex    = 0;
     imgHTML.externalOwner = false;
 }