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

Commit a3a0c9d2 authored by John Reck's avatar John Reck
Browse files

Fix issue preventing launcher from unblocking UI thread

When using a hardware bitmap in a paint that's being filtered, the
lazy-generated image was being incorrectly added to mMutableImages
which would then fail to pin. The failure to pin would be treated
as cache exhaustion, preventing the unblocking of the UI thread

Test: perfetto trace of launcher
Flag: EXEMPT bugfix
Change-Id: I1aceae0fb5a379f93f9991713b7b4975ef8bbd7e
parent 41995c9d
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 */

#include "SkiaRecordingCanvas.h"
#include "hwui/Paint.h"

#include <SkBlendMode.h>
#include <SkData.h>
#include <SkDrawable.h>
@@ -24,12 +24,15 @@
#include <SkMatrix.h>
#include <SkPaint.h>
#include <SkPoint.h>
#include <SkRRect.h>
#include <SkRect.h>
#include <SkRefCnt.h>
#include <SkRRect.h>
#include <SkSamplingOptions.h>
#include <SkTypes.h>
#include <src/image/SkImage_Base.h>

#include "CanvasTransform.h"
#include "hwui/Paint.h"
#ifdef __ANDROID__ // Layoutlib does not support Layers
#include "Layer.h"
#include "LayerDrawable.h"
@@ -243,9 +246,17 @@ void SkiaRecordingCanvas::onFilterPaint(android::Paint& paint) {
    //  It's better than nothing, though
    SkImage* image = shader ? shader->isAImage(nullptr, nullptr) : nullptr;
    if (image) {
        // This could be a hardware bitmap, in which case the type will be kLazy and attempting
        // to pin the image will fail. This will incorrectly block us from releasing the UI
        // thread, hurting performance.
        // Inspect the type directly to handle this, as we know that if it's not kRasterPinnable
        // then it isn't a mutable bitmap.
        auto ib = as_IB(image);
        if (ib->type() == SkImage_Base::Type::kRasterPinnable) {
            mDisplayList->mMutableImages.push_back(image);
        }
    }
}

void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const Paint* paint) {
    auto payload = DrawImagePayload(bitmap);