[webkit-dev] Question about OpenGL and NPAPI plugins

Damien Chavarria dchavarria at divxcorp.com
Fri Mar 30 14:15:36 PDT 2007

Hi again,

Just some additional info:

If I only record the values of the port x & y information and the clip
rectangle in NPP_SetWindow() and wait until the next call to
HandleEvent() to redisplay the OpenGL surface (instead of re-displaying
directly from NPP_SetWindow()) then I don't see any artifacts BUT this
only works when scrolling with the mouse wheel because there is an
"activateEvent" immediately sent through HandleEvent() following the
NPP_SetWindow() call.

When scrolling using the scrollbars on the side of the web page however
this doesn't work as HandleEvent() doesn't seem to be called at all
while the user scrolls (only NPP_SetWindow() is called repeatedly, and
later an "activateEvent" is fired when the user releases the mouse
button). So this causes my opengl surface to only update when the user
releaes the mouse.

Hope this helps,
Damien Chavarria.


-----Original Message-----

From: webkit-dev-bounces at lists.webkit.org
[mailto:webkit-dev-bounces at lists.webkit.org] On Behalf Of Damien
Sent: vendredi 30 mars 2007 21:05
To: webkit-dev at lists.webkit.org
Subject: [webkit-dev] Question about OpenGL and NPAPI plugins

Ye almighty gods of teh WebKit,

I am writing a web browser plugin for Mac (Firefox, Safari, ..) so I
built a .plugin bundle using the oldish NPAPI and Carbon. Everything is
going rather fine but my problem is that my plugin uses OpenGL (AGL) to
draw its contents.

I implement some logic the NPP_SetWindow() method that the browser is
calling on my plugin to determine where I need to draw in the browser
window and how I need to clip by looking at the clipRect and the port x
and y in the structure I receive. Since the OpenGL surface is above
pretty much everything on the window I need to be careful not to
overwrite anything when the contents are scrolled.

While my code seems to work fine with Firefox and Camino, I can't get it
to behave ok in Safari. What happens is that when I scroll the page
(using the mouse wheel or the scrollbars) my plugin leaves artifacts on
the rest of the HTML page in Safari. It doesn't go "out" of the HTML
scrolled viewport frame but leaves slices of it's content around where
it's been moved.

I used AGL_BUFFER_RECT and glScissor() in my OpenGL rendering to place
and clip the contents of the plugin UI.

I don't know if they are other browser plugins out there that still use
the older NPAPI and are able to render OpenGL contents in Safari or if
there is a workaround I could experiment. I think I have the option to
write a NSView-based .webplugin to fix this but if there is a shorter
term fix that could help me quite a bit.

I have tried my plugin with the latest WebKit nighlty and it still shows
the problem so I am turning to you guys for help :)

Let me know if you need more details.
Damien Chavarria.
webkit-dev mailing list
webkit-dev at lists.webkit.org

More information about the webkit-dev mailing list