private static final int SELECT_PICTURE = 1;
private static final String LOGTAG = "FilterShowActivity";
- protected static final boolean ANIMATE_PANELS = true;
private boolean mShowingTinyPlanet = false;
private boolean mShowingImageStatePanel = false;
private WeakReference<ProgressDialog> mSavingProgressDialog;
private LoadBitmapTask mLoadBitmapTask;
- private boolean mLoading = true;
private Uri mOriginalImageUri = null;
private ImagePreset mOriginalPreset = null;
}
private void startLoadBitmap(Uri uri) {
- mLoading = true;
final View loading = findViewById(R.id.loading);
final View imageShow = findViewById(R.id.imageShow);
imageShow.setVisibility(View.INVISIBLE);
if (mAction == TINY_PLANET_ACTION) {
showRepresentation(mCategoryFiltersAdapter.getTinyPlanet());
}
- mLoading = false;
+
MasterImage.getImage().notifyGeometryChange();
LoadHighresBitmapTask highresLoad = new LoadHighresBitmapTask();
highresLoad.execute();
mImage.set(r.mImage);
}
+ @Override
+ public boolean equals(FilterRepresentation rep) {
+ if (!(rep instanceof FilterCropRepresentation)) {
+ return false;
+ }
+ FilterCropRepresentation crop = (FilterCropRepresentation) rep;
+ if (mCrop.bottom != crop.mCrop.bottom
+ || mCrop.left != crop.mCrop.left
+ || mCrop.right != crop.mCrop.right
+ || mCrop.top != crop.mCrop.top
+ || mImage.bottom != crop.mImage.bottom
+ || mImage.left != crop.mImage.left
+ || mImage.right != crop.mImage.right
+ || mImage.top != crop.mImage.top) {
+ return false;
+ }
+ return true;
+ }
+
public RectF getCrop() {
return new RectF(mCrop);
}
mMirrorRep.set(g.mMirrorRep);
}
+ @Override
+ public boolean equals(FilterRepresentation rep) {
+ if (!(rep instanceof GeometryMetadata)) {
+ return false;
+ }
+ GeometryMetadata geo = (GeometryMetadata) rep;
+ if (geo.mScaleFactor != mScaleFactor
+ || !geo.mRotationRep.equals(mRotationRep)
+ || !geo.mStraightenRep.equals(mStraightenRep)
+ || !geo.mCropRep.equals(mCropRep)
+ || !geo.mMirrorRep.equals(mMirrorRep)) {
+ return false;
+ }
+ return true;
+ }
+
public float getScaleFactor() {
return mScaleFactor;
}
public Bitmap process(Bitmap originalBitmap,
Vector<FilterRepresentation> filters,
FilterEnvironment environment) {
- Bitmap cacheBitmap = originalBitmap;
+
+ if (filters.size() == 0) {
+ return originalBitmap;
+ }
// New set of filters, let's clear the cache and rebuild it.
if (filters.size() != mSteps.size()) {
// First, let's find how similar we are in our cache
// compared to the current list of filters
- int similarUpToIndex = 0;
+ int similarUpToIndex = -1;
for (int i = 0; i < filters.size(); i++) {
FilterRepresentation representation = filters.elementAt(i);
CacheStep step = mSteps.elementAt(i);
}
// Now, let's get the earliest cached result in our pipeline
+ Bitmap cacheBitmap = null;
int findBaseImageIndex = similarUpToIndex;
- while (findBaseImageIndex > 0
- && mSteps.elementAt(findBaseImageIndex).cache == null) {
- findBaseImageIndex--;
+ if (findBaseImageIndex > -1) {
+ while (findBaseImageIndex > 0
+ && mSteps.elementAt(findBaseImageIndex).cache == null) {
+ findBaseImageIndex--;
+ }
+ cacheBitmap = mSteps.elementAt(findBaseImageIndex).cache;
}
- cacheBitmap = mSteps.elementAt(findBaseImageIndex).cache;
boolean emptyStack = false;
if (cacheBitmap == null) {
emptyStack = true;
// Damn, it's an empty stack, we have to start from scratch
// TODO: use a bitmap cache + RS allocation instead of Bitmap.copy()
cacheBitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true);
+ if (findBaseImageIndex > -1) {
+ FilterRepresentation representation = filters.elementAt(findBaseImageIndex);
+ cacheBitmap = environment.applyRepresentation(representation, cacheBitmap);
+ mSteps.elementAt(findBaseImageIndex).representation = representation.copy();
+ mSteps.elementAt(findBaseImageIndex).cache = cacheBitmap;
+ }
if (DEBUG) {
Log.v(LOGTAG, "empty stack");
}
// rebuild the cache image for this step
if (!emptyStack) {
cacheBitmap = cacheBitmap.copy(Bitmap.Config.ARGB_8888, true);
+ } else {
+ // if it was an empty stack, we already applied it
+ findBaseImageIndex ++;
}
for (int i = findBaseImageIndex; i <= similarUpToIndex; i++) {
FilterRepresentation representation = filters.elementAt(i);