From: Corey C Date: Tue, 18 Sep 2012 21:25:20 +0000 (-0400) Subject: wfreerdp-server: win8 code cleanup X-Git-Tag: 1.1.0-beta1~29^2~56^2~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=77c84cd606c8c307cb91b389a3bb6c3dd66e6716;p=platform%2Fupstream%2Ffreerdp.git wfreerdp-server: win8 code cleanup --- diff --git a/server/Windows/wf_dxgi.c b/server/Windows/wf_dxgi.c index 695f1ce..feaf206 100644 --- a/server/Windows/wf_dxgi.c +++ b/server/Windows/wf_dxgi.c @@ -81,10 +81,6 @@ int wf_dxgi_init(wfInfo* context) //guessing this must be null MeinAcquiredDesktopImage = NULL; - - _tprintf(_T("Hallo, welt!\n")); - - _tprintf(_T("Trying to create a DX11 Device...\n")); // Create device for (DriverTypeIndex = 0; DriverTypeIndex < NumDriverTypes; ++DriverTypeIndex) { @@ -101,24 +97,18 @@ int wf_dxgi_init(wfInfo* context) _tprintf(_T("Failed to create device in InitializeDx\n")); return 1; } - _tprintf(_T("Gut!\n")); /////////////////////////////////////////////////////// - - _tprintf(_T("Trying to get QI for DXGI Device...\n")); - + hr = MeinDevice->lpVtbl->QueryInterface(MeinDevice, &IID_IDXGIDevice, (void**) &DxgiDevice); if (FAILED(hr)) { _tprintf(_T("Failed to get QI for DXGI Device\n")); return 1; } - _tprintf(_T("Gut!\n")); ////////////////////////////////////////////////////////// - - _tprintf(_T("Trying to get adapter for DXGI Device...\n")); hr = DxgiDevice->lpVtbl->GetParent(DxgiDevice, &IID_IDXGIAdapter, (void**) &DxgiAdapter); DxgiDevice->lpVtbl->Release(DxgiDevice); @@ -128,14 +118,12 @@ int wf_dxgi_init(wfInfo* context) _tprintf(_T("Failed to get parent DXGI Adapter\n")); return 1; } - _tprintf(_T("Gut!\n")); //////////////////////////////////////////////////////////// memset(&desc, 0, sizeof(desc)); pOutput = NULL; - _tprintf(_T("\nLooping through ouputs on DXGI adapter...\n")); while(DxgiAdapter->lpVtbl->EnumOutputs(DxgiAdapter, i, &pOutput) != DXGI_ERROR_NOT_FOUND) { DXGI_OUTPUT_DESC* pDesc = &desc; @@ -156,11 +144,10 @@ int wf_dxgi_init(wfInfo* context) ++i; } - //for now stick to the first one + //for now stick to the first one -- need to change this for multimon dTop = 0; - _tprintf(_T("\nTrying to get output...\n")); hr = DxgiAdapter->lpVtbl->EnumOutputs(DxgiAdapter, dTop, &DxgiOutput); DxgiAdapter->lpVtbl->Release(DxgiAdapter); DxgiAdapter = NULL; @@ -169,11 +156,9 @@ int wf_dxgi_init(wfInfo* context) _tprintf(_T("Failed to get output\n")); return 1; } - _tprintf(_T("Gut!\n")); ////////////////////////////////////////////// - _tprintf(_T("Trying to get IDXGIOutput1...\n")); hr = DxgiOutput->lpVtbl->QueryInterface(DxgiOutput, &IID_IDXGIOutput1, (void**) &DxgiOutput1); DxgiOutput->lpVtbl->Release(DxgiOutput); DxgiOutput = NULL; @@ -182,12 +167,9 @@ int wf_dxgi_init(wfInfo* context) _tprintf(_T("Failed to get IDXGIOutput1\n")); return 1; } - _tprintf(_T("Gut!\n")); ////////////////////////////////////////////// - - _tprintf(_T("Trying to duplicate the output...\n")); hr = DxgiOutput1->lpVtbl->DuplicateOutput(DxgiOutput1, (IUnknown*)MeinDevice, &MeinDeskDupl); DxgiOutput1->lpVtbl->Release(DxgiOutput1); DxgiOutput1 = NULL; @@ -201,7 +183,6 @@ int wf_dxgi_init(wfInfo* context) _tprintf(_T("Failed to get duplicate output\n")); return 1; } - _tprintf(_T("Gut! Init Complete!\n")); return 0; } @@ -254,12 +235,9 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout) MeinAcquiredDesktopImage = NULL; } - _tprintf(_T("\nTrying to acquire a frame...\n")); hr = MeinDeskDupl->lpVtbl->AcquireNextFrame(MeinDeskDupl, timeout, &FrameInfo, &DesktopResource); - _tprintf(_T("hr = %#0X\n"), hr); if (hr == DXGI_ERROR_WAIT_TIMEOUT) { - _tprintf(_T("Timeout\n")); return 1; } if (FAILED(hr)) @@ -273,27 +251,21 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout) } return 1; } - _tprintf(_T("Gut!\n")); /////////////////////////////////////////////// - _tprintf(_T("Trying to QI for ID3D11Texture2D...\n")); hr = DesktopResource->lpVtbl->QueryInterface(DesktopResource, &IID_ID3D11Texture2D, (void**) &MeinAcquiredDesktopImage); DesktopResource->lpVtbl->Release(DesktopResource); DesktopResource = NULL; if (FAILED(hr)) { - _tprintf(_T("Failed to QI for ID3D11Texture2D from acquired IDXGIResource\n")); return 1; } - _tprintf(_T("Gut!\n")); wfi->framesWaiting = FrameInfo.AccumulatedFrames; - return 0; - } int wf_dxgi_getPixelData(wfInfo* context, BYTE** data, int* pitch, RECT* invalid) @@ -303,8 +275,8 @@ int wf_dxgi_getPixelData(wfInfo* context, BYTE** data, int* pitch, RECT* invalid D3D11_TEXTURE2D_DESC tDesc; D3D11_BOX Box; - tDesc.Width = (invalid->right - invalid->left) + 1; - tDesc.Height = (invalid->bottom - invalid->top) + 1; + tDesc.Width = (invalid->right - invalid->left); + tDesc.Height = (invalid->bottom - invalid->top); tDesc.MipLevels = 1; tDesc.ArraySize = 1; tDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; @@ -322,7 +294,6 @@ int wf_dxgi_getPixelData(wfInfo* context, BYTE** data, int* pitch, RECT* invalid Box.front = 0; Box.back = 1; - _tprintf(_T("Trying to create staging surface\n")); hr = MeinDevice->lpVtbl->CreateTexture2D(MeinDevice, &tDesc, NULL, &sStage); if (FAILED(hr)) { @@ -330,11 +301,9 @@ int wf_dxgi_getPixelData(wfInfo* context, BYTE** data, int* pitch, RECT* invalid exit(1); return 1; } - _tprintf(_T("Gut!\n")); MeinContext->lpVtbl->CopySubresourceRegion(MeinContext, (ID3D11Resource*)sStage, 0,0,0,0, (ID3D11Resource*)MeinAcquiredDesktopImage, 0, &Box); - _tprintf(_T("Trying to QI staging surface\n")); hr = sStage->lpVtbl->QueryInterface(sStage, &IID_IDXGISurface, (void**)&surf); if (FAILED(hr)) { @@ -342,9 +311,7 @@ int wf_dxgi_getPixelData(wfInfo* context, BYTE** data, int* pitch, RECT* invalid exit(1); return 1; } - _tprintf(_T("Gut!\n")); - _tprintf(_T("Trying to map staging surface\n")); surf->lpVtbl->Map(surf, &MeinData, DXGI_MAP_READ); if (FAILED(hr)) { @@ -352,10 +319,7 @@ int wf_dxgi_getPixelData(wfInfo* context, BYTE** data, int* pitch, RECT* invalid exit(1); return 1; } - _tprintf(_T("Gut!\n")); - //access pixel data - *data = MeinData.pBits; *pitch = MeinData.Pitch; @@ -380,7 +344,6 @@ int wf_dxgi_releasePixelData(wfInfo* wfi) } wfi->framesWaiting = 0; - _tprintf(_T("PixelData Release\n")); return 0; } @@ -403,11 +366,6 @@ int wf_dxgi_getInvalidRegion(RECT* invalid) return 1; } - _tprintf(_T("FrameInfo\n")); - _tprintf(_T("\tAccumulated Frames: %d\n"), FrameInfo.AccumulatedFrames); - _tprintf(_T("\tCoalesced Rectangles: %d\n"), FrameInfo.RectsCoalesced); - _tprintf(_T("\tMetadata buffer size: %d\n"), FrameInfo.TotalMetadataBufferSize); - if(FrameInfo.TotalMetadataBufferSize) { @@ -438,7 +396,6 @@ int wf_dxgi_getInvalidRegion(RECT* invalid) _tprintf(_T("Failed to get frame move rects\n")); return 1; } - _tprintf(_T("Move rects: %d\n"), BufSize / sizeof(DXGI_OUTDUPL_MOVE_RECT)); DirtyRects = MeinMetaDataBuffer + BufSize; BufSize = FrameInfo.TotalMetadataBufferSize - BufSize; @@ -451,19 +408,11 @@ int wf_dxgi_getInvalidRegion(RECT* invalid) return 1; } dirty = BufSize / sizeof(RECT); - _tprintf(_T("Dirty rects: %d\n"), dirty); pRect = (RECT*) DirtyRects; for(i = 0; ileft, - pRect->top, - pRect->right, - pRect->bottom); - UnionRect(invalid, invalid, pRect); - ++pRect; } } diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index 0abcf2d..2e9d072 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -137,7 +137,7 @@ wfInfo* wf_info_init() wfi->peers = (freerdp_peer**) malloc(sizeof(freerdp_peer*) * 32); - wfi->framesPerSecond = 10; + wfi->framesPerSecond = 24; status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey); @@ -308,8 +308,11 @@ BOOL wf_info_have_invalid_region(wfInfo* wfi) return IsRectEmpty(&wfi->invalid); } -void wf_info_getScreenData(wfInfo* wfi, uint8** pBits, int* pitch) +void wf_info_getScreenData(wfInfo* wfi, long* width, long* height, uint8** pBits, int* pitch) { + *width = (wfi->invalid.right - wfi->invalid.left); + *height = (wfi->invalid.bottom - wfi->invalid.top); + if(wfi->win8) { wf_dxgi_getPixelData(wfi, pBits, pitch, &wfi->invalid); @@ -320,6 +323,9 @@ void wf_info_getScreenData(wfInfo* wfi, uint8** pBits, int* pitch) GETCHANGESBUF* changes; changes = (GETCHANGESBUF*) wfi->changeBuffer; + *width += 1; + *height += 1; + offset = (4 * wfi->invalid.left) + (wfi->invalid.top * wfi->width * 4); *pBits = ((uint8*) (changes->Userbuffer)) + offset; *pitch = wfi->width * 4; diff --git a/server/Windows/wf_info.h b/server/Windows/wf_info.h index 1a15a20..c23ad87 100644 --- a/server/Windows/wf_info.h +++ b/server/Windows/wf_info.h @@ -36,6 +36,6 @@ void wf_info_find_invalid_region(wfInfo* wfi); void wf_info_clear_invalid_region(wfInfo* wfi); void wf_info_invalidate_full_screen(wfInfo* wfi); BOOL wf_info_have_invalid_region(wfInfo* wfi); -void wf_info_getScreenData(wfInfo* wfi, uint8** pBits, int* pitch); +void wf_info_getScreenData(wfInfo* wfi, long* width, long* height, uint8** pBits, int* pitch); #endif /* WF_INFO_H */ \ No newline at end of file diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index bb3c892..a049e4a 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -59,24 +59,24 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) { wf_update_encode(wfi); - printf("Start of parallel sending\n"); + //printf("Start of parallel sending\n"); for (index = 0; index < wfi->peerCount; index++) { if (wfi->peers[index]->activated) { - printf("Setting event for %d of %d\n", index + 1, wfi->activePeerCount); + //printf("Setting event for %d of %d\n", index + 1, wfi->activePeerCount); SetEvent(((wfPeerContext*) wfi->peers[index]->context)->updateEvent); } } for (index = 0; index < wfi->activePeerCount; index++) { - printf("Waiting for %d of %d\n", index + 1, wfi->activePeerCount); + //printf("Waiting for %d of %d\n", index + 1, wfi->activePeerCount); WaitForSingleObject(wfi->updateSemaphore, INFINITE); } - printf("End of parallel sending\n"); + //printf("End of parallel sending\n"); wf_info_clear_invalid_region(wfi); } @@ -94,7 +94,7 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) } } - printf("Exiting Update Thread\n"); + //printf("Exiting Update Thread\n"); return 0; } @@ -113,13 +113,11 @@ void wf_update_encode(wfInfo* wfi) wf_info_find_invalid_region(wfi); cmd = &wfi->cmd; - - - width = (wfi->invalid.right - wfi->invalid.left) + 1; - height = (wfi->invalid.bottom - wfi->invalid.top) + 1; stream_set_pos(wfi->s, 0); + wf_info_getScreenData(wfi, &width, &height, &pDataBits, &stride); + rect.x = 0; rect.y = 0; rect.width = (uint16) width; @@ -127,8 +125,6 @@ void wf_update_encode(wfInfo* wfi) //printf("x:%d y:%d w:%d h:%d\n", wfi->invalid.left, wfi->invalid.top, width, height); - wf_info_getScreenData(wfi, &pDataBits, &stride); - rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1, pDataBits, width, height, stride);