emailuis/uicomponents/src/fstextureloader.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-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: This file implements class CFsTextureLoader.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "emailtrace.h"
       
    21 #include <e32std.h>
       
    22 #include <eikenv.h> 
       
    23 #include <imageconversion.h>
       
    24 //<cmail> removed __FS_ALFRED_SUPPORT flag 
       
    25 //#include <fsconfig.h>
       
    26 //</cmail> removed __FS_ALFRED_SUPPORT flag 
       
    27 
       
    28 #include "fstexture.h"
       
    29 #include "fsbitmapprovider.h"
       
    30 #include "fstextureloader.h"
       
    31 
       
    32 // CONSTANTS
       
    33 const TInt KGranularity = 5;
       
    34 
       
    35 // ============================= LOCAL FUNCTIONS  =============================
       
    36 
       
    37 // ============================= MEMBER FUNCTIONS =============================
       
    38 
       
    39 // ----------------------------------------------------------------------------
       
    40 // CFsTextureLoader::TView::operator= ( const CFsTextureLoader::TView& )
       
    41 // Operator =
       
    42 // Status : Draft
       
    43 // ----------------------------------------------------------------------------
       
    44 //
       
    45 CFsTextureLoader::TView& CFsTextureLoader::TView::operator=( const CFsTextureLoader::TView& aView )
       
    46     {
       
    47     FUNC_LOG;
       
    48     iStart = aView.iStart;
       
    49     iLength = aView.iLength;
       
    50     
       
    51     return *this;
       
    52     }    
       
    53 
       
    54 // ----------------------------------------------------------------------------
       
    55 // CFsTextureLoader::NewL
       
    56 // Two-phased constructor
       
    57 // (static, may leave)
       
    58 // Status : Draft
       
    59 // ----------------------------------------------------------------------------
       
    60 //
       
    61 
       
    62 CFsTextureLoader* CFsTextureLoader::NewL( CAlfTextureManager& aManager,
       
    63                                           MFsTextureObserver& aObserver
       
    64                                         )
       
    65 
       
    66     {
       
    67     FUNC_LOG;
       
    68     CFsTextureLoader* loader = new (ELeave) CFsTextureLoader( aManager, 
       
    69                                                               aObserver 
       
    70                                                             );
       
    71     CleanupStack::PushL( loader );
       
    72     loader->ConstructL();
       
    73     CleanupStack::Pop( loader );
       
    74     
       
    75     return loader;
       
    76     }
       
    77     
       
    78 // ----------------------------------------------------------------------------
       
    79 // CFsTextureLoader::~CFsTextureLoader
       
    80 // C++ Destructor
       
    81 // Status : Draft
       
    82 // ----------------------------------------------------------------------------
       
    83 //
       
    84 CFsTextureLoader::~CFsTextureLoader()
       
    85     {
       
    86     FUNC_LOG;
       
    87     SetDefaultTimeOut( TTimeIntervalMicroSeconds32( 0 ) );
       
    88     
       
    89 
       
    90     iManager.RemoveLoadObserver( this );
       
    91 
       
    92    
       
    93     if ( iTextures )
       
    94         {
       
    95         const TInt count = iTextures->Count();
       
    96         for ( TInt i = count - 1; i >= 0; --i )
       
    97             {
       
    98             delete iTextures->At( i );
       
    99             }
       
   100         delete iTextures;
       
   101         iTextures = NULL;
       
   102         }
       
   103    
       
   104     return;
       
   105     }
       
   106     
       
   107 // ----------------------------------------------------------------------------
       
   108 // CFsTextureLoader::TextureLoadingCompleted
       
   109 // Loader callback
       
   110 // Status : Draft
       
   111 // ----------------------------------------------------------------------------
       
   112 //
       
   113 
       
   114 void CFsTextureLoader::TextureLoadingCompleted( CAlfTexture& aTexture,
       
   115                                                 TInt /* aTextureId */,
       
   116                                                 TInt /* aErrorCode */
       
   117                                               )
       
   118 
       
   119     {
       
   120     FUNC_LOG;
       
   121     TInt index = 0;
       
   122 
       
   123     HBufC* fn = aTexture.FileName();
       
   124     TFileName fileName;
       
   125     if ( fn )
       
   126         {
       
   127         fileName.Copy( fn->Des() );
       
   128         }
       
   129     else
       
   130         {
       
   131         fileName.Zero();
       
   132         }
       
   133     CFsTexture* p = SearchByImageName( fileName, &index );
       
   134 
       
   135     while ( p )
       
   136         {
       
   137         iObserver.FsTextureEvent( MFsTextureObserver::EUpdated, *p );
       
   138 
       
   139         fn = aTexture.FileName();
       
   140         if ( fn )
       
   141             {
       
   142             fileName.Copy( fn->Des() );
       
   143             }
       
   144         else
       
   145             {
       
   146             fileName.Zero();
       
   147             }
       
   148         p = SearchByImageName( fileName, &index );
       
   149 
       
   150         }
       
   151     
       
   152     TRAP_IGNORE( UnloadL() )
       
   153         {
       
   154         TRAP_IGNORE( LoadL() )
       
   155         }
       
   156     
       
   157     return;
       
   158     }                                               
       
   159     
       
   160 // ----------------------------------------------------------------------------
       
   161 // CFsTextureLoader::SetView
       
   162 // Set current view area
       
   163 // (may leave)
       
   164 // Status : Draft
       
   165 // ----------------------------------------------------------------------------
       
   166 //
       
   167 void CFsTextureLoader::SetViewL( const TInt& aStart, 
       
   168                                  const TInt& aLength 
       
   169                                )
       
   170     {
       
   171     FUNC_LOG;
       
   172     iView.iStart = aStart;
       
   173     iView.iLength = aLength;
       
   174 
       
   175     UnloadL();
       
   176     LoadL();
       
   177     
       
   178     return;
       
   179     }
       
   180 
       
   181 // ----------------------------------------------------------------------------
       
   182 // CFsTextureLoader::SetView
       
   183 // Set current view area
       
   184 // (may leave)
       
   185 // Status : Draft
       
   186 // ----------------------------------------------------------------------------
       
   187 //
       
   188 void CFsTextureLoader::SetViewL( const TView& aView )
       
   189     {
       
   190     FUNC_LOG;
       
   191     SetViewL( aView.iStart, aView.iLength );
       
   192     
       
   193     return;
       
   194     }
       
   195 
       
   196 // ----------------------------------------------------------------------------
       
   197 // CFsTextureLoader::CFsTextureLoader
       
   198 // C++ Constructor
       
   199 // Status : Draft
       
   200 // ----------------------------------------------------------------------------
       
   201 //
       
   202 
       
   203 CFsTextureLoader::CFsTextureLoader( CAlfTextureManager& aManager,
       
   204                                     MFsTextureObserver& aObserver
       
   205                                   )
       
   206 
       
   207     : iManager( aManager ),
       
   208       iFs( CEikonEnv::Static()->FsSession() ),
       
   209       iTextures( NULL ),
       
   210       iObserver( aObserver ),
       
   211       iId( 0 ),
       
   212       iDefaultTimeOut( 10000000 ) // 10 sec.
       
   213     {
       
   214     FUNC_LOG;
       
   215     return;
       
   216     }  
       
   217 
       
   218 // ----------------------------------------------------------------------------
       
   219 // CFsTextureLoader::ConstructL
       
   220 // 2nd phase contructor
       
   221 // (may leave)
       
   222 // Status : Draft
       
   223 // ----------------------------------------------------------------------------
       
   224 //
       
   225 void CFsTextureLoader::ConstructL()
       
   226     {
       
   227     FUNC_LOG;
       
   228 
       
   229     iManager.AddLoadObserverL( this );
       
   230 
       
   231     
       
   232     iTextures = new ( ELeave ) CArrayPtrFlat<CFsTexture>( KGranularity );
       
   233 
       
   234     return;
       
   235     }
       
   236     
       
   237 // ----------------------------------------------------------------------------
       
   238 // CFsTextureLoader::TimerExpiredL
       
   239 // Timer callback passed from texture
       
   240 // Status : Draft
       
   241 // ----------------------------------------------------------------------------
       
   242 //
       
   243 void CFsTextureLoader::TimerExpiredL( CFsTexture& aTexture )
       
   244     {
       
   245     FUNC_LOG;
       
   246     Unload( aTexture );
       
   247     
       
   248     return;
       
   249     }
       
   250     
       
   251 // ----------------------------------------------------------------------------
       
   252 // CFsTextureLoader::TextureCount
       
   253 // Return number of textures
       
   254 // Status : Draft
       
   255 // ----------------------------------------------------------------------------
       
   256 //
       
   257 TInt CFsTextureLoader::TextureCount() const
       
   258     {
       
   259     FUNC_LOG;
       
   260     const TInt count = iTextures ? iTextures->Count() : 0;
       
   261 
       
   262     return count;
       
   263     }    
       
   264 
       
   265 // ----------------------------------------------------------------------------
       
   266 // CFsTextureLoader::TextureAtIndex
       
   267 // Return texture
       
   268 // Status : Draft
       
   269 // ----------------------------------------------------------------------------
       
   270 //
       
   271 CFsTexture* CFsTextureLoader::TextureAtIndex( const TInt& aIndex )
       
   272     {
       
   273     FUNC_LOG;
       
   274     CFsTexture* texture = NULL;
       
   275     if ( iTextures &&
       
   276          aIndex >= 0 && 
       
   277          aIndex < TextureCount() 
       
   278        )
       
   279         {
       
   280         texture = iTextures->At( aIndex );
       
   281         }
       
   282 
       
   283     return texture;
       
   284     }
       
   285     
       
   286 // ----------------------------------------------------------------------------
       
   287 // CFsTextureLoader::Unload
       
   288 // Unload texture
       
   289 // Status : Draft
       
   290 // ----------------------------------------------------------------------------
       
   291 //
       
   292 void CFsTextureLoader::Unload( CFsTexture& aTexture )
       
   293     {
       
   294     FUNC_LOG;
       
   295     const TInt c = iTextures->Count();
       
   296     TInt refCount = 0;
       
   297     TInt index = KErrNotFound;
       
   298     for ( TInt i = 0; i < c; i++ )
       
   299         {
       
   300         if ( iTextures->At( i ) == &aTexture )
       
   301             {
       
   302             index = i;
       
   303             }
       
   304         if ( &iTextures->At( i )->Texture() == &aTexture.Texture() )
       
   305             {
       
   306             refCount++;
       
   307             }
       
   308         }
       
   309     
       
   310     if ( refCount == 1 )
       
   311         {
       
   312 
       
   313         HBufC* p = aTexture.Texture().FileName();
       
   314         if ( p )
       
   315             {
       
   316             iManager.UnloadTexture( p->Des() );
       
   317             delete &(aTexture.Texture());
       
   318             }
       
   319 
       
   320         }
       
   321         
       
   322     if ( index != KErrNotFound )
       
   323         {
       
   324         CFsTexture* p = iTextures->At( index );
       
   325         CFsBitmapProvider* provider = p->Provider();
       
   326         if ( provider )
       
   327             {
       
   328             const TInt flags = p->TextFlags();
       
   329             if ( !( flags & CFsTexture::EFlagPreserveProvider ) )
       
   330                 {
       
   331                 iManager.UnloadTexture( provider->Id() );
       
   332                 delete &(aTexture.Texture());
       
   333                 }
       
   334             }
       
   335         }
       
   336     
       
   337     return;
       
   338     }    
       
   339     
       
   340 // ----------------------------------------------------------------------------
       
   341 // CFsTextureLoader::SearchByImageName
       
   342 // Search textures by filename
       
   343 // Status : Draft
       
   344 // ----------------------------------------------------------------------------
       
   345 //
       
   346 CFsTexture* CFsTextureLoader::SearchByImageName( const TDesC& aImageFileName,
       
   347                                                  TInt* aIndex
       
   348                                                )
       
   349     {
       
   350     FUNC_LOG;
       
   351     CFsTexture* r = NULL;
       
   352     const TInt c = iTextures->Count();
       
   353     TInt i; // Temporaly index
       
   354     for ( i = aIndex ? *aIndex : 0; i < c && !r; i++ )
       
   355         {
       
   356         CFsTexture* tmp = iTextures->At( i );
       
   357 
       
   358         CAlfTexture& texture = tmp->Texture();
       
   359         HBufC* p = texture.FileName();
       
   360         if ( p && !p->Des().Compare( aImageFileName ) )
       
   361 
       
   362             {
       
   363             r = tmp;
       
   364             }
       
   365         }
       
   366     
       
   367     // Update index
       
   368     if ( aIndex )
       
   369         {
       
   370         *aIndex = i;
       
   371         }
       
   372     
       
   373     return r;
       
   374     }
       
   375 
       
   376 // ----------------------------------------------------------------------------
       
   377 // CFsTextureLoader::SearchByPos
       
   378 // Search textures by position
       
   379 // Status : Draft
       
   380 // ----------------------------------------------------------------------------
       
   381 //
       
   382 CFsTexture* CFsTextureLoader::SearchByPos( const TInt& aPos,
       
   383                                            TInt* aIndex )
       
   384     {
       
   385     FUNC_LOG;
       
   386     CFsTexture* r = NULL;
       
   387     const TInt c = iTextures->Count();
       
   388     TInt i; // Temporaly index
       
   389     for ( i = aIndex ? *aIndex : 0; i < c && !r; i++ )
       
   390         {
       
   391         CFsTexture* tmp = iTextures->At( i );
       
   392         const TInt pos = tmp->Pos();
       
   393 
       
   394         CAlfTexture& texture = tmp->Texture();
       
   395 
       
   396         if ( pos >= 0 && pos == aPos )
       
   397             {
       
   398             r = tmp;
       
   399             }
       
   400         }
       
   401 
       
   402     // Update index
       
   403     if ( aIndex )
       
   404         {
       
   405         *aIndex = i;
       
   406         }
       
   407     
       
   408     return r;
       
   409     }
       
   410 
       
   411 // ----------------------------------------------------------------------------
       
   412 // CFsTextureLoader::SearchById
       
   413 // Search textures by id
       
   414 // Status : Draft
       
   415 // ----------------------------------------------------------------------------
       
   416 //
       
   417 CFsTexture* CFsTextureLoader::SearchById( TInt aId )
       
   418     {
       
   419     CFsTexture* r = NULL;
       
   420     const TInt c = iTextures->Count();
       
   421     TInt i; // Temporaly index
       
   422     for ( i = 0 ; i < c && !r ; ++i )
       
   423         {
       
   424         CFsTexture* tmp = iTextures->At( i );
       
   425         
       
   426         if ( tmp->Id() == aId )
       
   427             {
       
   428             r = tmp;
       
   429             }
       
   430         }
       
   431     
       
   432     return r;
       
   433     }
       
   434 // ----------------------------------------------------------------------------
       
   435 // CFsTextureLoader::LoadTextureL
       
   436 // Create texture from file
       
   437 // (may leave)
       
   438 // Status : Draft
       
   439 // ----------------------------------------------------------------------------
       
   440 //
       
   441 
       
   442 CFsTexture& CFsTextureLoader::LoadTextureL( const TDesC& aImageFileName,
       
   443                                             TSize aTextureMaxSize,
       
   444                                             TAlfTextureFlags aFlags,
       
   445                                             TInt aId,
       
   446                                             const TInt& aLoaderFlags
       
   447                                           )
       
   448 
       
   449     {                                            
       
   450     // If id's not given by user, generate unique id
       
   451     if ( !aId )
       
   452        {
       
   453        aId = GetId();
       
   454        }
       
   455 
       
   456 
       
   457     CAlfTexture& texture = iManager.LoadTextureL( aImageFileName,
       
   458                                                   aTextureMaxSize,
       
   459 
       
   460                                                   aFlags,
       
   461                                                   aId
       
   462                                                 );
       
   463     CFsTexture* holder = CFsTexture::NewL( texture, *this, NULL, aId );
       
   464     // Verify if this has been previously loaded or was loaded syncronously
       
   465     if ( texture.HasContent() )
       
   466         {
       
   467         iObserver.FsTextureEvent( MFsTextureObserver::EUpdated, *holder );
       
   468         }
       
   469     // Pass flagging
       
   470     if ( aLoaderFlags & EFlagSetStatic )
       
   471         {
       
   472         holder->SetTextFlags( holder->TextFlags() | CFsTexture::EFlagStatic );
       
   473         }
       
   474     CleanupStack::PushL( holder );
       
   475     iTextures->AppendL( holder );
       
   476     CleanupStack::Pop( holder );
       
   477     
       
   478     return *holder;
       
   479     }
       
   480     
       
   481 // ----------------------------------------------------------------------------
       
   482 // CFsTextureLoader::AppendBitmapL
       
   483 // Create texture from bitmap(s) 
       
   484 // (may leave)
       
   485 // Status : Draft
       
   486 // ----------------------------------------------------------------------------
       
   487 //
       
   488 
       
   489 CFsTexture& CFsTextureLoader::AppendBitmapL( CFbsBitmap* aBitmap,
       
   490                                              CFbsBitmap* aBitmapMask,
       
   491                                              TAlfTextureFlags aFlags,
       
   492                                              TInt aId,
       
   493                                              const TInt& aLoaderFlags
       
   494                                            )
       
   495 
       
   496     {                                            
       
   497     // If id's not given by user, generate unique id
       
   498     if ( !aId )
       
   499        {
       
   500        aId = GetId();
       
   501        }
       
   502     
       
   503     CFsBitmapProvider* provider = CFsBitmapProvider::NewL( aBitmap,
       
   504                                                            aBitmapMask,
       
   505                                                            aId
       
   506                                                          );
       
   507 
       
   508     CAlfTexture& texture = iManager.CreateTextureL( aId,
       
   509                                                     provider,
       
   510                                                     aFlags
       
   511                                                   );
       
   512     CFsTexture* holder  = CFsTexture::NewL( texture, *this, provider, aId );
       
   513     // Pass flagging
       
   514     if ( aLoaderFlags & EFlagSetStatic )
       
   515         {
       
   516         holder->SetTextFlags( holder->TextFlags() | CFsTexture::EFlagStatic );
       
   517         }
       
   518     CleanupStack::PushL( holder );
       
   519     iTextures->AppendL( holder );
       
   520     CleanupStack::Pop( holder );
       
   521     iObserver.FsTextureEvent( MFsTextureObserver::EUpdated, *holder );
       
   522 
       
   523     return *holder;
       
   524     }    
       
   525 
       
   526 // ----------------------------------------------------------------------------
       
   527 // CFsTextureLoader::LoadL
       
   528 // Load next picture in queue
       
   529 // (may leave)
       
   530 // Status : Draft
       
   531 // ----------------------------------------------------------------------------
       
   532 //
       
   533 void CFsTextureLoader::LoadL( CFsTexture* aTexture )
       
   534     {
       
   535     FUNC_LOG;
       
   536     const TInt c = iTextures->Count();
       
   537     CFsTexture* texture = aTexture;
       
   538     for ( TInt i = 0; i < c && !aTexture; i++ )
       
   539         {
       
   540         CFsTexture* tmp = iTextures->At( i );
       
   541         const TInt flags = tmp->TextFlags();
       
   542         const TInt pos = tmp->Pos();
       
   543         const TBool hasContent = tmp->Texture().HasContent();
       
   544         if ( !hasContent && 
       
   545              flags & CFsTexture::EFlagStatic )
       
   546             {
       
   547             texture = tmp;
       
   548             }
       
   549         else if ( !hasContent &&
       
   550                   pos != KFsUndefined &&
       
   551                   iView.iStart <= pos &&
       
   552                   pos <= ( iView.iStart + iView.iLength )
       
   553                 )
       
   554             {
       
   555             texture = tmp;
       
   556             }
       
   557         else
       
   558             {
       
   559             // Left for Lint
       
   560             }
       
   561         } // i
       
   562    
       
   563     if ( texture )
       
   564         {
       
   565         const TInt id = texture->Id();
       
   566         if ( id )
       
   567             {
       
   568             const TBool isLoaded = iManager.IsLoaded( id );
       
   569             if ( !isLoaded )
       
   570                 {
       
   571                 iManager.LoadTextureL( id );
       
   572                 } // !isLoaded
       
   573             } // id
       
   574         } // texture
       
   575     
       
   576     return;
       
   577     } 
       
   578 
       
   579 // ----------------------------------------------------------------------------
       
   580 // CFsTextureLoader::UnloadL
       
   581 // Unload picture when possible
       
   582 // (may leave)
       
   583 // Status : Draft
       
   584 // ----------------------------------------------------------------------------
       
   585 //
       
   586 void CFsTextureLoader::UnloadL()
       
   587     {
       
   588     FUNC_LOG;
       
   589     const TInt c = iTextures->Count();
       
   590     CFsTexture* texture = NULL;
       
   591     for ( TInt i = 0; i < c ; i++ )
       
   592         {
       
   593         texture = iTextures->At( i );
       
   594         const TBool isStatic = ( texture->TextFlags() & CFsTexture::EFlagStatic );
       
   595         const TInt pos = texture->Pos();
       
   596         const TBool isVisible = iView.iStart <= pos && pos <= ( iView.iStart + iView.iLength );
       
   597         if ( texture->Texture().HasContent() && 
       
   598              !isStatic &&
       
   599              !isVisible
       
   600            )
       
   601             {
       
   602             texture->UnloadL( EFalse );
       
   603             }
       
   604         else if ( isVisible )
       
   605             {
       
   606             texture->UnloadL( ETrue ); // cancel possible unload
       
   607             }
       
   608         else
       
   609             {
       
   610             // Left for Lint
       
   611             }
       
   612         } // i
       
   613         
       
   614     return;
       
   615     } 
       
   616 
       
   617 // ----------------------------------------------------------------------------
       
   618 // CFsTextureLoader::View
       
   619 // Return view
       
   620 // Status : Draft
       
   621 // ----------------------------------------------------------------------------
       
   622 //
       
   623 CFsTextureLoader::TView CFsTextureLoader::View() const
       
   624     {
       
   625     FUNC_LOG;
       
   626     return iView;
       
   627     }
       
   628     
       
   629 // ----------------------------------------------------------------------------
       
   630 // CFsTextureLoader::GetFrameInfoL
       
   631 // Extract frameinfo from picture header
       
   632 // (may leave, static)
       
   633 // Status : Draft
       
   634 // ----------------------------------------------------------------------------
       
   635 //
       
   636 void CFsTextureLoader::GetFrameInfoL( const TDesC& aImageFileName, 
       
   637                                       TFrameInfo& aFrameInfo 
       
   638                                     )
       
   639     {
       
   640     FUNC_LOG;
       
   641     CImageDecoder* imageDecoder = CImageDecoder::FileNewL( CEikonEnv::Static()->FsSession(), 
       
   642                                                            aImageFileName 
       
   643                                                          );
       
   644     CleanupStack::PushL( imageDecoder );
       
   645     aFrameInfo = imageDecoder->FrameInfo();
       
   646     CleanupStack::PopAndDestroy( imageDecoder );
       
   647 
       
   648     return;
       
   649     }                                            
       
   650     
       
   651 // ----------------------------------------------------------------------------
       
   652 // CFsTextureLoader::GetId
       
   653 // Get unique id
       
   654 // Status : Draft
       
   655 // ----------------------------------------------------------------------------
       
   656 //
       
   657 TInt CFsTextureLoader::GetId()
       
   658    {
       
   659    FUNC_LOG;
       
   660    TInt err;
       
   661    TRAP( err, iManager.TextureL( ++iId ) )
       
   662    while ( err != KErrNotFound )
       
   663        {
       
   664        TRAP( err, iManager.TextureL( ++iId ) )
       
   665        } // err
       
   666    
       
   667    return iId;
       
   668    }
       
   669    
       
   670 // ----------------------------------------------------------------------------
       
   671 // CFsTextureLoader::SetDefaultTimeOut
       
   672 // Set default timeout
       
   673 // Status : Draft
       
   674 // ----------------------------------------------------------------------------
       
   675 //
       
   676 void CFsTextureLoader::SetDefaultTimeOut( const TTimeIntervalMicroSeconds32& aTimeOut )
       
   677     {
       
   678     FUNC_LOG;
       
   679     iDefaultTimeOut = aTimeOut;
       
   680     
       
   681     return;
       
   682     }
       
   683     
       
   684 // ----------------------------------------------------------------------------
       
   685 // CFsTextureLoader::DefaultTimeOut
       
   686 // From MFsTextureLoaderObserver
       
   687 // Status : Draft
       
   688 // ----------------------------------------------------------------------------
       
   689 //
       
   690 void CFsTextureLoader::DefaultTimeOut( TTimeIntervalMicroSeconds32& aTimeOut )
       
   691     {
       
   692     FUNC_LOG;
       
   693     aTimeOut = iDefaultTimeOut;
       
   694     
       
   695     return;
       
   696     }
       
   697     
       
   698 // ----------------------------------------------------------------------------
       
   699 // CFsTextureLoader::PosUpdated
       
   700 // From MFsTextureLoaderObserver
       
   701 // Status : Draft
       
   702 // ----------------------------------------------------------------------------
       
   703 //
       
   704 void CFsTextureLoader::PosUpdated( CFsTexture& aTexture )
       
   705     {
       
   706     FUNC_LOG;
       
   707     iObserver.FsTextureEvent( MFsTextureObserver::EPositionUpdated, aTexture );
       
   708     
       
   709     const TInt newPos = aTexture.Pos();
       
   710     if ( newPos < iView.iStart ||
       
   711          newPos > ( iView.iStart + iView.iLength )
       
   712        )
       
   713         {
       
   714         const TInt flags = aTexture.TextFlags();
       
   715         if ( !( flags & CFsTexture::EFlagStatic ) )
       
   716             {
       
   717             Unload( aTexture );
       
   718             } // flags
       
   719         }
       
   720     else
       
   721         {
       
   722         const TInt id = aTexture.Id();
       
   723         if ( !iManager.IsLoaded( id ) )
       
   724             {
       
   725             TRAP_IGNORE( iManager.LoadTextureL( id ) )
       
   726             }
       
   727         TRAP_IGNORE( aTexture.UnloadL( ETrue ) ) // cancel possible unload
       
   728         }
       
   729     
       
   730     return;
       
   731     }
       
   732     
       
   733 // ----------------------------------------------------------------------------
       
   734 // CFsTextureLoader::Deleted
       
   735 // From MFsTextureLoaderObserver
       
   736 // Status : Draft
       
   737 // ----------------------------------------------------------------------------
       
   738 //
       
   739 void CFsTextureLoader::Deleted( CFsTexture& aTexture )
       
   740     {
       
   741     FUNC_LOG;
       
   742     Unload( aTexture );
       
   743     
       
   744     const TInt c = iTextures->Count();
       
   745     for ( TInt i = 0; i < c; i++ )
       
   746         {
       
   747         CFsTexture* p = iTextures->At( i );
       
   748         if ( p == &aTexture )
       
   749             {
       
   750             iTextures->Delete( i );
       
   751             i = ( c + 1 );
       
   752             }
       
   753         }
       
   754     
       
   755     return;
       
   756     }
       
   757     
       
   758 // ----------------------------------------------------------------------------
       
   759 // CFsTextureLoader::FlagsUpdated
       
   760 // From MFsTextureLoaderObserver
       
   761 // Status : Draft
       
   762 // ----------------------------------------------------------------------------
       
   763 //
       
   764 void CFsTextureLoader::FlagsUpdated( CFsTexture& aTexture )
       
   765     {
       
   766     FUNC_LOG;
       
   767     const TInt flags = aTexture.TextFlags();
       
   768     if ( flags & CFsTexture::EFlagStatic )
       
   769         {
       
   770         TRAP_IGNORE( LoadL() );
       
   771         }
       
   772     else
       
   773         {
       
   774         TRAP_IGNORE( UnloadL() );
       
   775         }
       
   776     
       
   777     return;
       
   778     }    
       
   779     
       
   780 // ----------------------------------------------------------------------------
       
   781 // CFsTextureLoader::SizeUpdated
       
   782 // From MFsTextureLoaderObserver
       
   783 // Status : Draft
       
   784 // ----------------------------------------------------------------------------
       
   785 //
       
   786 void CFsTextureLoader::SizeUpdated( CFsTexture& aTexture )
       
   787     {
       
   788     FUNC_LOG;
       
   789     // Forward observation
       
   790     iObserver.FsTextureEvent( MFsTextureObserver::EUpdated, aTexture );
       
   791     
       
   792     return;
       
   793     }    
       
   794        
       
   795     
       
   796 // ========================= OTHER EXPORTED FUNCTIONS =========================
       
   797 
       
   798 // End of file
       
   799 
       
   800