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

Commit bb1a1d43 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Hook up transforms to SkiaRE

There are 2 types of transforms that we need to consider:
- Display transforms: for outputs with different sizes and translations
- Layer transforms: used for scaling and translating individual layers

Screen rotation has not been addressed by this CL.

Test: visual
Test: atest LayerTypeAndRenderTypeTransactionTest
Bug: 164223050
Change-Id: I9d6a65bdd1ceaff2cdc9c501cd66f3a1cdcb3691
parent 21f348ec
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -389,7 +389,17 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
        return BAD_VALUE;
    }
    auto canvas = surface->getCanvas();

    canvas->save();

    // Before doing any drawing, let's make sure that we'll start at the origin of the display.
    // Some displays don't start at 0,0 for example when we're mirroring the screen. Also, virtual
    // displays might have different scaling when compared to the physical screen.
    canvas->translate(display.physicalDisplay.left, display.physicalDisplay.top);
    const auto scaleX = static_cast<SkScalar>(display.physicalDisplay.width()) /
            static_cast<SkScalar>(display.clip.width());
    const auto scaleY = static_cast<SkScalar>(display.physicalDisplay.height()) /
            static_cast<SkScalar>(display.clip.height());
    canvas->scale(scaleX, scaleY);
    canvas->clipRect(SkRect::MakeLTRB(display.clip.left, display.clip.top, display.clip.right,
                                      display.clip.bottom));
    canvas->drawColor(0, SkBlendMode::kSrc);
@@ -428,16 +438,22 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
            paint.setColor(SkColor4f{.fR = color.r, .fG = color.g, .fB = color.b, layer->alpha});
        }

        // Layers have a local transform matrix that should be applied to them.
        canvas->save();
        canvas->concat(getSkM44(layer->geometry.positionTransform));

        if (layer->geometry.roundedCornersRadius > 0) {
            canvas->drawRRect(getRoundedRect(layer), paint);
        } else {
            canvas->drawRect(dest, paint);
        }
        canvas->restore();
    }
    {
        ATRACE_NAME("flush surface");
        surface->flush();
    }
    canvas->restore();

    if (drawFence != nullptr) {
        *drawFence = flush();
@@ -471,6 +487,13 @@ inline SkRRect SkiaGLRenderEngine::getRoundedRect(const LayerSettings* layer) {
    return SkRRect::MakeRectXY(rect, cornerRadius, cornerRadius);
}

inline SkM44 SkiaGLRenderEngine::getSkM44(const mat4& matrix) {
    return SkM44(matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
                 matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
                 matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
                 matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);
}

size_t SkiaGLRenderEngine::getMaxTextureSize() const {
    return mGrContext->maxTextureSize();
}
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ private:
    static EGLSurface createPlaceholderEglPbufferSurface(EGLDisplay display, EGLConfig config,
                                                         int hwcFormat, Protection protection);
    inline SkRRect getRoundedRect(const LayerSettings* layer);
    inline SkM44 getSkM44(const mat4& matrix);

    base::unique_fd flush();
    bool waitFence(base::unique_fd fenceFd);