uiacceltk/hitchcock/ServerCore/Src/alfwindow.cpp
changeset 0 15bf7259bb7c
child 6 10534483575f
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2009 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 #include "alfwindow.h"
       
    19 
       
    20 #include "alfwindowmanager.h"
       
    21 #include "alfwindowstructs.h"
       
    22 #include "alfwindowbuffer.h"
       
    23 #include "alfstreamerbridge.h"
       
    24 #include "alf/alfconstants.h"
       
    25 #include <uiacceltk/HuiUtil.h>
       
    26 #include "alfwindowdata.h"
       
    27 
       
    28 #include <string.h>
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // NewL
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CAlfWindow* CAlfWindow::NewL(TUint aId, CAlfWindowManager& aOwner, const TSize& aSizeInPixels)
       
    35     {
       
    36     CAlfWindow* self = new (ELeave) CAlfWindow;
       
    37     CleanupStack::PushL(self);
       
    38     self->ConstructL(aId, aOwner, aSizeInPixels);
       
    39     CleanupStack::Pop();
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // destructor
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CAlfWindow::~CAlfWindow()
       
    48     {
       
    49     if (iData)
       
    50         {
       
    51         delete iData->iBufferGc;
       
    52         delete iData->iBufferDev;
       
    53         delete iData->iInBuffer;
       
    54         delete iData->iOutBuffer;
       
    55         
       
    56         delete iData;
       
    57         }
       
    58     }
       
    59         
       
    60 // ---------------------------------------------------------------------------
       
    61 // WsInfo
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C const TAlfWServInfo& CAlfWindow::WsInfo() const
       
    65     {
       
    66     return iData->iOriginalInfo;
       
    67     }
       
    68     
       
    69 // ---------------------------------------------------------------------------
       
    70 // Position
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C TPoint CAlfWindow::Position() const
       
    74     {
       
    75     return iData->iPosition;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // Size
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 EXPORT_C TSize CAlfWindow::Size() const
       
    83     {
       
    84     return iData->iSize;
       
    85     }
       
    86     
       
    87 // ---------------------------------------------------------------------------
       
    88 // Opacity
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C TReal32 CAlfWindow::Opacity() const __SOFTFP
       
    92     {
       
    93     return iData->iOpacity;
       
    94     }
       
    95     
       
    96 // ---------------------------------------------------------------------------
       
    97 // Rotation
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 EXPORT_C TReal32 CAlfWindow::Rotation() const __SOFTFP
       
   101     {
       
   102     return iData->iRotation;
       
   103     }
       
   104     
       
   105 // ---------------------------------------------------------------------------
       
   106 // Identifier
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 EXPORT_C TUint CAlfWindow::Identifier() const
       
   110     {
       
   111     return iData->iIdentifier;
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // IsActive
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 EXPORT_C TBool CAlfWindow::IsActive() const
       
   119     {
       
   120     return iData->iIsActive;
       
   121     }
       
   122     
       
   123 // ---------------------------------------------------------------------------
       
   124 // SurfaceExtent
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 EXPORT_C TRect CAlfWindow::SurfaceExtent() const
       
   128     {
       
   129     return iData->iSurfaceExtent;
       
   130     }
       
   131     
       
   132 // ---------------------------------------------------------------------------
       
   133 // Index
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C TUint CAlfWindow::Index() const
       
   137     {
       
   138     return iData->iIndex;
       
   139     }
       
   140     
       
   141 // ---------------------------------------------------------------------------
       
   142 // InBuffer
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 EXPORT_C CAlfWindowBuffer* CAlfWindow::InBuffer()
       
   146     { // we currently support only fixed type of buffers
       
   147     if (!iData->iInBuffer)
       
   148         {
       
   149         TRAP_IGNORE(CreateInBufferL());    
       
   150         }
       
   151 
       
   152     return iData->iInBuffer;
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // OutBuffer
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C CAlfWindowBuffer* CAlfWindow::OutBufferL(TBool aCopyContents)
       
   160     { // we currently support only fixed type of buffers
       
   161     if (!iData->iInBuffer)
       
   162         {
       
   163         CreateInBufferL();    
       
   164         }
       
   165 
       
   166     if (!iData->iOutBuffer)
       
   167         {
       
   168         iData->iOutBuffer = iData->iInBuffer->CreateCopyL(aCopyContents);
       
   169         }
       
   170     return iData->iOutBuffer;
       
   171     }
       
   172 
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // SetActive
       
   176 // ---------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C void CAlfWindow::SetActive(TBool aVisible)
       
   179     {
       
   180     if (!IsInsertedToScene())
       
   181      	{
       
   182      	iData->iIsActive = aVisible;
       
   183      	}
       
   184 
       
   185     TAlfWServInfo wservInfo = WsInfo();
       
   186 
       
   187     TInt offset;
       
   188     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   189     if ( windowAttributes )
       
   190         {
       
   191         windowAttributes->iActive = aVisible; 
       
   192         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   193         
       
   194         TAlfBridgerData d;
       
   195         d.Set(EAlfDSSetWindowActive, 
       
   196             wservInfo.iRefId.iWindowGroupId, 
       
   197             wservInfo.iRefId.iWindowIdentifer, 
       
   198             (TAny*)offset); 
       
   199 
       
   200         if (iData->iWindowManager->PostIt(d))
       
   201             {
       
   202             iData->iIsActive = aVisible;
       
   203             }
       
   204         }
       
   205 
       
   206     //SetOpacity(aVisible?1.0f:0.0f, 500);
       
   207     }
       
   208     
       
   209 // ---------------------------------------------------------------------------
       
   210 // SetSurfaceExtent
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 EXPORT_C void CAlfWindow::SetSurfaceExtent(const TRect& aRect)
       
   214     {
       
   215     if (!IsInsertedToScene())
       
   216      	{
       
   217         iData->iSurfaceExtent = aRect;
       
   218      	return;
       
   219      	}
       
   220 
       
   221     TAlfWServInfo wservInfo = WsInfo();
       
   222 
       
   223     TInt offset;
       
   224     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   225         
       
   226     if (windowAttributes)
       
   227         {
       
   228         // Setting the extent rectangle in one command fails in armv5 if the alignment is not
       
   229         // divisible by 8 (maybe 4 would be enough).
       
   230         // Therefore the corners must be set one by one. That succeeds even if the address
       
   231         // is not aligned.
       
   232 //        windowAttributes->iSurfaceExtent = aRect;
       
   233         windowAttributes->iSurfaceExtent.iTl.iX = aRect.iTl.iX;
       
   234         windowAttributes->iSurfaceExtent.iTl.iY = aRect.iTl.iY;
       
   235         windowAttributes->iSurfaceExtent.iBr.iX = aRect.iBr.iX;
       
   236         windowAttributes->iSurfaceExtent.iBr.iY = aRect.iBr.iY;
       
   237         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   238 
       
   239         TAlfBridgerData d;
       
   240         d.Set(EAlfDSSetSurfaceExtent, 
       
   241             wservInfo.iRefId.iWindowGroupId, 
       
   242             wservInfo.iRefId.iWindowIdentifer, 
       
   243             (TAny*)offset); 
       
   244 
       
   245         if (iData->iWindowManager->PostIt(d))
       
   246             {
       
   247         	iData->iSurfaceExtent = aRect;
       
   248             }
       
   249         }
       
   250     }
       
   251 
       
   252 
       
   253 // ---------------------------------------------------------------------------
       
   254 // SetLayerUsesAplhaFlag
       
   255 // ---------------------------------------------------------------------------
       
   256 //
       
   257 EXPORT_C void CAlfWindow::SetLayerUsesAplhaFlag( TBool aEnabled )
       
   258     {
       
   259     if (!IsInsertedToScene())
       
   260         {
       
   261         iData->iLayerUsesAlphaFlagEnabled = aEnabled;
       
   262         return;
       
   263         }
       
   264 
       
   265     TAlfWServInfo wservInfo = WsInfo();
       
   266 
       
   267     TInt offset;
       
   268     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   269         
       
   270     if (windowAttributes)
       
   271         {
       
   272         windowAttributes->iLayerUsesAlphaFlagEnabled = aEnabled;
       
   273         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   274         
       
   275         TAlfBridgerData d;
       
   276         d.Set(EAlfDsLayerUsesAlphaFlagChanged, 
       
   277             wservInfo.iRefId.iWindowGroupId, 
       
   278             wservInfo.iRefId.iWindowIdentifer, 
       
   279             (TAny*)offset); 
       
   280 
       
   281         if (iData->iWindowManager->PostIt(d))
       
   282             {
       
   283             iData->iLayerUsesAlphaFlagEnabled = aEnabled;
       
   284             }
       
   285         }    
       
   286     }
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // ContentReady
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 EXPORT_C void CAlfWindow::ContentReady(const TRegion& /*aUpdatedArea*/)
       
   293     {
       
   294     // Todo: Should check whether window is active
       
   295     __ASSERT_ALWAYS( iData, USER_INVARIANT() );
       
   296     
       
   297     CAlfWindowBuffer* buffer = iData->iOutBuffer ? iData->iOutBuffer : iData->iInBuffer;
       
   298         
       
   299     iData->iWindowManager->ContentReady(*this, buffer); // Todo: add region;            
       
   300     }
       
   301 
       
   302 // ---------------------------------------------------------------------------
       
   303 // Move
       
   304 // ---------------------------------------------------------------------------
       
   305 //
       
   306 EXPORT_C void CAlfWindow::Move(TUint aIndex)
       
   307     {
       
   308     if (!IsInsertedToScene())
       
   309      	{
       
   310      	return;
       
   311      	}
       
   312 
       
   313     TAlfWServInfo wservInfo = WsInfo();
       
   314 
       
   315     TInt offset;
       
   316     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   317     if ( windowAttributes )
       
   318         {
       
   319         windowAttributes->iOrdinalPosition = aIndex; 
       
   320         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   321         
       
   322         TAlfBridgerData d;
       
   323         d.Set(EAlfDSReorder, 
       
   324             wservInfo.iRefId.iWindowGroupId, 
       
   325             wservInfo.iRefId.iWindowIdentifer, 
       
   326             (TAny*)offset ); 
       
   327         
       
   328         if (iData->iWindowManager->PostIt(d) == KErrNone)
       
   329             {
       
   330             iData->iIndex = aIndex; // ToDo: if app gives out of bounds val, it is modified in 
       
   331                                     // alf scene and this member is set to wrong value
       
   332             }
       
   333         }
       
   334     }
       
   335 
       
   336 // ---------------------------------------------------------------------------
       
   337 // EnableIndexChangedNotifications
       
   338 // ---------------------------------------------------------------------------
       
   339 //
       
   340 EXPORT_C void CAlfWindow::EnableIndexChangedNotifications(TBool /*aEnable*/)
       
   341     {
       
   342     // Todo
       
   343     //iData->iWindowManager->
       
   344     }
       
   345 
       
   346 // ---------------------------------------------------------------------------
       
   347 // SetPos
       
   348 // ---------------------------------------------------------------------------
       
   349 //
       
   350 EXPORT_C void CAlfWindow::SetPos(TPoint aPos, TUint aDuration)
       
   351     {
       
   352     if (!IsInsertedToScene())
       
   353      	{
       
   354         iData->iPosition = aPos;
       
   355      	return;
       
   356      	}
       
   357 
       
   358     TAlfWServInfo wservInfo = WsInfo();
       
   359     TInt offset;
       
   360     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   361     if (windowAttributes)
       
   362         {
       
   363         windowAttributes->iPosition = aPos;
       
   364         windowAttributes->iTransitionTime = aDuration; 
       
   365         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   366 
       
   367         TAlfBridgerData d;
       
   368         d.Set(EAlfDSSetWindowPos, 
       
   369             wservInfo.iRefId.iWindowGroupId, 
       
   370             wservInfo.iRefId.iWindowIdentifer, 
       
   371             (TAny*)offset ); 
       
   372 
       
   373         if (iData->iWindowManager->PostIt(d))
       
   374             {
       
   375             iData->iPosition = aPos;
       
   376             }
       
   377         }
       
   378     iData->iPosition = aPos; // TODO: This breaks the animation loop
       
   379     }
       
   380 
       
   381 // ---------------------------------------------------------------------------
       
   382 // SetSize
       
   383 // ---------------------------------------------------------------------------
       
   384 //
       
   385 EXPORT_C void CAlfWindow::SetSize(TSize aSize, TUint aDuration)
       
   386     {
       
   387     if (!IsInsertedToScene())
       
   388     	{
       
   389         iData->iSize = aSize;
       
   390     	return;
       
   391     	}
       
   392 
       
   393     if ( aSize != iData->iSize )
       
   394     	{
       
   395     	// TODO: Only texture size should be changed. not the window size at this point.
       
   396     	iData->iSize = aSize;
       
   397     	if (iData->iBufferDev)
       
   398     		{
       
   399     		iData->iBufferDev->Resize( aSize );
       
   400     		}
       
   401     	}
       
   402 
       
   403     TAlfWServInfo wservInfo = WsInfo();
       
   404     TInt offset;
       
   405     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   406     
       
   407     if (windowAttributes)
       
   408         {
       
   409         windowAttributes->iSize = aSize;
       
   410         windowAttributes->iTransitionTime = aDuration; 
       
   411         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   412 
       
   413         TAlfBridgerData d;
       
   414         d.Set(EAlfDSSetWindowSize, 
       
   415             wservInfo.iRefId.iWindowGroupId, 
       
   416             wservInfo.iRefId.iWindowIdentifer, 
       
   417             (TAny*)offset); 
       
   418 
       
   419         if (iData->iWindowManager->PostIt(d))
       
   420             {
       
   421             iData->iSize = aSize;
       
   422             }
       
   423         }
       
   424     }
       
   425 
       
   426 // ---------------------------------------------------------------------------
       
   427 // SetRotation
       
   428 // ---------------------------------------------------------------------------
       
   429 //
       
   430 EXPORT_C void CAlfWindow::SetRotation(TReal32 aAngle, TUint aDuration) __SOFTFP
       
   431     {
       
   432     if (!IsInsertedToScene())
       
   433      	{
       
   434         iData->iRotation = aAngle;
       
   435      	return;
       
   436      	}
       
   437 
       
   438     TAlfWServInfo wservInfo = WsInfo();
       
   439 
       
   440     TInt offset;
       
   441     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   442 
       
   443     if (windowAttributes)
       
   444         {
       
   445         windowAttributes->iRotation = aAngle;
       
   446         windowAttributes->iTransitionTime = aDuration; 
       
   447         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   448         
       
   449         TAlfBridgerData d;
       
   450         d.Set(EAlfDSSetWindowRotation, 
       
   451             wservInfo.iRefId.iWindowGroupId, 
       
   452             wservInfo.iRefId.iWindowIdentifer, 
       
   453             (TAny*)offset ); 
       
   454 
       
   455         if (iData->iWindowManager->PostIt(d))
       
   456             {
       
   457             iData->iRotation = aAngle;
       
   458             }
       
   459         }
       
   460     }
       
   461     
       
   462 // ---------------------------------------------------------------------------
       
   463 // SetOpacity
       
   464 // ---------------------------------------------------------------------------
       
   465 //
       
   466 EXPORT_C void CAlfWindow::SetOpacity(TReal32 aOpacity, TUint aDuration) __SOFTFP
       
   467     {
       
   468     if (!IsInsertedToScene())
       
   469      	{
       
   470         iData->iOpacity = aOpacity;
       
   471      	return;
       
   472      	}
       
   473 
       
   474     TAlfWServInfo wservInfo = WsInfo();
       
   475     TInt offset;
       
   476     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   477     if (windowAttributes)
       
   478         {
       
   479         windowAttributes->iOpacity = aOpacity;
       
   480         windowAttributes->iTransitionTime = aDuration;
       
   481         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   482         
       
   483         TAlfBridgerData d;
       
   484         d.Set(EAlfDSSetWindowOpacity, 
       
   485             wservInfo.iRefId.iWindowGroupId, 
       
   486             wservInfo.iRefId.iWindowIdentifer, 
       
   487             (TAny*)offset); 
       
   488 
       
   489         if (iData->iWindowManager->PostIt(d))
       
   490             {
       
   491             iData->iOpacity = aOpacity;
       
   492             }
       
   493         }
       
   494     }
       
   495 
       
   496 // ---------------------------------------------------------------------------
       
   497 // SetWsInfo
       
   498 // ---------------------------------------------------------------------------
       
   499 //
       
   500 void CAlfWindow::SetWsInfo(const TAlfWServInfo& aInfo)
       
   501     {
       
   502     iData->iOriginalInfo = aInfo;    
       
   503     SetPos(aInfo.iPosition);
       
   504     SetSize(aInfo.iSize);
       
   505     }
       
   506 
       
   507 // ---------------------------------------------------------------------------
       
   508 // constructor
       
   509 // ---------------------------------------------------------------------------
       
   510 //
       
   511 CAlfWindow::CAlfWindow()
       
   512     {
       
   513     }
       
   514     
       
   515 // ---------------------------------------------------------------------------
       
   516 // ConstructL
       
   517 // ---------------------------------------------------------------------------
       
   518 //
       
   519 void CAlfWindow::ConstructL(TUint aId, CAlfWindowManager& aOwner, const TSize& aSizeInPixels)
       
   520     {
       
   521     iData = new (ELeave) TAlfWindowData;
       
   522     memset(iData, 0, sizeof(TAlfWindowData)); // initialize all values to zero
       
   523     iData->iWindowManager = &aOwner;
       
   524     iData->iIdentifier = aId;
       
   525     iData->iIsActive = ETrue;
       
   526     iData->iOpacity = 1.0f;    
       
   527     SetSize(aSizeInPixels);
       
   528     }
       
   529     
       
   530 // ---------------------------------------------------------------------------
       
   531 // CreateInBufferL
       
   532 // ---------------------------------------------------------------------------
       
   533 //
       
   534 void CAlfWindow::CreateInBufferL()
       
   535     {
       
   536     if (!iData->iInBuffer)
       
   537         {
       
   538         iData->iInBuffer = CAlfWindowBuffer::NewL(TSize(0,0),0,0,0);            
       
   539         }    
       
   540     }
       
   541     
       
   542 // ---------------------------------------------------------------------------
       
   543 // SetFlag
       
   544 // ---------------------------------------------------------------------------
       
   545 //
       
   546 void CAlfWindow::SetFlag( TInt aFlag )
       
   547     {
       
   548     iData->iFlags |= aFlag;
       
   549     
       
   550     TAlfWServInfo wservInfo = WsInfo();
       
   551 
       
   552     TInt offset;
       
   553     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   554     if ( windowAttributes )
       
   555         {
       
   556         windowAttributes->iActive = aFlag;  // transporting this in iActive field
       
   557         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   558         
       
   559         TAlfBridgerData d;
       
   560         d.Set(EAlfDSSetWindowFlag, 
       
   561             wservInfo.iRefId.iWindowGroupId, 
       
   562             wservInfo.iRefId.iWindowIdentifer, 
       
   563             (TAny*)offset); 
       
   564 
       
   565         iData->iWindowManager->PostIt(d);
       
   566         }
       
   567     }
       
   568 
       
   569 // ---------------------------------------------------------------------------
       
   570 // ClearFlag
       
   571 // ---------------------------------------------------------------------------
       
   572 //
       
   573 void CAlfWindow::ClearFlag( TInt aFlag )
       
   574     {
       
   575     iData->iFlags &= ~aFlag;
       
   576     
       
   577     TAlfWServInfo wservInfo = WsInfo();
       
   578 
       
   579     TInt offset;
       
   580     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   581     if ( windowAttributes )
       
   582         {
       
   583         windowAttributes->iActive = aFlag;  // transporting this in iActive field
       
   584         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   585         
       
   586         TAlfBridgerData d;
       
   587         d.Set(EAlfDSClearWindowFlag, 
       
   588             wservInfo.iRefId.iWindowGroupId, 
       
   589             wservInfo.iRefId.iWindowIdentifer, 
       
   590             (TAny*)offset); 
       
   591 
       
   592         iData->iWindowManager->PostIt(d);
       
   593         }
       
   594     }
       
   595 
       
   596 
       
   597 // ---------------------------------------------------------------------------
       
   598 // GetBitGcL
       
   599 // ---------------------------------------------------------------------------
       
   600 //
       
   601 CFbsBitGc* CAlfWindow::GetBitGcL()
       
   602     {
       
   603     if (!iData->iBufferDev)
       
   604         {
       
   605         if (!iData->iInBuffer)
       
   606             {
       
   607             CreateInBufferL();    
       
   608             }
       
   609         
       
   610         iData->iBufferDev = CFbsBitmapDevice::NewL( iData->iInBuffer->Bmp() );
       
   611         TInt err = iData->iBufferDev->CreateContext( iData->iBufferGc );
       
   612         if ( err != KErrNone)
       
   613             {
       
   614             delete iData->iBufferDev;
       
   615             iData->iBufferDev = 0;
       
   616             User::Leave(err);
       
   617             }
       
   618         }
       
   619          
       
   620     return iData->iBufferGc;
       
   621     }    
       
   622 
       
   623 // ---------------------------------------------------------------------------
       
   624 // CommitGc
       
   625 // ---------------------------------------------------------------------------
       
   626 //
       
   627 void CAlfWindow::CommitGc()
       
   628     {
       
   629     delete iData->iBufferGc;
       
   630     iData->iBufferGc = 0;
       
   631     delete iData->iBufferDev;
       
   632     iData->iBufferDev = 0;
       
   633     if(!iData->iOutBuffer) // Todo: Should we update textures even if window not active?
       
   634         {
       
   635         iData->iWindowManager->ContentReady(*this, iData->iInBuffer);
       
   636         }
       
   637     }
       
   638 
       
   639 // ---------------------------------------------------------------------------
       
   640 // IsInsertedToScene
       
   641 // ---------------------------------------------------------------------------
       
   642 //
       
   643 TBool CAlfWindow::IsInsertedToScene()
       
   644     {
       
   645     __ASSERT_ALWAYS( iData, USER_INVARIANT() );
       
   646     return iData->iIsInScene;
       
   647     }
       
   648 
       
   649 
       
   650 // ---------------------------------------------------------------------------
       
   651 // InsertedToScene
       
   652 // ---------------------------------------------------------------------------
       
   653 //
       
   654 void CAlfWindow::InsertedToScene(TBool aInserted)
       
   655     {
       
   656     __ASSERT_ALWAYS( iData, USER_INVARIANT() );
       
   657     iData->iIsInScene = aInserted;
       
   658     }
       
   659 
       
   660 // ---------------------------------------------------------------------------
       
   661 // 
       
   662 // ---------------------------------------------------------------------------
       
   663 //
       
   664 TBool CAlfWindow::ShouldBeDeactivated()
       
   665     {
       
   666     __ASSERT_ALWAYS( iData, USER_INVARIANT() );
       
   667     return iData->iFlags & TAlfWindowData::EShouldInactivate;
       
   668     }
       
   669 
       
   670 // ---------------------------------------------------------------------------
       
   671 // PostBuffer
       
   672 // ---------------------------------------------------------------------------
       
   673 //
       
   674 void CAlfWindow::PostPartialBuffer( TAny* aPtr, TInt aSize, TBool aPartial, TBool aLastPart, TBool aEmptyBuffers, TInt aNodeFlags )
       
   675     {
       
   676     TAlfWServInfo wservInfo = WsInfo();
       
   677     TInt offset;
       
   678     TAlfWindowCommandBufferAttributes* windowCommandBuffer = CreateWindowCommandBufferAttributes(offset);
       
   679     if (windowCommandBuffer)
       
   680         {
       
   681         windowCommandBuffer->iBufferLength = aSize;
       
   682         windowCommandBuffer->iBuffer = aPtr;
       
   683         windowCommandBuffer->iEmptyThisBuffer = aEmptyBuffers;
       
   684         windowCommandBuffer->iWindowNodeFlags = aNodeFlags;
       
   685         windowCommandBuffer->iScreenNumber = wservInfo.iScreenNumber;
       
   686         if ( aLastPart && aPartial )
       
   687         	{
       
   688         	windowCommandBuffer->iPartStatus = TAlfWindowCommandBufferAttributes::ELastPart;
       
   689         	}
       
   690         else if ( aPartial )
       
   691         	{
       
   692         	windowCommandBuffer->iPartStatus = TAlfWindowCommandBufferAttributes::ENotComplete;
       
   693         	}
       
   694         else if (!aPartial)
       
   695         	{
       
   696         	windowCommandBuffer->iPartStatus = TAlfWindowCommandBufferAttributes::EPartComplete;
       
   697         	}
       
   698         
       
   699         TAlfBridgerData d;
       
   700         d.Set(EAlfDSPostCanvasBuffer, 
       
   701         		wservInfo.iRefId.iWindowGroupId, 
       
   702         		wservInfo.iRefId.iWindowIdentifer, 
       
   703         		(TAny*)offset ); 
       
   704 
       
   705         if (iData->iWindowManager->PostIt(d))
       
   706             {
       
   707             // ???
       
   708             }
       
   709         }
       
   710     
       
   711     }
       
   712 
       
   713 // ---------------------------------------------------------------------------
       
   714 // PostBuffer
       
   715 // ---------------------------------------------------------------------------
       
   716 //
       
   717 void CAlfWindow::PostBuffer( TAny* aPtr, TInt aSize, TInt aNodeFlags )
       
   718     {
       
   719     TAlfWServInfo wservInfo = WsInfo();
       
   720     TInt offset;
       
   721     TAlfWindowCommandBufferAttributes* windowCommandBuffer = CreateWindowCommandBufferAttributes(offset);
       
   722            
       
   723     if (windowCommandBuffer)
       
   724         {
       
   725         windowCommandBuffer->iBufferLength = aSize;
       
   726         windowCommandBuffer->iBuffer = aPtr;
       
   727         windowCommandBuffer->iEmptyThisBuffer = ETrue;
       
   728         windowCommandBuffer->iPartStatus = TAlfWindowCommandBufferAttributes::EPartComplete;
       
   729         windowCommandBuffer->iWindowNodeFlags = aNodeFlags;
       
   730         
       
   731 
       
   732         TAlfBridgerData d;
       
   733         d.Set(EAlfDSPostCanvasBuffer, 
       
   734             wservInfo.iRefId.iWindowGroupId, 
       
   735             wservInfo.iRefId.iWindowIdentifer, 
       
   736             (TAny*)offset); 
       
   737 
       
   738         if (iData->iWindowManager->PostIt(d))
       
   739             {
       
   740             // ???
       
   741             }
       
   742         }
       
   743     }
       
   744 
       
   745 // ---------------------------------------------------------------------------
       
   746 // SetNodeTracking
       
   747 // ---------------------------------------------------------------------------
       
   748 //
       
   749 void CAlfWindow::SetNodeTracking( TInt aValue )
       
   750     {
       
   751     TAlfBridgerData d;
       
   752     TAlfWServInfo wservInfo = WsInfo();
       
   753       
       
   754     d.Set(EAlfDSSetNodeTracking, 
       
   755         wservInfo.iRefId.iWindowIdentifer,
       
   756         aValue,
       
   757         NULL);
       
   758     iData->iWindowManager->PostIt(d);
       
   759     }
       
   760 
       
   761 // ---------------------------------------------------------------------------
       
   762 // 
       
   763 // ---------------------------------------------------------------------------
       
   764 //
       
   765 TAlfWindowAttributes* CAlfWindow::CreateWindowAttributes(TInt& aIndex)
       
   766     {
       
   767     TAlfWindowAttributes empty;
       
   768     TAlfWindowAttributes* attributes = NULL;
       
   769     TRAP_IGNORE(attributes = (TAlfWindowAttributes*)iData->iWindowManager->Bridge()->AppendVarDataL( sizeof(TAlfWindowAttributes), aIndex ))
       
   770     if ( attributes )
       
   771         {
       
   772         *attributes = empty;
       
   773         }
       
   774     return attributes;
       
   775     }
       
   776 
       
   777 // ---------------------------------------------------------------------------
       
   778 // 
       
   779 // ---------------------------------------------------------------------------
       
   780 //
       
   781 TAlfWindowCommandBufferAttributes* CAlfWindow::CreateWindowCommandBufferAttributes(TInt& aIndex)
       
   782     {
       
   783     TAlfWindowCommandBufferAttributes empty;    
       
   784     TAlfWindowCommandBufferAttributes* windowCommandBuffer = NULL;    
       
   785     TRAP_IGNORE(windowCommandBuffer = (TAlfWindowCommandBufferAttributes*)iData->iWindowManager->Bridge()->AppendVarDataL( sizeof(TAlfWindowCommandBufferAttributes), aIndex ))    
       
   786     if ( windowCommandBuffer )
       
   787         {
       
   788         *windowCommandBuffer = empty;
       
   789         }
       
   790     return windowCommandBuffer;
       
   791     }