class CHuiTexture : public CBase |
CHuiTexture is the base class for all texture objects. It implements the MHuiSegmentedTexture interface for multipart support. Multi-segment textures can be operated in the same way as one would operate single-segment textures.
The application will only need to call a method with "Segment" in its name if it explicitly wants to manipulate a specific segment in a texture. (E.g., when it wants to upload a new sub-texture into the segment.)
The base class enables CHuiTexture to handle large textures as smaller texture segments. Each segment has a position, dimensions, and a name that identifies the texture image of the segment. The purpose is that it is possible to compose large images out of smaller segments. The segments can overlap.
One use case is where the OpenGL texture size is limited (e.g., 256x256). CHuiTexture can split the uploaded source image to multiple segments and create a different OpenGL texture for each. All of the segments are hidden inside CHuiTexture , though, so it could be treated as a single entity.
A CHuiTexture always represents one or more fully loaded (OpenGL ES) texture objects. When drawing something, THuiImages are used for determining the area of the texture to draw. However, different segments may utilize textures in different resolutions.
THuiImage CHuiGc
Protected Member Functions | |
---|---|
CHuiTexture () | |
IMPORT_C void | BaseConstructL () |
void | InitSegmentL ( TInt ) |
void | ResetSegment ( TInt ) |
IMPORT_C void | SetSegment ( TInt , const TSize &, const TPoint &, const TSize &) |
IMPORT_C void | TextureExtension (const TUid &, TAny **) |
Private Member Functions | |
---|---|
NONSHARABLE_STRUCT (TShadowData) | |
void | RemoveAllSegments () |
Private Member Enumerations | |
---|---|
enum | THuiTextureFlags { EHuiTextureFlagDefault = 0, EHuiTextureFlagShadowEnabled = 1, EHuiTextureFlagSkinContent = 2, EHuiTextureFlagAddedToTManager = 4, EHuiTextureFlagNvgContent = 8 } |
Public Attributes | |
---|---|
RHuiObserverArray < MHuiTextureContentObserver > | iContentObservers |
TInt | iFrameCount |
TInt | iFrameInterval |
TInt | iFrameNumber |
Private Attributes | |
---|---|
TInt | iActiveSegment |
TBool | iAutoSizeCalculationEnabled |
THuiTextureAutoSizeParams | iAutoSizeParams |
THuiRealSize | iCalculatedAutoSize |
THuiRealSize | iCalculatedPreviousAutoSize |
HBufC * | iImageFileName |
TUint | iInternalState |
THuiTextureHandle * | iPlaceholder |
RArray < THuiRealSize > | iPreferredSizes |
TInt | iPriority |
RArray < TSegment > | iSegments |
TInt | iSessionId |
THuiShadowStyle | iShadowStyle |
RArray < TShadowData > | iShadows |
TSize | iSize |
TBool | iTextureChanged |
IMPORT_C | CHuiTexture | ( | ) | [protected] |
Constructor. Creates a new texture object with no texture maps.
IMPORT_C THuiTextureAutoSizeParams | AutoSizeParams | ( | ) | const |
Gets parameters to be used when calculating auto size.
THuiRealSize | CalculateAutoSize | ( | ) |
Calculates one size which is most optimal based on all the reported sizes.
TBool | CalculatedAutoSizeChanged | ( | ) | const |
Checks if calculated auto size has been changed since last frame.
IMPORT_C TInt | ClearL | ( | const TSize & | aSize, |
const TRgb & | aColor | |||
) |
Clears the texture object and initializes it with solid color pixels. Will setup the logical size and reserve space for the texture if size and segmentation has not yet been prepared.
IMPORT_C TInt | ClearWithAlphaL | ( | const TSize & | aSize, |
const TRgb & | aColor, | |||
TUint8 | aAlpha | |||
) |
Clears the texture object and initializes it with solid color pixels. The texture will be initialized with alpha data. Will setup the logical size and reserve space for the texture, if needed.
const TSize & aSize | Size of the texture. Does not matter if the size and segmentation of this texture has already been set up. Use Reset() before calling Clear() to change the texture resolution and dimensions. |
const TRgb & aColor | Initial color of the texture. |
TUint8 aAlpha | Initial alpha level of the texture. |
void | CreateShadowTextureL | ( | TInt | aBlurDimension, |
THuiShadowStyle | aStyle | |||
) |
TInt aBlurDimension | |
THuiShadowStyle aStyle |
IMPORT_C void | EnableAutoSizeCalculation | ( | TBool | aEnable = ETrue | ) |
Enables auto size calculations for this texture.
Caller of this method may observe auto size changes through texture managers MHuiTextureAutoSizeObserver interface.
TBool aEnable = ETrue | ETrue if auto size calculation is to be enabled. |
IMPORT_C void | EnableShadow | ( | TBool | aEnable = ETrue | ) | [virtual] |
TBool aEnable = ETrue |
void | GenerateBlobL | ( | const TSize & | aSize | ) |
Generates a blob texture. The texture can be then used for drawing shadow edges, for example.
const TSize & aSize | Dimensions of the blob texture. |
TBool | GetShadowTexture | ( | THuiTextureHandle & | aHandle, |
TInt | aBlurDimension | |||
) | const |
THuiTextureHandle & aHandle | |
TInt aBlurDimension |
IMPORT_C TBool | GetShadowTexture | ( | THuiTextureHandle & | aHandle | ) | const |
THuiTextureHandle & aHandle |
IMPORT_C TBool | HasContent | ( | ) | const [virtual] |
Determines whether the texture has content. Only textures that have content can be drawn.
Note that a texture that has not finished loading will return EFalse here, because its content will only become available after it has been fully loaded.
IMPORT_C const TDesC & | ImageFileName | ( | ) | const |
Returns the file name of the texture's source image (if any).
void | InitSegmentL | ( | TInt | aSegment | ) | [protected, pure virtual] |
Initialize segment for holding texture data. Allocate texture name etc.
TInt aSegment |
TBool | IsAutoSizeCalculationEnabled | ( | ) | const |
Flag to indicate that auto size calculations for this texture is enabled.
IMPORT_C TBool | IsNvgContent | ( | ) | const |
Informs whether this texture is in NVG format or not.
IMPORT_C TBool | IsSkinContent | ( | ) | const [virtual] |
Informs whether this texture is part of skin content or not. By default textures are not part of skin content.
TSize | MaxTextureSize | ( | ) | const [pure virtual] |
Determines the maximum possible actual (OpenGL/in-memory) size for textures. Typically returns power-of-two dimensions. This limit is usually set by the underlying graphics driver/hardware.
NONSHARABLE_STRUCT | ( | TShadowData | ) | [private, inline] |
TShadowData |
IMPORT_C CHuiTexture * | NewL | ( | const THuiTextureHandle * | aExistingTexture = 0 | ) | [static] |
Exported static factory method. Creates a texture appropriate for the current renderer.
const THuiTextureHandle * aExistingTexture = 0 |
IMPORT_C CHuiTexture * | NewLC | ( | const THuiTextureHandle * | aExistingTexture = 0 | ) | [static] |
Exported static factory method. Creates a texture appropriate for the current renderer.
const THuiTextureHandle * aExistingTexture = 0 |
void | NotifyPreferredSize | ( | const THuiRealSize & | aSize | ) |
Notifies one size what would be the most optimal size for this texture. This method can be called e.g. from some CHuiGc image drawing operation which knows the excact size that the image appears in the display.
const THuiRealSize & aSize | Auto size candidate. |
void | PartialUploadL | ( | THuiTextureFormat | aFormat, |
const TPoint & | aOrigin, | |||
const TSize & | aSize, | |||
const TUint8 * | aBuffer | |||
) | [pure virtual] |
Updates a partial area of this texture. Does not change the dimensions of the texture (logical size or segmentation).
You must first call Upload() at least once so the texture object has dimensions.
Does not work with multisegmented textures!
THuiTextureFormat aFormat | Format of the data buffer. |
const TPoint & aOrigin | Position to place the partial texture data. |
const TSize & aSize | Size of the texture in the data buffer. |
const TUint8 * aBuffer | Texture data buffer. |
IMPORT_C void | Release | ( | ) | [virtual] |
Releases the texture. The caller is responsible of checking the release priority of the texture.
void | ResetAutoSizeCalculation | ( | ) |
Clears auto size candidates that has been reported (during last frame). This is called by the texture manager after each frame.
void | ResetSegment | ( | TInt | aSegment | ) | [protected, pure virtual] |
Deallocate resources associated with segment. Will free all resources associated with a texture segment. SetSegmentCount()
TInt aSegment |
void | SegmentClearL | ( | TInt | aSegment, |
TBool | aWithAlpha, | |||
const TRgb & | aColor, | |||
TUint8 | aAlpha | |||
) | [pure virtual] |
Clear a texture segment to a solid color.
IMPORT_C TUint | SegmentName | ( | TInt | aSegment | ) | const |
ID of the given segment.
TInt aSegment | The ordinal of the segment that we want the name of. |
IMPORT_C TPoint | SegmentOffset | ( | TInt | aSegment | ) | const |
Return offset of a segment.
TInt aSegment | The ordinal of the segment that we want the offset of. |
void | SegmentPartialUpload | ( | TInt | aSegment, |
THuiTextureFormat | aFormat, | |||
const TPoint & | aOrigin, | |||
const TSize & | aSize, | |||
const TUint8 * | aBuffer | |||
) | [pure virtual] |
Updates a partial area to a texture segment. Does not change the dimensions of the texture (logical size or segmentation).
You must first call Upload() at least once so the texture object has dimensions and at least one segment to be updated.
TInt aSegment | Valid segment index for this texture. |
THuiTextureFormat aFormat | Format of the data buffer. |
const TPoint & aOrigin | Position to place the partial texture data. |
const TSize & aSize | Size of the texture in the data buffer. |
const TUint8 * aBuffer | Texture data buffer. |
IMPORT_C TSize | SegmentSize | ( | TInt | aSegment | ) | const |
Return logical dimensions of a segment.
TInt aSegment | The ordinal of the segment that we want the dimensions of. |
IMPORT_C TSize | SegmentTextureSize | ( | TInt | aSegment | ) | const |
Return texture dimensions of a segment.
TInt aSegment | The ordinal of the segment that we want the texture dimensions of. |
void | SegmentUploadL | ( | TInt | aSegment, |
THuiTextureFormat | aFormat, | |||
const TSize & | aSize, | |||
const TUint8 * | aBuffer, | |||
TUint | aBufferSize = 0 | |||
) | [pure virtual] |
Uploads bitmap data onto a texture segment. Does not change the dimensions of the texture (logical size or segmentation).
The image segment has to have valid dimensions.
TInt aSegment | Valid segment index for this texture. |
THuiTextureFormat aFormat | Format of the image data buffer. |
const TSize & aSize | Size (width and height in pixels) of the texture in the data buffer (aBuffer). |
const TUint8 * aBuffer | Image data buffer. |
TUint aBufferSize = 0 | Length of the compressed image data. Set as 0 for non-compressed formats. |
void | SegmentUploadL | ( | TInt | aSegment, |
const CFbsBitmap & | aBitmap, | |||
const CFbsBitmap * | aMaskBitmap = NULL, | |||
THuiTextureUploadFlags | aFlags = EHuiTextureUploadFlagDefault | |||
) | [pure virtual] |
Uploads FBS bitmap data onto a texture segment. Does not change the dimensions of the texture (logical size or segmentation).
The image segment has to have valid dimensions.
TInt aSegment | Valid segment index for this texture. |
const CFbsBitmap & aBitmap | Bitmap to copy image contents and format from (RGB data). |
const CFbsBitmap * aMaskBitmap = NULL | Optional Bitmap for alpha (transparency) channel. If the image does not require an alpha channel or the aBitmap already has alpha information (RGBA image) this value may be left as NULL. The bitmap will be combined with aBitmap to single RGBA image. If used, this alpha mask bitmap will replace any alpha information in aBitmap. |
THuiTextureUploadFlags aFlags = EHuiTextureUploadFlagDefault | Specify how the uploaded data is laid out to a texture. |
IMPORT_C void | SetAutoSizeParams | ( | const THuiTextureAutoSizeParams & | aParams | ) |
Sets parameters to be used when calculating auto size.
const THuiTextureAutoSizeParams & aParams | New parameters. |
void | SetImageFileNameL | ( | const TDesC & | aFileName | ) |
Sets the file name of the texture's source image.
const TDesC & aFileName | Image file name. |
IMPORT_C void | SetNvgContent | ( | TBool | aNvgContent | ) |
Defines whether the texture is in NVG format or not. If the texture is in NVG format, it will not eat up any texture memory. Also the autosizing is being disabled by default, since the sizing is practically free with NVG and OpenVG backend.
EnableAutoSizeCalculation() IsNVGContent()
TBool aNvgContent | ETrue to set this texture as extended with NVG content. EFalse to mark that this is not an extended texture. |
void | SetPlaceholder | ( | THuiTextureHandle * | aPlaceholder | ) |
Sets the placeholder texture. Set to zero to disable the placeholder.
THuiTextureHandle * aPlaceholder | Placeholder texture. |
IMPORT_C void | SetPriority | ( | TInt | aPriority | ) |
Sets the texture priority. The prioriry is used when the textures are released/restored.
TInt aPriority | 0 = never release other values to be decided By default != 0 |
IMPORT_C void | SetSegment | ( | TInt | aSegment, |
const TSize & | iSize, | |||
const TPoint & | iOffset, | |||
const TSize & | iTextureSize | |||
) | [protected, virtual] |
Set segment data. Note that the texture name is allocated when calling InitSegmentL() .
Set segment data.
IMPORT_C void | SetSegmentCountL | ( | TInt | aSegmentCount | ) | [virtual] |
Sets the number of segments. Will delete/create new segments as needed.
TInt aSegmentCount | Number of segments. |
IMPORT_C void | SetSegmentName | ( | TInt | aSegment, |
TUint | aName | |||
) | [virtual] |
Sets the name of a segment.
IMPORT_C void | SetSegmentOffset | ( | TInt | aSegment, |
const TPoint & | aOffset | |||
) | [virtual] |
Sets the logical offset of a texture segment.
IMPORT_C void | SetSegmentSize | ( | TInt | aSegment, |
const TSize & | aSegmentSize | |||
) | [virtual] |
Sets the size of a segment.
IMPORT_C void | SetSegmentTextureSize | ( | TInt | aSegment, |
const TSize & | aSegmentTextureSize | |||
) | [virtual] |
Sets the texture size of the segment.
IMPORT_C void | SetSessionId | ( | TInt | aSessionId | ) |
Sets the session id for object.
TInt aSessionId |
IMPORT_C void | SetShadowStyle | ( | THuiShadowStyle | aShadowStyle | ) | [virtual] |
Sets the shadow generation style of the texture.
THuiShadowStyle aShadowStyle | Shadowing style. |
IMPORT_C void | SetSize | ( | const TSize & | aSize | ) | [virtual] |
Set the logical dimensions of the texture. This is the original size of the image loaded as a texture. Also will update (resize) the logical sizes and offsets of texture segments, if such segments have been previously configured.
Size() Use to check the logical size of the texture.
const TSize & aSize |
IMPORT_C void | SetSkinContent | ( | TBool | aSkinContent | ) | [virtual] |
Defines whether the texture is of skin content or not. If this texture is a part of skin content this texture will be released and restored whenever CHuiEnv::NotifySkinChangedL is called. This allows skin specific texture observers to update the content of this texture depending on the skin and it's parameters. Textures that are not part of skin content will be inaffected by the call to the CHuiEnv::NotifySkinChangedL.
CHuiEnv::NotifySkinChangedL() IsSkinContent()
TBool aSkinContent | ETrue to set this texture as part of skin content. EFalse to mark that this texture is not part of skin content. |
IMPORT_C void | SetTextureChanged | ( | TBool | aChanged | ) |
Set texture as (not) changed. Clear the changed flag of this texture once changes have been handled. TextureChanged()
TBool aChanged |
void | SetupSegmentsL | ( | const TSize & | aLogicalSize, |
const TSize & | aTextureSize, | |||
THuiTextureUploadFlags | aFlags = EHuiTextureUploadFlagDefault | |||
) | [pure virtual] |
Calculates and sets up segmentation for given size. If the given size exceeds the available maximum texture size, the area is split up to segments having dimensions no more than the maximum texture size.
const TSize & aLogicalSize | Logical size of the full image. |
const TSize & aTextureSize | Texture resolution required, in pixels. |
THuiTextureUploadFlags aFlags = EHuiTextureUploadFlagDefault |
IMPORT_C TBool | TextureChanged | ( | ) | const [virtual] |
Has texture changed. Check if the texture has changed since the last update.
IMPORT_C void | TextureClearChanged | ( | ) | const [virtual] |
Set texture as not changed. Clear the changed flag of this texture once changes have been handled. TextureChanged()
IMPORT_C void | TextureExtension | ( | const TUid & | aExtensionUid, |
TAny ** | aExtensionParameters | |||
) | [protected] |
void | UploadDirectL | ( | const CFbsBitmap & | aBitmap, |
const CFbsBitmap * | aMaskBitmap, | |||
THuiTextureUploadFlags | aFlags | |||
) |
Uploads the texture data to the texture. Allows using EHuiTextureFlagAllowDirectBitmapUsage flag, but the caller have to take care of deleting the bitmaps.
The bitmaps must be suitable for direct usage. Otherwise this can cause panic in rendering.
const CFbsBitmap & aBitmap | Bitmap to copy image contents from. |
const CFbsBitmap * aMaskBitmap | Optional Bitmap for alpha (transparency) channel. |
THuiTextureUploadFlags aFlags | Specify texture upload behavior. |
void | UploadL | ( | const CFbsBitmap & | aBitmap, |
const CFbsBitmap * | aMaskBitmap = NULL, | |||
THuiTextureUploadFlags | aFlags = EHuiTextureUploadFlagDefault | |||
) | [pure virtual] |
Uploads texture data from an FBS bitmap onto this texture.
Setups the texture (logical) size.
Calculates if segmentation is needed, and setups the segments (as necessary / optional).
Convert / downscale and crop the bitmap data to create bitmap(s) suitable for uploading.
Transfers bitmap data to the graphics device driver.
If the texture uses EHuiTextureFlagAllowDirectBitmapUsage flag, the method CHuiTextureManager::UpdateTextureFromBitmapL() should be used instead. This method leaves with KErrNotSupported in that case.
If the UploadL runs out of memory while uploading/converting the method may try to upload with smaller bitmap sizes and force use of more memory-efficient single-segment texture.
SetSize() Use if you want to change the logical size (for example to fix the aspect ratio of the bitmap) of the texture after uploading.
const CFbsBitmap & aBitmap | Bitmap to copy image contents and format from (RGB data). The support for input CFbsBitmap formats varies between different renderers. See Input bitmaps supported Table describing renderer bitmap support. |
const CFbsBitmap * aMaskBitmap = NULL | Optional Bitmap for alpha (transparency) channel. If the image does not require an alpha channel or the aBitmap already has alpha information (RGBA image) this value may be left as NULL. The bitmap will be combined with aBitmap to single RGBA image. If used, this alpha mask bitmap will replace any alpha information in aBitmap. |
THuiTextureUploadFlags aFlags = EHuiTextureUploadFlagDefault | Specify texture upload behavior - how to convert the bitmap to texture. You can OR these flags together. |
void | UploadL | ( | THuiTextureFormat | aFormat, |
const TSize & | aSize, | |||
const TUint8 * | aBuffer, | |||
THuiTextureUploadFlags | aFlags = EHuiTextureUploadFlagDefault, | |||
TUint | aBufferSize = 0 | |||
) | [pure virtual] |
Uploads bitmap data onto this texture.
Setups the texture (logical) size.
Transfers bitmap data to the graphics device driver.
Note: This method does NOT support texture segmentation. See the CFbsBitmap upload methods ( UploadL() ) to create segmented textures.
THuiTextureFormat aFormat | Format of aBuffer, the image data buffer. |
const TSize & aSize | Size (width and height in pixels) of the texture in the data buffer (aBuffer). |
const TUint8 * aBuffer | Source Image data buffer. |
THuiTextureUploadFlags aFlags = EHuiTextureUploadFlagDefault | Specify upload behavior - how to convert the bitmap to texure. |
TUint aBufferSize = 0 | Length of the compressed image data. Set as 0 for non-compressed formats. |
Flags for texture state.
EHuiTextureFlagDefault = 0 |
Default flags. All special properties disabled. |
EHuiTextureFlagShadowEnabled = 1 |
Shadow is enabled in the texture. |
EHuiTextureFlagSkinContent = 2 |
Texture is included in the skin content. |
EHuiTextureFlagAddedToTManager = 4 | |
EHuiTextureFlagNvgContent = 8 |
Texture is extended and has NVG content |
TBool | iAutoSizeCalculationEnabled | [private] |
Flag to indicate that auto size calculations for this texture is enabled
THuiRealSize | iCalculatedAutoSize | [private] |
Most optimal size calculated based on all reported sizes
THuiRealSize | iCalculatedPreviousAutoSize | [private] |
Previous most optimal size calculated based on all reported sizes
RHuiObserverArray < MHuiTextureContentObserver > | iContentObservers |
Array of content observers.
HBufC * | iImageFileName | [private] |
Name of the image file where the texture was loaded from.
TUint | iInternalState | [private] |
The internal texture state. Composed of THuiTextureFlags.
THuiTextureHandle * | iPlaceholder | [private] |
Temporary texture to use until the real texture has been loaded.
RArray < THuiRealSize > | iPreferredSizes | [private] |
Sizes reported for this texture during last frame
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.