int g_rgb_read(Engine *eng, GpColor *rgb, long *nx, long *ny) { XEngine *xeng = GisXEngine(eng); if (!xeng || !xeng->w || !xeng->win) return 1; GpPreempt(eng); GdDraw(1); /* make sure screen updated */ GpPreempt(0); if (xeng->w == xeng->win) { /* not in animate mode */ if (!rgb) { *nx = xeng->wtop; *ny = xeng->htop; } else { p_rgb_read(xeng->win, rgb, xeng->leftMargin, xeng->topMargin, xeng->leftMargin+xeng->wtop, xeng->topMargin+xeng->htop); } } else { /* in animate mode, read offscreen pixmap */ if (!rgb) { *nx = xeng->a_width; *ny = xeng->a_height; } else { p_rgb_read(xeng->w, rgb, 0, 0, xeng->a_width, xeng->a_height); } } return 0; }
void GxExpose(Engine *engine, Drauing *drawing, int *xy) { XEngine *xeng = (XEngine *)engine; GpBox damage; if (!drawing || !xeng->w) return; /* xy=0 to redraw all, otherwise x0,y0,x1,y1 */ if (xy) { GpXYMap *map = &engine->devMap; damage.xmin= (xy[0]-map->x.offset)/map->x.scale; damage.xmax= (xy[2]-map->x.offset)/map->x.scale; damage.ymax= (xy[1]-map->y.offset)/map->y.scale; damage.ymin= (xy[3]-map->y.offset)/map->y.scale; } else { damage.xmin = xeng->swapped.viewport.xmin; damage.xmax = xeng->swapped.viewport.xmax; damage.ymin = xeng->swapped.viewport.ymin; damage.ymax = xeng->swapped.viewport.ymax; } if (engine->damaged) { GpSwallow(&engine->damage, &damage); } else { engine->damage = damage; engine->damaged = 1; } GdSetDrawing(drawing); GpPreempt(engine); GdDraw(1); GpPreempt(0); /* not correct if damaged during a preempt... */ GdSetDrawing(0); }
static void UpdateOrRedraw(int changesOnly) { Engine *display= currentDevice<0? 0 : ghDevices[currentDevice].display; if (!display) return; GpPreempt(display); if (gdraw_hook) gdraw_hook(display, 0); GdDraw(changesOnly); GpFlush(0); if (gdraw_hook) gdraw_hook(display, 1); GpPreempt(0); }
void GhHCP(void) { Engine *hcp= currentDevice<0? 0 : ghDevices[currentDevice].hcp; if (!hcp) hcp= hcpDefault; if (!hcp) return; GpPreempt(hcp); if (gdraw_hook) gdraw_hook(hcp, 4); GdDraw(0); /* NB- must be very careful not to Preempt twice with GdDrawLegends */ if (ghDevices[currentDevice].doLegends) GdDrawLegends(0); GpClear(0, ALWAYS); GpFlush(0); if (gdraw_hook) gdraw_hook(hcp, 5); GpPreempt(0); }
void GhFMA(void) { Engine *display; Engine *hcp= 0; if (currentDevice<0) return; display= ghDevices[currentDevice].display; if (animateOn && !display) animateOn= 0; if (hcpOn) { hcp= ghDevices[currentDevice].hcp; if (!hcp) hcp= hcpDefault; if (hcp) GpActivate(hcp); } if (gdraw_hook) gdraw_hook(display, 2); GdDraw(1); if (hcpOn && hcp && ghDevices[currentDevice].doLegends) GdDrawLegends(hcp); if (animateOn) GxStrobe(display, 1); GpFlush(0); if (animateOn!=1) GdClear(0); else GdClearSystem(); if (gdraw_hook) gdraw_hook(display, 3); if (hcpOn && hcp) { GpClear(hcp, CONDITIONALLY); GpDeactivate(hcp); } ghDevices[currentDevice].fmaCount++; if (++fmaCount > 100) { /* clean house once in a while */ fmaCount= 0; GaFreeScratch(); } }