1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/nga/SERVER/drawresource.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,134 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "drawresource.h"
1.20 +#include "wstop.h"
1.21 +#include <graphics/sgimage.h>
1.22 +
1.23 +
1.24 +CWsDrawableSource::CWsDrawableSource(CWsClient *aOwner)
1.25 + : CWsObject(aOwner, WS_HANDLE_DRAWABLE_SOURCE)
1.26 + {
1.27 + }
1.28 +
1.29 +CWsDrawableSource::~CWsDrawableSource()
1.30 + {
1.31 + if (iDrawableSource && iDrawResource)
1.32 + {
1.33 + iDrawResource->CloseDrawableSource(iDrawableSource);
1.34 + }
1.35 + }
1.36 +
1.37 +void CWsDrawableSource::ConstructL(const TWsClCmdCreateDrawableSource &aParams)
1.38 + {
1.39 + NewObjL();
1.40 +
1.41 + CScreen* screen = NULL;
1.42 + if (Rng(0, aParams.iScreenNumber, CWsTop::NumberOfScreens() - 1))
1.43 + {
1.44 + screen = CWsTop::Screen(aParams.iScreenNumber);
1.45 + }
1.46 + else
1.47 + {
1.48 + User::Leave(KErrArgument);
1.49 + }
1.50 + MWsScreen* pOI=screen;
1.51 + CWsDrawableSource::iDrawResource = pOI->ObjectInterface<MWsDrawableSourceProvider>();
1.52 + if (!iDrawResource)
1.53 + {
1.54 + User::Leave(KErrNotSupported);
1.55 + }
1.56 + User::LeaveIfError(iDrawResource->CreateDrawableSource(aParams.iDrawableId, iDrawableSource));
1.57 + IncRefCount();
1.58 + }
1.59 +
1.60 +void CWsDrawableSource::CommandL(TInt aOpcode, const TAny *)
1.61 + {
1.62 + switch(aOpcode)
1.63 + {
1.64 + case EWsDrawableSourceOpFree:
1.65 + iFlags |= EWsClientHandleClosed;
1.66 + DecRefCount();
1.67 + break;
1.68 + default:
1.69 + OwnerPanic(EWservPanicOpcode);
1.70 + break;
1.71 + }
1.72 + }
1.73 +
1.74 +/*
1.75 +CWsDrawableSource is a reference counted object so we cannot simply close the object as somebody else may have a reference to it
1.76 +*/
1.77 +void CWsDrawableSource::CloseObject()
1.78 + {
1.79 + RemoveFromIndex();
1.80 + if (!(iFlags & EWsClientHandleClosed))
1.81 + {
1.82 + DecRefCount();
1.83 + }
1.84 + }
1.85 +
1.86 +void CWsDrawableSource::IncRefCount()
1.87 + {
1.88 + iRefCount++;
1.89 + }
1.90 +
1.91 +void CWsDrawableSource::DecRefCount()
1.92 + {
1.93 + if (--iRefCount <= 0)
1.94 + {
1.95 + delete this;
1.96 + }
1.97 + }
1.98 +
1.99 +void CWsDrawableSource::DrawResource(MWsGraphicsContext *aGc, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation) const
1.100 + {
1.101 + ASSERT(iDrawResource);
1.102 + MWsDrawableSourceProvider* drawResource = aGc->ObjectInterface<MWsDrawableSourceProvider>();
1.103 + if (drawResource == iDrawResource)
1.104 + {
1.105 + drawResource->DrawResource(iDrawableSource, aPos, aRotation);
1.106 + }
1.107 + }
1.108 +
1.109 +void CWsDrawableSource::DrawResource(MWsGraphicsContext *aGc, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation) const
1.110 + {
1.111 + ASSERT(iDrawResource);
1.112 + MWsDrawableSourceProvider* drawResource = aGc->ObjectInterface<MWsDrawableSourceProvider>();
1.113 + if (drawResource == iDrawResource)
1.114 + {
1.115 + drawResource->DrawResource(iDrawableSource, aRect, aRotation);
1.116 + }
1.117 + }
1.118 +
1.119 +void CWsDrawableSource::DrawResource(MWsGraphicsContext *aGc, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation) const
1.120 + {
1.121 + ASSERT(iDrawResource);
1.122 + MWsDrawableSourceProvider* drawResource = aGc->ObjectInterface<MWsDrawableSourceProvider>();
1.123 + if (drawResource == iDrawResource)
1.124 + {
1.125 + drawResource->DrawResource(iDrawableSource, aRectDest, aRectSrc, aRotation);
1.126 + }
1.127 + }
1.128 +
1.129 +void CWsDrawableSource::DrawResource(MWsGraphicsContext *aGc, const TRect& aRect, const TDesC8& aDes) const
1.130 + {
1.131 + ASSERT(iDrawResource);
1.132 + MWsDrawableSourceProvider* drawResource = aGc->ObjectInterface<MWsDrawableSourceProvider>();
1.133 + if (drawResource == iDrawResource)
1.134 + {
1.135 + drawResource->DrawResource(iDrawableSource, aRect, aDes);
1.136 + }
1.137 + }