Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Offscreen rendering from C++

57 views
Skip to first unread message

Christian Sell

unread,
Feb 13, 2014, 12:17:11 PM2/13/14
to
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

Benjamin Smedberg

unread,
Feb 13, 2014, 12:36:03 PM2/13/14
to Christian Sell, dev-em...@lists.mozilla.org
On 2/13/2014 12:17 PM, Christian Sell wrote:
> Now I would like to rewrite this in C++, and am mighty stuck.

Why do you want this to be in C++? I strongly recommend writing as much
of this as you can in JS. It's going to be a more stable API surface,
especially if you're using DOM JS calls. I really don't expect this to
be easy or perhaps even possible from C++.

--BDS

Christian Sell

unread,
Feb 13, 2014, 12:43:19 PM2/13/14
to
Hi,

I almost expected this answer. Actually, we already have the working code in a Javascript component, which we previously called via JavaXPCOM. Since we are now forced to write our own C++ XPCOM access layer, I thought it would make sense to also migrate the component code in order to limit the number of project languages. I also THOUGHT it could't be difficult. Naive I was.

Another reason for trying the rewrite was the fact that I am not able to get the Javascript component registered. See my other post.

Thanks,
Christian

0 new messages