os/graphics/graphicscomposition/openwfc_ri_displayupdater/src/openwfc_ri_displayupdater.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 //
     3 // Permission is hereby granted, free of charge, to any person obtaining a
     4 // copy of this software and/or associated documentation files (the
     5 // "Materials"), to deal in the Materials without restriction, including
     6 // without limitation the rights to use, copy, modify, merge, publish,
     7 // distribute, sublicense, and/or sell copies of the Materials, and to
     8 // permit persons to whom the Materials are furnished to do so, subject to
     9 // the following conditions:
    10 //
    11 // The above copyright notice and this permission notice shall be included
    12 // in all copies or substantial portions of the Materials.
    13 //
    14 // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    17 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    18 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    19 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    20 // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
    21 // 
    22 // Description:
    23 // Display Adaptation Interface Implementation for Display Updater
    24 // 
    25 //
    26 
    27 #include "openwfc_ri_displayupdater.h"
    28 #include <e32debug.h>
    29 #include <hal.h>
    30 
    31 #if defined(ENABLE_LOGGING)
    32 #define LOG(X)  RDebug::Printf X
    33 #else
    34 #define LOG(X)
    35 #endif
    36 
    37 // #define LOG_DISPLAY_PROPERTIES
    38 
    39 const TUint32 KDefaultScreenNumber = 0;
    40 
    41 #ifdef _DEBUG
    42 void Panic(TInt aPanic)
    43     {
    44     _LIT(KPanic, "DA-DU");
    45     User::Panic(KPanic, aPanic);
    46     }
    47 #endif
    48 
    49 EXPORT_C COpenWFC_RI_Display* COpenWFC_RI_Display::NewL(TUint aScreen)
    50     {
    51     return COpenWFC_RI_DisplayUpdater::NewL(aScreen);
    52     }
    53 
    54 EXPORT_C TUint32 COpenWFC_RI_Display::DefaultScreenNumber()
    55     {
    56     return KDefaultScreenNumber;
    57     }
    58     
    59 COpenWFC_RI_DisplayUpdater::COpenWFC_RI_DisplayUpdater(TUint aScreen):
    60 iScreenNumber(aScreen),
    61 iDisplayUpdater(NULL),
    62 iCurrentSceneStream(SYMBIAN_INVALID_HANDLE),
    63 iCurrentReadBuffer(SYMBIAN_INVALID_HANDLE),
    64 iNextSceneStream(SYMBIAN_INVALID_HANDLE),
    65 iNextReadBuffer(SYMBIAN_INVALID_HANDLE)
    66     {
    67     }
    68 
    69 COpenWFC_RI_DisplayUpdater* COpenWFC_RI_DisplayUpdater::NewL(TUint aScreen)
    70     {
    71     LOG((" +++ COpenWFC_RI_DisplayUpdater::NewL(%d)", aScreen));
    72     COpenWFC_RI_DisplayUpdater* screenContext = new(ELeave) COpenWFC_RI_DisplayUpdater(aScreen);
    73     CleanupStack::PushL(screenContext);
    74     screenContext->ConstructL();
    75     CleanupStack::Pop(screenContext);
    76     LOG((" --- COpenWFC_RI_DisplayUpdater::NewL(%d) : 0x%X", aScreen, screenContext));
    77     return screenContext;
    78     }
    79 
    80 COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater()
    81     {
    82     LOG((" +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater(%d)", iScreenNumber));
    83     if (iDisplayUpdater)
    84         {
    85         TDisplayViewSettings viewSettings;  // DEFAULT
    86         TBufferInfo bufferInfo; // DEFAULT
    87         TInt err = KErrNone;
    88 
    89         // Set to default view to release layer
    90         err = iDisplayUpdater->SetView(KTopMostLayer, viewSettings, bufferInfo);
    91         if (err != KErrNone)
    92             {
    93             LOG((" !!! COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater()ERROR: Display update set view failed %d", err));
    94             }
    95 
    96         TRequestStatus completedWhenReady = KRequestPending;
    97         LOG(("\n  +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() FLUSHING *******\n"));
    98         iDisplayUpdater->Flush(completedWhenReady);
    99         LOG(("\n  +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() AFTER FLUSHING ******* 2\n"));
   100         User::WaitForRequest(completedWhenReady);
   101         LOG(("\n  +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() FLUSHING:REQUEST COMPLETED %d*******\n", completedWhenReady.Int()));
   102 
   103         if (iCurrentSceneStream != SYMBIAN_INVALID_HANDLE && iCurrentReadBuffer != SYMBIAN_INVALID_HANDLE)
   104             {
   105             SymbianStreamReleaseReadBuffer(iCurrentSceneStream, iCurrentReadBuffer);
   106             }
   107         if (iNextSceneStream != SYMBIAN_INVALID_HANDLE && iNextReadBuffer != SYMBIAN_INVALID_HANDLE)
   108             {
   109             SymbianStreamReleaseReadBuffer(iNextSceneStream, iNextReadBuffer);
   110             }
   111         }
   112     delete iDisplayUpdater;
   113     iSurfaceManager.Close();
   114     LOG((" --- COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() completed"));    
   115     }
   116 
   117 void COpenWFC_RI_DisplayUpdater::ConstructL()
   118     {
   119     LOG((" +++ COpenWFC_RI_DisplayUpdater::ConstructL"));
   120     User::LeaveIfError(iSurfaceManager.Open());
   121     iDisplayUpdater = CDisplayUpdater::NewL(iScreenNumber);
   122     iScreenInfo.iDefaultRotation = EScreenRotate0;
   123     iDefaultRotation = ERotate0Deg;
   124     iCurrentRotation = ERotate0Deg;
   125     iRotationOffset = 0;
   126     iScreenInfo.iCurrentRotation = EScreenRotate0;
   127     iNewRotation = iScreenInfo.iCurrentRotation;
   128     
   129     TDisplayDrvInfo displayInfo;
   130     iDisplayUpdater->GetDisplayProperties(displayInfo);
   131 
   132 #if defined(LOG_DISPLAY_PROPERTIES)
   133     LOG((" ??? Display resolution (%d,%d)", displayInfo.iPanelResolution.iWidth, displayInfo.iPanelResolution.iHeight));
   134     LOG((" ??? Display twips (%d,%d)", displayInfo.iPanelTwips.iWidth, displayInfo.iPanelTwips.iHeight));
   135     LOG((" ??? Display refresh rate %dHz", displayInfo.iPanelRefreshRateHz));
   136     LOG((" ??? Display %d internal composition buffers", (TInt)displayInfo.iNumberOfBuffers));
   137     LOG((" ??? Display pixel formats: 0x%08.8X", (TInt)displayInfo.iSupportedFormats));
   138     LOG((" ??? Display pixel aspect ratio %d/%d", (TInt)displayInfo.iPixelAspectRNumerator, (TInt)displayInfo.iPixelAspectRDenominator));
   139     LOG((" ??? Display supported per-layer rotations: 0x%08.8X", (TInt)displayInfo.iSupportedPerLayerRotations));
   140     LOG((" ??? Display rotation works with: 0x%08.8X", (TInt)displayInfo.iRotationWorksWithTheseFeatures));
   141     LOG((" ??? Display scaling works with: 0x%08.8X", (TInt)displayInfo.iScalingWorksWithTheseFeatures));
   142     LOG((" ??? Display minimum scaling: 100/%d", (TInt)displayInfo.iScalingMinDenominator));
   143     LOG((" ??? Display maximum scaling: %d/100", (TInt)displayInfo.iScalingMaxNumerator));
   144     LOG((" ??? Display maximum overlays: %d", (TInt)displayInfo.iNumberOfOverlays));
   145     LOG((" ??? Display colour space: 0x%08.8X", (TInt)displayInfo.iDestinationColorSpace));
   146     LOG((" ??? Display colour coords: (%d,%d)R (%d,%d)G (%d,%d)B (%d,%d)W",
   147             displayInfo.iDestinationColorCoordinates.iRed.iX, displayInfo.iDestinationColorCoordinates.iRed.iY,
   148             displayInfo.iDestinationColorCoordinates.iGreen.iX, displayInfo.iDestinationColorCoordinates.iGreen.iY,
   149             displayInfo.iDestinationColorCoordinates.iBlue.iX, displayInfo.iDestinationColorCoordinates.iBlue.iY,
   150             displayInfo.iDestinationColorCoordinates.iWhite.iX, displayInfo.iDestinationColorCoordinates.iWhite.iY));
   151     LOG((" ??? Display direct buffer display: %d", (TInt)displayInfo.iGivenBufferWorksAsFrameBuffer));
   152     LOG((" ??? Display variable resolution: %d", (TInt)displayInfo.iVariableResolution));
   153     LOG((" ??? Display draw overscan: %d", (TInt)displayInfo.iOverscanToBeDrawn));
   154     LOG((" ??? Display is on: %d", (TInt)displayInfo.iDisplayOn));
   155 #endif
   156 
   157     TInt supportedFormats = displayInfo.iSupportedFormats;
   158     /* Note that in theory other formats could be supported for composition 
   159      * (eg  EPixelFormatARgb8888Le | EPixelFormatARgb8888LeP )
   160      * So long as the background colour is opaque then the final compiosed image should end up opaque,
   161      * so compatible with alpha modes.
   162      * However, it would give problems for fastpathing, where alpha byte should be ignored,
   163      * probably fastpath would need to be disabled.
   164      * At present we only care about PlatSim, 
   165      * and it is unlikely that any platform will NOT support xrgb32,
   166      * so it is better to assert the capabilities match than think about this hypothetical case too hard.  
   167      */
   168     if (supportedFormats & (EPixelFormatXRgb8888Le ))
   169         {
   170         iScreenInfo.iPixelFormat = EUidPixelFormatXRGB_8888;
   171         iScreenInfo.iBytesPerPixel = 4;
   172         }
   173     else
   174         {
   175         LOG((" !!! COpenWFC_RI_DisplayUpdater::ConstructL() unsupported pixel formats 0x%08.8x", supportedFormats));
   176         User::Leave(KErrNotSupported);
   177         }
   178 
   179     iScreenInfo.iPixelFormat = EUidPixelFormatXRGB_8888;
   180     if (displayInfo.iRotationWorksWithTheseFeatures & EFeatureExternalBuf)
   181         {
   182         iScreenInfo.iSupportedRotations = displayInfo.iSupportedPerLayerRotations & 0x0f;
   183         }
   184     else
   185         {
   186         LOG((" +++ COpenWFC_RI_DisplayUpdater::ConstructL() fixed output rotation"));
   187         iScreenInfo.iSupportedRotations = (TInt32)ERotate0Deg;
   188         }
   189     
   190     iScreenInfo.iNormalWidth = displayInfo.iPanelResolution.iWidth;
   191     iScreenInfo.iNormalHeight = displayInfo.iPanelResolution.iHeight;
   192     iScreenInfo.iFlippedWidth = iScreenInfo.iNormalHeight;
   193     iScreenInfo.iFlippedHeight = iScreenInfo.iNormalWidth;
   194         
   195     iScreenInfo.iNormalStride = iScreenInfo.iBytesPerPixel * iScreenInfo.iNormalWidth;
   196     iScreenInfo.iFlippedStride = iScreenInfo.iBytesPerPixel * iScreenInfo.iFlippedWidth;
   197     LOG((" --- COpenWFC_RI_DisplayUpdater::ConstructL"));
   198     }
   199 
   200 TInt COpenWFC_RI_Display::GetAttributeSize(TUint aAttributeId)
   201     {
   202     LOG((" +++ COpenWFC_RI_DisplayUpdater::GetAttributeSize(%d)", aAttributeId));
   203     switch (aAttributeId)
   204         {
   205         case EScreenAttributeImplementationVersion:
   206         case EScreenAttributePixelFormat:
   207         case EScreenAttributeBytesPerPixel:
   208         case EScreenAttributeSupportedRotation:
   209         case EScreenAttributeNormalWidth:
   210         case EScreenAttributeNormalHeight:
   211         case EScreenAttributeNormalStride:
   212         case EScreenAttributeFlippedWidth:
   213         case EScreenAttributeFlippedHeight:
   214         case EScreenAttributeFlippedStride:
   215         case EScreenAttributeDefaultRotation:
   216         case EScreenAttributeCurrentRotation:
   217             LOG((" --- COpenWFC_RI_DisplayUpdater::GetAttributeSize(%d) = 4", aAttributeId));
   218             return sizeof(TUint32);
   219          
   220         case EScreenAttributeScreenGeometry:
   221             LOG((" --- COpenWFC_RI_DisplayUpdater::GetAttributeSize(%d) = %d", aAttributeId, sizeof(TScreenGeometryAttribute)));
   222             return sizeof(TScreenGeometryAttribute);
   223             
   224         default:
   225             LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttributeSize(%d) UNKNOWN", aAttributeId));
   226             return 0;
   227         }
   228     }
   229 
   230 TInt COpenWFC_RI_DisplayUpdater::GetAttribute(TInt aAttributeId, TAny* aAttribute, TInt aAttributeSize)
   231     {
   232     LOG((" +++ COpenWFC_RI_DisplayUpdater::GetAttribute(%d, 0x%X, %d)", aAttributeId, aAttribute, aAttributeSize));
   233     TInt parameterSize = GetAttributeSize(aAttributeId);
   234 
   235     if (aAttribute == NULL)
   236         {
   237         LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttribute() aAttribute NULL ptr"));
   238         return KErrArgument;
   239         }
   240     
   241     if (parameterSize == 0)
   242         {
   243         LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttribute() Not Supported parameter aAttributeId"));
   244         return KErrNotSupported;
   245         }
   246     
   247     if (aAttributeSize != parameterSize)
   248         {
   249         LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttribute() aAttributeSize wrong size"));
   250         return KErrArgument;
   251         }
   252     
   253     switch (aAttributeId)
   254         {
   255         case EScreenAttributeImplementationVersion:
   256             *((TUint32*)aAttribute) = KImplementationVersion;
   257             break;
   258         case EScreenAttributePixelFormat:
   259             *((TUint32*)aAttribute) = iScreenInfo.iPixelFormat;
   260             break;
   261         case EScreenAttributeBytesPerPixel:
   262             *((TUint32*)aAttribute) = iScreenInfo.iBytesPerPixel;
   263             break;
   264         case EScreenAttributeSupportedRotation:
   265             *((TUint32*)aAttribute) = iScreenInfo.iSupportedRotations;
   266             break;
   267         case EScreenAttributeNormalWidth:
   268             *((TUint32*)aAttribute) = iScreenInfo.iNormalWidth;
   269             break;
   270         case EScreenAttributeNormalHeight:
   271             *((TUint32*)aAttribute) = iScreenInfo.iNormalHeight;
   272             break;
   273         case EScreenAttributeNormalStride:
   274             *((TUint32*)aAttribute) = iScreenInfo.iNormalStride;
   275             break;
   276         case EScreenAttributeFlippedWidth:
   277             *((TUint32*)aAttribute) = iScreenInfo.iFlippedWidth;
   278             break;
   279         case EScreenAttributeFlippedHeight:
   280             *((TUint32*)aAttribute) = iScreenInfo.iFlippedHeight;
   281             break;
   282         case EScreenAttributeFlippedStride:
   283             *((TUint32*)aAttribute) = iScreenInfo.iFlippedStride;
   284             break;
   285         case EScreenAttributeDefaultRotation:
   286             *((TUint32*)aAttribute) = iScreenInfo.iDefaultRotation;
   287             break;
   288         case EScreenAttributeCurrentRotation:
   289             *((TUint32*)aAttribute) = iScreenInfo.iCurrentRotation;
   290             break;
   291         case EScreenAttributeScreenGeometry:
   292             *((TScreenGeometryAttribute*)aAttribute) = iScreenInfo;
   293             break;
   294         default:
   295             LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttribute() attribute unrecognised"));
   296             return KErrNotSupported;
   297         }
   298     
   299     LOG((" --- COpenWFC_RI_DisplayUpdater::GetAttribute() = %d", *((TUint32*)aAttribute)));
   300     return KErrNone;
   301     }
   302 
   303 
   304 TInt COpenWFC_RI_DisplayUpdater::SetAttribute(TInt aAttributeId, TAny* aAttribute, TInt aAttributeSize)
   305     {
   306     LOG((" +++ COpenWFC_RI_DisplayUpdater::SetAttribute(%d, 0x%X, %d)", aAttributeId, aAttribute, aAttributeSize));
   307     // the only parameter we can modify is the current rotation
   308     TInt parameterSize = GetAttributeSize(aAttributeId);
   309 
   310     if (aAttributeSize != parameterSize || aAttribute == NULL)
   311         {
   312         LOG((" !!! COpenWFC_RI_DisplayUpdater::SetAttribute() Invalid parameter"));
   313         return KErrArgument;
   314         }
   315     
   316     switch (aAttributeId)
   317         {
   318         case EScreenAttributeCurrentRotation:
   319             iNewRotation = static_cast<TScreenRotation>(*((TUint32*)aAttribute));
   320             LOG((" +++ COpenWFC_RI_DisplayUpdater::SetAttribute(CurrentRotation, %d)", (TInt)iNewRotation));
   321             break;
   322         default:
   323             LOG((" !!! COpenWFC_RI_DisplayUpdater::SetAttribute() Invalid attribute"));
   324             return KErrNotSupported;
   325         }
   326     LOG((" --- COpenWFC_RI_DisplayUpdater::SetAttribute()"));
   327     return KErrNone;
   328     }
   329 
   330 
   331 TInt COpenWFC_RI_DisplayUpdater::CommitAttribute()
   332     {
   333     LOG((" +++ COpenWFC_RI_DisplayUpdater::CommitAttribute"));
   334     // Hardware rotation is not demonstrated on PlatSim
   335     __ASSERT_DEBUG(iScreenInfo.iCurrentRotation == iNewRotation, Panic(__LINE__));
   336     return KErrNone;
   337     }
   338 
   339 TInt COpenWFC_RI_DisplayUpdater::SetLayerSurface(TInt aLayer, SymbianStreamType aStream, TInt* aNonTrivialAttribs)
   340     {
   341     // display channel interface can be seen as mono-layered
   342     if (aLayer != 0)
   343         {
   344         LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : non-zero layer not supported"));
   345         return KErrArgument;
   346         }
   347     
   348     if (aNonTrivialAttribs && *aNonTrivialAttribs)
   349         { 
   350         LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Non-trivial attributes not accepted."));
   351         return KErrNotSupported;
   352         }
   353     
   354     if (aStream!=iNextSceneStream)
   355         {   //If, in future non-trivial attributes are supported then this condition is inadequate
   356          SymbianStreamBuffer nextReadBuffer=NULL;
   357         //Scene stream has changed - re-validate and set up for new info
   358         TInt err=SymbianStreamAcquireReadBuffer(aStream,&nextReadBuffer);
   359         if (err<KErrNone)
   360             {
   361             LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Falied to access stream properties"));
   362             return err;
   363             }
   364         const TSurfaceId* surfaceId;
   365         khronos_int32_t index;
   366         err= SymbianStreamGetBufferId(aStream,nextReadBuffer,&index,&surfaceId);
   367         if (err<KErrNone)
   368             {
   369             LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Falied to access stream properties"));
   370             SymbianStreamReleaseReadBuffer(aStream, nextReadBuffer);
   371             return err;
   372             }
   373         RSurfaceManager::TInfoBuf surfaceInfo;
   374         iSurfaceManager.SurfaceInfo(*surfaceId,surfaceInfo);
   375         TBool acceptable=ETrue;
   376         if (!surfaceInfo().iContiguous)
   377             {
   378             acceptable=EFalse;
   379             LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream 0x%08x iContiguous not accepted ",aStream));
   380             }
   381         khronos_int32_t format=surfaceInfo().iPixelFormat;
   382         if (format!=EUidPixelFormatARGB_8888 && format!=EUidPixelFormatARGB_8888_PRE && format!=EUidPixelFormatXRGB_8888)
   383             {
   384             acceptable=EFalse;
   385             LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream 0x%08x iPixelFormat 0x%08x not accepted ",aStream,surfaceInfo().iPixelFormat));
   386             }
   387                 
   388         if (!acceptable)
   389             {
   390             LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream 0x%08x properties not accepted ",aStream));
   391             SymbianStreamReleaseReadBuffer(aStream, nextReadBuffer);
   392             return KErrNotSupported;
   393             }
   394         
   395         //Note that if we early-return before this point the previous top stream should still be locked for use.
   396         
   397         LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream changed 0x%08x --> 0x%08x ",iNextSceneStream,aStream));
   398         if (iNextSceneStream != SYMBIAN_INVALID_HANDLE && iNextReadBuffer != SYMBIAN_INVALID_HANDLE)
   399              {
   400              LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : double-call to SetLayerSurface. First discarded."));
   401              SymbianStreamReleaseReadBuffer(iNextSceneStream, iNextReadBuffer);
   402              }
   403         iNextReadBuffer=nextReadBuffer;
   404         iNextSceneStream=aStream;
   405         }
   406     else
   407         {
   408         LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream still 0x%08x",aStream));
   409         }
   410     return KErrNone;
   411     }
   412 
   413 TInt COpenWFC_RI_DisplayUpdater::SetTopLayerSurface(SymbianStreamType aStream, TInt* aNonTrivialAttribs)
   414     {
   415     return SetLayerSurface(KTopMostLayer, aStream, aNonTrivialAttribs);
   416     }
   417 
   418 TInt COpenWFC_RI_DisplayUpdater::UpdateDisplay()
   419     {
   420     TInt err = KErrNone;
   421 
   422     SymbianStreamBuffer readBuffer = iNextReadBuffer;
   423     iNextReadBuffer = SYMBIAN_INVALID_HANDLE;
   424     if (!iNextSceneStream)
   425         {
   426         LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay() ASSERT: No top layer has been set!"));
   427         return KErrNotReady;
   428         }
   429     if (readBuffer == SYMBIAN_INVALID_HANDLE)
   430         {
   431         if ((err = SymbianStreamAcquireReadBuffer(iNextSceneStream, &readBuffer)) != KErrNone)
   432             {   //AcquireReadBuffer "Can't fail" in theory, but just incase....
   433             LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay() Acquire failed: %d", err));
   434             return err;
   435             }
   436         }
   437     TBufferInfo bufferInfo;
   438     khronos_int32_t width, height, stride;
   439     SymbianStreamGetHeader(iNextSceneStream, &width, &height, &stride, NULL, NULL);
   440     bufferInfo.iBufferWidth = (TInt16)width;
   441     bufferInfo.iBufferHeight = (TInt16)height;
   442     bufferInfo.iStride = (TInt16)stride;
   443     bufferInfo.iBufferFormat = EPixelFormatXRgb8888Le;
   444     bufferInfo.iLinearAddress = 0;
   445     err = SymbianStreamGetBufferPointer(iNextSceneStream, readBuffer,&bufferInfo.iLinearAddress);
   446     if (err == KErrNone)
   447         {
   448         err = SymbianStreamGetChunkHandle(iNextSceneStream, &bufferInfo.iBufferRChunkHandle);
   449         }
   450 
   451     if (err != KErrNone)
   452         {
   453         LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay() error %d getting stream data", err));
   454         SymbianStreamReleaseReadBuffer(iNextSceneStream, readBuffer);
   455         return err;
   456         }
   457 
   458     TRect displayRect;
   459     displayRect.SetRect(TPoint(0, 0), TSize(bufferInfo.iBufferWidth, bufferInfo.iBufferHeight ));
   460     
   461     TDisplayViewSettings viewSettings; // Default
   462     viewSettings.iSourceScissor         = displayRect;
   463     viewSettings.iDestinationScaledRect = displayRect;
   464     viewSettings.iLayerRotation         = ERotate0Deg;
   465     viewSettings.iUsageHint             = EPurposeUi;
   466     viewSettings.iTearingFree           = ETrue;
   467       
   468     LOG((" $$$*** bufferInfo.iBufferWidth %d", bufferInfo.iBufferWidth));
   469     LOG((" $$$*** bufferInfo.iBufferHeight %d", bufferInfo.iBufferHeight));
   470     LOG((" $$$*** bufferInfo.iStride %d", bufferInfo.iStride));
   471     LOG((" $$$*** bufferInfo.iBufferFormat %d", bufferInfo.iBufferFormat));
   472     LOG((" $$$*** bufferInfo.iLinearAddress %08x", bufferInfo.iLinearAddress));
   473     LOG((" $$$*** bufferInfo.iBufferRChunkHandle %d", bufferInfo.iBufferRChunkHandle));
   474 
   475     LOG((" $$$*** viewSettings iSourceScissor width %d", viewSettings.iSourceScissor.Width()));
   476     LOG((" $$$*** viewSettings iSourceScissor height %d", viewSettings.iSourceScissor.Height()));
   477     LOG((" $$$*** viewSettings iDestinationScaledRect width %d", viewSettings.iDestinationScaledRect.Width()));
   478     LOG((" $$$*** viewSettings iDestinationScaledRect height %d", viewSettings.iDestinationScaledRect.Height()));
   479     LOG((" $$$*** viewSettings iLayerRotation %d", viewSettings.iLayerRotation));
   480     LOG((" $$$*** viewSettings iUsageHint %d", viewSettings.iUsageHint));
   481     LOG((" $$$*** viewSettings iTearingFree %d", viewSettings.iTearingFree));
   482 
   483     TRequestStatus completedWhenReady = KRequestPending;
   484     viewSettings.iLayerRotation = iCurrentRotation;
   485 
   486     err = iDisplayUpdater->SetView(KTopMostLayer, viewSettings, bufferInfo);
   487     
   488     if (err != KErrNone)
   489         {
   490         LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay()ERROR: Display update set view failed %d", err));
   491         }
   492     else
   493         {
   494         err = iDisplayUpdater->SetBuffer(KTopMostLayer, displayRect, bufferInfo );
   495         if (err != KErrNone)
   496             {
   497             LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay()ERROR: Display Update set buffer failed %d", err));
   498             }
   499         }
   500 
   501     ////////////////////////////////////////////////////////////////////////////////////////////
   502     iDisplayUpdater->Flush(completedWhenReady);
   503     
   504     /* The TRequestStatus& aCompletedWhenReady parameter is signalled 
   505      * either when the buffer has been copied, 
   506      * or it is streaming the first pixel to the display
   507      * In either case this indicates that the previous buffer is no longer required.
   508      * By waiting here we guarantee that the previous iCurrentReadBuffer is no longer required,
   509      * but here are more intelligent ways to wait, I am sure!
   510      */
   511     User::WaitForRequest(completedWhenReady);
   512     if (iCurrentReadBuffer != SYMBIAN_INVALID_HANDLE)
   513         {
   514         // Release the previous update's read buffer.
   515         /* This ensures that a lock is held on the displayed buffer until the next commit/compose
   516          * This is correct behaviour for streaming direct to the display, but is actually not
   517          * necessary if the display makes its own copy.
   518          * However, PlatSim currently supports only the latter, and we think the former is important,
   519          * so this implementation allows us to validate that the behaviour is correct in direct streaming.
   520          */
   521         SymbianStreamReleaseReadBuffer(iCurrentSceneStream, iCurrentReadBuffer);
   522         }
   523     iCurrentReadBuffer = readBuffer;
   524     iCurrentSceneStream = iNextSceneStream;
   525     return err;
   526     }
   527