Castle Game Engine: CastleTextureImages: Class TTexturesVideosCache

# Class TTexturesVideosCache
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleTextureImages ## Declaration `type TTexturesVideosCache = class(TVideosCache)` ## Description A cache of loaded images for textures. Load by TextureImage_IncReference, free by TextureImage_DecReference. These replace LoadTextureImage, and manual freeing of Image/DDS. If you used IncReference that returns DDS, then you should also free using DecReference that takes DDS. If you used IncReference without DDS parameter, then also free using DecReference without DDS parameter. The idea is that instead of `LoadTextureImage(...)` call `Cache.TextureImage_IncReference(...)`. Later, instead of freeing this image, call `TextureImage_DecReference(Image)`. From your point of view, things will work the same. But if you expect to load many textures from the same URL, then you will get a great speed and memory saving, because image will only be actually loaded once. Notes: Note that in case of problems with loading, TextureImage_IncReference may raise an exception, just like normal LoadTextureImage. In this case it's guaranteed that no reference will be incremented, of course. If LoadTextureImage_IncReference returns in a normal way, then it will return something non-`Nil`, just like LoadTextureImage does. LoadTextureImage_DecReference alwas sets Image to `Nil`, like FreeAndNil. Since detecting image alpha channel type may be a little time-consuming (iteration over all pixels is needed), we also do it here and save in cache. Note that before destroying this object you must free all textures, i.e. call LoadTextureImage_DecReference for all images allocated by LoadTextureImage_IncReference. This class is not a lousy way of avoiding memory leaks — it would be a bad idea, because it would cause sloppy programming, where memory is unnecessarily allocated for a long time. In fact, this class asserts in destructor that no images are in cache anymore, so if you compiled with assertions enabled, this class does the job of memory-leak detector. ## Hierarchy TObject TVideosCache TTexturesVideosCache ## Overview ### Methods
| `constructor Create;`
| `destructor Destroy; override;`
| `function TextureImage_IncReference(const URL: string; out DDS: TDDSImage; out AlphaChannel: TAlphaChannel): TEncodedImage;`
| `function TextureImage_IncReference(const URL: string; out AlphaChannel: TAlphaChannel): TEncodedImage;`
| `procedure TextureImage_DecReference(var Image: TEncodedImage; var DDS: TDDSImage);`
| `procedure TextureImage_DecReference(var Image: TEncodedImage);`
| `function Empty: boolean; override;`
## Description ### Methods
| `constructor Create;`
| `destructor Destroy; override;`
| `function TextureImage_IncReference(const URL: string; out DDS: TDDSImage; out AlphaChannel: TAlphaChannel): TEncodedImage;`
| `function TextureImage_IncReference(const URL: string; out AlphaChannel: TAlphaChannel): TEncodedImage;`
| `procedure TextureImage_DecReference(var Image: TEncodedImage; var DDS: TDDSImage);`
| `procedure TextureImage_DecReference(var Image: TEncodedImage);`
| `function Empty: boolean; override;`
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:12