VirtualBox

Ignore:
Timestamp:
May 28, 2014 9:12:15 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
93991
Message:

Main,Frontends: IDisplay provides the guest screen bitmap to frontends.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp

    r50406 r51436  
    130130    mLabelOffs      = 0;
    131131#endif
     132
     133    mfUpdates = false;
    132134
    133135    rc = RTCritSectInit(&mUpdateLock);
     
    553555}
    554556
     557extern ComPtr<IDisplay> gpDisplay;
     558
     559/* This method runs on the main SDL thread. */
     560void VBoxSDLFB::notifyChange(ULONG aScreenId)
     561{
     562    /* Disable screen updates. */
     563    RTCritSectEnter(&mUpdateLock);
     564
     565    if (mpPendingSourceBitmap.isNull())
     566    {
     567        /* Do nothing. Change event already processed. */
     568        RTCritSectLeave(&mUpdateLock);
     569        return;
     570    }
     571
     572    /* Disable screen updates. */
     573    mfUpdates = false;
     574
     575    /* Release the current bitmap and keep the pending one. */
     576    mpSourceBitmap = mpPendingSourceBitmap;
     577    mpPendingSourceBitmap.setNull();
     578
     579    RTCritSectLeave(&mUpdateLock);
     580
     581    BYTE *pAddress = NULL;
     582    ULONG ulWidth = 0;
     583    ULONG ulHeight = 0;
     584    ULONG ulBitsPerPixel = 0;
     585    ULONG ulBytesPerLine = 0;
     586    ULONG ulPixelFormat = 0;
     587
     588    mpSourceBitmap->QueryBitmapInfo(&pAddress,
     589                                    &ulWidth,
     590                                    &ulHeight,
     591                                    &ulBitsPerPixel,
     592                                    &ulBytesPerLine,
     593                                    &ulPixelFormat);
     594
     595    if (   mGuestXRes    == ulWidth
     596        && mGuestYRes    == ulHeight
     597        && mBitsPerPixel == ulBitsPerPixel
     598        && mBytesPerLine == ulBytesPerLine
     599        && mPtrVRAM == pAddress
     600       )
     601    {
     602        mfSameSizeRequested = true;
     603    }
     604    else
     605    {
     606        mfSameSizeRequested = false;
     607    }
     608
     609    mGuestXRes   = ulWidth;
     610    mGuestYRes   = ulHeight;
     611    mPixelFormat = FramebufferPixelFormat_Opaque;
     612    mPtrVRAM     = pAddress;
     613    mBitsPerPixel = ulBitsPerPixel;
     614    mBytesPerLine = ulBytesPerLine;
     615    mUsesGuestVRAM = FALSE; /* yet */
     616
     617    resizeGuest();
     618}
     619
     620STDMETHODIMP VBoxSDLFB::NotifyChange(ULONG aScreenId,
     621                                     ULONG aXOrigin,
     622                                     ULONG aYOrigin,
     623                                     ULONG aWidth,
     624                                     ULONG aHeight)
     625{
     626    LogRel(("NotifyChange: %d %d,%d %dx%d\n",
     627             aScreenId, aXOrigin, aYOrigin, aWidth, aHeight));
     628
     629    /* Obtain the new screen bitmap. */
     630    RTCritSectEnter(&mUpdateLock);
     631
     632    /* Save the new bitmap. */
     633    mpPendingSourceBitmap.setNull();
     634    gpDisplay->QuerySourceBitmap(aScreenId, mpPendingSourceBitmap.asOutParam());
     635
     636    RTCritSectLeave(&mUpdateLock);
     637
     638    SDL_Event event;
     639    event.type       = SDL_USEREVENT;
     640    event.user.type  = SDL_USER_EVENT_NOTIFYCHANGE;
     641    event.user.code  = mScreenId;
     642
     643    PushSDLEventForSure(&event);
     644
     645    RTThreadYield();
     646
     647    return S_OK;
     648}
     649
    555650/**
    556651 * Returns whether we like the given video mode.
     
    686781
    687782    /* is the guest in a linear framebuffer mode we support? */
    688     if (mUsesGuestVRAM)
     783    if (mPtrVRAM || mUsesGuestVRAM)
    689784    {
    690785        /* Create a source surface from guest VRAM. */
     
    710805        mfSameSizeRequested = false;
    711806        LogFlow(("VBoxSDL:: the same resolution requested, skipping the resize.\n"));
     807
     808        /* Enable screen updates. */
     809        RTCritSectEnter(&mUpdateLock);
     810        mfUpdates = true;
     811        RTCritSectLeave(&mUpdateLock);
     812
    712813        return;
    713814    }
     
    715816    /* now adjust the SDL resolution */
    716817    resizeSDL();
     818
     819    /* Enable screen updates. */
     820    RTCritSectEnter(&mUpdateLock);
     821    mfUpdates = true;
     822    RTCritSectLeave(&mUpdateLock);
     823
     824    repaint();
    717825}
    718826
     
    9611069        return;
    9621070
     1071    RTCritSectEnter(&mUpdateLock);
     1072    Log(("Updates %d, %d,%d %dx%d\n", mfUpdates, x, y, w, h));
     1073    if (!mfUpdates)
     1074    {
     1075        RTCritSectLeave(&mUpdateLock);
     1076        return;
     1077    }
    9631078    /* the source and destination rectangles */
    9641079    SDL_Rect srcRect;
     
    10391154        paintSecureLabel(0, 0, 0, 0, false);
    10401155#endif
     1156    RTCritSectLeave(&mUpdateLock);
    10411157}
    10421158
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