Offscreen rendering from C++

Christian Sell <[email protected]> Thu, 13 Feb 2014 09:17:11 -0800 (PST)
Newsgroups gmane.comp.mozilla.devel.embedding
Message-ID <[email protected]>
Hello all,

we are using XULRunner 24 embedded in a Java application through Eclipse SWT. We need extended functionality only available through the XPCOM API, and since the old JavaXPCOM binding has vanished, we are migrating all code to C++, which we access from Java through a narrow JNI API. So far, so good.

Now to the real question: we have a XPCOM component written in Javascript that saves the content of a browser window onto disk. We do this using the Javascript code shown below:

// create a canvas
var canvas = cwin.document.createElement("canvas");

// get the 2D context and draw everythiong on it
var ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, width, height);
ctx.save();
ctx.drawWindow(cwin, 0, position, width, height, "rgb(255,255,255)");
ctx.restore();

//and then to disk..

Now I would like to rewrite this in C++, and am mighty stuck. Can someone give a hint how to proceed? I have spent a full day browsing the APIs and the web, but am not able to figure out how to get to the 2D context thingy and do the rest. I have found an old post from 2008 regarding a similar issue, but that would not even compile.

I'd be REALLY grateful for hints!

thanks
Christian