Well, I didn’t write this widget, but I’ll post the widgets draw
function so you can compare it to yours. It sounds like it’s doing more
or less the same thing you are doing now…they only thing I can think
of that would affect the rendering speed would be setting clip rects, if
you aren’t already doing that.
static void drawDisplay(PtWidget_t *widget,PhTile_t *damage)
{
PhRect_t canvas;
PtImageAreaWidget_t imageArea =
(PtImageAreaWidget_t)PtWidgetParent(widget);
if(!(imageArea->flags & Pt_IMAGEAREA_RENDERED))
renderDisplay(imageArea);
PtCalcCanvas(widget,&canvas);
if(imageArea->flags & Pt_IMAGEAREA_NO_MEMORY)
{
PgSetTextColor(((PtBasicWidget_t*)imageArea)->color);
PgSetFont(imageArea->errFont);
PgDrawTextArea(imageArea->errString,strlen(imageArea->errString),&canvas,
(imageArea->hAlign == Pt_LEFT ? Pg_TEXT_LEFT : imageArea->hAlign ==
Pt_RIGHT ? Pg_TEXT_RIGHT : Pg_TEXT_CENTER) |
(imageArea->vAlign == Pt_TOP ? Pg_TEXT_TOP : imageArea->vAlign ==
Pt_BOTTOM ? Pg_TEXT_BOTTOM : Pg_TEXT_MIDDLE));
return;
}
/* First ensure we don’t draw outside the widget boundary */
PtClipAdd(widget,&canvas);
if(imageArea->buffer.image)
{
PhSysInfo_t sysInfo;
if(imageArea->buffer.type == Pg_IMAGE_GRADIENT_BYTE ||
imageArea->buffer.type == Pg_IMAGE_GRADIENT_NIBBLE)
{
PgSetFillColor(Pg_BLACK);
PgSetTextColor(Pg_WHITE);
}
PtQuerySystemInfo(imageArea->display,&sysInfo);
if (sysInfo.gfx.capabilities & Ph_GCAP_RELAY)
{
if((imageArea->buffer.type & Pg_IMAGE_CLASS_MASK) ==
Pg_IMAGE_CLASS_PALETTE)
{
if(!(imageArea->iflags & Pt_IMAGEAREA_PALCRC_VALID))
{
imageArea->buffer.palette_tag =
PtCRC((char*)(imageArea->buffer.palette),imageArea->buffer.colors *
sizeof(PgColor_t));
imageArea->iflags |= Pt_IMAGEAREA_PALCRC_VALID;
}
PgSetPalette(imageArea->buffer.palette,0,0,imageArea->buffer.colors,Pg_PALSET_SOFT,imageArea->buffer.palette_tag);
}
if(!(imageArea->iflags & Pt_IMAGEAREA_IMGCRC_VALID))
{
imageArea->buffer.image_tag =
PtCRC(imageArea->buffer.image,imageArea->buffer.bpl *
imageArea->buffer.size.h);
imageArea->iflags |= Pt_IMAGEAREA_IMGCRC_VALID;
}
}
if((sysInfo.gen.valid_fields & Ph_GEN_INFO_NUM_GFX) &&
(sysInfo.gfx.valid_fields & Ph_GFX_CAPABILITIES) &&
(sysInfo.gfx.capabilities & Ph_GCAP_SHMEM))
{
PgDrawPhImagemx(&canvas.ul,&imageArea->buffer,0);
}
else
{
PgDrawImage(imageArea->buffer.image,imageArea->buffer.type,&canvas.ul,&imageArea->buffer.size,
imageArea->buffer.bpl,imageArea->buffer.image_tag);
}
}
if(imageArea->selection.ul.x >= 0 && imageArea->selection.ul.y >= 0 &&
imageArea->selection.lr.x >= 0 && imageArea->selection.lr.y >= 0)
{
PhRect_t rect;
PgSetStrokeWidth(1);
PgSetDrawMode(Pg_DRAWMODE_XOR);
PgSetStrokeColor(Pg_INVERT_COLOR);
rect.ul.x = (GR_FPMUL(imageArea->selection.ul.x << 16,imageArea->zoom)
-
- 1;
rect.ul.y = (GR_FPMUL(imageArea->selection.ul.y << 16,imageArea->zoom)
-
- 1;
rect.lr.x = ((GR_FPMUL((imageArea->selection.lr.x + 1)
16,imageArea->zoom) + 0xffff) >> 16) + 1;
rect.lr.y = ((GR_FPMUL((imageArea->selection.lr.y + 1) <<
16,imageArea->zoom) + 0xffff) >> 16) + 1;
PtDeTranslateRect(&rect,&imageArea->topLeft);
PtTranslateRect(&rect,&canvas.ul);
PgDrawRect(&rect,Pg_DRAW_STROKE);
PgSetDrawMode(Pg_DRAWMODE_OPAQUE);
}
/* Remove the clipping region */
PtClipRemove();
}
Kevin Stallard wrote:
Well…it got better when is used PgDrawPhImagemx() > > ! But it still isn’t
as good as the ImageArea widget…
Kevin
“Kevin Stallard” <> kevin@fffflyingrobbbotsss.com> > wrote in message
news:ba3g0m$6uv$> 1@inn.qnx.com> …
Hi,
It’s fast, and what I find most interesting, is that I am using two
graphics
cards in my 6.2.1 development box and so I know that image area can’t be
using off screen contexts in which to draw because it works on both
monitors…and it’s really fast … (Offscreen contexts don’t redraw on
one of the monitors…)
How is the repair to the image done when I move it to the othe rmonitor,
there is no flicker, it’s smooth.
Just to play around, I’m using a memory context which I fill with a color
and gets flushed to a PhImage_t. It does it once when the image is first
created, then subsequent calls to my drawing routine just calls
PgDrawPhImage(). The image uses shared memory. But it flickers like
crazy
when I move it around and to a different monitor.
Anyone willing to share their secrets? I would like to avoid the
offscreen
context so that I can have it work with dualing graphics cards…
Thanks,
Kevin
\