Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1244b22b authored by Shawn Lin's avatar Shawn Lin Committed by Automerger Merge Worker
Browse files

Merge "Reland - Fix flicker when swiching resolution change" into tm-qpr-dev am: 5d83ecce

parents c260ddee 5d83ecce
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -86,30 +86,38 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {
        onUpdate()
    }

    fun onDisplayChanged(newDisplayUniqueId: String?) {
    fun updateConfiguration(newDisplayUniqueId: String?) {
        val info = DisplayInfo()
        context.display?.getDisplayInfo(info)
        val oldMode: Display.Mode? = displayMode
        val display: Display? = context.display
        displayMode = display?.mode
        displayMode = info.mode

        if (displayUniqueId != display?.uniqueId) {
            displayUniqueId = display?.uniqueId
            shouldDrawCutout = DisplayCutout.getFillBuiltInDisplayCutout(
                context.resources, displayUniqueId
            )
        }
        updateDisplayUniqueId(info.uniqueId)

        // Skip if display mode or cutout hasn't changed.
        if (!displayModeChanged(oldMode, displayMode) &&
                display?.cutout == displayInfo.displayCutout) {
                displayInfo.displayCutout == info.displayCutout &&
                displayRotation == info.rotation) {
            return
        }
        if (newDisplayUniqueId == display?.uniqueId) {
        if (newDisplayUniqueId == info.uniqueId) {
            displayRotation = info.rotation
            updateCutout()
            updateProtectionBoundingPath()
            onUpdate()
        }
    }

    open fun updateDisplayUniqueId(newDisplayUniqueId: String?) {
        if (displayUniqueId != newDisplayUniqueId) {
            displayUniqueId = newDisplayUniqueId
            shouldDrawCutout = DisplayCutout.getFillBuiltInDisplayCutout(
                    context.resources, displayUniqueId
            )
            invalidate()
        }
    }

    open fun updateRotation(rotation: Int) {
        displayRotation = rotation
        updateCutout()
+5 −34
Original line number Diff line number Diff line
@@ -456,7 +456,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
                    }
                }

                boolean needToUpdateProviderViews = false;
                final String newUniqueId = mDisplayInfo.uniqueId;
                if (!Objects.equals(newUniqueId, mDisplayUniqueId)) {
                    mDisplayUniqueId = newUniqueId;
@@ -474,37 +473,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
                        setupDecorations();
                        return;
                    }

                    if (mScreenDecorHwcLayer != null) {
                        updateHwLayerRoundedCornerDrawable();
                        updateHwLayerRoundedCornerExistAndSize();
                    }
                    needToUpdateProviderViews = true;
                }

                final float newRatio = getPhysicalPixelDisplaySizeRatio();
                if (mRoundedCornerResDelegate.getPhysicalPixelDisplaySizeRatio() != newRatio) {
                    mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(newRatio);
                    if (mScreenDecorHwcLayer != null) {
                        updateHwLayerRoundedCornerExistAndSize();
                    }
                    needToUpdateProviderViews = true;
                }

                if (needToUpdateProviderViews) {
                    updateOverlayProviderViews(null);
                } else {
                    updateOverlayProviderViews(new Integer[] {
                            mFaceScanningViewId,
                            R.id.display_cutout,
                            R.id.display_cutout_left,
                            R.id.display_cutout_right,
                            R.id.display_cutout_bottom,
                    });
                }

                if (mScreenDecorHwcLayer != null) {
                    mScreenDecorHwcLayer.onDisplayChanged(newUniqueId);
                }
            }
        };
@@ -1070,9 +1038,11 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
                && (newRotation != mRotation || displayModeChanged(mDisplayMode, newMod))) {
            mRotation = newRotation;
            mDisplayMode = newMod;
            mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(
                    getPhysicalPixelDisplaySizeRatio());
            if (mScreenDecorHwcLayer != null) {
                mScreenDecorHwcLayer.pendingConfigChange = false;
                mScreenDecorHwcLayer.updateRotation(mRotation);
                mScreenDecorHwcLayer.updateConfiguration(mDisplayUniqueId);
                updateHwLayerRoundedCornerExistAndSize();
                updateHwLayerRoundedCornerDrawable();
            }
@@ -1111,7 +1081,8 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
                context.getResources(), context.getDisplay().getUniqueId());
    }

    private void updateOverlayProviderViews(@Nullable Integer[] filterIds) {
    @VisibleForTesting
    void updateOverlayProviderViews(@Nullable Integer[] filterIds) {
        if (mOverlays == null) {
            return;
        }
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ class CutoutDecorProviderImpl(
        (view as? DisplayCutoutView)?.let { cutoutView ->
            cutoutView.setColor(tintColor)
            cutoutView.updateRotation(rotation)
            cutoutView.onDisplayChanged(displayUniqueId)
            cutoutView.updateConfiguration(displayUniqueId)
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ class FaceScanningOverlayProviderImpl(
            view.layoutParams = it
            (view as? FaceScanningOverlay)?.let { overlay ->
                overlay.setColor(tintColor)
                overlay.onDisplayChanged(displayUniqueId)
                overlay.updateConfiguration(displayUniqueId)
            }
        }
    }
+6 −11
Original line number Diff line number Diff line
@@ -78,23 +78,18 @@ class RoundedCornerResDelegate(
        reloadMeasures()
    }

    private fun reloadAll(newReloadToken: Int) {
        if (reloadToken == newReloadToken) {
            return
        }
        reloadToken = newReloadToken
        reloadRes()
        reloadMeasures()
    }

    fun updateDisplayUniqueId(newDisplayUniqueId: String?, newReloadToken: Int?) {
        if (displayUniqueId != newDisplayUniqueId) {
            displayUniqueId = newDisplayUniqueId
            newReloadToken ?.let { reloadToken = it }
            reloadRes()
            reloadMeasures()
        } else {
            newReloadToken?.let { reloadAll(it) }
        } else if (newReloadToken != null) {
            if (reloadToken == newReloadToken) {
                return
            }
            reloadToken = newReloadToken
            reloadMeasures()
        }
    }

Loading