Loading src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java +12 −4 Original line number Diff line number Diff line Loading @@ -64,13 +64,16 @@ public abstract class ImageFilterRS extends ImageFilter { if (DEBUG) { Log.v(LOGTAG, "apply filter " + getName() + " in pipeline " + pipeline.getName()); } pipeline.prepareRenderscriptAllocations(bitmap); Resources rsc = pipeline.getResources(); if (pipeline.prepareRenderscriptAllocations(bitmap) || !isResourcesLoaded()) { freeResources(); createFilter(rsc, scaleFactor, quality); setResourcesLoaded(true); } bindScriptValues(); runFilter(); update(bitmap); freeResources(); if (DEBUG) { Log.v(LOGTAG, "DONE apply filter " + getName() + " in pipeline " + pipeline.getName()); } Loading Loading @@ -158,6 +161,11 @@ public abstract class ImageFilterRS extends ImageFilter { */ abstract protected void resetScripts(); /** * Scripts values should be bound here */ abstract protected void bindScriptValues(); public void freeResources() { if (!isResourcesLoaded()) { return; Loading src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java +10 −8 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ public class ImageFilterSharpen extends ImageFilterRS { private static final String LOGTAG = "ImageFilterSharpen"; private ScriptC_convolve3x3 mScript; float mScaleFactor; private FilterBasicRepresentation mParameters; Loading Loading @@ -63,19 +62,14 @@ public class ImageFilterSharpen extends ImageFilterRS { @Override protected void createFilter(android.content.res.Resources res, float scaleFactor, int quality) { int w = getInPixelsAllocation().getType().getX(); int h = getInPixelsAllocation().getType().getY(); mScaleFactor = scaleFactor; if (mScript == null) { mScript = new ScriptC_convolve3x3(getRenderScriptContext(), res, R.raw.convolve3x3); } mScript.set_gWidth(w); mScript.set_gHeight(h); } private void computeKernel() { float p1 = mParameters.getValue() * mScaleFactor; float scaleFactor = getEnvironment().getScaleFactor(); float p1 = mParameters.getValue() * scaleFactor; float value = p1 / 100.0f; float f[] = new float[9]; float p = value; Loading @@ -91,6 +85,14 @@ public class ImageFilterSharpen extends ImageFilterRS { mScript.set_gCoeffs(f); } @Override protected void bindScriptValues() { int w = getInPixelsAllocation().getType().getX(); int h = getInPixelsAllocation().getType().getY(); mScript.set_gWidth(w); mScript.set_gHeight(h); } @Override protected void runFilter() { if (mParameters == null) { Loading src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java +1 −0 Original line number Diff line number Diff line Loading @@ -77,4 +77,5 @@ public class FilterEnvironment { public void setCachingPipeline(CachingPipeline cachingPipeline) { mCachingPipeline = cachingPipeline; } } Loading
src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java +12 −4 Original line number Diff line number Diff line Loading @@ -64,13 +64,16 @@ public abstract class ImageFilterRS extends ImageFilter { if (DEBUG) { Log.v(LOGTAG, "apply filter " + getName() + " in pipeline " + pipeline.getName()); } pipeline.prepareRenderscriptAllocations(bitmap); Resources rsc = pipeline.getResources(); if (pipeline.prepareRenderscriptAllocations(bitmap) || !isResourcesLoaded()) { freeResources(); createFilter(rsc, scaleFactor, quality); setResourcesLoaded(true); } bindScriptValues(); runFilter(); update(bitmap); freeResources(); if (DEBUG) { Log.v(LOGTAG, "DONE apply filter " + getName() + " in pipeline " + pipeline.getName()); } Loading Loading @@ -158,6 +161,11 @@ public abstract class ImageFilterRS extends ImageFilter { */ abstract protected void resetScripts(); /** * Scripts values should be bound here */ abstract protected void bindScriptValues(); public void freeResources() { if (!isResourcesLoaded()) { return; Loading
src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java +10 −8 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ public class ImageFilterSharpen extends ImageFilterRS { private static final String LOGTAG = "ImageFilterSharpen"; private ScriptC_convolve3x3 mScript; float mScaleFactor; private FilterBasicRepresentation mParameters; Loading Loading @@ -63,19 +62,14 @@ public class ImageFilterSharpen extends ImageFilterRS { @Override protected void createFilter(android.content.res.Resources res, float scaleFactor, int quality) { int w = getInPixelsAllocation().getType().getX(); int h = getInPixelsAllocation().getType().getY(); mScaleFactor = scaleFactor; if (mScript == null) { mScript = new ScriptC_convolve3x3(getRenderScriptContext(), res, R.raw.convolve3x3); } mScript.set_gWidth(w); mScript.set_gHeight(h); } private void computeKernel() { float p1 = mParameters.getValue() * mScaleFactor; float scaleFactor = getEnvironment().getScaleFactor(); float p1 = mParameters.getValue() * scaleFactor; float value = p1 / 100.0f; float f[] = new float[9]; float p = value; Loading @@ -91,6 +85,14 @@ public class ImageFilterSharpen extends ImageFilterRS { mScript.set_gCoeffs(f); } @Override protected void bindScriptValues() { int w = getInPixelsAllocation().getType().getX(); int h = getInPixelsAllocation().getType().getY(); mScript.set_gWidth(w); mScript.set_gHeight(h); } @Override protected void runFilter() { if (mParameters == null) { Loading
src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java +1 −0 Original line number Diff line number Diff line Loading @@ -77,4 +77,5 @@ public class FilterEnvironment { public void setCachingPipeline(CachingPipeline cachingPipeline) { mCachingPipeline = cachingPipeline; } }