Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.h
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.h	(revision 53815)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.h	(revision 53816)
@@ -215,6 +215,6 @@
         int SetVisibleRegionsChanged();
         int SetCompositor(const struct VBOXVR_SCR_COMPOSITOR * pCompositor);
-        void SetScaleFactor(GLdouble scaleFactor);
-        GLdouble GetScaleFactor();
+        bool SetScaleFactor(GLdouble scaleFactorW, GLdouble scaleFactorH);
+        bool GetScaleFactor(GLdouble *scaleFactorW, GLdouble *scaleFactorH);
         int UpdateBegin();
         void UpdateEnd();
@@ -252,5 +252,8 @@
         CR_FBWIN_FLAGS mFlags;
         uint64_t mParentId;
-        volatile uint32_t mScaleFactorStorage;
+
+        RTSEMRW scaleFactorLock;
+        GLdouble mScaleFactorWStorage;
+        GLdouble mScaleFactorHStorage;
 };
 
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/window.cpp
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/window.cpp	(revision 53815)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/window.cpp	(revision 53816)
@@ -29,7 +29,14 @@
     mHeight(0),
     mParentId(parentId),
-    mScaleFactorStorage(1)
-{
+    mScaleFactorWStorage(1.0),
+    mScaleFactorHStorage(1.0)
+{
+    int rc;
+
     mFlags.Value = 0;
+
+    rc = RTSemRWCreate(&scaleFactorLock);
+    if (!RT_SUCCESS(rc))
+        WARN(("Unable to initialize scaling factor data lock."));
 }
 
@@ -131,9 +138,13 @@
     if (mWidth != width || mHeight != height)
     {
-        GLdouble scaleFactor = GetScaleFactor();
+        GLdouble scaleFactorW, scaleFactorH;
+
+        /* Reset to default values if operation was unsuccessfull. */
+        if (!GetScaleFactor(&scaleFactorW, &scaleFactorH))
+            scaleFactorW = scaleFactorH = 1.0;
 
         mFlags.fCompositoEntriesModified = 1;
-        mWidth  = scaleFactor ? (uint32_t)((GLdouble)width  * scaleFactor) : width;
-        mHeight = scaleFactor ? (uint32_t)((GLdouble)height * scaleFactor) : height;
+        mWidth  = scaleFactorW ? (uint32_t)((GLdouble)width  * scaleFactorW) : width;
+        mHeight = scaleFactorH ? (uint32_t)((GLdouble)height * scaleFactorH) : height;
 
         LOG(("CrWIN: Size [%d ; %d]", width, height));
@@ -197,13 +208,35 @@
 
 
-void CrFbWindow::SetScaleFactor(GLdouble scaleFactor)
-{
-    ASMAtomicWriteU32(&mScaleFactorStorage, (uint32_t)scaleFactor);
-}
-
-
-GLdouble CrFbWindow::GetScaleFactor()
-{
-    return (GLdouble)ASMAtomicReadU32(&mScaleFactorStorage);
+bool CrFbWindow::SetScaleFactor(GLdouble scaleFactorW, GLdouble scaleFactorH)
+{
+    int rc;
+
+    rc = RTSemRWRequestWrite(scaleFactorLock, RT_INDEFINITE_WAIT);
+    if (RT_SUCCESS(rc))
+    {
+        mScaleFactorWStorage = scaleFactorW;
+        mScaleFactorHStorage = scaleFactorH;
+        RTSemRWReleaseWrite(scaleFactorLock);
+        return true;
+    }
+
+    return false;
+}
+
+
+bool CrFbWindow::GetScaleFactor(GLdouble *scaleFactorW, GLdouble *scaleFactorH)
+{
+    int rc;
+
+    rc = RTSemRWRequestRead(scaleFactorLock, RT_INDEFINITE_WAIT);
+    if (RT_SUCCESS(rc))
+    {
+        *scaleFactorW = mScaleFactorWStorage;
+        *scaleFactorH = mScaleFactorHStorage;
+        RTSemRWReleaseRead(scaleFactorLock);
+        return true;
+    }
+
+    return false;
 }
 
@@ -242,10 +275,13 @@
         if (fPresentNeeded || mFlags.fForcePresentOnReenable)
         {
-            GLdouble scaleFactor = GetScaleFactor();
+            GLdouble scaleFactorW, scaleFactorH;
+            /* Reset to default values if operation was unseccessfull. */
+            if (!GetScaleFactor(&scaleFactorW, &scaleFactorH))
+                scaleFactorW = scaleFactorH = 1.0;
 
             mFlags.fForcePresentOnReenable = false;
             if (mpCompositor)
             {
-                CrVrScrCompositorSetStretching((VBOXVR_SCR_COMPOSITOR *)mpCompositor, scaleFactor, scaleFactor);
+                CrVrScrCompositorSetStretching((VBOXVR_SCR_COMPOSITOR *)mpCompositor, scaleFactorW, scaleFactorH);
                 cr_server.head_spu->dispatch_table.VBoxPresentComposition(mSpuWindow, mpCompositor, NULL);
             }
@@ -259,5 +295,5 @@
                 Rect.yBottom = mHeight;
                 CrVrScrCompositorInit(&TmpCompositor, &Rect);
-                CrVrScrCompositorSetStretching((VBOXVR_SCR_COMPOSITOR *)&TmpCompositor, scaleFactor, scaleFactor);
+                CrVrScrCompositorSetStretching((VBOXVR_SCR_COMPOSITOR *)&TmpCompositor, scaleFactorW, scaleFactorH);
                 /* this is a cleanup operation
                  * empty compositor is guarantid to be released on VBoxPresentComposition return */
@@ -316,5 +352,11 @@
 CrFbWindow::~CrFbWindow()
 {
+    int rc;
+
     Destroy();
+
+    rc = RTSemRWDestroy(scaleFactorLock);
+    if (!RT_SUCCESS(rc))
+        WARN(("Unable to release scaling factor data lock."));
 }
 
