]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Update hardware mouse cursor if texture was reallocated.
authorToni Wilen <twilen@winuae.net>
Sat, 18 Nov 2023 13:27:29 +0000 (15:27 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 18 Nov 2023 13:27:29 +0000 (15:27 +0200)
od-win32/direct3d.cpp
od-win32/direct3d.h
od-win32/direct3d11.cpp
od-win32/gdirender.cpp
od-win32/picasso96_win.cpp

index f0a1238039cf1b958bbab7322e663cd735679379..a7f2f98c0cd90f12004ace86d44e26322fda5afe 100644 (file)
@@ -2173,7 +2173,7 @@ static void setupscenecoords(struct d3dstruct *d3d, bool normalrender, int monid
 
        MatrixTranslation (&d3d->m_matView_out, tx, ty, 1.0f);
 
-       MatrixScaling (&d3d->m_matWorld_out, sw + 0.5f / sw, sh + 0.5f / sh, 1.0f);
+       MatrixScaling (&d3d->m_matWorld_out, sw, sh, 1.0f);
 
        struct amigadisplay *ad = &adisplays[monid];
        int rota = currprefs.gf[ad->picasso_on ? GF_RTG : ad->interlace_on ? GF_INTERLACE : GF_NORMAL].gfx_filter_rotation;
@@ -4171,9 +4171,12 @@ static int xD3D_isenabled(int monid)
        return d3d->d3d_enabled ? 1 : 0;
 }
 
-static uae_u8 *xD3D_setcursorsurface(int monid, int *pitch)
+static uae_u8 *xD3D_setcursorsurface(int monid, bool query, int *pitch)
 {
        struct d3dstruct *d3d = &d3ddata[monid];
+       if (query) {
+               return d3d->cursorsurfaced3dtexbuf;
+       }
        if (pitch) {
                *pitch = CURSORMAXWIDTH * 4;
                return d3d->cursorsurfaced3dtexbuf;
index 7f310713fc5d16d2977902a27a5516120d61efff..426b582f1c0f61e0aa2de7c5a4580e196c4453e4 100644 (file)
@@ -24,7 +24,7 @@ extern void(*D3D_clear)(int);
 extern int(*D3D_canshaders)(void);
 extern int(*D3D_goodenough)(void);
 extern bool(*D3D_setcursor)(int, int x, int y, int width, int height, float mx, float my, bool visible, bool noscale);
-extern uae_u8 *(*D3D_setcursorsurface)(int, int *pitch);
+extern uae_u8 *(*D3D_setcursorsurface)(int, bool, int *pitch);
 extern float(*D3D_getrefreshrate)(int);
 extern void(*D3D_restore)(int, bool);
 extern void(*D3D_resize)(int, int);
index 3b461d73b5b0aba36b9a715c2fa4b615d6ad27b5..add203d1ceb3de4b23338347186a71dd4edab90b 100644 (file)
@@ -62,7 +62,7 @@ void (*D3D_clear)(int);
 int (*D3D_canshaders)(void);
 int (*D3D_goodenough)(void);
 bool (*D3D_setcursor)(int, int x, int y, int width, int height, float mx, float my, bool visible, bool noscale);
-uae_u8 *(*D3D_setcursorsurface)(int, int *pitch);
+uae_u8 *(*D3D_setcursorsurface)(int, bool, int *pitch);
 float (*D3D_getrefreshrate)(int);
 void(*D3D_restore)(int, bool);
 void(*D3D_resize)(int, int);
@@ -205,6 +205,7 @@ struct d3d11sprite
        bool screenlimit;
        uae_u8 *texbuf;
        bool updated;
+       bool empty;
 };
 
 struct d3doverlay
@@ -1929,6 +1930,7 @@ static bool allocsprite(struct d3d11struct *d3d, struct d3d11sprite *s, int widt
        s->alpha = alpha;
        s->rotation = rotation;
        s->screenlimit = screenlimit;
+       s->empty = true;
 
        if (screenlimit) {
                s->texbuf = xcalloc(uae_u8, width * height * 4);
@@ -5344,6 +5346,7 @@ static void updatecursorsurface(int monid)
        }
 
        sp->updated = false;
+       sp->empty = false;
        D3D11_MAPPED_SUBRESOURCE map;
        HRESULT hr = d3d->m_deviceContext->Map(sp->texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
        if (SUCCEEDED(hr)) {
@@ -5425,16 +5428,20 @@ static bool xD3D_setcursor(int monid, int x, int y, int width, int height, float
        return true;
 }
 
-static uae_u8 *xD3D_setcursorsurface(int monid, int *pitch)
+static uae_u8 *xD3D_setcursorsurface(int monid, bool query, int *pitch)
 {
        struct d3d11struct *d3d = &d3d11data[monid];
-       if (!d3d->hwsprite.texbuf)
+       d3d->hwsprite.updated = false;
+       if (query) {
+               return d3d->hwsprite.empty ? NULL : d3d->hwsprite.texbuf;
+       }
+       if (!d3d->hwsprite.texbuf) {
                return NULL;
+       }
        if (pitch) {
                *pitch = d3d->hwsprite.width * 4;
                return d3d->hwsprite.texbuf;
        }
-       d3d->hwsprite.updated = false;
        return NULL;
 }
 
index c1b6b2dd6ffad5037b5187d0e83adc73a218f3ae..31167cfb8ccb858cbe9632c964943b76887c98e4 100644 (file)
@@ -515,10 +515,14 @@ static bool gdi_setcursor(int monid, int x, int y, int width, int height, float
        return true;
 }
 
-static uae_u8 *gdi_setcursorsurface(int monid, int *pitch)
+static uae_u8 *gdi_setcursorsurface(int monid, bool query, int *pitch)
 {
        struct gdistruct* gdi = &gdidata[monid];
 
+       if (query) {
+               return (uae_u8 *)gdi->cursor.bits;
+       }
+
        if (gdi->depth < 32) {
                return NULL;
        }
index 54ce718f5eee3857dd95f8a2a9f619e6b18e2f4a..4ebe62621c209c866c9c90d1d3f13f7db5387ca7 100644 (file)
@@ -790,7 +790,7 @@ static void setupcursor(void)
                return;
        gfx_lock ();
        setupcursor_needed = 1;
-       dptr = D3D_setcursorsurface(rbc->monitor_id, &pitch);
+       dptr = D3D_setcursorsurface(rbc->monitor_id, false, &pitch);
        if (dptr) {
                for (int y = 0; y < CURSORMAXHEIGHT; y++) {
                        uae_u8 *p2 = dptr + pitch * y;
@@ -803,7 +803,7 @@ static void setupcursor(void)
                                memcpy (p2, p1, cursorwidth * bpp);
                        }
                }
-               D3D_setcursorsurface(rbc->monitor_id, NULL);
+               D3D_setcursorsurface(rbc->monitor_id, false, NULL);
                setupcursor_needed = 0;
                P96TRACE_SPR((_T("cursorsurface3d updated\n")));
        } else {
@@ -841,6 +841,9 @@ static void mouseupdate(struct AmigaMonitor *mon)
        }
 
        if (D3D_setcursor) {
+               if (!D3D_setcursorsurface(mon->monitor_id, true, NULL)) {
+                       setupcursor_needed = 1;
+               }
                if (currprefs.gf[GF_RTG].gfx_filter_autoscale == RTG_MODE_CENTER) {
                        D3D_setcursor(mon->monitor_id, x, y, WIN32GFX_GetWidth(mon), WIN32GFX_GetHeight(mon), mx, my, cursorvisible, mon->scalepicasso == 2);
                } else {
@@ -1095,6 +1098,7 @@ static void setconvert(int monid)
                vidinfo->orgbformat = state->RGBFormat;
        }
        vidinfo->full_refresh = 1;
+       setupcursor_needed = 1;
        unlockrtg();
 }
 
@@ -1796,7 +1800,11 @@ static uae_u32 REGPARAM2 picasso_SetSpriteColor (TrapContext *ctx)
                return 0;
        if (idx >= 4)
                return 0;
+       uae_u32 oc = cursorrgb[idx];
        cursorrgb[idx] = (red << 16) | (green << 8) | (blue << 0);
+       if (oc != cursorrgb[idx]) {
+               setupcursor_needed = 1;
+       }
        P96TRACE_SPR ((_T("SetSpriteColor(%08x,%d:%02X%02X%02X). %x\n"), bi, idx, red, green, blue, bi + PSSO_BoardInfo_MousePens));
        return 1;
 }