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

Commit dcedc99b authored by Stan Iliev's avatar Stan Iliev Committed by android-build-merger
Browse files

DO NOT MERGE: Use GL_LINEAR filter when drawing scaled TextureView

am: 93ac4012

Change-Id: I969216b071ab42b9fa14ce3cfcd2b99a3ecc002c
parents 05f984a1 93ac4012
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -133,9 +133,10 @@ void DeferredLayerUpdater::doUpdateTexImage() {
        bool forceFilter = false;
        sp<GraphicBuffer> buffer = mSurfaceTexture->getCurrentBuffer();
        if (buffer != nullptr) {
            mLayer->setBufferSize(buffer->getWidth(), buffer->getHeight());
            // force filtration if buffer size != layer size
            forceFilter = mWidth != static_cast<int>(buffer->getWidth()) ||
                          mHeight != static_cast<int>(buffer->getHeight());
            forceFilter = mWidth != static_cast<int>(mLayer->getBufferWidth()) ||
                          mHeight != static_cast<int>(mLayer->getBufferHeight());
        }

#if DEBUG_RENDERER
+12 −0
Original line number Diff line number Diff line
@@ -94,6 +94,15 @@ public:
     */
    void postDecStrong();

    inline void setBufferSize(uint32_t width, uint32_t height) {
        mBufferWidth = width;
        mBufferHeight = height;
    }

    inline uint32_t getBufferWidth() const { return mBufferWidth; }

    inline uint32_t getBufferHeight() const { return mBufferHeight; }

protected:
    Layer(RenderState& renderState, Api api, sk_sp<SkColorFilter>, int alpha,
          SkBlendMode mode);
@@ -145,6 +154,9 @@ private:
     */
    mat4 transform;

    uint32_t mBufferWidth = 0;

    uint32_t mBufferHeight = 0;
};  // struct Layer

};  // namespace uirenderer
+10 −2
Original line number Diff line number Diff line
@@ -46,6 +46,11 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
    sk_sp<SkImage> layerImage;
    const int layerWidth = layer->getWidth();
    const int layerHeight = layer->getHeight();
    const int bufferWidth = layer->getBufferWidth();
    const int bufferHeight = layer->getBufferHeight();
    if (bufferWidth <= 0 || bufferHeight <=0) {
        return false;
    }
    if (layer->getApi() == Layer::Api::OpenGL) {
        GlLayer* glLayer = static_cast<GlLayer*>(layer);
        GrGLTextureInfo externalTexture;
@@ -57,7 +62,7 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
        // this is anticipated to have is that for some format types if we are not bound as an OES
        // texture we may get invalid results for SKP capture if we read back the texture.
        externalTexture.fFormat = GL_RGBA8;
        GrBackendTexture backendTexture(layerWidth, layerHeight, GrMipMapped::kNo, externalTexture);
        GrBackendTexture backendTexture(bufferWidth, bufferHeight, GrMipMapped::kNo, externalTexture);
        layerImage = SkImage::MakeFromTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin,
                                              kPremul_SkAlphaType, nullptr);
    } else {
@@ -76,7 +81,7 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
        flipV.setAll(1, 0, 0, 0, -1, 1, 0, 0, 1);
        textureMatrixInv.preConcat(flipV);
        textureMatrixInv.preScale(1.0f / layerWidth, 1.0f / layerHeight);
        textureMatrixInv.postScale(layerWidth, layerHeight);
        textureMatrixInv.postScale(bufferWidth, bufferHeight);
        SkMatrix textureMatrix;
        if (!textureMatrixInv.invert(&textureMatrix)) {
            textureMatrix = textureMatrixInv;
@@ -95,6 +100,9 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
        paint.setAlpha(layer->getAlpha());
        paint.setBlendMode(layer->getMode());
        paint.setColorFilter(layer->getColorSpaceWithFilter());
        if (layer->getForceFilter()) {
            paint.setFilterQuality(kLow_SkFilterQuality);
        }

        const bool nonIdentityMatrix = !matrix.isIdentity();
        if (nonIdentityMatrix) {