summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorLu, Shenghua <shenghua.lu@intel.com>2013-11-14 15:52:22 +0800
committerGuobin Zhang <guobin.zhang@intel.com>2014-04-25 16:11:13 +0800
commitea42e015277687cef168f960252b9d7596ff1160 (patch)
tree268a67e69aa3831d80add968e502eb03fa3d313f /libs
parent1e4cad8198056a5e27a7aeb104ceb8ada331eafe (diff)
downloadframeworks_base-ea42e015277687cef168f960252b9d7596ff1160.zip
frameworks_base-ea42e015277687cef168f960252b9d7596ff1160.tar.gz
frameworks_base-ea42e015277687cef168f960252b9d7596ff1160.tar.bz2
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: Shenghua Lu <shenghua.lu@intel.com> Signed-off-by: Shuo Gao <shuo.gao@intel.com>
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/FontRenderer.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 0be17ff..8d19ca2 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -735,30 +735,34 @@ 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);
}
-
- 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,
+ *image);
+ RSC::sp<RSC::Allocation> aout = RSC::Allocation::createTyped(mRs, t,
+ RS_ALLOCATION_MIPMAP_NONE,
+ RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED,
+ outImage);
+
+ mRsScript->setRadius(radius);
+ mRsScript->setInput(ain);
+ mRsScript->forEach(aout);
+
+ // replace the original image's pointer, avoiding a copy back to the original buffer
+ free(*image);
+ *image = outImage;
- 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,
- *image);
- RSC::sp<RSC::Allocation> aout = RSC::Allocation::createTyped(mRs, t,
- RS_ALLOCATION_MIPMAP_NONE, RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED,
- outImage);
-
- mRsScript->setRadius(radius);
- mRsScript->setInput(ain);
- mRsScript->forEach(aout);
-
- // replace the original image's pointer, avoiding a copy back to the original buffer
- free(*image);
- *image = outImage;
-
- return;
+ return;
+ }
}
#endif