Bug 1508378 - Fix round error when damage rect size/position is odd number and scale factor is used, r=lsalzman

We have rendering artifacts when sceen scale is set and damage size/position is odd number.
It's caused by round error so update the size/position accordingly.

Differential Revision: https://phabricator.services.mozilla.com/D26903

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Martin Stransky 2019-04-10 14:17:28 +00:00
Родитель afbad5faf0
Коммит f8f3c43a24
2 изменённых файлов: 23 добавлений и 3 удалений

Просмотреть файл

@ -629,6 +629,23 @@ static void WaylandBufferDelayCommitHandler(WindowSurfaceWayland** aSurface) {
}
}
void WindowSurfaceWayland::CalcRectScale(LayoutDeviceIntRect& aRect, int aScale) {
if (aRect.x & 0x1) {
aRect.width += 1;
}
aRect.x = aRect.x / aScale;
if (aRect.y & 0x1) {
aRect.height += 1;
}
aRect.y = aRect.y / aScale;
aRect.width = (aRect.width & 0x1) ? aRect.width / aScale + 1 :
aRect.width / aScale;
aRect.height = (aRect.height & 0x1) ? aRect.height / aScale + 1 :
aRect.height / aScale;
}
void WindowSurfaceWayland::CommitWaylandBuffer() {
MOZ_ASSERT(mPendingCommit, "Committing empty surface!");
@ -684,11 +701,13 @@ void WindowSurfaceWayland::CommitWaylandBuffer() {
gint scaleFactor = mWindow->GdkScaleFactor();
for (auto iter = mWaylandBufferDamage.RectIter(); !iter.Done();
iter.Next()) {
const mozilla::LayoutDeviceIntRect& r = iter.Get();
mozilla::LayoutDeviceIntRect r = iter.Get();
// We need to remove the scale factor because the wl_surface_damage
// also multiplies by current scale factor.
wl_surface_damage(waylandSurface, r.x / scaleFactor, r.y / scaleFactor,
r.width / scaleFactor, r.height / scaleFactor);
if (scaleFactor > 1) {
CalcRectScale(r, scaleFactor);
}
wl_surface_damage(waylandSurface, r.x, r.y, r.width, r.height);
}
}

Просмотреть файл

@ -101,6 +101,7 @@ class WindowSurfaceWayland : public WindowSurface {
const gfx::IntSize& aLockSize);
bool CommitImageSurfaceToWaylandBuffer(const LayoutDeviceIntRegion& aRegion);
void CommitWaylandBuffer();
void CalcRectScale(LayoutDeviceIntRect& aRect, int scale);
// TODO: Do we need to hold a reference to nsWindow object?
nsWindow* mWindow;