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

Commit ea42e015 authored by Lu, Shenghua's avatar Lu, Shenghua Committed by Guobin Zhang
Browse files

libhwui: Handle the blurImage() implement once RS::init fail



Once the RS::init failed, go through the original single thread path,
this will avoid blocking the main thread(ANR), but we also should have
some implement in RenderScript component.

Change-Id: I3a21395ffd5bc144c15254893f425b1dd2643ba4
Signed-off-by: default avatarShenghua Lu <shenghua.lu@intel.com>
Signed-off-by: default avatarShuo Gao <shuo.gao@intel.com>
parent 1e4cad81
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
@@ -735,19 +735,22 @@ void FontRenderer::blurImage(uint8_t** image, int32_t width, int32_t height, int
            // a null path is OK because there are no custom kernels used
            // hence nothing gets cached by RS
            if (!mRs->init("", RSC::RS_INIT_LOW_LATENCY | RSC::RS_INIT_SYNCHRONOUS)) {
                mRs.clear();
                ALOGE("blur RS failed to init");
            }

            } else {
                mRsElement = RSC::Element::A_8(mRs);
                mRsScript = RSC::ScriptIntrinsicBlur::create(mRs, mRsElement);
            }

        }
        if (mRs != 0) {
            RSC::sp<const RSC::Type> t = RSC::Type::create(mRs, mRsElement, width, height, 0);
            RSC::sp<RSC::Allocation> ain = RSC::Allocation::createTyped(mRs, t,
                RS_ALLOCATION_MIPMAP_NONE, RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED,
                    RS_ALLOCATION_MIPMAP_NONE,
                    RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED,
                    *image);
            RSC::sp<RSC::Allocation> aout = RSC::Allocation::createTyped(mRs, t,
                RS_ALLOCATION_MIPMAP_NONE, RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED,
                    RS_ALLOCATION_MIPMAP_NONE,
                    RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED,
                    outImage);

            mRsScript->setRadius(radius);
@@ -760,6 +763,7 @@ void FontRenderer::blurImage(uint8_t** image, int32_t width, int32_t height, int

            return;
        }
    }
#endif

    float *gaussian = new float[2 * radius + 1];