1 package com.android.gallery3d.filtershow.pipeline; 2 3 import android.graphics.Bitmap; 4 import com.android.gallery3d.filtershow.filters.FiltersManager; 5 6 public class FullresRenderingRequestTask extends ProcessingTask { 7 8 private CachingPipeline mFullresPipeline = null; 9 private boolean mPipelineIsOn = false; 10 11 public void setPreviewScaleFactor(float previewScale) { 12 mFullresPipeline.setPreviewScaleFactor(previewScale); 13 } 14 15 static class Render implements Request { 16 RenderingRequest request; 17 } 18 19 static class RenderResult implements Result { 20 RenderingRequest request; 21 } 22 23 public FullresRenderingRequestTask() { 24 mFullresPipeline = new CachingPipeline( 25 FiltersManager.getHighresManager(), "Fullres"); 26 } 27 28 public void setOriginal(Bitmap bitmap) { 29 mFullresPipeline.setOriginal(bitmap); 30 mPipelineIsOn = true; 31 } 32 33 public void stop() { 34 mFullresPipeline.stop(); 35 } 36 37 public void postRenderingRequest(RenderingRequest request) { 38 if (!mPipelineIsOn) { 39 return; 40 } 41 Render render = new Render(); 42 render.request = request; 43 postRequest(render); 44 } 45 46 @Override 47 public Result doInBackground(Request message) { 48 RenderingRequest request = ((Render) message).request; 49 RenderResult result = null; 50 mFullresPipeline.render(request); 51 result = new RenderResult(); 52 result.request = request; 53 return result; 54 } 55 56 @Override 57 public void onResult(Result message) { 58 if (message == null) { 59 return; 60 } 61 RenderingRequest request = ((RenderResult) message).request; 62 request.markAvailable(); 63 } 64 65 @Override 66 public boolean isDelayedTask() { return true; } 67 } 68