- Timestamp:
- Mar 21, 2023 3:24:35 PM (23 months ago)
- Location:
- trunk/src/VBox/Frontends/VBoxSDL
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp
r98371 r99090 400 400 event.user.code = mScreenId; 401 401 event.user.type = SDL_USER_EVENT_UPDATERECT; 402 // 16 bit is enough for coordinates 403 event.user.data1 = (void*)(uintptr_t)(x << 16 | y); 404 event.user.data2 = (void*)(uintptr_t)(w << 16 | h); 402 403 SDL_Rect *pUpdateRect = (SDL_Rect *)RTMemAlloc(sizeof(SDL_Rect)); 404 AssertPtrReturn(pUpdateRect, E_OUTOFMEMORY); 405 pUpdateRect->x = x; 406 pUpdateRect->y = y; 407 pUpdateRect->w = w; 408 pUpdateRect->h = h; 409 event.user.data1 = pUpdateRect; 410 411 event.user.data2 = NULL; 405 412 PushNotifyUpdateEvent(&event); 406 413 #else /* !VBOXSDL_WITH_X11 */ … … 843 850 #endif 844 851 RTCritSectEnter(&mUpdateLock); 845 Log(("Updates %d, %d,%d %dx%d\n", mfUpdates, x, y, w, h)); 846 // printf("Updates %d, %d,%d %dx%d\n", mfUpdates, x, y, w, h); 852 Log3Func(("mfUpdates=%RTbool %d,%d %dx%d\n", mfUpdates, x, y, w, h)); 847 853 if (!mfUpdates) 848 854 { … … 858 864 } 859 865 860 /* the source and destination rectangles */861 SDL_Rect srcRect;862 SDL_Rect dstRect;863 864 866 /* this is how many pixels we have to cut off from the height for this specific blit */ 865 int yCutoffGuest = 0; 867 int const yCutoffGuest = 0; 868 866 869 /** 867 870 * If we get a SDL window relative update, we … … 878 881 } 879 882 883 SDL_Rect srcRect; 880 884 srcRect.x = x; 881 885 srcRect.y = y + yCutoffGuest; … … 890 894 * yCutoffGuest >= 0) 891 895 */ 896 SDL_Rect dstRect; 892 897 dstRect.x = x + mCenterXOffset; 893 898 dstRect.y = y + yCutoffGuest + mTopOffset + mCenterYOffset; … … 895 900 dstRect.h = RT_MAX(0, h - yCutoffGuest); 896 901 897 SDL_Texture *pNewTexture = SDL_CreateTextureFromSurface(mpRenderer, mSurfVRAM); 898 /** @todo Do we need to update the dirty rect for the texture for SDL2 here as well? */ 899 // SDL_RenderClear(mpRenderer); 900 //SDL_UpdateTexture(mpTexture, &dstRect, mSurfVRAM->pixels, mSurfVRAM->pitch); 901 // SDL_RenderCopy(mpRenderer, mpTexture, NULL, NULL); 902 SDL_RenderCopy(mpRenderer, pNewTexture, &srcRect, &dstRect); 902 /* Calculate the offset within the VRAM to update the streaming texture directly. */ 903 uint8_t const *pbOff = (uint8_t *)mSurfVRAM->pixels 904 + (srcRect.y * mBytesPerLine) + (srcRect.x * (mBitsPerPixel / 8)); 905 SDL_UpdateTexture(mpTexture, &srcRect, pbOff, mSurfVRAM->pitch); 906 SDL_RenderCopy(mpRenderer, mpTexture, NULL, NULL); 907 908 RTCritSectLeave(&mUpdateLock); 909 903 910 SDL_RenderPresent(mpRenderer); 904 SDL_DestroyTexture(pNewTexture);905 RTCritSectLeave(&mUpdateLock);906 911 } 907 912 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r98392 r99090 494 494 Uint32 winId = 0; 495 495 VBoxSDLFB *fb = getFbFromWinId(winId); 496 SDL_SysWMinfo info; 497 SDL_VERSION(&info.version); 498 if (SDL_GetWindowWMInfo(fb->getWindow(), &info)) 499 fCanShow = true; 500 if (fCanShow) 501 pCSWEv->AddApproval(NULL); 502 else 503 pCSWEv->AddVeto(NULL); 496 if (fb) /* Framebuffer might not be around (yet). */ 497 { 498 SDL_SysWMinfo info; 499 SDL_VERSION(&info.version); 500 if (SDL_GetWindowWMInfo(fb->getWindow(), &info)) 501 fCanShow = true; 502 if (fCanShow) 503 pCSWEv->AddApproval(NULL); 504 else 505 pCSWEv->AddVeto(NULL); 506 } 504 507 #endif 505 508 break; … … 2477 2480 if (gfGrabbed || UseAbsoluteMouse()) 2478 2481 { 2479 VBoxSDLFB *fb; 2480 fb = getFbFromWinId(event.motion.windowID); 2481 AssertPtrBreak(fb); 2482 SendMouseEvent(fb, 0, 0, 0); 2482 VBoxSDLFB *fb = getFbFromWinId(event.motion.windowID); 2483 if (fb) 2484 SendMouseEvent(fb, 0, 0, 0); 2483 2485 } 2484 2486 break; … … 2487 2489 case SDL_MOUSEWHEEL: 2488 2490 { 2489 VBoxSDLFB *fb; 2490 fb = getFbFromWinId(event.button.windowID); 2491 AssertPtrBreak(fb); 2492 SendMouseEvent(fb, -1 * event.wheel.y, 0, 0); 2491 VBoxSDLFB *fb = getFbFromWinId(event.button.windowID); 2492 if (fb) 2493 SendMouseEvent(fb, -1 * event.wheel.y, 0, 0); 2493 2494 break; 2494 2495 } … … 2537 2538 VBoxSDLFB *fb; 2538 2539 fb = getFbFromWinId(event.button.windowID); 2539 AssertPtrBreak(fb);2540 SendMouseEvent(fb, 0 /*wheel vertical movement*/, event.type == SDL_MOUSEBUTTONDOWN, bev->button);2540 if (fb) 2541 SendMouseEvent(fb, 0 /*wheel vertical movement*/, event.type == SDL_MOUSEBUTTONDOWN, bev->button); 2541 2542 } 2542 2543 break; … … 2599 2600 */ 2600 2601 ASMAtomicDecS32(&g_cNotifyUpdateEventsPending); 2601 #define DECODEX(event) (int)((intptr_t)(event).user.data1 >> 16) 2602 #define DECODEY(event) (int)((intptr_t)(event).user.data1 & 0xFFFF) 2603 #define DECODEW(event) (int)((intptr_t)(event).user.data2 >> 16) 2604 #define DECODEH(event) (int)((intptr_t)(event).user.data2 & 0xFFFF) 2605 int x = DECODEX(event); 2606 int y = DECODEY(event); 2607 int w = DECODEW(event); 2608 int h = DECODEH(event); 2609 LogFlow(("SDL_USER_EVENT_UPDATERECT: x = %d, y = %d, w = %d, h = %d\n", 2610 x, y, w, h)); 2602 2603 SDL_Rect *pUpdateRect = (SDL_Rect *)event.user.data1; 2604 AssertPtrBreak(pUpdateRect); 2605 2606 int const x = pUpdateRect->x; 2607 int const y = pUpdateRect->y; 2608 int const w = pUpdateRect->w; 2609 int const h = pUpdateRect->h; 2610 2611 RTMemFree(event.user.data1); 2612 2613 Log3Func(("SDL_USER_EVENT_UPDATERECT: x=%d y=%d, w=%d, h=%d\n", x, y, w, h)); 2611 2614 2612 2615 Assert(gpFramebuffer[event.user.code]); 2613 2616 gpFramebuffer[event.user.code]->update(x, y, w, h, true /* fGuestRelative */); 2614 2615 #undef DECODEX2616 #undef DECODEY2617 #undef DECODEW2618 #undef DECODEH2619 2617 break; 2620 2618 }
Note:
See TracChangeset
for help on using the changeset viewer.