imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailgeneratetask.h
changeset 0 2014ca87e772
child 5 82749d516180
child 14 2edacbf5d3f9
equal deleted inserted replaced
-1:000000000000 0:2014ca87e772
       
     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:  Task for generating new thumbnails
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef THUMBNAILGENERATETASK_H
       
    20 #define THUMBNAILGENERATETASK_H
       
    21 
       
    22 #include <apmstd.h>
       
    23 
       
    24 #include "thumbnailtask.h"
       
    25 #include "thumbnailprovider.h"
       
    26 #include "thumbnailstore.h" // TThumbnailPersistentSize
       
    27 
       
    28 class CThumbnailServer;
       
    29 
       
    30 /**
       
    31  *  Task for generating new thumbnails.
       
    32  *
       
    33  *  @since S60 v5.0
       
    34  */
       
    35 class CThumbnailGenerateTask: public CThumbnailTask,
       
    36     public MThumbnailProviderObserver
       
    37     {
       
    38 public:
       
    39 
       
    40     /**
       
    41      * C++ default constructor
       
    42      *
       
    43      * @since S60 v5.0
       
    44      * @param aProcessor Processor object for running tasks.
       
    45      * @param aServer Thumbnail server in use.
       
    46      * @param aFile File from which the thumbnail is to be created.
       
    47      * @param aFlags Flags that control the creation of thumbnail.
       
    48      * @param aSize Requested size of thumbnail.
       
    49      * @param aDisplayMode Display mode.
       
    50      * @param aPriority Priority of the request.
       
    51      * @return New CThumbnailGenerateTask object.
       
    52      */
       
    53     CThumbnailGenerateTask( CThumbnailTaskProcessor& aProcessor, CThumbnailServer& aServer,
       
    54             RFile64* aFile, TDesC8* aBuffer, const TDataType* aMimeType,
       
    55             CThumbnailManager::TThumbnailFlags aFlags, const TSize& aSize,
       
    56             TDisplayMode aDisplayMode, TInt aPriority,
       
    57             RArray < TThumbnailPersistentSize >* aMissingSizes, const TDesC& aTargetUri,
       
    58             TThumbnailSize aThumbnailSize, const TThumbnailId aThumbnailId,
       
    59             const CThumbnailManager::TThumbnailQualityPreference aQualityPreference );
       
    60 
       
    61     /**
       
    62      * Destructor.
       
    63      *
       
    64      * @since S60 v5.0
       
    65      */
       
    66     virtual ~CThumbnailGenerateTask();
       
    67 
       
    68     /**
       
    69      * StartL
       
    70      *
       
    71      * @since S60 v5.0
       
    72      */
       
    73     void StartL();
       
    74 
       
    75     /**
       
    76      * Handles an active object's request completion event.
       
    77      *
       
    78      * @since S60 v5.0
       
    79      */
       
    80     void RunL();
       
    81 
       
    82     /**
       
    83      * Implements cancellation of an outstanding request.
       
    84      *
       
    85      * @since S60 v5.0
       
    86      */
       
    87     void DoCancel();
       
    88 
       
    89     /**
       
    90      * Defines if scaled bitmaps needs to be added to pool.
       
    91      *
       
    92      * @since S60 v5.0
       
    93      * @param aBool boolean
       
    94      */
       
    95     void ScaledBitmapToPool(TBool aBool);    
       
    96     
       
    97 private:
       
    98 
       
    99     /**
       
   100      * Calculate the largest non-cropped size and largest cropped size and
       
   101      * let the provider know.
       
   102      *
       
   103      * @since S60 v5.0
       
   104      * @param aEffectiveTargetSize Effective target size.
       
   105      * @param aCroppedTargetSize Cropped target size.
       
   106      */
       
   107     void CalculateTargetSizesL( TSize& aEffectiveTargetSize, TSize&
       
   108         aCroppedTargetSize );
       
   109 
       
   110     /**
       
   111      * For notifying when task has been finished.
       
   112      *
       
   113      * @since S60 v5.0
       
   114      * @param aError Error code.
       
   115      * @param aBitmap Thumbnail image.
       
   116      * @param aOriginalSize Original image size.
       
   117      * @param aEXIF is origin EXIF.
       
   118      */
       
   119     void ThumbnailProviderReady( const TInt aError, CFbsBitmap* aBitmap, const
       
   120         TSize& aOriginalSize, const TBool aEXIF, const TBool aPortrait );
       
   121 
       
   122     /**
       
   123      * For creating scaling task.
       
   124      *
       
   125      * @since S60 v5.0
       
   126      * @param aBitmap Bitmap image.
       
   127      * @param aEXIF is origin EXIF.
       
   128      */
       
   129     void CreateScaleTasksL( CFbsBitmap* aBitmap );
       
   130     
       
   131     /**
       
   132      * For creating blacklisted thumbnail.
       
   133      *
       
   134      * @param aOriginalSize Original size of bitmap.
       
   135      */
       
   136     void CreateBlackListedL( const TSize& aOriginalSize );
       
   137 
       
   138 private:
       
   139     // Data
       
   140 
       
   141     /**
       
   142      * Server.
       
   143      */
       
   144     CThumbnailServer& iServer;
       
   145 
       
   146     /**
       
   147      * Imagefile from which the thumbnail is to be created.
       
   148      */
       
   149     RFile64 iFile;
       
   150     
       
   151     /**
       
   152      * Image buffer
       
   153      */    
       
   154     TDesC8* iBuffer;
       
   155 
       
   156     /**
       
   157      * Mime type of the original image.
       
   158      */
       
   159     TDataType iMimeType;
       
   160 
       
   161     /**
       
   162      * Filename of the image from which the thumbnail is to be created.
       
   163      */
       
   164     TFileName iFilename;
       
   165     
       
   166     /**
       
   167      * Flags
       
   168      */
       
   169     CThumbnailManager::TThumbnailFlags iFlags;
       
   170     /**
       
   171      * Requested  size of thumbnail.
       
   172      */
       
   173     TSize iSize;
       
   174 
       
   175     /**
       
   176      * Display mode.
       
   177      */
       
   178     TDisplayMode iDisplayMode;
       
   179 
       
   180     /**
       
   181      * Only missing persistent sized thumbnails will be created
       
   182      */
       
   183     RArray < TThumbnailPersistentSize >* iMissingSizes;
       
   184 
       
   185     /**
       
   186      * Uri of the target object
       
   187      */
       
   188     TFileName iTargetUri;    
       
   189     
       
   190     /**
       
   191      * Relative thumbnail size
       
   192      */
       
   193     TThumbnailSize iThumbnailSize;    
       
   194     
       
   195 
       
   196     /**
       
   197      * Size of the original image.
       
   198      */
       
   199     TSize iOriginalSize;
       
   200 
       
   201     /**
       
   202      * Refers to a bitmap in the bitmap pool owned by server. Must be deleted
       
   203      * using CThumbnailServer::DeleteBitmapFromPool() to make reference
       
   204      * counting work.
       
   205      * Not own.
       
   206      */
       
   207     CFbsBitmap* iBitmap;
       
   208 
       
   209     /**
       
   210      * Thumbnail provider implementation.
       
   211      * Not own.
       
   212      */
       
   213     CThumbnailProvider* iProvider;
       
   214     
       
   215     TThumbnailId iThumbnailId;
       
   216     
       
   217     TBool iScaledBitmapToPool;
       
   218     
       
   219 #ifdef _DEBUG
       
   220     TTime aStart, aStop;
       
   221 #endif
       
   222     
       
   223     CThumbnailManager::TThumbnailQualityPreference iQualityPreference;
       
   224     
       
   225     TBool iEXIF;
       
   226     
       
   227     /**
       
   228      * Target rect rotated (portrait image)
       
   229      */
       
   230     TBool iPortrait;
       
   231 };
       
   232 
       
   233 #endif // THUMBNAILGENERATETASK_H