Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Eleven: Commit

packages/apps/Eleven


Commit MetaInfo

Revisiond378526526f5ae93a99a89176ee0a2afc452a356 (tree)
Time2018-05-31 18:26:24
AuthorMatthias Yzusqui <myzb.dev@gmai...>
CommiterSimon Shields

Log Message

Eleven: Catch unsupported bitmap exception

Android's renderscript allocation class only supports creating
elements from ALPHA_8, ARGB_4444, ARGB_8888 and RGB_565 bitmaps.

Change-Id: Ib3e40755e7eacd9725b97ae9ab4bde34c6eec70d

Change Summary

Incremental Difference

--- a/src/org/lineageos/eleven/cache/BlurBitmapWorkerTask.java
+++ b/src/org/lineageos/eleven/cache/BlurBitmapWorkerTask.java
@@ -23,6 +23,7 @@ import android.support.v8.renderscript.Allocation;
2323 import android.support.v8.renderscript.Element;
2424 import android.support.v8.renderscript.RenderScript;
2525 import android.support.v8.renderscript.ScriptIntrinsicBlur;
26+import android.util.Log;
2627 import android.widget.ImageView;
2728
2829 import org.lineageos.eleven.cache.ImageWorker.ImageType;
@@ -35,6 +36,9 @@ import java.lang.ref.WeakReference;
3536 * BlurScrimImage
3637 */
3738 public class BlurBitmapWorkerTask extends BitmapWorkerTask<String, Void, BlurBitmapWorkerTask.ResultContainer> {
39+
40+ private static final String TAG = BlurBitmapWorkerTask.class.getSimpleName();
41+
3842 // if the image is too small, the blur will look bad post scale up so we use the min size
3943 // to scale up before bluring
4044 private static final int MIN_BITMAP_SIZE = 500;
@@ -114,19 +118,24 @@ public class BlurBitmapWorkerTask extends BitmapWorkerTask<String, Void, BlurBit
114118
115119 // run the blur multiple times
116120 for (int i = 0; i < NUM_BLUR_RUNS; i++) {
117- final Allocation inputAlloc = Allocation.createFromBitmap(mRenderScript, input);
118- final Allocation outputAlloc = Allocation.createTyped(mRenderScript,
119- inputAlloc.getType());
120- final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(mRenderScript,
121- Element.U8_4(mRenderScript));
122-
123- script.setRadius(BLUR_RADIUS);
124- script.setInput(inputAlloc);
125- script.forEach(outputAlloc);
126- outputAlloc.copyTo(output);
127-
128- // if we run more than 1 blur, the new input should be the old output
129- input = output;
121+ try {
122+ final Allocation inputAlloc = Allocation.createFromBitmap(mRenderScript, input);
123+ final Allocation outputAlloc = Allocation.createTyped(mRenderScript,
124+ inputAlloc.getType());
125+ final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(mRenderScript,
126+ Element.U8_4(mRenderScript));
127+
128+ script.setRadius(BLUR_RADIUS);
129+ script.setInput(inputAlloc);
130+ script.forEach(outputAlloc);
131+ outputAlloc.copyTo(output);
132+
133+ // if we run more than 1 blur, the new input should be the old output
134+ input = output;
135+ } catch (RuntimeException e) {
136+ Log.w(TAG, "Cannot blur image. " + e.getMessage());
137+ break;
138+ }
130139 }
131140
132141 // Set the scrim color to be 50% gray
Show on old repository browser