uiacceltk/hitchcock/Client/src/alfsymbiansbdrawer.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Symbian specific screen buffer drawer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alf/alfsymbiansbdrawer.h"
       
    21 #include "alf/alfscreenbuffer.h"
       
    22 #include <uiacceltk/HuiUtil.h>
       
    23 #include <fbs.h>
       
    24 
       
    25 struct CAlfSymbianBufferDrawer::TPrivData
       
    26     {
       
    27     CFbsBitmap* iBitmap;
       
    28     CFbsBitmap* iMask;
       
    29     };
       
    30     
       
    31 CAlfSymbianBufferDrawer::CAlfSymbianBufferDrawer()
       
    32     {    
       
    33     }
       
    34 
       
    35 CAlfSymbianBufferDrawer::~CAlfSymbianBufferDrawer()
       
    36     {
       
    37     if (iPrivData)
       
    38     	{
       
    39     	delete iPrivData->iBitmap;
       
    40     	delete iPrivData->iMask;
       
    41     	delete iPrivData; 	
       
    42     	}
       
    43     }
       
    44 
       
    45 CAlfSymbianBufferDrawer* CAlfSymbianBufferDrawer::NewL()
       
    46     {
       
    47     CAlfSymbianBufferDrawer* self = new (ELeave) CAlfSymbianBufferDrawer;
       
    48     CleanupStack::PushL(self);
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop();
       
    51     return self;
       
    52     }
       
    53     
       
    54 void CAlfSymbianBufferDrawer::ConstructL()
       
    55     {
       
    56     iPrivData = new (ELeave) TPrivData;
       
    57     Mem::FillZ(iPrivData, sizeof(TPrivData));
       
    58     }
       
    59 
       
    60 
       
    61 EXPORT_C void CAlfSymbianBufferDrawer::ReleaseDrawer()
       
    62     {
       
    63     delete this;
       
    64     }
       
    65 
       
    66 EXPORT_C void CAlfSymbianBufferDrawer::DrawBuffer(CBitmapContext& aContext, const TPoint& aPos, const TRect& aRect)
       
    67     {
       
    68     if (iPrivData && iPrivData->iBitmap)
       
    69         {
       
    70         aContext.BitBlt(aPos,iPrivData->iBitmap, aRect);
       
    71         }
       
    72     }
       
    73 
       
    74 EXPORT_C void CAlfSymbianBufferDrawer::DrawBufferMasked(CBitmapContext& aContext, const CFbsBitmap* aMask,const TPoint& aPos, const TRect& aRect)
       
    75     {
       
    76     if (iPrivData && iPrivData->iBitmap && aMask)
       
    77         {
       
    78         aContext.BitBltMasked(aPos,iPrivData->iBitmap, aRect,aMask, EFalse);
       
    79         }
       
    80     else
       
    81         {
       
    82         DrawBuffer(aContext, aPos, aRect);
       
    83         }    
       
    84     }
       
    85     
       
    86 EXPORT_C void CAlfSymbianBufferDrawer::GetBufferBitmaps(CFbsBitmap*& aBitmap, CFbsBitmap*& aMask) const
       
    87     {
       
    88     if (iPrivData)
       
    89     	{
       
    90     	if (iPrivData->iBitmap)
       
    91     		{
       
    92     		aBitmap = iPrivData->iBitmap;
       
    93     		}
       
    94     	if (iPrivData->iMask)
       
    95     		{
       
    96     		aMask = iPrivData->iMask;
       
    97     		}
       
    98     	}
       
    99     }        
       
   100     
       
   101 void CAlfSymbianBufferDrawer::SetBufferL(TInt aBitmapHandle, TInt aMaskHandle)
       
   102     {
       
   103     __ASSERT_DEBUG(iPrivData, USER_INVARIANT());
       
   104     if (iPrivData && iPrivData->iBitmap)
       
   105         {
       
   106         delete iPrivData->iBitmap;
       
   107         iPrivData->iBitmap = NULL;
       
   108         }
       
   109     if (iPrivData && iPrivData->iMask)
       
   110         {
       
   111         delete iPrivData->iMask;
       
   112         iPrivData->iMask = NULL;
       
   113         }
       
   114  
       
   115  
       
   116     if (aBitmapHandle)
       
   117         {
       
   118         iPrivData->iBitmap = new (ELeave) CFbsBitmap;
       
   119         User::LeaveIfError(iPrivData->iBitmap->Duplicate(aBitmapHandle));
       
   120         }
       
   121     if (aMaskHandle)
       
   122         {
       
   123         iPrivData->iMask = new (ELeave) CFbsBitmap;
       
   124         User::LeaveIfError(iPrivData->iMask->Duplicate(aMaskHandle));
       
   125         }
       
   126     }
       
   127