Class TTexturesVideosCache

Unit

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/Composite.

If you used IncReference that returns Composite, then you should also free using DecReference that takes Composite. If you used IncReference without Composite parameter, then also free using DecReference without Composite 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 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

Overview

Methods

Public constructor Create;
Public destructor Destroy; override;
Public function TextureImage_IncReference(const URL: string; out Composite: TCompositeImage; out AlphaChannel: TAlphaChannel; const LoadOptions: TLoadImageOptions = []): TEncodedImage; overload;
Public function TextureImage_IncReference(const URL: string; out AlphaChannel: TAlphaChannel; const LoadOptions: TLoadImageOptions = []): TEncodedImage; overload;
Public function TextureImage_IncReference(const URL: string; const LoadOptions: TLoadImageOptions = []): TEncodedImage; overload;
Public procedure TextureImage_DecReference(var Image: TEncodedImage; var Composite: TCompositeImage); overload;
Public procedure TextureImage_DecReference(var Image: TEncodedImage); overload;
Public function Empty: boolean; override;

Description

Methods

Public constructor Create;
 
Public destructor Destroy; override;
 
Public function TextureImage_IncReference(const URL: string; out Composite: TCompositeImage; out AlphaChannel: TAlphaChannel; const LoadOptions: TLoadImageOptions = []): TEncodedImage; overload;
 
Public function TextureImage_IncReference(const URL: string; out AlphaChannel: TAlphaChannel; const LoadOptions: TLoadImageOptions = []): TEncodedImage; overload;
 
Public function TextureImage_IncReference(const URL: string; const LoadOptions: TLoadImageOptions = []): TEncodedImage; overload;
 
Public procedure TextureImage_DecReference(var Image: TEncodedImage; var Composite: TCompositeImage); overload;
 
Public procedure TextureImage_DecReference(var Image: TEncodedImage); overload;
 
Public function Empty: boolean; override;
 

Generated by PasDoc 0.16.0.