Support for off-screen rendering

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Support for off-screen rendering

Postby Spk » Thu Sep 17, 2009 4:01 am

Hello! CEF seems to be a very nice and clean wrapper!

Is it possible to use CEF for offscreen rendering of web pages? I would like to use this in my game engine by rendering web pages to a texture in memory. I haven't seen any exposed methods to access the rendered page's bitmap data, but I suppose it would be possible to access the browser window's HDC and copy its content to a texture.

Also, the latest binaries listed in your download section are for revision 27 (june) but on your main page you mention revision 37 being available. I'd like to avoid having to recompile both chromium and CEF to get the last version so I was wondering if there might be a downloadable version of revision 37 available for lazy people like myself :)

Thanks in advance!
Spk
Newbie
 
Posts: 1
Joined: Thu Sep 17, 2009 3:54 am

Re: Support for off-screen rendering

Postby magreenblatt » Thu Sep 17, 2009 9:06 am

It should be possible to use CEF for in-memory rendering with some minor changes. The implementation would be variant of how we currently handle printing. Can you give me more information about how you'd like the interface to look? For instance, is rendering to a client-provided HDC sufficient? How would you want to handle pagination and scaling?

I'm planning to provide a new binary release in the next few days, but it likely won't contain this feature since the implementation doesn't exist yet ;-). If you download and build the source you can help develop it, which will mean you'll get it that much faster :-).

Regards,
Marshall
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Support for off-screen rendering

Postby heshiming » Thu Sep 17, 2009 10:23 am

There is a project named "awesomium" you might be interested. http://princeofcode.com/awesomium.php

It's also based on chromium, I suppose it used testshell in the beginning too. I haven't look at its implementation details yet. But it looks like it's primary objective is off-screen rendering.
heshiming
Techie
 
Posts: 29
Joined: Fri Jul 31, 2009 1:59 am

Re: Support for off-screen rendering

Postby magreenblatt » Thu Sep 17, 2009 12:06 pm

A new binary distribution (rev 42) is now available for download:
http://code.google.com/p/chromiumembedd ... loads/list
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Support for off-screen rendering

Postby jacadcaps » Mon Nov 30, 2009 4:19 am

magreenblatt wrote:A new binary distribution (rev 42) is now available for download:
http://code.google.com/p/chromiumembedd ... loads/list


Are there any examples of off-screen rendering anywhere in the project ?
jacadcaps
Newbie
 
Posts: 6
Joined: Mon Nov 30, 2009 3:58 am

Re: Support for off-screen rendering

Postby speps » Wed Dec 30, 2009 7:49 am

Support for rendering to an offscreen buffer would be really great, with something close to the WebView::Render function of Awesomium. The problem of Awesomium is that it is limited in terms of events and notifications and is closed source.

Here is this Render function for reference :
Code: Select all
   /**
   * Renders the WebView to an off-screen buffer.
   *
   * @param   destination   The buffer to render to, its width and height should match the WebView's.
   *
   * @param   destRowSpan   The row-span of the destination buffer (number of bytes per row).
   *
   * @param   destDepth   The depth (bytes per pixel) of the destination buffer. Valid options
   *                  include 3 (BGR/RGB) or 4 (BGRA/RGBA).
   *
   * @param   renderedRect   Optional (pass 0 to ignore); if asynchronous rendering is not enabled,
   *                     you can provide a pointer to a Rect to store the dimensions of the
   *                     rendered area, or rather, the dimensions of the area that actually
   *                     changed since the last render.
   */
   void render(unsigned char* destination, int destRowSpan, int destDepth, Awesomium::Rect* renderedRect = 0);
speps
Newbie
 
Posts: 1
Joined: Wed Dec 30, 2009 7:44 am

Re: Support for off-screen rendering

Postby Jusas » Thu Jan 07, 2010 5:47 am

I'd like to take a crack at it but being new to Chromium & CEF code I have no idea where to start. Any pointers?

Basically what I'm thinking is:
- Injecting input events to CEF (mouse, keyboard)
- Rendering (or copying the rendered result) to a given memory buffer (RGB/RGBA) instead of a HWND

Very simple changes, perhaps even doable as a wrapper?
Jusas
Newbie
 
Posts: 2
Joined: Thu Jan 07, 2010 5:34 am

Re: Support for off-screen rendering

Postby Jusas » Fri Jan 08, 2010 5:19 am

I'll take that back - the platform specific code seems to be rather strongly integrated into the system. HWNDs everywhere and that seems how the test_shell app was designed, it has platform specific webwidget_host_win.cc, webwidget_host_gtk.cc etc. and taking away all the platform specific code wouldn't be practical.

So... I'm guessing the best way to go would be to let CEF draw into a hidden window and then copy the HDC contents to where ever it needs to go.
Jusas
Newbie
 
Posts: 2
Joined: Thu Jan 07, 2010 5:34 am

Re: Support for off-screen rendering

Postby cgravill » Tue Feb 23, 2010 11:46 am

I've got an instance of a CEF browser running and am able to extract the image and copy it on-demand to my surface. There are the various notifications for browser-type events I can register for in my CefHandler. What I'm looking for is a notification when CEF has just redrawn so I can extract it without having to resort to a timer, a dirty region would be a bonus! Is there such a notification or way to get it?

For the initial prototype we're OK with rendering to a client-provided HDC, though if we could render direct to the image or texture that would save on processing.

Thanks,

Colin
cgravill
Newbie
 
Posts: 2
Joined: Tue Feb 23, 2010 11:09 am

Re: Support for off-screen rendering

Postby jerryprez » Thu Feb 25, 2010 6:23 am

Hi Colin,
Could you please post the code snippets or explain how you can extract rendered image of a CEF browser?

Thank you!
jerryprez
Newbie
 
Posts: 7
Joined: Thu Feb 25, 2010 6:04 am

Next

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 78 guests