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

Commit 289e402d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[SF] Rename variables to match style" into rvc-dev

parents 9c6dd35a cfeebd4b
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -149,9 +149,9 @@ FloatRect OutputLayer::calculateOutputSourceCrop() const {
        // a modification of the axes of rotation. To account for this we
        // need to reorient the inverse rotation in terms of the current
        // axes of rotation.
        bool is_h_flipped = (invTransform & HAL_TRANSFORM_FLIP_H) != 0;
        bool is_v_flipped = (invTransform & HAL_TRANSFORM_FLIP_V) != 0;
        if (is_h_flipped == is_v_flipped) {
        bool isHFlipped = (invTransform & HAL_TRANSFORM_FLIP_H) != 0;
        bool isVFlipped = (invTransform & HAL_TRANSFORM_FLIP_V) != 0;
        if (isHFlipped == isVFlipped) {
            invTransform ^= HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_FLIP_H;
        }
        std::swap(winWidth, winHeight);
@@ -160,18 +160,18 @@ FloatRect OutputLayer::calculateOutputSourceCrop() const {
            activeCrop.transform(invTransform, bufferSize.getWidth(), bufferSize.getHeight());

    // below, crop is intersected with winCrop expressed in crop's coordinate space
    float xScale = crop.getWidth() / float(winWidth);
    float yScale = crop.getHeight() / float(winHeight);

    float insetL = winCrop.left * xScale;
    float insetT = winCrop.top * yScale;
    float insetR = (winWidth - winCrop.right) * xScale;
    float insetB = (winHeight - winCrop.bottom) * yScale;

    crop.left += insetL;
    crop.top += insetT;
    crop.right -= insetR;
    crop.bottom -= insetB;
    const float xScale = crop.getWidth() / float(winWidth);
    const float yScale = crop.getHeight() / float(winHeight);

    const float insetLeft = winCrop.left * xScale;
    const float insetTop = winCrop.top * yScale;
    const float insetRight = (winWidth - winCrop.right) * xScale;
    const float insetBottom = (winHeight - winCrop.bottom) * yScale;

    crop.left += insetLeft;
    crop.top += insetTop;
    crop.right -= insetRight;
    crop.bottom -= insetBottom;

    return crop;
}
+24 −24
Original line number Diff line number Diff line
@@ -158,19 +158,19 @@ void DisplayDevice::setProjection(ui::Rotation orientation, Rect viewport, Rect
    mOrientation = orientation;

    const Rect& displayBounds = getCompositionDisplay()->getState().bounds;
    const int w = displayBounds.width();
    const int h = displayBounds.height();
    const int displayWidth = displayBounds.width();
    const int displayHeight = displayBounds.height();

    ui::Transform R;
    ui::Transform rotation;
    if (const auto flags = ui::Transform::toRotationFlags(orientation);
        flags != ui::Transform::ROT_INVALID) {
        R.set(flags, w, h);
        rotation.set(flags, displayWidth, displayHeight);
    }

    if (!frame.isValid()) {
        // the destination frame can be invalid if it has never been set,
        // in that case we assume the whole display frame.
        frame = Rect(w, h);
        frame = Rect(displayWidth, displayHeight);
    }

    if (viewport.isEmpty()) {
@@ -178,45 +178,45 @@ void DisplayDevice::setProjection(ui::Rotation orientation, Rect viewport, Rect
        // we assume the whole display size.
        // it's also invalid to have an empty viewport, so we handle that
        // case in the same way.
        viewport = Rect(w, h);
        if (R.getOrientation() & ui::Transform::ROT_90) {
        viewport = Rect(displayWidth, displayHeight);
        if (rotation.getOrientation() & ui::Transform::ROT_90) {
            // viewport is always specified in the logical orientation
            // of the display (ie: post-rotation).
            std::swap(viewport.right, viewport.bottom);
        }
    }

    ui::Transform TL, TP, S;
    float src_width  = viewport.width();
    float src_height = viewport.height();
    float dst_width  = frame.width();
    float dst_height = frame.height();
    if (src_width != dst_width || src_height != dst_height) {
        float sx = dst_width  / src_width;
        float sy = dst_height / src_height;
        S.set(sx, 0, 0, sy);
    ui::Transform logicalTranslation, physicalTranslation, scale;
    const float sourceWidth = viewport.width();
    const float sourceHeight = viewport.height();
    const float destWidth = frame.width();
    const float destHeight = frame.height();
    if (sourceWidth != destWidth || sourceHeight != destHeight) {
        const float scaleX = destWidth / sourceWidth;
        const float scaleY = destHeight / sourceHeight;
        scale.set(scaleX, 0, 0, scaleY);
    }

    float src_x = viewport.left;
    float src_y = viewport.top;
    float dst_x = frame.left;
    float dst_y = frame.top;
    TL.set(-src_x, -src_y);
    TP.set(dst_x, dst_y);
    const float sourceX = viewport.left;
    const float sourceY = viewport.top;
    const float destX = frame.left;
    const float destY = frame.top;
    logicalTranslation.set(-sourceX, -sourceY);
    physicalTranslation.set(destX, destY);

    // need to take care of primary display rotation for globalTransform
    // for case if the panel is not installed aligned with device orientation
    if (isPrimary()) {
        if (const auto flags = ui::Transform::toRotationFlags(orientation + mPhysicalOrientation);
            flags != ui::Transform::ROT_INVALID) {
            R.set(flags, w, h);
            rotation.set(flags, displayWidth, displayHeight);
        }
    }

    // The viewport and frame are both in the logical orientation.
    // Apply the logical translation, scale to physical size, apply the
    // physical translation and finally rotate to the physical orientation.
    ui::Transform globalTransform = R * TP * S * TL;
    ui::Transform globalTransform = rotation * physicalTranslation * scale * logicalTranslation;

    const uint8_t type = globalTransform.getType();
    const bool needsFiltering =
+4 −4
Original line number Diff line number Diff line
@@ -66,15 +66,15 @@ std::unique_ptr<DispSync> createDispSync() {
    // TODO (140302863) remove this and use the vsync_reactor system.
    if (property_get_bool("debug.sf.vsync_reactor", true)) {
        // TODO (144707443) tune Predictor tunables.
        static constexpr int default_rate = 60;
        static constexpr auto initial_period =
                std::chrono::duration<nsecs_t, std::ratio<1, default_rate>>(1);
        static constexpr int defaultRate = 60;
        static constexpr auto initialPeriod =
                std::chrono::duration<nsecs_t, std::ratio<1, defaultRate>>(1);
        static constexpr size_t vsyncTimestampHistorySize = 20;
        static constexpr size_t minimumSamplesForPrediction = 6;
        static constexpr uint32_t discardOutlierPercent = 20;
        auto tracker = std::make_unique<
                scheduler::VSyncPredictor>(std::chrono::duration_cast<std::chrono::nanoseconds>(
                                                   initial_period)
                                                   initialPeriod)
                                                   .count(),
                                           vsyncTimestampHistorySize, minimumSamplesForPrediction,
                                           discardOutlierPercent);