Move image rendering code to Image.cpp

This commit is contained in:
radha%netscape.com 1998-08-24 20:19:46 +00:00
Родитель 03c24bb4c3
Коммит 588dd981f1
1 изменённых файлов: 2 добавлений и 274 удалений

Просмотреть файл

@ -136,9 +136,7 @@ extern "C" {
XP_Bool fe_IsConferenceInstalled();
URL_Struct *fe_GetBrowserStartupUrlStruct();
void displayImage(MWContext * context, IL_Pixmap * image,
IL_Pixmap * mask,PRInt32 x,PRInt32 y,
PRInt32 x_offset, PRInt32 y_offset, PRInt32 width, PRInt32 height);
};
extern MWContext *last_documented_xref_context;
@ -1840,7 +1838,7 @@ XFE_Frame::initializeMWContext(EFrameType frame_type,
CONTEXT_DATA (m_context)->colormap = m_cmap;
// set image library Callback functions
CONTEXT_DATA (m_context)->DisplayPixmap = (DisplayPixmapPtr)DisplayPixmap;
CONTEXT_DATA (m_context)->DisplayPixmap = (DisplayPixmapPtr)fe_DisplayPixmap;
CONTEXT_DATA (m_context)->NewPixmap = (NewPixmapPtr)NULL;
CONTEXT_DATA (m_context)->ImageComplete = (ImageCompletePtr)NULL;
@ -5113,275 +5111,5 @@ XFE_Frame::zaxis_BelowEH(Widget shell,
///////////////////////////////////////////////////////////////////////////
// ImageLibrary Callbacks //
///////////////////////////////////////////////////////////////////////////
extern "C"
{
void
DisplayPixmap(MWContext * context, IL_Pixmap * image, IL_Pixmap * mask, PRInt32 x, PRInt32 y, PRInt32 x_offset, PRInt32 y_offset, PRInt32 width, PRInt32 height)
{
XFE_Frame * frameHandle=(XFE_Frame *)NULL;
/* Get the handle to the frame from the context */
if (context)
frameHandle = (XFE_Frame *)ViewGlue_getFrame(context);
/* Check the context type. If it is anything other than MWContextIcon
* let it do the regular image processing. If it is MWContextIcon,
* Look for a NavCenterVIew in th frame and let the view handle the
* pixmap display
*/
if (context->type != MWContextIcon)
{
/* Call the frame's displayImage method */
displayImage(context, image, mask, x, y, x_offset, y_offset,
width, height);
}
else
{
/* If the context type is MWContextIcon, get a handle to
* NavCenterView and let it handle pixmap
*/
XFE_View * navCenterView = XFE_View::getNavCenterView(frameHandle->getView());
if (navCenterView)
{
Widget buttonWidget = CONTEXT_WIDGET(context);
navCenterView->handleDisplayPixmap(buttonWidget, image, mask, width, height);
}
}
} /* DisplayPixmap */
void
NewPixmap(MWContext * context, IL_Pixmap * image, Boolean mask)
{
XFE_Frame * frameHandle=(XFE_Frame *)NULL;
/* Get the handle to the frame from the context */
if (context)
frameHandle = ViewGlue_getFrame(context);
/* Check the context type. If it is anything other than MWContextIcon
* simply return, 'coz the frames don't have any processing for the
* the NewPixmap callback. If it is MWContextIcon,
* Look for a NavCenterView in th frame and let the view handle it.
*/
if (frameHandle)
{
if (context->type == MWContextIcon)
{
/* If the context type is MWContextIcon, get a handle to
* NavCenterView and let it handle pixmap
*/
XFE_View * navCenterView = XFE_View::getNavCenterView(frameHandle->getView());
if (navCenterView)
{
Widget buttonWidget = CONTEXT_WIDGET(context);
navCenterView->handleNewPixmap(buttonWidget, image, mask);
}
}
}
} /* NewPixmap */
void
ImageComplete(MWContext * context, IL_Pixmap * image)
{
XFE_Frame * frameHandle=(XFE_Frame *)NULL;
/* Get the handle to the frame from the context */
if (context)
frameHandle = (XFE_Frame *)ViewGlue_getFrame(context);
/* Check the context type. If it is anything other than MWContextIcon
* simply return, 'coz the frames don't have any processing for the
* the NewPixmap callback. If it is MWContextIcon,
* Look for a NavCenterView in th frame and let the view handle it.
*/
if (frameHandle)
{
if (context->type == MWContextIcon)
{
/* If the context type is MWContextIcon, let the NavCenterView
* handle it
*/
XFE_View * navCenterView = XFE_View::getNavCenterView(frameHandle->getView());
if (navCenterView)
{
Widget buttonWidget = CONTEXT_WIDGET(context);
navCenterView->handleImageComplete(buttonWidget, image);
}
}
}
} /* ImageComplete */
void
displayImage(MWContext * context, IL_Pixmap * image,
IL_Pixmap * mask, PRInt32 x, PRInt32 y,
PRInt32 x_offset, PRInt32 y_offset, PRInt32 width,PRInt32 height)
{
int32 img_x_offset, img_y_offset; /* Offset of image in drawable. */
int32 rect_x_offset, rect_y_offset; /* Offset of update rect in
drawable. */
NI_PixmapHeader *img_header = &image->header;
uint32 img_width = img_header->width; /* Image width. */
uint32 img_height = img_header->height; /* Image height. */
Widget widget = CONTEXT_WIDGET(context);
fe_Drawable *fe_drawable = CONTEXT_DATA(context)->drawable;
Drawable drawable = fe_drawable->xdrawable;
Display *dpy = XtDisplay(widget);
Pixmap img_x_pixmap, mask_x_pixmap;
fe_PixmapClientData *img_client_data, *mask_client_data;
GC gc;
XGCValues gcv;
unsigned long flags;
XP_Bool tiling_required = FALSE;
/* Check for zero display area. */
if (width == 0 || height == 0)
return;
/* Retrieve the server pixmaps. */
img_client_data = (fe_PixmapClientData *)image->client_data;
if (!img_client_data)
return;
img_x_pixmap = img_client_data->pixmap;
if (!img_x_pixmap)
return;
if (mask) {
mask_client_data = (fe_PixmapClientData *)mask->client_data;
mask_x_pixmap = mask_client_data->pixmap;
}
/* Determine whether tiling is required. */
if ((x_offset + width > img_width) || (y_offset + height > img_height))
tiling_required = TRUE;
/* Compute the offset into the drawable of the image origin. */
img_x_offset = x - CONTEXT_DATA(context)->document_x +
fe_drawable->x_origin;
img_y_offset = y - CONTEXT_DATA(context)->document_y +
fe_drawable->y_origin;
/* Compute the offset into the drawable for the area to be drawn. */
rect_x_offset = img_x_offset + x_offset;
rect_y_offset = img_y_offset + y_offset;
/* Do the actual drawing. There are several cases to be dealt with:
transparent vs non-transparent, tiled vs non-tiled and clipped by
compositor's clip region vs not clipped. */
memset(&gcv, ~0, sizeof (XGCValues));
if (mask) { /* Image is transparent. */
if (tiling_required) {
/* Offsets are measured wrt the origin of the tiled mask to
be generated. */
int x_tile_offset = img_x_offset - rect_x_offset;
int y_tile_offset = img_y_offset - rect_y_offset;
Pixmap tmp_pixmap = 0;
/* Create the mask by tiling the mask_x_pixmap and computing
the intersection with the compositor's clip region. */
tmp_pixmap =
fe_TiledMaskWithClipRegion(dpy, drawable, mask_x_pixmap,
width, height, x_tile_offset,
y_tile_offset, -rect_x_offset,
-rect_y_offset,
(Region)fe_drawable->clip_region);
/* Create the GC. Don't attempt to get a GC from the GC cache
because we are using a temporary mask pixmap. */
gcv.fill_style = FillTiled;
gcv.tile = img_x_pixmap;
gcv.ts_x_origin = img_x_offset;
gcv.ts_y_origin = img_y_offset;
gcv.clip_mask = tmp_pixmap;
gcv.clip_x_origin = rect_x_offset;
gcv.clip_y_origin = rect_y_offset;
flags = GCFillStyle | GCTile | GCTileStipXOrigin |
GCTileStipYOrigin | GCClipMask | GCClipXOrigin | GCClipYOrigin;
gc = XCreateGC(dpy, drawable, flags, &gcv);
/* Draw the image (transparent and tiled.) */
XFillRectangle (dpy, drawable, gc, rect_x_offset, rect_y_offset,
width, height);
/* Clean up. */
XFreeGC(dpy, gc);
XFreePixmap(dpy, tmp_pixmap);
}
else { /* Tiling not required. */
if (fe_drawable->clip_region) {
/* Draw the image (transparent, non-tiled and with
clip_region.) x_offset and y_offset are wrt the image
origin, while rect_x_offset and rect_y_offset are wrt the
drawable origin. */
fe_DrawMaskedImageWithClipRegion(dpy, drawable, img_x_pixmap,
mask_x_pixmap, width, height,
img_x_offset, img_y_offset,
x_offset, y_offset,
(Region)fe_drawable->clip_region);
}
else { /* No clip region. */
/* XXX transparent, non-tiled and no clip_region. */
}
}
}
else { /* Image is not transparent. */
if (tiling_required) {
/* Get the GC from the GC cache. If the compositor has given us
a clip region, then the GC must have a matching clip mask. */
gcv.fill_style = FillTiled;
gcv.tile = img_x_pixmap;
gcv.ts_x_origin = img_x_offset;
gcv.ts_y_origin = img_y_offset;
flags = GCFillStyle | GCTile | GCTileStipXOrigin |
GCTileStipYOrigin;
if (fe_drawable->clip_region)
gc = fe_GetGCfromDW(dpy, drawable, flags, &gcv,
(Region)fe_drawable->clip_region);
else
gc = fe_GetGCfromDW(dpy, drawable, flags, &gcv, NULL);
/* Draw the image (opaque and tiled.) */
XFillRectangle (dpy, drawable, gc, rect_x_offset, rect_y_offset,
width, height);
}
else { /* Tiling not required. */
/* Get the GC from the GC cache. If the compositor has given us
a clip region, then the GC must have a matching clip mask. */
gcv.function = GXcopy;
if (fe_drawable->clip_region)
gc = fe_GetGCfromDW(dpy, drawable, GCFunction,
&gcv, (Region)fe_drawable->clip_region);
else
gc = fe_GetGCfromDW(dpy, drawable, GCFunction, &gcv, NULL);
/* Draw the image (opaque and non-tiled.) */
XCopyArea (dpy, img_x_pixmap, drawable, gc, x_offset,
y_offset, width, height, rect_x_offset, rect_y_offset);
}
}
} /* displayImage */
}; /* extern "C" */