crash with windowless plugin and drawWindow
arno renevier <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.plugins |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm trying to implement a x11 plugin which can work windowless. Then, I can
display it in a hidden iframe, and draw it on a canvas with drawWindow.
Unfortunately, that does not work.
Here is my NPP_HandleEvent function, which displays a black rectangle.
NPError NPP_HandleEvent(NPP instance, void* event)
{
XEvent *evt = event;
if (evt->type == GraphicsExpose) {
Window drawable = evt->xgraphicsexpose.drawable;
GdkDrawable *result = (GdkDrawable*) gdk_xid_table_lookup(drawable);
Display *display = evt->xgraphicsexpose.display;
Screen *screen = DefaultScreenOfDisplay(display);
int width = evt->xgraphicsexpose.width;
int height = evt->xgraphicsexpose.height;
XRenderColor black={0,0,0,0xffff};
Visual *visual=DefaultVisual(display, DefaultScreen(display));
XRenderPictFormat *fmt = XRenderFindVisualFormat (display, visual);
Picture drawingarea = XRenderCreatePicture (display, drawable, fmt, 0, NULL);
XRenderFillRectangle(display, PictOpOver, drawingarea, &black, evt->xgraphicsexpose.x + 10, evt->xgraphicsexpose.y + 10, width - 20, height - 20);
return NPERR_NO_ERROR;
}
return NPERR_NO_ERROR;
}
The second of part of the functions (xrender specific method) is basically equivalent to
cairo_surface_t *res = cairo_xlib_surface_create(display, drawable, DefaultVisualOfScreen(screen), width, height);
cairo_t * cr = cairo_create (res);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_rectangle (cr, evt->xgraphicsexpose.x + 10, evt->xgraphicsexpose.y + 10, width - 20, height - 20);
cairo_fill(cr);
Unfortunely, soon after calling drawWindow on the (hidden) window where that
plugin is displayed, my application crashes as follows:
###!!! ABORT: RenderCreatePicture: BadMatch (invalid parameter attributes); 12 requests ago: file /home/arno/mozilla/toolkit/xre/nsX11ErrorHandler.cpp, line 190
###!!! ABORT: RenderCreatePicture: BadMatch (invalid parameter attributes); 12 requests ago: file /home/arno/mozilla/toolkit/xre/nsX11ErrorHandler.cpp, line 190
If I use XRenderPictFormat *fmt = XRenderFindStandardFormat(display,
PictStandardARGB32), the plugin does not crash. But unfortunately, I want to
use cairo, and cairo uses XRenderFindVisualFormat (display, visual);
I know some plugins work well. For example, the flash plugin in transparent
mode, does not trigger the crash.
So, does anyone have an idea what could be possibly wrong with my plugin ?
Thanks
arno