mfreerdp-server: fixed geometry again

This commit is contained in:
C-o-r-E 2012-12-09 22:17:53 -05:00
parent 9391e60c13
commit f9e8ff4927
4 changed files with 47 additions and 32 deletions

View File

@ -277,11 +277,13 @@ BOOL mf_info_have_invalid_region(mfInfo* mfi)
void mf_info_getScreenData(mfInfo* mfi, long* width, long* height, BYTE** pBits, int* pitch)
{
*width = mfi->invalid.width / 2;
*height = mfi->invalid.height / 2;
*pitch = 2880 * 4;
*width = mfi->invalid.width / mfi->scale;
*height = mfi->invalid.height / mfi->scale;
*pitch = mfi->servscreen_width * mfi->scale * 4;
mf_mlion_get_pixelData(mfi->invalid.x / 2, mfi->invalid.y / 2, *width, *height, pBits);
mf_mlion_get_pixelData(mfi->invalid.x / mfi->scale, mfi->invalid.y / mfi->scale, *width, *height, pBits);
*pBits = *pBits + (mfi->invalid.x * 4) + (*pitch * mfi->invalid.y);
}

View File

@ -93,6 +93,7 @@ struct mf_info
freerdp_peer** peers;
//BOOL mirrorDriverActive;
unsigned int framesWaiting;
int scale;
//HANDLE snd_mutex;
//BOOL snd_stop;

View File

@ -49,20 +49,20 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef, CGDisp
dispatch_semaphore_wait(region_sem, DISPATCH_TIME_FOREVER);
//may need to move this down
if(ready == TRUE);
if(ready == TRUE)
{
RFX_RECT rect;
unsigned long offset_beg;
unsigned long offset_end;
unsigned long surflen;
unsigned long stride;
rect.x = 0;
rect.y = 0;
rect.width = 2880;
rect.height = 1800;
//mf_mlion_peek_dirty_region(&rect);
rect.width = 0;
rect.height = 0;
mf_mlion_peek_dirty_region(&rect);
//offset_beg = ((rect.width * 4) * rect.y) + rect.x * 4;
//offset_end =
//lock surface
IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, NULL);
@ -70,12 +70,20 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef, CGDisp
void* baseAddress = IOSurfaceGetBaseAddress(frameSurface);
//copy region
//offset_beg =
memcpy(localBuf, baseAddress, rect.width * rect.height * 4);
stride = IOSurfaceGetBytesPerRow(frameSurface);
//memcpy(localBuf, baseAddress + offset_beg, surflen);
for(int i = 0; i < rect.height; i++)
{
offset_beg = (stride * (rect.y + i) + (rect.x * 4));
memcpy(localBuf + offset_beg,
baseAddress + offset_beg,
rect.width * 4);
}
//unlock surface
IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, NULL);
ready = FALSE;
dispatch_semaphore_signal(data_sem);
}
@ -219,9 +227,9 @@ int mf_mlion_get_dirty_region(RFX_RECT* invalid)
{
mf_mlion_peek_dirty_region(invalid);
CFRelease(lastUpdate);
//CFRelease(lastUpdate);
lastUpdate = NULL;
//lastUpdate = NULL;
}
@ -269,21 +277,23 @@ int mf_mlion_clear_dirty_region()
dispatch_semaphore_signal(region_sem);
*/
CFRelease(lastUpdate);
lastUpdate = NULL;
return 0;
}
int mf_mlion_get_pixelData(long x, long y, long width, long height, BYTE** pxData)
{
printf("waiting for region semaphore...\n");
dispatch_semaphore_wait(region_sem, DISPATCH_TIME_FOREVER);
ready = TRUE;
printf("waiting for data semaphore...\n");
dispatch_semaphore_wait(data_sem, DISPATCH_TIME_FOREVER);
dispatch_semaphore_signal(region_sem);
//this second wait allows us to block until data is copied... more on this later
dispatch_semaphore_wait(data_sem, DISPATCH_TIME_FOREVER);
printf("got it\n");
*pxData = localBuf;
dispatch_semaphore_signal(data_sem);

View File

@ -120,6 +120,8 @@ void mf_peer_rfx_update(freerdp_peer* client)
mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch);
mf_info_clear_invalid_region(mfi);
//encode
STREAM* s;
@ -137,6 +139,8 @@ void mf_peer_rfx_update(freerdp_peer* client)
stream_clear(s);
stream_set_pos(s, 0);
UINT32 x = mfi->invalid.x / mfi->scale;
UINT32 y = mfi->invalid.y / mfi->scale;
rect.x = 0;
rect.y = 0;
@ -146,9 +150,6 @@ void mf_peer_rfx_update(freerdp_peer* client)
rfx_compose_message(mfp->rfx_context, s, &rect, 1,
(BYTE*) dataBits, rect.width, rect.height, pitch);
UINT32 x = mfi->invalid.x / 2;
UINT32 y = mfi->invalid.y / 2;
cmd->destLeft = x;
cmd->destTop = y;
cmd->destRight = x + rect.width;
@ -169,7 +170,6 @@ void mf_peer_rfx_update(freerdp_peer* client)
//clean up
mf_info_clear_invalid_region(mfi);
// note: need to stop getting new dirty rects until here
@ -191,10 +191,10 @@ void mf_peer_context_new(freerdp_peer* client, mfPeerContext* context)
context->rfx_context->mode = RLGR3;
context->rfx_context->width = client->settings->DesktopWidth;
context->rfx_context->height = client->settings->DesktopHeight;
rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_R8G8B8A8);
rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
context->nsc_context = nsc_context_new();
nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_R8G8B8A8);
nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_B8G8R8A8);
context->s = stream_new(0xFFFF);
@ -280,19 +280,21 @@ BOOL mf_peer_post_connect(freerdp_peer* client)
}
printf("\n");
mfInfo* mfi = mf_info_get_instance();
mfi->scale = 1;
UINT32 servscreen_width = 2880 / 2;
UINT32 servscreen_height = 1800 / 2;
mfi->servscreen_width = 2880 / mfi->scale;
mfi->servscreen_height = 1800 / mfi->scale;
UINT32 bitsPerPixel = 32;
if ((settings->DesktopWidth != servscreen_width) || (settings->DesktopHeight != servscreen_height))
if ((settings->DesktopWidth != mfi->servscreen_width) || (settings->DesktopHeight != mfi->servscreen_height))
{
printf("Client requested resolution %dx%d, but will resize to %dx%d\n",
settings->DesktopWidth, settings->DesktopHeight, servscreen_width, servscreen_height);
settings->DesktopWidth, settings->DesktopHeight, mfi->servscreen_width, mfi->servscreen_height);
}
settings->DesktopWidth = servscreen_width;
settings->DesktopHeight = servscreen_height;
settings->DesktopWidth = mfi->servscreen_width;
settings->DesktopHeight = mfi->servscreen_height;
settings->ColorDepth = bitsPerPixel;
client->update->DesktopResize(client->update->context);