[dfb,422221] Gtk/DirectFB: half-fix/enable plugins for DirectFB port

This commit is contained in:
Vladimir Vukicevic 2008-08-06 13:48:55 -07:00
parent 517a03d55c
commit d5014f52b1
3 changed files with 36 additions and 26 deletions

View File

@ -159,13 +159,16 @@ enum { XKeyPress = KeyPress };
#ifdef KeyPress
#undef KeyPress
#endif
#include "gfxXlibNativeRenderer.h"
#ifdef MOZ_WIDGET_GTK2
#include <gdk/gdkwindow.h>
#include <gdk/gdkx.h>
#endif
#endif
#ifdef MOZ_WIDGET_GTK2
#include "gfxGdkNativeRenderer.h"
#endif
#ifdef XP_WIN
#include <wtypes.h>
#include <winuser.h>
@ -361,7 +364,7 @@ public:
void Paint(const nsRect& aDirtyRect, HDC ndc);
#elif defined(XP_MACOSX)
void Paint(const nsRect& aDirtyRect);
#elif defined(MOZ_X11)
#elif defined(MOZ_X11) || defined(MOZ_DFB)
void Paint(gfxContext* aContext,
const gfxRect& aFrameRect,
const gfxRect& aDirtyRect);
@ -477,18 +480,16 @@ private:
nsresult EnsureCachedAttrParamArrays();
#ifdef MOZ_X11
class Renderer : public gfxXlibNativeRenderer {
#ifdef MOZ_WIDGET_GTK2
class Renderer : public gfxGdkNativeRenderer {
public:
Renderer(nsPluginWindow* aWindow, nsIPluginInstance* aInstance,
const nsIntSize& aPluginSize, const nsIntRect& aDirtyRect)
: mWindow(aWindow), mInstance(aInstance),
mPluginSize(aPluginSize), mDirtyRect(aDirtyRect)
{}
virtual nsresult NativeDraw(Screen* screen, Drawable drawable,
Visual* visual, Colormap colormap,
short offsetX, short offsetY,
XRectangle* clipRects, PRUint32 numClipRects);
virtual nsresult NativeDraw(GdkDrawable * drawable, short offsetX,
short offsetY, GdkRectangle * clipRects, PRUint32 numClipRects);
private:
nsPluginWindow* mWindow;
nsIPluginInstance* mInstance;
@ -1372,7 +1373,7 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext,
mInstanceOwner->Paint(aDirtyRect);
}
}
#elif defined(MOZ_X11)
#elif defined(MOZ_X11) || defined(MOZ_DFB)
if (mInstanceOwner)
{
nsPluginWindow * window;
@ -2502,7 +2503,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetValue(nsPluginInstancePeerVariable varia
if (!gdkWindow)
return rv;
gdkWindow = gdk_window_get_toplevel(gdkWindow);
#ifdef MOZ_X11
*static_cast<Window*>(value) = GDK_WINDOW_XID(gdkWindow);
#endif
return NS_OK;
#endif
} else NS_ASSERTION(mOwner, "plugin owner has no owner in getting doc's window handle");
@ -4042,7 +4045,7 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, HPS aHPS)
}
#endif
#ifdef MOZ_X11
#if defined(MOZ_X11) || defined(MOZ_DFB)
void nsPluginInstanceOwner::Paint(gfxContext* aContext,
const gfxRect& aFrameRect,
const gfxRect& aDirtyRect)
@ -4105,16 +4108,11 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
gfxContextAutoSaveRestore autoSR(aContext);
aContext->Translate(pluginRect.pos);
// The display used by gfxXlibNativeRenderer will be the one for the cairo
// surface (provided that it is an Xlib surface) but the display argument
// here needs to be non-NULL for cairo_draw_with_xlib ->
// _create_temp_xlib_surface -> DefaultScreen(dpy).
NPSetWindowCallbackStruct* ws_info =
static_cast<NPSetWindowCallbackStruct*>(window->ws_info);
renderer.Draw(ws_info->display, aContext, pluginSize.width, pluginSize.height,
renderer.Draw(aContext, window->width, window->height,
rendererFlags, nsnull);
}
#ifdef MOZ_X11
static int
DepthOfVisual(const Screen* screen, const Visual* visual)
{
@ -4129,14 +4127,20 @@ DepthOfVisual(const Screen* screen, const Visual* visual)
NS_ERROR("Visual not on Screen.");
return 0;
}
#endif
nsresult
nsPluginInstanceOwner::Renderer::NativeDraw(Screen* screen, Drawable drawable,
Visual* visual, Colormap colormap,
nsPluginInstanceOwner::Renderer::NativeDraw(GdkDrawable * drawable,
short offsetX, short offsetY,
XRectangle* clipRects,
GdkRectangle * clipRects,
PRUint32 numClipRects)
{
#ifdef MOZ_X11
Visual * visual = GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(drawable));
Colormap colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(drawable));
Screen * screen = GDK_SCREEN_XSCREEN (gdk_drawable_get_screen(drawable));
#endif
// See if the plugin must be notified of new window parameters.
PRBool doupdatewindow = PR_FALSE;
@ -4187,16 +4191,19 @@ nsPluginInstanceOwner::Renderer::NativeDraw(Screen* screen, Drawable drawable,
NPSetWindowCallbackStruct* ws_info =
static_cast<NPSetWindowCallbackStruct*>(mWindow->ws_info);
#ifdef MOZ_X11
if (ws_info->visual != visual || ws_info->colormap != colormap) {
ws_info->visual = visual;
ws_info->colormap = colormap;
ws_info->depth = DepthOfVisual(screen, visual);
doupdatewindow = PR_TRUE;
}
#endif
if (doupdatewindow)
mInstance->SetWindow(mWindow);
#ifdef MOZ_X11
// Translate the dirty rect to drawable coordinates.
nsIntRect dirtyRect = mDirtyRect + nsIntPoint(offsetX, offsetY);
// Intersect the dirty rect with the clip rect to ensure that it lies within
@ -4209,11 +4216,11 @@ nsPluginInstanceOwner::Renderer::NativeDraw(Screen* screen, Drawable drawable,
// set the drawing info
exposeEvent.type = GraphicsExpose;
exposeEvent.display = DisplayOfScreen(screen);
exposeEvent.drawable = drawable;
exposeEvent.x = dirtyRect.x;
exposeEvent.y = dirtyRect.y;
exposeEvent.width = dirtyRect.width;
exposeEvent.height = dirtyRect.height;
exposeEvent.drawable = GDK_DRAWABLE_XID(drawable);
exposeEvent.x = mDirtyRect.x + offsetX;
exposeEvent.y = mDirtyRect.y + offsetY;
exposeEvent.width = mDirtyRect.width;
exposeEvent.height = mDirtyRect.height;
exposeEvent.count = 0;
// information not set:
exposeEvent.serial = 0;
@ -4223,6 +4230,7 @@ nsPluginInstanceOwner::Renderer::NativeDraw(Screen* screen, Drawable drawable,
PRBool eventHandled = PR_FALSE;
mInstance->HandleEvent(&pluginEvent, &eventHandled);
#endif
return NS_OK;
}

View File

@ -174,7 +174,7 @@
#include "nsContentPolicyUtils.h"
#include "nsContentErrors.h"
#if defined(XP_UNIX) && defined(MOZ_WIDGET_GTK2)
#if defined(XP_UNIX) && defined(MOZ_WIDGET_GTK2) & defined(MOZ_X11)
#include <gdk/gdkx.h> // for GDK_DISPLAY()
#endif

View File

@ -50,7 +50,9 @@
#include <stdio.h>
#include <gtk/gtk.h>
#ifdef MOZ_X11
#include <gdk/gdkx.h>
#endif
#include <gdk/gdkkeysyms.h>
/* Xlib/Xt stuff */