windowing/windowserver/nga/SERVER/BITMAP.CPP
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Window server side bitmap class
       
    15 // All this class does is actually give the window server ownership of the bitmap
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "ScrDev.H"
       
    20 
       
    21 DWsBitmap::DWsBitmap(CWsClient *aOwner) : CWsObject(aOwner, WS_HANDLE_BITMAP)
       
    22 	{
       
    23 	}
       
    24 
       
    25 DWsBitmap::~DWsBitmap()
       
    26 	{
       
    27 	delete iFbsBitmap;
       
    28 	}
       
    29 
       
    30 void DWsBitmap::ConstructL(const TWsClCmdCreateBitmap &aParams)
       
    31 	{
       
    32 	NewObjL();
       
    33 	iFbsBitmap=new(ELeave) CFbsBitmap();
       
    34 	TInt ret = iFbsBitmap->Duplicate(aParams.handle);
       
    35 	if(ret == KErrNoMemory)
       
    36 		{
       
    37 		User::Leave(ret);
       
    38 		}
       
    39 	if (ret !=KErrNone)
       
    40 		OwnerPanic(EWservPanicBitmap);
       
    41 	IncRefCount();
       
    42 	}
       
    43 
       
    44 void DWsBitmap::CommandL(TInt aOpcode, const TAny *)
       
    45 	{
       
    46 	switch(aOpcode)
       
    47 		{
       
    48 		case EWsBitmapOpFree:
       
    49 			iFlags |= EWsBitmapClientObjectFreed;
       
    50 			DecRefCount();
       
    51 			break;
       
    52 		default:
       
    53 			OwnerPanic(EWservPanicOpcode);
       
    54 			break;
       
    55 		}
       
    56 	}
       
    57 
       
    58 /*
       
    59 DWsBitmap is a reference couting object so we cannot simply close the object as somebody else may have a reference to it
       
    60 */
       
    61 void DWsBitmap::CloseObject()
       
    62 	{
       
    63 	RemoveFromIndex();
       
    64 	if (!(iFlags & EWsBitmapClientObjectFreed))
       
    65 		{
       
    66 		DecRefCount();
       
    67 		}
       
    68 	}
       
    69 
       
    70 void DWsBitmap::IncRefCount()
       
    71 	{
       
    72 	iRefCount++;
       
    73 	}
       
    74 
       
    75 void DWsBitmap::DecRefCount()
       
    76 	{
       
    77 	if (--iRefCount <= 0)
       
    78 		delete this;
       
    79 	}