Commit a6ad02ea authored by Marco Trevisan's avatar Marco Trevisan

xf86Crtc: keep transformation filters used by crtcs around

Make a temporary copy and restore it once we might need them, as they might get
free'd by the server in the mean time.

Fixes #14
parent e6cd1c9b
Pipeline #9072 failed with stage
in 24 seconds
......@@ -152,6 +152,7 @@ xf86CrtcDestroy(xf86CrtcPtr crtc)
xf86_config->num_crtc--;
break;
}
RRTransformFini(&crtc->transform);
free(crtc->params);
free(crtc->gamma_red);
free(crtc);
......@@ -260,6 +261,58 @@ xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen)
PictureSetSubpixelOrder(pScreen, subpixel_order);
}
static Bool
xf86CrtcCopyTransformFilter(RRTransformPtr transform)
{
PictFilterRec *filter;
PictFilterRec *filterCopy;
filter = transform->filter;
if (filter->temp_copy)
return TRUE;
filterCopy = malloc(sizeof(PictFilterRec));
if (!filterCopy)
return FALSE;
memcpy(filterCopy, filter, sizeof(PictFilterRec));
filterCopy->name = strdup(filter->name);
filterCopy->temp_copy = TRUE;
transform->filter = filterCopy;
return TRUE;
}
static Bool
xf86CrtcTryRestoreTransformFilterCopy(ScreenPtr pScreen, RRTransformPtr transform)
{
PictFilterPtr actualFilter;
PictFilterPtr filterCopy;
if (!transform->filter->temp_copy)
return TRUE;
filterCopy = transform->filter;
actualFilter = PictureFindFilter(pScreen, filterCopy->name, -1);
if (!actualFilter) {
PictureAddFilter(pScreen, filterCopy->name, filterCopy->ValidateParams,
filterCopy->width, filterCopy->height);
actualFilter = PictureFindFilter(pScreen, filterCopy->name, -1);
}
free(filterCopy->name);
free(filterCopy);
if (!actualFilter) {
transform->filter = NULL;
return FALSE;
}
transform->filter = actualFilter;
return TRUE;
}
/**
* Sets the given video mode on the given crtc
*/
......@@ -295,7 +348,8 @@ xf86CrtcSetModeTransform(xf86CrtcPtr crtc, DisplayModePtr mode,
saved_x = crtc->x;
saved_y = crtc->y;
saved_rotation = crtc->rotation;
if (crtc->transformPresent) {
if (crtc->transformPresent &&
xf86CrtcTryRestoreTransformFilterCopy(scrn->pScreen, &crtc->transform)) {
RRTransformInit(&saved_transform);
RRTransformCopy(&saved_transform, &crtc->transform);
}
......@@ -774,6 +828,16 @@ xf86CrtcCloseScreen(ScreenPtr screen)
xf86CrtcPtr crtc = config->crtc[c];
crtc->randr_crtc = NULL;
if (crtc->transformPresent) {
&crtc->transform, crtc->transform.filter);
if (!xf86CrtcCopyTransformFilter(&crtc->transform))
crtc->transformPresent = FALSE;
}
if (crtc->desiredTransformPresent) {
if (!xf86CrtcCopyTransformFilter(&crtc->desiredTransform))
crtc->desiredTransformPresent = FALSE;
}
}
screen->CloseScreen = config->CloseScreen;
......@@ -2822,12 +2886,17 @@ xf86SetDesiredModes(ScrnInfoPtr scrn)
crtc->desiredTransformPresent = FALSE;
crtc->desiredX = 0;
crtc->desiredY = 0;
RRTransformFini(&crtc->desiredTransform);
}
if (crtc->desiredTransformPresent)
if (crtc->desiredTransformPresent &&
xf86CrtcTryRestoreTransformFilterCopy(scrn->pScreen,
&crtc->desiredTransform)) {
transform = &crtc->desiredTransform;
else
} else {
crtc->desiredTransformPresent = FALSE;
transform = NULL;
}
if (xf86CrtcSetModeTransform
(crtc, &crtc->desiredMode, crtc->desiredRotation, transform,
crtc->desiredX, crtc->desiredY)) {
......@@ -2968,6 +3037,7 @@ xf86SetSingleMode(ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
crtc->desiredTransformPresent = FALSE;
crtc->desiredX = 0;
crtc->desiredY = 0;
RRTransformFini(&crtc->desiredTransform);
}
}
xf86DisableUnusedFunctions(pScrn);
......
......@@ -37,6 +37,10 @@ RRTransformInit(RRTransformPtr transform)
void
RRTransformFini(RRTransformPtr transform)
{
if (transform->filter && transform->filter->temp_copy) {
free(transform->filter->name);
free(transform->filter);
}
free(transform->params);
}
......
......@@ -157,6 +157,7 @@ PictureAddFilter(ScreenPtr pScreen,
ps->filters[i].ValidateParams = ValidateParams;
ps->filters[i].width = width;
ps->filters[i].height = height;
ps->filters[i].temp_copy = FALSE;
return id;
}
......
......@@ -168,6 +168,7 @@ typedef struct {
int id;
PictFilterValidateParamsProcPtr ValidateParams;
int width, height;
Bool temp_copy;
} PictFilterRec, *PictFilterPtr;
#define PictFilterNearest 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment