javauis/lcdui_akn/lcdgr/src/LcdBitmapSurface.cpp
branchRCL_3
changeset 26 2455ef1f5bbc
parent 14 04becd199f91
equal deleted inserted replaced
25:ae942d28ec0e 26:2455ef1f5bbc
       
     1 /*
       
     2 * Copyright (c) 2005 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "LcdBitmapSurface.h"
       
    20 
       
    21 CLcdBitmapSurface* CLcdBitmapSurface::NewL(const CFbsBitmap* aTarget)
       
    22 {
       
    23     CLcdBitmapSurface* surface = new(ELeave) CLcdBitmapSurface;
       
    24     CleanupStack::PushL(surface);
       
    25     surface->ConstructL(*aTarget);
       
    26     CleanupStack::Pop(surface);
       
    27     return surface;
       
    28 }
       
    29 
       
    30 void CLcdBitmapSurface::ConstructL(const CFbsBitmap& aTarget)
       
    31 {
       
    32     iBitmap = new(ELeave) CFbsBitmap;
       
    33     User::LeaveIfError(iBitmap->Duplicate(aTarget.Handle()));
       
    34     iDevice = CFbsBitmapDevice::NewL(iBitmap);
       
    35     User::LeaveIfError(iDevice->CreateContext(iContext));
       
    36     iSpec = TAcceleratedBitmapSpec(iBitmap);
       
    37     iImageType.iColorMode = aTarget.DisplayMode();
       
    38     iImageType.iAlphaMode = ENone;
       
    39     iImageType.iTransparency = ETransparencyNone;
       
    40     iBounds = TRect(aTarget.SizeInPixels());
       
    41     iRegion.AddRect(iBounds);
       
    42 }
       
    43 
       
    44 CLcdBitmapSurface::~CLcdBitmapSurface()
       
    45 {
       
    46     delete iContext;
       
    47     delete iDevice;
       
    48     delete iBitmap;
       
    49     iRegion.Close();
       
    50 }
       
    51 
       
    52 CFbsBitmap* CLcdBitmapSurface::Bitmap() const
       
    53 {
       
    54     return iBitmap;
       
    55 }
       
    56 
       
    57 CLcdSurface::TSurfaceType CLcdBitmapSurface::Type() const
       
    58 {
       
    59     return CLcdSurface::EBitmapSurface;
       
    60 }
       
    61 
       
    62 void CLcdBitmapSurface::Update(const TRect& /*aRect*/)
       
    63 {
       
    64     // NOP. but could copy up from pbuffer here
       
    65 }
       
    66 
       
    67 void CLcdBitmapSurface::Begin(TAcceleratedBitmapInfo& aInfo, TBitmapLockCount& aCount)
       
    68 {
       
    69     iSpec.Lock(aCount);
       
    70     iSpec.GetInfo(aInfo);
       
    71 }
       
    72 
       
    73 void CLcdBitmapSurface::End(TBitmapLockCount& aCount)
       
    74 {
       
    75     iSpec.Unlock(aCount);
       
    76 }
       
    77 
       
    78 TRect CLcdBitmapSurface::Bounds() const
       
    79 {
       
    80     return iBounds;
       
    81 }
       
    82 
       
    83 RRegion* CLcdBitmapSurface::VisibleRegion() const
       
    84 {
       
    85     return const_cast<RRegion*>(&iRegion);
       
    86 }
       
    87 
       
    88 CBitmapContext* CLcdBitmapSurface::Context() const
       
    89 {
       
    90     return iContext;
       
    91 }
       
    92 
       
    93 TImageType CLcdBitmapSurface::ImageType() const
       
    94 {
       
    95     return iImageType;
       
    96 }