Custom Resource Handler for Images

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.

Re: Custom Resource Handler for Images

Postby blawa » Thu Feb 26, 2015 2:26 am

I've implemented the CefSChemeHandlerFactory and a CefResourceHandler.

Im registering my scheme with CefRegisterSchemeHandlerFactory("client", "myapp", new MySchemeHandlerFactory());

Are the headers already set in the request or do I have to manually set every field in the GetResponseHeaders? Or is CEF using some defaults here?

Currently I'm only setting the MimeType and the Status in the response header.


Edit:
Is there a way to tell the render process in CEF to redraw the screen or to manually set a dirty rect?
Or can someone post me a link to the standard file resource handler so I can compare it to my implementation to see if there is a difference?

I've just read the release notes from January 27, 2015 - there it says that webGl now can be used in ofscreen rendering. Is that exclusive to webGl or is it now possible to use hardware acceleration on any offscreen view?

Edit2:
I have done some further experimenting, and found something really weird.
As said above, I get a crash when I load with my custome ResourceHandler, but if I first draw the image on a second canvas, the use getPixelData and pass these to a WebGL texture, it works fine. Can someone explain me what is going on here?
Example:
Code: Select all
// Throws an exception
image.src = "client://myapp/test.bmp";
//...
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);

// Works fine
image.src = "file:////cef_binary_3.2171.1979_linux64/cefsimple/Debug/test.bmp";
//...
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);

// Works fine
image.src = "client://myapp/test.bmp";
canvas1ctx.drawImage(image,0,0);
var imgData = canvas1ctx.getImageData(0,0,canvas.width,canvas.height);
//...
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imgData);


I can attach the Stacktrace if someone is interested
blawa
Techie
 
Posts: 14
Joined: Thu Feb 19, 2015 7:16 am

Re: Custom Resource Handler for Images

Postby magreenblatt » Fri Feb 27, 2015 10:11 am

blawa wrote:I've implemented the CefSChemeHandlerFactory and a CefResourceHandler.

Im registering my scheme with CefRegisterSchemeHandlerFactory("client", "myapp", new MySchemeHandlerFactory());

You also need to implement CefApp::OnRegisterCustomSchemes().

blawa wrote:Are the headers already set in the request or do I have to manually set every field in the GetResponseHeaders? Or is CEF using some defaults here?

CEF will provide default response headers, but it will not handle request headers like Range that change what should be returned.

blawa wrote:Is there a way to tell the render process in CEF to redraw the screen or to manually set a dirty rect?

Why?

blawa wrote:I've just read the release notes from January 27, 2015 - there it says that webGl now can be used in ofscreen rendering. Is that exclusive to webGl or is it now possible to use hardware acceleration on any offscreen view?

It applies to any accelerated content. However, there are performance considerations. See https://code.google.com/p/chromiumembed ... il?id=1368.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Custom Resource Handler for Images

Postby blawa » Mon Mar 02, 2015 3:22 am

You also need to implement CefApp::OnRegisterCustomSchemes().


Sorry, I forgot to write that down. I did implement everything mentioned in the basic documentation (otherwise I suppose my handler wouldnt load at all)

CEF will provide default response headers, but it will not handle request headers like Range that change what should be returned.


Ok thank you, I fugured some parts of the header handling by outputting them to the console, but it seems to be easy to set fields manually if needed.


Why?


As I mentioned before, we are trying to get a rendered frame to be displayed in CEF. I tought it might work if i set the 'src' of an image to request the image from my handler (which would just copy from memory) - but after some more testing, I found out that using resource handler won't work for me, since it seems to take a good amount of time until a resource is actually ready on the html side. Loading a full-hd image resulted in a time of about 80-100ms measured from the request (img.src=client://...) und the image.onLoad function got called.

It applies to any accelerated content. However, there are performance considerations. See https://code.google.com/p/chromiumembed ... il?id=1368.

Ok thats good to know, thank you again
blawa
Techie
 
Posts: 14
Joined: Thu Feb 19, 2015 7:16 am

Previous

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 96 guests