MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
451 stars 55 forks source link

WebView2 + Direct2D + DirectX12 == ??? #381

Closed c1t1z3n0 closed 1 year ago

c1t1z3n0 commented 4 years ago

Hello. I'm trying to incorporate WebView2 into my D3D12 app and am running into a few issues. Basically, all I want to do is take a window created with webview2 and put its content on a d3d12 texture and render on a 3D object in a scene. GDI is probably not the way to go because Direct2D is better with hardware acceleration. The problem though is the change from DX11 to DX12 and the migration from DXGISurfaces -> D3D12Resources, the removal of 'Context' from D3D12, D2D still wants contexts and dxgisurfaces, etc. I've tried using GDI and hdc/hmemorydc and d2d. i can get a normal hwnd copied to a d3d texture with getdibbits(). i have also got a d2d rendertarget copied to a d3d texture. I've played around with CreateWicBitmapRenderTarget() and CreateHwndRenderTarget(), but for some reason, haven't figured out a way to get a webview created window onto a d3d texture. Whats the best route to take? Is Microsoft going to update Direct2D eventually to play nice with D3D12? Should I stick with GDI for now? Eventually I want to port my engine from rasterization to DXR ray-tracing, so I want a solution that will work with that. I'm desigining an app to work on PC + XBox. Any advice is greatly appreciated. Thank you. c1t1z3n0 sample of the engine i'm working with, minus some new d2d code i've added: http://hellod3d12.epizy.com/source/HelloD3D12.htm

pagoe-msft commented 4 years ago

@c1t1z3n0

Our current hosting model doesn't provide support for this, but it is something we have been investigating. One potential "hack" would be to take a screenshot of the content in WebView2.

c1t1z3n0 commented 4 years ago

I've tried some hacks but haven't gotten much from them besides more confusion. I did find some info that might help:

https://www.briskbard.com/forum/viewtopic.php?t=774 https://www.tenforums.com/tutorials/149042-enable-disable-hardware-acceleration-microsoft-edge-chromium.html

More questions ;)

  1. Would you recommend going the IWebView2->CapturePreview() route using some kind of memory IStream instead of file as the hack, or try to directly interface with DWM thumbnail to get the hWnd/screenshot data?
  2. Do you think having hardware acceleration enabled is causing me to get white blank data every time I try to copy bits from the initial "WebView2" hWnd I create with CreateWIndowEx()? If so, is there a way to turn off hardware acceleration with the main ICoreWebView2/ICoreWebView2Controller/ICoreWebView2Environment interfaces?
  3. Why is Microsoft so 'touchy' when it comes to DWM? All the patents and clipping changes to latest builds. Seems like they think 2D UI is gonna be around forever when 3D UI like the kind in Johnny Mnemonic 'Internet 2021' will be here soon. :) I mean really, all I want is a simple pointer to some RGBA data that I can copy to a texture to use on a 3D object. There seems to be very little documentation/info, except things like:

https://en.wikipedia.org/wiki/Desktop_Window_Manager https://en.wikipedia.org/wiki/Compositing_window_manager https://en.wikipedia.org/wiki/ANGLE_(software) https://en.wikipedia.org/wiki/WebGPU

which tend to add more confusion than solution. My guess is that Gates got careless, and filled Microsofts teams with a bunch of college grads with more loyalty to Google/Unix/OpenGL/STL than true Win32API/DirectX/C/C++ coding. Perhaps he should hire John Carmack as his head of the DWM/window compositing department, I'm sure he'd have an API that was hardware accelerated with ample developer controls of things as simple as 'Window Data'. Anyhow, enough ranting. Just give me a little more advice on which solution you think will be faster/easier and I'll be happy and figure out the hack. Thanks in advance. c1t1z3n0

ps. its issues like this that is why Microsoft lost the browser war to Google. https://en.wikipedia.org/wiki/Microsoft_Edge#Market_share please help us take back 90% of the web/browser/phone market and crush google/android/mac. ;) we just need the tools.

UMU618 commented 1 year ago

WebView2 + Direct2D + DirectX12 == Native Cloud Gaming

champnic commented 1 year ago

Tracked in #20 and #547.