uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiSegmentedTexture.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Declares MHuiSegmentedTexture interface class for texture image objects.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __HUISEGMENTEDTEXTURE_H__
       
    21 #define __HUISEGMENTEDTEXTURE_H__
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 
       
    27 /* Forward declarations. */
       
    28 class THuiTextureHandle;
       
    29 
       
    30 
       
    31 /**
       
    32  * MHuiSegmentedTexture is an abstract base class for texture image objects.
       
    33  * It specifies one or more texture images that comprise a larger (virtual) image.
       
    34  * THuiImage refers to objects that implement MHuiSegmentedTexture.
       
    35  *
       
    36  * A segmented texture is a texture that is composed of one or more segments.
       
    37  * Each segment has a position, dimensions, and a name that identifies the texture
       
    38  * image of the segment. The purpose is that it is possible to compose large images
       
    39  * out of smaller segments. The segments can overlap.
       
    40  *
       
    41  * One use case is where the OpenGL texture size is limited (e.g., 256x256). A class
       
    42  * implementing MHuiSegmentedTexture would in this case split the uploaded source
       
    43  * image to multiple segments and create a different OpenGL texture for each. All
       
    44  * of the segments would still be hidden inside the implementing
       
    45  * MHuiSegmentedTexture-derived class, though, so it could be treated as a single entity.
       
    46  *
       
    47  * When an object implements the MHuiSegmentedTexture interface, it can be drawn using
       
    48  * the DrawImage() methods in CHuiGc (since THuiImage specifies the image as
       
    49  * MHuiSegmentedTexture).
       
    50  *
       
    51  * @note CHuiGc and CHuiTexture only support single-segment textures at the moment.
       
    52  * @see CHuiGles10Texture
       
    53  * @see CHuiTexture
       
    54  * @see CHuiGc
       
    55  * @see THuiImage
       
    56  *
       
    57  */
       
    58 class MHuiSegmentedTexture
       
    59     {
       
    60 public:
       
    61 
       
    62     /** @beginAPI */
       
    63 
       
    64     /** Construction / Destruction */
       
    65 
       
    66     /**
       
    67      * Virtual destructor, needed because we have a couple of implemented
       
    68      * methods.
       
    69      */
       
    70     IMPORT_C virtual ~MHuiSegmentedTexture();
       
    71 
       
    72 
       
    73     /* Methods. */
       
    74 
       
    75     /**
       
    76      * Returns the logical size of this texture. Ie. the original size of the
       
    77      * image represented with this texture. This size is independent of the
       
    78      * possible segmentation of this texture.
       
    79      *
       
    80      * On the other hand the actual texture size may
       
    81      * vary across segments and typically has some driver/hw limitations.
       
    82      *
       
    83      * Note that all the segments must be contained inside the logical
       
    84      * area defined with this function.
       
    85      *
       
    86      * @see SegmentSize() To return logical size for a particular texture segment.
       
    87      * @see SegmentOffset() To return logical position for a particular texture segment.
       
    88      * @see SegmentTextureSize() To return texture size for a segment.
       
    89      */
       
    90     virtual TSize Size() const = 0;
       
    91 
       
    92     /**
       
    93      * Determines how many segments the texture has. Will return 1 if
       
    94      * the texture is not segmented.
       
    95      *
       
    96      * @return  Number of segments in this texture.
       
    97      */
       
    98     virtual TInt SegmentCount() const = 0;
       
    99 
       
   100     /**
       
   101      * Determines the texture name of a segment. For example with
       
   102      * OpenGL ES renderer, this will be the texture id generated
       
   103      * with glGenTextures().
       
   104      *
       
   105      * @param aSegment Segment index to access.
       
   106      */
       
   107     virtual TUint SegmentName(TInt aSegment) const = 0;
       
   108 
       
   109     /**
       
   110      * Determines the logical size of a texture segment.
       
   111      * Can be non-power-of-two (NPOT) and may be different
       
   112      * from the actual texture size.
       
   113      *
       
   114      * @param aSegment Valid segment index for this texture.
       
   115      * @see Size() to return logical size of the whole texture.
       
   116      * @see SegmentTextureSize() to determine the actual resolution of
       
   117      * the texture.
       
   118      */
       
   119     virtual TSize SegmentSize(TInt aSegment) const = 0;
       
   120 
       
   121     /**
       
   122      * Determines the actual resolution of the texture used
       
   123      * by the segment. Most likely only Power-of-Two, unless NPOT
       
   124      * supported by the graphics library.
       
   125      *
       
   126      * @param aSegment Valid segment index for this texture.
       
   127      */
       
   128     virtual TSize SegmentTextureSize(TInt aSegment) const = 0;
       
   129 
       
   130     /**
       
   131      * Determines the logical offset for a texture segment.
       
   132      *
       
   133      * @param aSegment Valid segment index for this texture.
       
   134      */
       
   135     virtual TPoint SegmentOffset(TInt aSegment) const = 0;
       
   136 
       
   137     /**
       
   138      * Returns a handle to given texture segment. Defaults to first segment.
       
   139      */
       
   140     IMPORT_C THuiTextureHandle Handle(TInt aSegment = 0) const;
       
   141 
       
   142     /**
       
   143      * Binds given texture segment to the texture target. Binding makes
       
   144      * the texture segment active.
       
   145      *
       
   146      * @param aSegment Index of a segment. Defaults to the first segment.
       
   147      * @param aTextureUnit  Which (multi-)texture unit to bind to. The default
       
   148      * value binds to the first texture unit (single-texturing mode).
       
   149      * @see SegmentCount() to get the number of available segments.
       
   150      */
       
   151     IMPORT_C void Bind(TInt aSegment = 0, TInt aTextureUnit = 0) const;
       
   152 
       
   153     /** @endAPI */
       
   154     
       
   155     };
       
   156 
       
   157 
       
   158 #endif // __HUISEGMENTEDTEXTURE_H__