Skip to content

Conversation

@valadaptive
Copy link
Contributor

As I mentioned in #5612 (comment), cv->back_img_out_of_date and cv->backimgs were only used by the X11 drawing backend, which has now been removed. We can therefore remove them as well now (as well as supporting functionality like SC_OutOfDateBackground).

Type of change

  • Non-breaking change

Copy link
Contributor

@iorsh iorsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@frank-trampe
Copy link
Contributor

How does the GDK back-end handle the background images?

@valadaptive
Copy link
Contributor Author

How does the GDK back-end handle the background images?

Seems to just draw them unconditionally in CVExpose.

Here's the diff of the original conditional, when the X11 backend was removed. GitHub's subpar UI doesn't seem to properly jump to it, but it's highlighted in orange in the middle of charview.c.

@iorsh
Copy link
Contributor

iorsh commented Sep 26, 2025

How does the GDK back-end handle the background images?

From the code excerpt below (before #5612) it seems that all the backends do the same job in a different order:

X11 (no Cairo):

  • Create off-screen pixmap window for drawing (charview::backimgs)
  • Draw hints with CVShowHints() onto the off-screen pixmap
  • Draw background images with DrawImageList() onto the off-screen pixmap
  • Draw off-screen pixmap onto CharView

Cairo:

  • Draw background images with DrawImageList() directly into CharView window
  • Draw hints with CVShowHints() directly into CharView window

I don't know what was the reason for the off-screen hack, maybe transparency or performance issues.

	if ( cv->backimgs==NULL && !(GDrawHasCairo(cv->v)&gc_buildpath))
	    cv->backimgs = GDrawCreatePixmap(GDrawGetDisplayOfWindow(cv->v),cv->v,cv->width,cv->height);
	if ( GDrawHasCairo(cv->v)&gc_buildpath ) {
	    for ( layer = ly_back; layer<cv->b.sc->layer_cnt; ++layer ) if ( cv->b.sc->layers[layer].images!=NULL ) {
		if (( sf->multilayer && ((( cv->showback[0]&1 || cvlayer==layer) && layer==ly_back ) ||
			    ((cv->showfore || cvlayer==layer) && layer>ly_back)) ) ||
		    ( !sf->multilayer && (((cv->showfore && cvlayer==layer) && layer==ly_fore) ||
			    (((cv->showback[layer>>5]&(1<<(layer&31))) || cvlayer==layer) && layer!=ly_fore))) ) {
		    /* This really should be after the grids, but then it would completely*/
		    /*  hide them. */
		    DrawImageList(cv,pixmap,cv->b.sc->layers[layer].images);
		}
	    }
	    cv->back_img_out_of_date = false;
	    if ( cv->showhhints || cv->showvhints || cv->showdhints || cv->showblues || cv->showfamilyblues)
		CVShowHints(cv,pixmap);
	} else if ( cv->back_img_out_of_date ) {
	    GDrawFillRect(cv->backimgs,NULL,view_bgcol);
	    if ( cv->showhhints || cv->showvhints || cv->showdhints || cv->showblues || cv->showfamilyblues)
		CVShowHints(cv,cv->backimgs);
	    for ( layer = ly_back; layer<cv->b.sc->layer_cnt; ++layer ) if ( cv->b.sc->layers[layer].images!=NULL ) {
		if (( sf->multilayer && ((( cv->showback[0]&1 || cvlayer==layer) && layer==ly_back ) ||
			    ((cv->showfore || cvlayer==layer) && layer>ly_back)) ) ||
		    ( !sf->multilayer && (((cv->showfore && cvlayer==layer) && layer==ly_fore) ||
			    (((cv->showback[layer>>5]&(1<<(layer&31))) || cvlayer==layer) && layer!=ly_fore))) ) {
		    /* This really should be after the grids, but then it would completely*/
		    /*  hide them. */
		    if ( cv->back_img_out_of_date )
			DrawImageList(cv,cv->backimgs,cv->b.sc->layers[layer].images);
		}
	    }
	    cv->back_img_out_of_date = false;
	}
	if ( cv->backimgs!=NULL ) {
	    GRect r;
	    r.x = r.y = 0; r.width = cv->width; r.height = cv->height;
	    GDrawDrawPixmap(pixmap,cv->backimgs,&r,0,0);
	} else if ( !(GDrawHasCairo(cv->v)&gc_buildpath) &&
		( cv->showhhints || cv->showvhints || cv->showdhints || cv->showblues || cv->showfamilyblues)) {
	    /* if we've got bg images (and we're showing them) then the hints live in */
	    /*  the bg image pixmap (else they get overwritten by the pixmap) */
	    CVShowHints(cv,pixmap);
	}

@iorsh iorsh mentioned this pull request Sep 28, 2025
17 tasks
@iorsh iorsh merged commit 07da9d3 into fontforge:master Oct 2, 2025
7 checks passed
@frank-trampe
Copy link
Contributor

This is fine to merge. I am still puzzling over it, though. Was the idea perhaps to be able to redraw the foreground continuously without redrawing the background?

@iorsh
Copy link
Contributor

iorsh commented Oct 5, 2025

This is fine to merge. I am still puzzling over it, though. Was the idea perhaps to be able to redraw the foreground continuously without redrawing the background?

That sounds reasonable. Maybe this approach could have been implemented for GDK too, but with the modern hardware the delay is probably unnoticeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants