xfree86: deal with pitch that isn't a multiple of the granularity
When the pitch isn't a multiple of the granularity, allocate more space to compensate.
This commit is contained in:
parent
329f641727
commit
83080809f9
|
@ -368,10 +368,8 @@ AllocateArea(
|
||||||
/* look through the free boxes */
|
/* look through the free boxes */
|
||||||
for(i = 0; i < num; i++, boxp++) {
|
for(i = 0; i < num; i++, boxp++) {
|
||||||
x = boxp->x1;
|
x = boxp->x1;
|
||||||
if(granularity) {
|
if (granularity > 1)
|
||||||
int tmp = x % granularity;
|
x = ((x + granularity - 1) / granularity) * granularity;
|
||||||
if(tmp) x += (granularity - tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w))
|
if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w))
|
||||||
continue;
|
continue;
|
||||||
|
@ -398,10 +396,8 @@ AllocateArea(
|
||||||
|
|
||||||
boxp = &(link->area.box);
|
boxp = &(link->area.box);
|
||||||
x = boxp->x1;
|
x = boxp->x1;
|
||||||
if(granularity) {
|
if (granularity > 1)
|
||||||
int tmp = x % granularity;
|
x = ((x + granularity - 1) / granularity) * granularity;
|
||||||
if(tmp) x += (granularity - tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) {
|
if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) {
|
||||||
link = link->next;
|
link = link->next;
|
||||||
|
@ -685,10 +681,8 @@ localQueryLargestOffscreenArea(
|
||||||
|
|
||||||
while(nbox--) {
|
while(nbox--) {
|
||||||
x = pbox->x1;
|
x = pbox->x1;
|
||||||
if(granularity) {
|
if (granularity > 1)
|
||||||
int tmp = x % granularity;
|
x = ((x + granularity - 1) / granularity) * granularity;
|
||||||
if(tmp) x += (granularity - tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
w = pbox->x2 - x;
|
w = pbox->x2 - x;
|
||||||
h = pbox->y2 - pbox->y1;
|
h = pbox->y2 - pbox->y1;
|
||||||
|
@ -845,7 +839,9 @@ AllocateLinear(
|
||||||
while (linear) {
|
while (linear) {
|
||||||
/* Make sure we get a free area that's not an XY fallback case */
|
/* Make sure we get a free area that's not an XY fallback case */
|
||||||
if (!linear->area && linear->free) {
|
if (!linear->area && linear->free) {
|
||||||
offset = (linear->linear.offset + granularity) & ~granularity;
|
offset = linear->linear.offset;
|
||||||
|
if (granularity > 1)
|
||||||
|
offset = ((offset + granularity - 1) / granularity) * granularity;
|
||||||
end = offset+size;
|
end = offset+size;
|
||||||
if (end <= (linear->linear.offset + linear->linear.size))
|
if (end <= (linear->linear.offset + linear->linear.size))
|
||||||
break;
|
break;
|
||||||
|
@ -935,17 +931,20 @@ localAllocateOffscreenLinear(
|
||||||
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
|
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
|
||||||
pitch = extents->x2 - extents->x1;
|
pitch = extents->x2 - extents->x1;
|
||||||
|
|
||||||
if (gran && gran > pitch) {
|
if (gran > 1) {
|
||||||
/* we can't match the specified alignment with XY allocations */
|
if (gran > pitch) {
|
||||||
xfree(link);
|
/* we can't match the specified alignment with XY allocations */
|
||||||
return NULL;
|
xfree(link);
|
||||||
}
|
return NULL;
|
||||||
if (gran && (pitch % gran)) {
|
}
|
||||||
/* pitch and granularity aren't a perfect match, let's allocate
|
|
||||||
* a bit more so we can align later on
|
if (pitch % gran) {
|
||||||
*/
|
/* pitch and granularity aren't a perfect match, let's allocate
|
||||||
length += gran - 1;
|
* a bit more so we can align later on
|
||||||
}
|
*/
|
||||||
|
length += gran - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(length < pitch) { /* special case */
|
if(length < pitch) { /* special case */
|
||||||
w = length;
|
w = length;
|
||||||
|
@ -968,8 +967,8 @@ localAllocateOffscreenLinear(
|
||||||
linear->pScreen = pScreen;
|
linear->pScreen = pScreen;
|
||||||
linear->size = h * w;
|
linear->size = h * w;
|
||||||
linear->offset = (pitch * area->box.y1) + area->box.x1;
|
linear->offset = (pitch * area->box.y1) + area->box.x1;
|
||||||
if (gran && linear->offset % gran)
|
if (gran > 1)
|
||||||
linear->offset += gran - (linear->offset % gran);
|
linear->offset += ((linear->offset + gran - 1) / gran) * gran;
|
||||||
linear->granularity = gran;
|
linear->granularity = gran;
|
||||||
linear->MoveLinearCallback = moveCB;
|
linear->MoveLinearCallback = moveCB;
|
||||||
linear->RemoveLinearCallback = removeCB;
|
linear->RemoveLinearCallback = removeCB;
|
||||||
|
@ -1435,9 +1434,12 @@ xf86AllocateLinearOffscreenArea (
|
||||||
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
|
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
|
||||||
w = extents->x2 - extents->x1;
|
w = extents->x2 - extents->x1;
|
||||||
|
|
||||||
if(gran && ((gran > w) || (w % gran))) {
|
if (gran > 1) {
|
||||||
/* we can't match the specified alignment with XY allocations */
|
if (gran > w)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (w % gran)
|
||||||
|
length += gran - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(length <= w) { /* special case */
|
if(length <= w) { /* special case */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user