UnloadFromHardware() public method

public UnloadFromHardware ( Javax.Microedition.Khronos.Opengles.IGL10 pGL ) : void
pGL Javax.Microedition.Khronos.Opengles.IGL10
return void
示例#1
0
        public void updateTextures(GL10 pGL)
        {
            HashSet <Texture> texturesManaged = this.mTexturesManaged;
            //final ArrayList<Texture> texturesLoaded = this.mTexturesLoaded;
            //final ArrayList<Texture> texturesToBeLoaded = this.mTexturesToBeLoaded;
            //final ArrayList<Texture> texturesToBeUnloaded = this.mTexturesToBeUnloaded;

            List <Texture> texturesLoaded       = this.mTexturesLoaded;
            List <Texture> texturesToBeLoaded   = this.mTexturesToBeLoaded;
            List <Texture> texturesToBeUnloaded = this.mTexturesToBeUnloaded;

            /* First reload Textures that need to be updated. */
            int texturesLoadedCount = texturesLoaded.Count;

            if (texturesLoadedCount > 0)
            {
                for (int i = texturesLoadedCount - 1; i >= 0; i--)
                {
                    Texture textureToBeUpdated = texturesLoaded[i];
                    if (textureToBeUpdated.IsUpdateOnHardwareNeeded())
                    {
                        textureToBeUpdated.UnloadFromHardware(pGL);
                        textureToBeUpdated.LoadToHardware(pGL);
                    }
                }
            }

            /* Then load pending Textures. */
            int texturesToBeLoadedCount = texturesToBeLoaded.Count;

            if (texturesToBeLoadedCount > 0)
            {
                for (int i = texturesToBeLoadedCount - 1; i >= 0; i--)
                {
                    Texture textureToBeLoaded = texturesToBeLoaded[i];
                    texturesToBeLoaded.RemoveAt(i);
                    if (!textureToBeLoaded.IsLoadedToHardware())
                    {
                        textureToBeLoaded.LoadToHardware(pGL);
                    }
                    texturesLoaded.Add(textureToBeLoaded);
                }
            }

            /* Then unload pending Textures. */
            int texturesToBeUnloadedCount = texturesToBeUnloaded.Count;

            if (texturesToBeUnloadedCount > 0)
            {
                for (int i = texturesToBeUnloadedCount - 1; i >= 0; i--)
                {
                    Texture textureToBeUnloaded = texturesToBeUnloaded[i];
                    texturesToBeUnloaded.RemoveAt(i);
                    if (textureToBeUnloaded.IsLoadedToHardware())
                    {
                        textureToBeUnloaded.UnloadFromHardware(pGL);
                    }
                    texturesLoaded.Remove(textureToBeUnloaded);
                    texturesManaged.Remove(textureToBeUnloaded);
                }
            }

            /* Finally invoke the GC if anything has changed. */
            if (texturesToBeLoadedCount > 0 || texturesToBeUnloadedCount > 0)
            {
                //System.gc();
                // TODO: See if any equivalent to System.gc(); is required
            }
        }