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

Commit 0c71308c authored by John Hoford's avatar John Hoford Committed by Android (Google) Code Review
Browse files

Merge "interruptible renderer" into gb-ub-photos-bryce

parents 7d62e546 17218987
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -96,6 +96,10 @@ public class CachingPipeline {
        sResources = null;
    }

    public void stop() {
        mEnvironment.setStop(true);
    }

    public synchronized void reset() {
        synchronized (CachingPipeline.class) {
            if (getRenderScriptContext() == null) {
@@ -170,6 +174,7 @@ public class CachingPipeline {
        }
        mEnvironment.setQuality(ImagePreset.QUALITY_PREVIEW);
        mEnvironment.setImagePreset(preset);
        mEnvironment.setStop(false);
    }

    public void setOriginal(Bitmap bitmap) {
@@ -294,7 +299,9 @@ public class CachingPipeline {
                }

                Bitmap bmp = preset.apply(bitmap, mEnvironment);
                if (!mEnvironment.needsStop()) {
                    request.setBitmap(bmp);
                }
                mFiltersManager.freeFilterResources(preset);
            }
        }
+6 −3
Original line number Diff line number Diff line
@@ -117,9 +117,11 @@ public class FilteringPipeline implements Handler.Callback {
                } else {
                    mAccessoryPipeline.render(request);
                }
                if (request.getBitmap() != null) {
                    Message uimsg = mUIHandler.obtainMessage(NEW_RENDERING_REQUEST);
                    uimsg.obj = request;
                    mUIHandler.sendMessage(uimsg);
                }
                break;
            }
        }
@@ -185,6 +187,7 @@ public class FilteringPipeline implements Handler.Callback {
            return;
        }
        mHasUnhandledPreviewRequest = true;
        mHighresPreviewPipeline.stop();
        if (mProcessingHandler.hasMessages(COMPUTE_PRESET)) {
            return;
        }
+10 −0
Original line number Diff line number Diff line
@@ -35,6 +35,16 @@ public class FilterEnvironment {
    private int mQuality;
    private FiltersManager mFiltersManager;
    private CachingPipeline mCachingPipeline;
    private volatile boolean mStop = false;

    public synchronized boolean needsStop() {
        return mStop;
    }

    public synchronized void setStop(boolean stop) {
        this.mStop = stop;
    }

    private HashMap<Long, WeakReference<Bitmap>>
            bitmapCach = new HashMap<Long, WeakReference<Bitmap>>();

+3 −0
Original line number Diff line number Diff line
@@ -472,6 +472,9 @@ public class ImagePreset {
                    representation.synchronizeRepresentation();
                }
                bitmap = environment.applyRepresentation(representation, bitmap);
                if (environment.needsStop()) {
                    return bitmap;
                }
            }
        }