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

Commit b801a98e authored by Vishnu Nair's avatar Vishnu Nair
Browse files

CompositionEngine: Update blur state correctly

Previously when blur state (blur radius or blur region) was
updated, we would recompute visible regions. This is not
necessary and triggers expensive visible region checks that
may contribute to sf missing the frame deadline.

Fix this by only triggering a visible region change if we
start or stop drawing blur. In addition, when visible region
does not change, update the blur parameters so Composition
Engine picks up the most up-to-date blur parameters.

Test: atest libcompositionengine_test
Fixes: 202589767

Change-Id: I442f190d92d6b911bb6bd9b4a440e0dcdbd7fb2e
parent e6adce59
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -421,8 +421,6 @@ void Layer::prepareBasicGeometryCompositionState() {

    compositionState->blendMode = static_cast<Hwc2::IComposerClient::BlendMode>(blendMode);
    compositionState->alpha = alpha;
    compositionState->backgroundBlurRadius = drawingState.backgroundBlurRadius;
    compositionState->blurRegions = drawingState.blurRegions;
    compositionState->stretchEffect = getStretchEffect();
}

@@ -498,6 +496,9 @@ void Layer::preparePerFrameCompositionState() {
        compositionState->stretchEffect.hasEffect()) {
        compositionState->forceClientComposition = true;
    }
    // If there are no visible region changes, we still need to update blur parameters.
    compositionState->blurRegions = drawingState.blurRegions;
    compositionState->backgroundBlurRadius = drawingState.backgroundBlurRadius;
}

void Layer::prepareCursorCompositionState() {
@@ -938,8 +939,11 @@ bool Layer::setCornerRadius(float cornerRadius) {

bool Layer::setBackgroundBlurRadius(int backgroundBlurRadius) {
    if (mDrawingState.backgroundBlurRadius == backgroundBlurRadius) return false;

    // If we start or stop drawing blur then the layer's visibility state may change so increment
    // the magic sequence number.
    if (mDrawingState.backgroundBlurRadius == 0 || backgroundBlurRadius == 0) {
        mDrawingState.sequence++;
    }
    mDrawingState.backgroundBlurRadius = backgroundBlurRadius;
    mDrawingState.modified = true;
    setTransactionFlags(eTransactionNeeded);
@@ -972,6 +976,11 @@ bool Layer::setTransparentRegionHint(const Region& transparent) {
}

bool Layer::setBlurRegions(const std::vector<BlurRegion>& blurRegions) {
    // If we start or stop drawing blur then the layer's visibility state may change so increment
    // the magic sequence number.
    if (mDrawingState.blurRegions.size() == 0 || blurRegions.size() == 0) {
        mDrawingState.sequence++;
    }
    mDrawingState.blurRegions = blurRegions;
    mDrawingState.modified = true;
    setTransactionFlags(eTransactionNeeded);