windowing/windowserver/nga/SERVER/openwfc/screen.cpp
changeset 110 7f25ef56562d
parent 69 3365349494cc
equal deleted inserted replaced
98:bf7481649c98 110:7f25ef56562d
  1121 			iDsaSurface = newSurface;
  1121 			iDsaSurface = newSurface;
  1122 			}
  1122 			}
  1123 		
  1123 		
  1124 		//updaterotation should not fail after this point (no cleanup)
  1124 		//updaterotation should not fail after this point (no cleanup)
  1125 			
  1125 			
       
  1126         //update the last set config with the new rotation change so we don't incorrectly
       
  1127         //change the layer extents
       
  1128         if (iDisplayControl)
       
  1129             {
       
  1130             TDisplayConfiguration config;
       
  1131             config.SetRotation(static_cast<TDisplayConfiguration::TRotation>(newRotation));           
       
  1132             iConfigChangeNotifier->UpdateLastSetConfiguration(config);
       
  1133             }		
       
  1134 		
  1126 		TWservCrEvent crEvent(TWservCrEvent::EDeviceOrientationChanged,iScreenNumber,&gcOrientation);
  1135 		TWservCrEvent crEvent(TWservCrEvent::EDeviceOrientationChanged,iScreenNumber,&gcOrientation);
  1127 		TWindowServerEvent::NotifyDrawer(crEvent);
  1136 		TWindowServerEvent::NotifyDrawer(crEvent);
  1128 		
  1137 		
  1129 		if(iDsaDevice && iDsaDevice->GraphicsAccelerator())
  1138 		if(iDsaDevice && iDsaDevice->GraphicsAccelerator())
  1130 			{
  1139 			{
  1982 			}	
  1991 			}	
  1983 		if (reply==KErrNone)
  1992 		if (reply==KErrNone)
  1984 			{
  1993 			{
  1985 			TSize oldConfigRes;
  1994 			TSize oldConfigRes;
  1986 			oldConfig.GetResolution(oldConfigRes);
  1995 			oldConfig.GetResolution(oldConfigRes);
       
  1996             TDisplayConfiguration newConfig;
  1987 			if (oldConfigRes.iWidth == 0 || oldConfigRes.iHeight == 0)
  1997 			if (oldConfigRes.iWidth == 0 || oldConfigRes.iHeight == 0)
  1988 				{
  1998 				{
  1989 				TDisplayConfiguration newConfig;
       
  1990 				iDisplayControl->GetConfiguration(newConfig);
  1999 				iDisplayControl->GetConfiguration(newConfig);
  1991 				RecalculateModeTwips(&newConfig);	//needs res and twips information
  2000 				RecalculateModeTwips(&newConfig);	//needs res and twips information
  1992 				}
  2001 				}
  1993 			UpdateDynamicScreenModes();
  2002 			UpdateDynamicScreenModes();
       
  2003 			
       
  2004 			//update the last set config in the config change notifier to 
       
  2005 			//prevent SetConfiguration() from being called again!
       
  2006 			newConfig.ClearAll();
       
  2007 			iDisplayControl->GetConfiguration(newConfig);
       
  2008 			iConfigChangeNotifier->UpdateLastSetConfiguration(newConfig); 			
  1994 			
  2009 			
  1995 			TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode));
  2010 			TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode));
  1996 			// This will remove all the DSA elements from the scene
  2011 			// This will remove all the DSA elements from the scene
  1997 			AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation);
  2012 			AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation);
  1998 			
  2013 			
  2034 		reply = KErrNotSupported;
  2049 		reply = KErrNotSupported;
  2035 		}
  2050 		}
  2036 	return reply;
  2051 	return reply;
  2037 	}
  2052 	}
  2038 
  2053 
       
  2054 /**
       
  2055  * Updates the screen device display properties. This is to ensure the screen device is 
       
  2056  * consistent with any configuration changes not made using CScreen::SetConfiguration.
       
  2057  * 
       
  2058  * @param aConfigInput a fully populated display configuration
       
  2059  **/
       
  2060 TInt CScreen::UpdateConfiguration(const TDisplayConfiguration& aConfigInput)
       
  2061     {
       
  2062     TInt reply = KErrNone;
       
  2063     if(iDisplayControl)
       
  2064         {
       
  2065         TDisplayConfiguration config(aConfigInput);
       
  2066         TRect sizeModePosition;
       
  2067         if (iDisplayPolicy)
       
  2068             {   //validate config and update to a valid hardware config
       
  2069             reply = iDisplayPolicy->GetSizeModeConfiguration(iScreenSizeMode,config,sizeModePosition);
       
  2070             if (reply >= KErrNone)
       
  2071                 {//set appmode in policy
       
  2072                 if (iDisplayMapping)
       
  2073                     {
       
  2074                     iDisplayMapping->SetSizeModeExtent(sizeModePosition,MWsDisplayMapping::KOffsetAll);
       
  2075                     }
       
  2076                 }
       
  2077             }
       
  2078         else
       
  2079             {   //exessive strategy: limit rotation agains curr app mode.
       
  2080                 //really we want the system to accept the rotation change regardless of the app mode.
       
  2081             TDisplayConfiguration::TRotation newRot;
       
  2082             if (aConfigInput.GetRotation(newRot))
       
  2083                 {   //This should cast between rotation enumertaions "properly"
       
  2084                 if (!(iModes[0][iScreenSizeMode]->iAlternativeRotations&(1<<newRot)))
       
  2085                     {
       
  2086                     reply=KErrArgument;
       
  2087                     }
       
  2088                 }
       
  2089             }
       
  2090 
       
  2091         MWsScene::TSceneRotation oldRotation;
       
  2092         oldRotation = iScene->SceneRotation();
       
  2093         TSize newUiSize;
       
  2094         config.GetResolution(newUiSize);
       
  2095         if(iFlags&EHasDynamicSizeModes)
       
  2096             {
       
  2097             reply = iFallbackMap->Resize(newUiSize);
       
  2098             }
       
  2099 
       
  2100         RecalculateModeTwips(&config);   //needs res and twips information
       
  2101         UpdateDynamicScreenModes();        
       
  2102         
       
  2103         TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode));
       
  2104         // This will remove all the DSA elements from the scene
       
  2105         AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation);
       
  2106         
       
  2107         //SetDigitiserAreas needs revisiting if/when we support dynamic resolutions
       
  2108         //on a screen with touch input.
       
  2109         //SetDigitiserAreas(newUiSize);
       
  2110         
       
  2111         //failure here should only be because of DSA orientation change failure, which shouldn't happen, either.
       
  2112         //Or there may be no change to do.
       
  2113         (void)UpdateOrientation(&oldRotation);
       
  2114         
       
  2115         iWindowElementSet->ResubmitAllElementExtents();
       
  2116         if(iDsaDevice && iDsaDevice->GraphicsAccelerator())
       
  2117             {
       
  2118             iDsaDevice->ChangeScreenDevice(iDsaDevice); // orientation has changed, therefore we need to re-initialise the screen device's graphics accelerator
       
  2119             }
       
  2120         
       
  2121         iRootWindow->AdjustCoordsDueToRotation();
       
  2122 
       
  2123         //TODO jonas: we'd like to not have to clear at all... make the actual change to compositor etc lazily!
       
  2124         if(BlankScreenOnRotation())
       
  2125             {
       
  2126             iRootWindow->ClearDisplay();
       
  2127             }
       
  2128 
       
  2129         CWsTop::ClearAllRedrawStores();
       
  2130         DiscardAllSchedules();
       
  2131         iRootWindow->InvalidateWholeScreen();
       
  2132         CWsWindowGroup::SetScreenDeviceValidStates(this);
       
  2133         TWindowServerEvent::SendScreenDeviceChangedEvents(this);
       
  2134         }
       
  2135     else
       
  2136         {
       
  2137         reply = KErrNotSupported;
       
  2138         }
       
  2139     return reply;  
       
  2140     }
       
  2141 
  2039 void CScreen::UpdateDynamicScreenModes()
  2142 void CScreen::UpdateDynamicScreenModes()
  2040 	{
  2143 	{
  2041 	WS_ASSERT_DEBUG(iDisplayControl,EWsPanicNoDisplayControl);
  2144 	WS_ASSERT_DEBUG(iDisplayControl,EWsPanicNoDisplayControl);
  2042 	TDisplayConfiguration newConfig;
  2145 	TDisplayConfiguration newConfig;
  2043 	iDisplayControl->GetConfiguration(newConfig);
  2146 	iDisplayControl->GetConfiguration(newConfig);