Quantcast

Offscreen rendering from C++

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Offscreen rendering from C++

Christian Sell
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
_______________________________________________
dev-embedding mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-embedding
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Offscreen rendering from C++

Benjamin Smedberg
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

_______________________________________________
dev-embedding mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-embedding
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Offscreen rendering from C++

Christian Sell
In reply to this post by Christian Sell
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

_______________________________________________
dev-embedding mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-embedding
Loading...