VirtualBox

Changeset 105182 in vbox


Ignore:
Timestamp:
Jul 8, 2024 11:44:04 AM (5 months ago)
Author:
vboxsync
Message:

Devices/Graphics: screens handling cleanup. bugref:10708

Location:
trunk/src/VBox/Devices/Graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp

    r104853 r105182  
    19401940        pScreen->cbPitch = pCmd->width * 4;
    19411941        pScreen->cBpp    = 32;
     1942        pScreen->cDpi    = pCmd->dpi;
     1943
     1944        /* The screen bitmap must be deallocated after 'vmsvgaR3ChangeMode'. */
     1945        void *pvOldScreenBitmap = pScreen->pvScreenBitmap;
     1946        pScreen->pvScreenBitmap = 0;
    19421947
    19431948        if (RT_LIKELY(pThis->svga.f3DEnabled))
     
    19521957        pThis->svga.fGFBRegisters = false;
    19531958        vmsvgaR3ChangeMode(pThis, pThisCC);
     1959
     1960        RTMemFree(pvOldScreenBitmap);
    19541961    }
    19551962}
     
    76997706    VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[idScreen];
    77007707    Assert(pScreen->idScreen == idScreen);
     7708    pScreen->cDpi      = 0; /* SVGAFifoCmdDefineScreen does not support dpi. */
     7709
     7710    /* SVGAFifoCmdDefineScreen uses the guest VRAM. The screen bitmap must be deallocated after 'vmsvgaR3ChangeMode'. */
     7711    void *pvOldScreenBitmap = pScreen->pvScreenBitmap;
     7712    pScreen->pvScreenBitmap = 0;
     7713
    77017714    pScreen->fDefined  = true;
    77027715    pScreen->fModified = true;
     
    77217734    }
    77227735
    7723     pThis->svga.fGFBRegisters = false;
    7724     vmsvgaR3ChangeMode(pThis, pThisCC);
    7725 
    77267736#ifdef VBOX_WITH_VMSVGA3D
    77277737    if (RT_LIKELY(pThis->svga.f3DEnabled))
    77287738        vmsvga3dDefineScreen(pThis, pThisCC, pScreen);
    77297739#endif
     7740
     7741    pThis->svga.fGFBRegisters = false;
     7742    vmsvgaR3ChangeMode(pThis, pThisCC);
     7743
     7744    RTMemFree(pvOldScreenBitmap);
    77307745}
    77317746
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp

    r104907 r105182  
    16831683        VMSVGASCREENOBJECT *pScreen = &pSVGAState->aScreens[0];
    16841684        Assert(pScreen->idScreen == 0);
     1685
     1686        if (   pScreen->cWidth  == VMSVGA_VAL_UNINITIALIZED
     1687            || pScreen->cHeight == VMSVGA_VAL_UNINITIALIZED
     1688            || pScreen->cBpp    == VMSVGA_VAL_UNINITIALIZED)
     1689        {
     1690            /* Do not apply the change if the guest has not finished updating registers.
     1691             * This is necessary in order to make a full mode change, including freeing
     1692             * pvScreenBitmap buffers for screen 0 if necessary.
     1693             */
     1694            return VINF_SUCCESS;
     1695        }
     1696
     1697        /* Remember screen bitmap buffers to be freed. */
     1698        void * apvOldScreenBitmap[RT_ELEMENTS(pSVGAState->aScreens)];
     1699        RT_ZERO(apvOldScreenBitmap);
     1700
    16851701        pScreen->fDefined  = true;
    16861702        pScreen->fModified = true;
     
    16931709        pScreen->cHeight   = pThis->svga.uHeight;
    16941710        pScreen->cBpp      = pThis->svga.uBpp;
     1711        pScreen->cDpi      = 0; /* GFB mode does not support dpi. */
     1712        /* GFB mode uses the guest VRAM. The screen bitmap must be deallocated after 'vmsvgaR3VBVAResize'. */
     1713        apvOldScreenBitmap[0] = pScreen->pvScreenBitmap;
     1714        /* Set pvScreenBitmap to zero because if it is not, then vmsvgaR3VBVAResize uses it as VRAM address. */
     1715        pScreen->pvScreenBitmap = 0;
    16951716
    16961717        for (unsigned iScreen = 1; iScreen < RT_ELEMENTS(pSVGAState->aScreens); ++iScreen)
     
    17021723                pScreen->fModified = true;
    17031724                pScreen->fDefined = false;
    1704             }
    1705         }
     1725
     1726#ifdef VBOX_WITH_VMSVGA3D
     1727                if (RT_LIKELY(pThis->svga.f3DEnabled))
     1728                    vmsvga3dDestroyScreen(pThisCC, pScreen);
     1729#endif
     1730                apvOldScreenBitmap[iScreen] = pScreen->pvScreenBitmap;
     1731                pScreen->pvScreenBitmap = 0;
     1732            }
     1733        }
     1734
     1735        vmsvgaR3VBVAResize(pThis, pThisCC);
     1736
     1737        /* Deallocate screen bitmaps for all screens because GFB mode uses the guest VRAM. */
     1738        for (unsigned iScreen = 0; iScreen < RT_ELEMENTS(apvOldScreenBitmap); ++iScreen)
     1739            RTMemFree(apvOldScreenBitmap[iScreen]);
    17061740    }
    17071741    else
     
    17141748        pThis->svga.uHeight = VMSVGA_VAL_UNINITIALIZED;
    17151749        pThis->svga.uBpp    = pThis->svga.uHostBpp;
    1716     }
    1717 
    1718     vmsvgaR3VBVAResize(pThis, pThisCC);
     1750
     1751        vmsvgaR3VBVAResize(pThis, pThisCC);
     1752    }
    17191753
    17201754    /* Last stuff. For the VGA device screenshot. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette