// Draw cursor image into GDI drawing texture
CComPtrCustom<IDXGISurface1> lIDXGISurface1;
hr = lGDIImage->QueryInterface(IID_PPV_ARGS(&lIDXGISurface1));
if (FAILED(hr))
break;
CURSORINFO lCursorInfo = { 0 };
lCursorInfo.cbSize = sizeof(lCursorInfo);
auto lBoolres = GetCursorInfo(&lCursorInfo);
if (lBoolres == TRUE)
{
if (lCursorInfo.flags == CURSOR_SHOWING)
{
auto lCursorPosition = lCursorInfo.ptScreenPos;
auto lCursorSize = lCursorInfo.cbSize;
HDC lHDC;
printf("time microsecond2: %lld\n", std::chrono::duration_cast<std::chrono::microseconds>(chrono::steady_clock::now() - lastFrameTime).count());
lIDXGISurface1->GetDC(FALSE, &lHDC);
DrawIconEx(
lHDC,
lCursorPosition.x,
lCursorPosition.y,
lCursorInfo.hCursor,
0,
0,
0,
0,
DI_NORMAL | DI_DEFAULTSIZE);
printf("time microsecond3: %lld\n", std::chrono::duration_cast<std::chrono::microseconds>(chrono::steady_clock::now() - lastFrameTime).count());
lIDXGISurface1->ReleaseDC(nullptr);//too slow
}
}
printf("time microsecond4: %lld\n", std::chrono::duration_cast<std::chrono::microseconds>(chrono::steady_clock::now() - lastFrameTime).count());
// Copy image into CPU access texture
pCtx->CopyResource(*ppTex2D, lGDIImage);
time microsecond1: 19102
time microsecond2: 28896
time microsecond3: 46015
time microsecond4: 146072
time microsecond5: 287259
time microsecond1: 12035
time microsecond2: 22040
time microsecond3: 33243
time microsecond4: 124891
time microsecond5: 248231
I don't think the APIs we currently use in the helper functions (starting with GetCursorInfo) have the ability to give us correctly-sized textures. My guess is that as it's a legacy API (Windows 2000-era), it will always recieve a 32x32 icon for compatibility reasons, and getting more modern cursors should be done with newer APIs (ie GetFramePointerShape, Windows 8+).