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

Commit 5a663768 authored by Leon Scroggins III's avatar Leon Scroggins III Committed by Leon Scroggins
Browse files

Use filtering when drawing nine-patches

Bug: 77917978
Test: Look at toggles; CtsUiRenderingTestCases

Prior to this change, the toggles look pixelated due to using a
"nearest" filter instead of a "bilerp".

This matches the behavior of the hwui renderer.

Depends on changes in Skia (Ib7d0abdd51981bddf36ec5c3fd84bb651f405f0f)
to respect the filter quality when drawing to a GPU canvas and to
remove the resulting "bleeding" effect from drawImageLattice.

Change-Id: I59d81a17f351e18574539479a38a580a02e1619b
parent 4a7913c2
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -219,8 +219,20 @@ void SkiaRecordingCanvas::drawNinePatch(Bitmap& bitmap, const Res_png_9patch& ch
    SkPaint tmpPaint;
    sk_sp<SkColorFilter> colorFilter;
    sk_sp<SkImage> image = bitmap.makeImage(&colorFilter);
    mRecorder.drawImageLattice(image.get(), lattice, dst,
                               bitmapPaint(paint, &tmpPaint, colorFilter));
    const SkPaint* filteredPaint = bitmapPaint(paint, &tmpPaint, colorFilter);
    // Besides kNone, the other three SkFilterQualities are treated the same. And Android's
    // Java API only supports kLow and kNone anyway.
    if (!filteredPaint || filteredPaint->getFilterQuality() == kNone_SkFilterQuality) {
        if (filteredPaint != &tmpPaint) {
            if (paint) {
                tmpPaint = *paint;
            }
            filteredPaint = &tmpPaint;
        }
        tmpPaint.setFilterQuality(kLow_SkFilterQuality);
    }

    mRecorder.drawImageLattice(image.get(), lattice, dst, filteredPaint);
    if (!bitmap.isImmutable() && image.get() && !image->unique() && !dst.isEmpty()) {
        mDisplayList->mMutableImages.push_back(image.get());
    }