diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index 9d82ea4a1..03b931a1e 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -305,6 +305,12 @@ static UINT gdi_StartFrame(RdpgfxClientContext* context, const RDPGFX_START_FRAM return CHANNEL_RC_OK; } +static UINT gdi_call_update_surfaces(RdpgfxClientContext* context) +{ + WINPR_ASSERT(context); + return IFCALLRESULT(CHANNEL_RC_OK, context->UpdateSurfaces, context); +} + /** * Function description * @@ -312,19 +318,25 @@ static UINT gdi_StartFrame(RdpgfxClientContext* context, const RDPGFX_START_FRAM */ static UINT gdi_EndFrame(RdpgfxClientContext* context, const RDPGFX_END_FRAME_PDU* endFrame) { - UINT status = CHANNEL_RC_OK; - rdpGdi* gdi = NULL; - WINPR_ASSERT(context); WINPR_ASSERT(endFrame); - gdi = (rdpGdi*)context->custom; + rdpGdi* gdi = (rdpGdi*)context->custom; WINPR_ASSERT(gdi); - IFCALLRET(context->UpdateSurfaces, status, context); + const UINT status = gdi_call_update_surfaces(context); gdi->inGfxFrame = FALSE; return status; } +static UINT gdi_interFrameUpdate(rdpGdi* gdi, RdpgfxClientContext* context) +{ + WINPR_ASSERT(gdi); + UINT status = CHANNEL_RC_OK; + if (!gdi->inGfxFrame) + status = gdi_call_update_surfaces(context); + return status; +} + /** * Function description * @@ -379,11 +391,7 @@ static UINT gdi_SurfaceCommand_Uncompressed(rdpGdi* gdi, RdpgfxClientContext* co if (status != CHANNEL_RC_OK) goto fail; - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } + status = gdi_interFrameUpdate(gdi, context); fail: return status; @@ -438,11 +446,7 @@ static UINT gdi_SurfaceCommand_RemoteFX(rdpGdi* gdi, RdpgfxClientContext* contex for (UINT32 x = 0; x < nrRects; x++) region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &rects[x]); - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } + status = gdi_interFrameUpdate(gdi, context); fail: region16_uninit(&invalidRegion); @@ -497,11 +501,7 @@ static UINT gdi_SurfaceCommand_ClearCodec(rdpGdi* gdi, RdpgfxClientContext* cont if (status != CHANNEL_RC_OK) goto fail; - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } + status = gdi_interFrameUpdate(gdi, context); fail: return status; @@ -554,11 +554,7 @@ static UINT gdi_SurfaceCommand_Planar(rdpGdi* gdi, RdpgfxClientContext* context, if (status != CHANNEL_RC_OK) goto fail; - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } + status = gdi_interFrameUpdate(gdi, context); fail: return status; @@ -637,11 +633,7 @@ static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi, RdpgfxClientContext* context, if (status != CHANNEL_RC_OK) goto fail; - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } + status = gdi_interFrameUpdate(gdi, context); fail: return status; @@ -742,11 +734,7 @@ static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context, if (status != CHANNEL_RC_OK) goto fail; - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } + status = gdi_interFrameUpdate(gdi, context); fail: return status; @@ -918,11 +906,7 @@ static UINT gdi_SurfaceCommand_Alpha(rdpGdi* gdi, RdpgfxClientContext* context, if (status != CHANNEL_RC_OK) goto fail; - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } + status = gdi_interFrameUpdate(gdi, context); fail: return status; @@ -999,11 +983,7 @@ static UINT gdi_SurfaceCommand_Progressive(rdpGdi* gdi, RdpgfxClientContext* con region16_uninit(&invalidRegion); - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } + status = gdi_interFrameUpdate(gdi, context); fail: return status; @@ -1297,13 +1277,7 @@ static UINT gdi_SolidFill(RdpgfxClientContext* context, const RDPGFX_SOLID_FILL_ LeaveCriticalSection(&context->mux); - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } - - return status; + return gdi_interFrameUpdate(gdi, context); fail: LeaveCriticalSection(&context->mux); return status; @@ -1375,13 +1349,7 @@ static UINT gdi_SurfaceToSurface(RdpgfxClientContext* context, LeaveCriticalSection(&context->mux); - if (!gdi->inGfxFrame) - { - status = CHANNEL_RC_NOT_INITIALIZED; - IFCALLRET(context->UpdateSurfaces, status, context); - } - - return status; + return gdi_interFrameUpdate(gdi, context); fail: LeaveCriticalSection(&context->mux); return status; @@ -1527,12 +1495,7 @@ static UINT gdi_CacheToSurface(RdpgfxClientContext* context, LeaveCriticalSection(&context->mux); - if (!gdi->inGfxFrame) - status = IFCALLRESULT(CHANNEL_RC_NOT_INITIALIZED, context->UpdateSurfaces, context); - else - status = CHANNEL_RC_OK; - - return status; + return gdi_interFrameUpdate(gdi, context); fail: LeaveCriticalSection(&context->mux);