Any existing way to print Chromium window to DC?

684 views
Skip to first unread message

xdi...@gmail.com

unread,
Sep 1, 2016, 9:14:21 AM9/1/16
to Graphics-dev
Hello.
I am writing about well-known and discussed problem of PrintWindow().
And I have all of the GPU compositing stuff disabled in Chrome.
I need to print Google Chrome window to the device context.
So, PrintWindow() does not work; it prints black rectangle only.

So, since Windows 8.1 there is undocumented flag PW_RENDERFULLCONTENT, which does the trick. But on Windows 7 there is no such flag, and I need to print window not in extension (so I can not use extension API or something like this), but from separate Windows application.

Anyway, is there a proper way to print Google Chrome window when GPU compositing is disabled? Maybe I need to disable something else? Is there a code printing to DC anywhere in Chromium? Maybe there is a way to call it? Maybe I need to hook something: I have read that PrintWindow() problem is related to asynchronous message processing, so hook message processing to make it synchronous?

John Bauman

unread,
Sep 1, 2016, 3:23:10 PM9/1/16
to xdi...@gmail.com, Graphics-dev
Based on https://cs.chromium.org/chromium/src/third_party/webrtc/modules/desktop_capture/window_capturer_win.cc?q=PrintWindow&sq=package:chromium&dr=C&l=163 you could try using BitBlt in cases where PrintWindow fails. That does have issues when aero is disabled and the window is occluded, though.

xdi...@gmail.com

unread,
Sep 1, 2016, 10:42:53 PM9/1/16
to Graphics-dev, xdi...@gmail.com
Thank you, BitBlt() is nice, but I need to print window even if it minimized or overlapped. Is there another solution? Does Chromium paint itself on the device context anywhere in it's code?

четверг, 1 сентября 2016 г., 22:23:10 UTC+3 пользователь John Bauman написал:

John Bauman

unread,
Sep 2, 2016, 1:45:01 AM9/2/16
to xdi...@gmail.com, Graphics-dev
Yeah, it draws to the DC at https://cs.chromium.org/chromium/src/content/browser/compositor/software_output_device_win.cc?sq=package:chromium&dr&l=188 but I don't know that there's a good way to hook that

xdi...@gmail.com

unread,
Sep 2, 2016, 11:37:08 AM9/2/16
to Graphics-dev, xdi...@gmail.com
Thank you, it looks like something I am looking for! Where is SoftwareOutputDeviceWin::EndPaint() called? From a message loop?

пятница, 2 сентября 2016 г., 8:45:01 UTC+3 пользователь John Bauman написал:

mysoft...@gmail.com

unread,
Mar 11, 2019, 4:46:56 PM3/11/19
to Graphics-dev, xdi...@gmail.com
use SetWindowLong to set WS_EX_COMPOSITED do the PrintWindow() set it back to what was before (or leave it with COMPOSITED to speed up... but that will affect the visibility of the real window unless hw acc is disabled) maybe trying to see if WS_EX_LAYERED and setting opacity to 254 would work better

Sunny Sachanandani

unread,
Mar 11, 2019, 5:07:47 PM3/11/19
to mysoft...@gmail.com, kyle...@chromium.org, Graphics-dev, xdi...@gmail.com
Assuming you have OOP-D turned on (VizDisplayCompositor in chrome://gpu), you might want to call PrintWindow on the browser's child HWND that's created and drawn in the GPU (viz) process.  Furthermore, that window could be a layered window on Windows 7 (if it has to be translucent).  See https://cs.chromium.org/chromium/src/components/viz/service/display_embedder/software_output_device_win.cc?sq=package:chromium&q=CreateSoftwareOutputDeviceWinGpu&g=0&l=352

+kylechar@ who knows more about this

Reply all
Reply to author
Forward
0 new messages