diff options
63 files changed, 1129 insertions, 119 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index fb4e88b2a..00190572a 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -597,7 +597,7 @@ public class PhotoPage extends ActivityState implements @Override public boolean canDisplayBottomControls() { - return mIsActive && !mPhotoView.getFilmMode(); + return mIsActive; } @Override @@ -608,13 +608,14 @@ public class PhotoPage extends ActivityState implements switch(control) { case R.id.photopage_bottom_control_edit: return mHaveImageEditor && mShowBars + && !mPhotoView.getFilmMode() && (mCurrentPhoto.getSupportedOperations() & MediaItem.SUPPORT_EDIT) != 0 && mCurrentPhoto.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE; case R.id.photopage_bottom_control_panorama: return mIsPanorama; case R.id.photopage_bottom_control_tiny_planet: return mHaveImageEditor && mShowBars - && mIsPanorama360; + && mIsPanorama360 && !mPhotoView.getFilmMode(); default: return false; } diff --git a/src/com/android/gallery3d/app/PhotoPageBottomControls.java b/src/com/android/gallery3d/app/PhotoPageBottomControls.java index f416fe52f..415111fb9 100644 --- a/src/com/android/gallery3d/app/PhotoPageBottomControls.java +++ b/src/com/android/gallery3d/app/PhotoPageBottomControls.java @@ -116,6 +116,7 @@ public class PhotoPageBottomControls implements OnClickListener { control.startAnimation(getControlAnimForVisibility(curVisibility)); } control.setVisibility(curVisibility ? View.VISIBLE : View.INVISIBLE); + control.requestLayout(); // Kick framework to draw the control. mControlsVisible.put(control, curVisibility); } } diff --git a/src/com/android/gallery3d/filtershow/CenteredLinearLayout.java b/src/com/android/gallery3d/filtershow/CenteredLinearLayout.java index 16b969535..bc9342d6f 100644 --- a/src/com/android/gallery3d/filtershow/CenteredLinearLayout.java +++ b/src/com/android/gallery3d/filtershow/CenteredLinearLayout.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.android.gallery3d.filtershow; import android.content.Context; @@ -5,7 +21,6 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.util.AttributeSet; import android.util.TypedValue; -import android.view.View.MeasureSpec; import android.widget.LinearLayout; import com.android.gallery3d.R; diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 2851a2e74..c8c7421f1 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow; @@ -7,6 +22,7 @@ import android.app.Activity; import android.app.ProgressDialog; import android.content.ContentValues; import android.content.Intent; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -262,7 +278,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, listColors.removeView(v); filters[i].setParameter(filters[i].getPreviewParameter()); - if(v instanceof ImageButtonTitle) + if (v instanceof ImageButtonTitle) filters[i].setName(((ImageButtonTitle) v).getText()); fView.setImageFilter(filters[i]); fView.setController(this); @@ -280,7 +296,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, R.drawable.filtershow_button_colors_sharpen, R.drawable.filtershow_button_colors_curve }; - int []overlayNames = { + int[] overlayNames = { R.string.sharpness, R.string.curvesRGB }; @@ -352,7 +368,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, } String action = intent.getAction(); - if (action.equalsIgnoreCase(CROP_ACTION)){ + if (action.equalsIgnoreCase(CROP_ACTION)) { mPanelController.showComponent(findViewById(R.id.cropButton)); } else if (action.equalsIgnoreCase(TINY_PLANET_ACTION)) { mPanelController.showComponent(findViewById(R.id.tinyplanetButton)); @@ -571,7 +587,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, filter.setSelected(true); mCurrentImageSmallFilter = filter; - filter.setImageFilter(new ImageFilterFx(null,getString(R.string.none))); + filter.setImageFilter(new ImageFilterFx(null, getString(R.string.none))); filter.setController(this); filter.setImageLoader(mImageLoader); @@ -711,6 +727,15 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, invalidateOptionsMenu(); } + @Override + public void onConfigurationChanged(Configuration newConfig) + { + super.onConfigurationChanged(newConfig); + if (mShowingHistoryPanel) { + toggleHistoryPanel(); + } + } + // ////////////////////////////////////////////////////////////////////////////// // history panel... diff --git a/src/com/android/gallery3d/filtershow/HistoryAdapter.java b/src/com/android/gallery3d/filtershow/HistoryAdapter.java index d938c5aa6..471999292 100644 --- a/src/com/android/gallery3d/filtershow/HistoryAdapter.java +++ b/src/com/android/gallery3d/filtershow/HistoryAdapter.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow; diff --git a/src/com/android/gallery3d/filtershow/ImageStateAdapter.java b/src/com/android/gallery3d/filtershow/ImageStateAdapter.java index 0bca9a3ed..44b94e45e 100644 --- a/src/com/android/gallery3d/filtershow/ImageStateAdapter.java +++ b/src/com/android/gallery3d/filtershow/ImageStateAdapter.java @@ -1,18 +1,31 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow; -import com.android.gallery3d.R; -import com.android.gallery3d.filtershow.filters.ImageFilter; -import com.android.gallery3d.filtershow.presets.ImagePreset; - import android.content.Context; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; +import com.android.gallery3d.R; +import com.android.gallery3d.filtershow.filters.ImageFilter; + public class ImageStateAdapter extends ArrayAdapter<ImageFilter> { private static final String LOGTAG = "ImageStateAdapter"; @@ -20,6 +33,7 @@ public class ImageStateAdapter extends ArrayAdapter<ImageFilter> { super(context, textViewResourceId); } + @Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { diff --git a/src/com/android/gallery3d/filtershow/PanelController.java b/src/com/android/gallery3d/filtershow/PanelController.java index 2fbd831b6..9fc1109cb 100644 --- a/src/com/android/gallery3d/filtershow/PanelController.java +++ b/src/com/android/gallery3d/filtershow/PanelController.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow; diff --git a/src/com/android/gallery3d/filtershow/cache/BitmapCache.java b/src/com/android/gallery3d/filtershow/cache/BitmapCache.java index e04c36606..ba623c39a 100644 --- a/src/com/android/gallery3d/filtershow/cache/BitmapCache.java +++ b/src/com/android/gallery3d/filtershow/cache/BitmapCache.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.cache; diff --git a/src/com/android/gallery3d/filtershow/cache/Cache.java b/src/com/android/gallery3d/filtershow/cache/Cache.java index 364c9c5f1..7a3ce9d98 100644 --- a/src/com/android/gallery3d/filtershow/cache/Cache.java +++ b/src/com/android/gallery3d/filtershow/cache/Cache.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.cache; diff --git a/src/com/android/gallery3d/filtershow/cache/DelayedPresetCache.java b/src/com/android/gallery3d/filtershow/cache/DelayedPresetCache.java index 361190b78..408ba5912 100644 --- a/src/com/android/gallery3d/filtershow/cache/DelayedPresetCache.java +++ b/src/com/android/gallery3d/filtershow/cache/DelayedPresetCache.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.cache; diff --git a/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java b/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java index 25d1db414..fe75ccc27 100644 --- a/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java +++ b/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.cache; @@ -49,6 +64,7 @@ public class DirectPresetCache implements Cache { for (int i = 0; i < mObservers.size(); i++) { ImageShow imageShow = mObservers.elementAt(i); imageShow.invalidate(); + imageShow.updateImage(); } } diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java index 40bffb243..a8ad6800f 100644 --- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java +++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java @@ -87,7 +87,7 @@ public class ImageLoader { mActivity = activity; mContext = context; mCache = new DelayedPresetCache(this, 30); - mHiresCache = new DelayedPresetCache(this, 2); + mHiresCache = new DelayedPresetCache(this, 3); } public void loadBitmap(Uri uri,int size) { @@ -348,9 +348,11 @@ public class ImageLoader { if (filteredImage == null) { if (hiRes) { - cachePreset(imagePreset, mHiresCache, caller); + mHiresCache.prepare(imagePreset); + mHiresCache.addObserver(caller); } else { - cachePreset(imagePreset, mCache, caller); + mCache.prepare(imagePreset); + mCache.addObserver(caller); } } return filteredImage; @@ -384,11 +386,6 @@ public class ImageLoader { return mAdapter; } - private void cachePreset(ImagePreset preset, Cache cache, ImageShow caller) { - cache.prepare(preset); - cache.addObserver(caller); - } - public Object getXmpObject() { try { InputStream is = mContext.getContentResolver().openInputStream(getUri()); diff --git a/src/com/android/gallery3d/filtershow/cache/ZoomCache.java b/src/com/android/gallery3d/filtershow/cache/ZoomCache.java index e6e7f14ce..dbd0751ac 100644 --- a/src/com/android/gallery3d/filtershow/cache/ZoomCache.java +++ b/src/com/android/gallery3d/filtershow/cache/ZoomCache.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.android.gallery3d.filtershow.cache; import android.graphics.Bitmap; diff --git a/src/com/android/gallery3d/filtershow/filters/ColorSpaceMatrix.java b/src/com/android/gallery3d/filtershow/filters/ColorSpaceMatrix.java index 6791cd341..7c307a9e7 100644 --- a/src/com/android/gallery3d/filtershow/filters/ColorSpaceMatrix.java +++ b/src/com/android/gallery3d/filtershow/filters/ColorSpaceMatrix.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java index 21a1dffb5..d00c7e31b 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java index bdbd1d535..f4a7717f9 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java index 96300ef2d..45f49164b 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java index 002d31704..8f91c3c82 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java index e67a9cd65..f0c65d71e 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java index 4291fe47a..a310358ce 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java index 5117f60bc..0c3bb37ca 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java index 8c5bda04d..89641d103 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java index ee8741399..e38dc8eb5 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java index 3adfbef53..04d764100 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGradient.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGradient.java index 4fbd08613..be4ba871d 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGradient.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGradient.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java index e5e52ecd0..279718edb 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java index 66dad7881..5c5c0b496 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java index 37c5526b6..cb2bae722 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.android.gallery3d.filtershow.filters; import android.app.Activity; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java index 00a18091b..c77de330f 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java @@ -1,10 +1,22 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; -import android.util.Log; - -import java.util.Arrays; public class ImageFilterRedEye extends ImageFilter { private static final String TAG = "ImageFilterRedEye"; @@ -24,6 +36,7 @@ public class ImageFilterRedEye extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, short []matrix); + @Override public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java index 904705636..1d3459195 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java index ee621966d..4e6b848ae 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java index d28e40517..a355539c2 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java index db85292be..85fcf273f 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java index cba1cd231..ccf0dc951 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java index 8281573e6..34f8b245e 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java index fed583832..7a471e5b9 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java index 5e613ebce..b00b867b3 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java @@ -1,8 +1,22 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; -import android.util.Log; public class ImageFilterWBalance extends ImageFilter { private static final String TAG = "ImageFilterWBalance"; diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java index 95d174f42..3f9d4fa28 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java +++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.android.gallery3d.filtershow.imageshow; public class GeometryMath { diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageBorder.java b/src/com/android/gallery3d/filtershow/imageshow/ImageBorder.java index f8c0142ae..0977d7d90 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageBorder.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageBorder.java @@ -1,16 +1,24 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.imageshow; -import com.android.gallery3d.filtershow.presets.ImagePreset; - import android.content.Context; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.drawable.NinePatchDrawable; import android.util.AttributeSet; public class ImageBorder extends ImageSlave { @@ -24,10 +32,12 @@ public class ImageBorder extends ImageSlave { super(context, attrs); } + @Override public boolean showTitle() { return false; } + @Override public void onDraw(Canvas canvas) { super.onDraw(canvas); diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java b/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java index 1cf8d7af5..6bdbeb815 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java @@ -221,12 +221,6 @@ public abstract class ImageGeometry extends ImageSlave { return getLocalRotation() + getLocalStraighten(); } - protected Bitmap getMasterImage() { - if (getMaster() == null) - return null; - return getMaster().mForegroundImage; - } - protected static float[] getCornersFromRect(RectF r) { // Order is: // 0------->1 @@ -375,7 +369,7 @@ public abstract class ImageGeometry extends ImageSlave { ImagePreset lastHistoryItem = getHistory().getLast(); if (lastHistoryItem != null && lastHistoryItem.historyName().equalsIgnoreCase(getName())) { getImagePreset().setGeometry(mLocalGeometry); - mImageLoader.resetImageForPreset(getImagePreset(), this); + resetImageCaches(this); } else { ImagePreset copy = new ImagePreset(getImagePreset()); copy.setGeometry(mLocalGeometry); @@ -535,8 +529,10 @@ public abstract class ImageGeometry extends ImageSlave { syncLocalToMasterGeometry(); clearDirtyGeometryFlag(); } - Bitmap image = getMasterImage(); + requestFilteredImages(); + Bitmap image = getMaster().getFiltersOnlyImage(); if (image == null) { + invalidate(); return; } mHasDrawn = true; diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java index c009b99dd..72c594c85 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java @@ -59,6 +59,9 @@ public class ImageShow extends View implements OnGestureListener, protected static int mTextPadding = 20; protected ImagePreset mImagePreset = null; + protected ImagePreset mImageGeometryOnlyPreset = null; + protected ImagePreset mImageFiltersOnlyPreset = null; + protected ImageLoader mImageLoader = null; private ImageFilter mCurrentFilter = null; private boolean mDirtyGeometry = true; @@ -67,9 +70,9 @@ public class ImageShow extends View implements OnGestureListener, private final boolean USE_BACKGROUND_IMAGE = false; private static int mBackgroundColor = Color.RED; - // TODO: remove protected here, it should be private - protected Bitmap mForegroundImage = null; - protected Bitmap mFilteredImage = null; + private Bitmap mGeometryOnlyImage = null; + private Bitmap mFiltersOnlyImage = null; + private Bitmap mFilteredImage = null; private final boolean USE_SLIDER_GESTURE = false; // set to true to have // slider gesture @@ -324,13 +327,6 @@ public class ImageShow extends View implements OnGestureListener, return mImagePreset; } - protected Bitmap getOriginalFrontBitmap() { - if (mImageLoader != null) { - return mImageLoader.getOriginalBitmapLarge(); - } - return null; - } - public void drawToast(Canvas canvas) { if (mShowToast && mToast != null) { Paint paint = new Paint(); @@ -355,12 +351,16 @@ public class ImageShow extends View implements OnGestureListener, } } + public void defaultDrawImage(Canvas canvas) { + drawImage(canvas, getFilteredImage()); + drawPartialImage(canvas, getGeometryOnlyImage()); + } + @Override public void onDraw(Canvas canvas) { drawBackground(canvas); - getFilteredImage(); - drawImage(canvas, mFilteredImage); - drawPartialImage(canvas, mForegroundImage); + requestFilteredImages(); + defaultDrawImage(canvas); if (showTitle() && getImagePreset() != null) { mPaint.setARGB(200, 0, 0, 0); @@ -382,25 +382,87 @@ public class ImageShow extends View implements OnGestureListener, drawToast(canvas); } - public void getFilteredImage() { - Bitmap filteredImage = null; + public void resetImageCaches(ImageShow caller) { + if (mImageLoader == null) { + return; + } + updateImagePresets(true); + } + + public void updateImagePresets(boolean force) { + ImagePreset preset = getImagePreset(); + if (preset == null) { + return; + } + if (force) { + mImageLoader.resetImageForPreset(getImagePreset(), this); + } + if (force || mImageGeometryOnlyPreset == null) { + ImagePreset newPreset = new ImagePreset(preset); + newPreset.setDoApplyFilters(false); + if (mImageGeometryOnlyPreset == null + || !newPreset.same(mImageGeometryOnlyPreset)) { + mImageGeometryOnlyPreset = newPreset; + mGeometryOnlyImage = null; + } + } + if (force || mImageFiltersOnlyPreset == null) { + ImagePreset newPreset = new ImagePreset(preset); + newPreset.setDoApplyGeometry(false); + if (mImageFiltersOnlyPreset == null + || !newPreset.same(mImageFiltersOnlyPreset)) { + mImageFiltersOnlyPreset = newPreset; + mFiltersOnlyImage = null; + } + } + } + + public void requestFilteredImages() { if (mImageLoader != null) { - filteredImage = mImageLoader.getImageForPreset(this, + Bitmap bitmap = mImageLoader.getImageForPreset(this, getImagePreset(), showHires()); - } - if (filteredImage == null) { - // if no image for the current preset, use the previous one - filteredImage = mFilteredImage; - } else { - mFilteredImage = filteredImage; + if (bitmap != null) { + if (mFilteredImage == null) { + invalidate(); + } + mFilteredImage = bitmap; + } + + updateImagePresets(false); + if (mImageGeometryOnlyPreset != null) { + bitmap = mImageLoader.getImageForPreset(this, mImageGeometryOnlyPreset, + showHires()); + if (bitmap != null) { + mGeometryOnlyImage = bitmap; + } + } + if (mImageFiltersOnlyPreset != null) { + bitmap = mImageLoader.getImageForPreset(this, mImageFiltersOnlyPreset, + showHires()); + if (bitmap != null) { + mFiltersOnlyImage = bitmap; + } + } } - if (mShowOriginal || mFilteredImage == null) { - mFilteredImage = mForegroundImage; + if (mShowOriginal) { + mFilteredImage = mGeometryOnlyImage; } } + public Bitmap getFiltersOnlyImage() { + return mFiltersOnlyImage; + } + + public Bitmap getGeometryOnlyImage() { + return mGeometryOnlyImage; + } + + public Bitmap getFilteredImage() { + return mFilteredImage; + } + public void drawImage(Canvas canvas, Bitmap image) { if (image != null) { Rect s = new Rect(0, 0, image.getWidth(), @@ -522,15 +584,17 @@ public class ImageShow extends View implements OnGestureListener, } public void setImagePreset(ImagePreset preset, boolean addToHistory) { + if (preset == null) { + return; + } mImagePreset = preset; - if (getImagePreset() != null) { - getImagePreset().setImageLoader(mImageLoader); - if (addToHistory) { - mHistoryAdapter.addHistoryItem(getImagePreset()); - } - getImagePreset().setEndpoint(this); - updateImage(); + getImagePreset().setImageLoader(mImageLoader); + updateImagePresets(true); + if (addToHistory) { + mHistoryAdapter.addHistoryItem(getImagePreset()); } + getImagePreset().setEndpoint(this); + updateImage(); mImagePreset.fillImageStateAdapter(mImageStateAdapter); invalidate(); } @@ -573,10 +637,19 @@ public class ImageShow extends View implements OnGestureListener, setDirtyGeometryFlag(); } + public boolean updateGeometryFlags() { + return true; + } + public void updateImage() { - mForegroundImage = getOriginalFrontBitmap(); - imageSizeChanged(mForegroundImage); // TODO: should change to filtered - setDirtyGeometryFlag(); + if (!updateGeometryFlags()) { + return; + } + Bitmap bitmap = mImageLoader.getOriginalBitmapLarge(); + if (bitmap != null) { + imageSizeChanged(bitmap); + invalidate(); + } } public void updateFilteredImage(Bitmap bitmap) { @@ -609,7 +682,7 @@ public class ImageShow extends View implements OnGestureListener, mTouchY = ey; if (!mActivity.isShowingHistoryPanel() && (System.currentTimeMillis() - mTouchShowOriginalDate - > mTouchShowOriginalDelayMin)) { + > mTouchShowOriginalDelayMin)) { mTouchShowOriginal = true; } } @@ -725,8 +798,8 @@ public class ImageShow extends View implements OnGestureListener, || (mActivity.isShowingHistoryPanel() && endEvent.getX() > startEvent.getX())) { if (!mTouchShowOriginal || (mTouchShowOriginal && - (System.currentTimeMillis() - mTouchShowOriginalDate - < mTouchShowOriginalDelayMax))) { + (System.currentTimeMillis() - mTouchShowOriginalDate + < mTouchShowOriginalDelayMax))) { mActivity.toggleHistoryPanel(); } } @@ -756,4 +829,5 @@ public class ImageShow extends View implements OnGestureListener, // TODO Auto-generated method stub return false; } + } diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageSlave.java b/src/com/android/gallery3d/filtershow/imageshow/ImageSlave.java index ba4da91c9..3d79ae0d7 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageSlave.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageSlave.java @@ -17,6 +17,7 @@ package com.android.gallery3d.filtershow.imageshow; import android.content.Context; +import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; import android.util.AttributeSet; @@ -51,6 +52,11 @@ public class ImageSlave extends ImageShow { } @Override + public void resetImageCaches(ImageShow caller) { + mMasterImageShow.resetImageCaches(caller); + } + + @Override public ImagePreset getImagePreset() { return mMasterImageShow.getImagePreset(); } @@ -76,6 +82,26 @@ public class ImageSlave extends ImageShow { } @Override + public Bitmap getFilteredImage() { + return mMasterImageShow.getFilteredImage(); + } + + @Override + public void updateImage() { + mMasterImageShow.updateImage(); + } + + @Override + public void updateImagePresets(boolean force) { + mMasterImageShow.updateImagePresets(force); + } + + @Override + public void requestFilteredImages() { + mMasterImageShow.requestFilteredImages(); + } + + @Override public boolean showTitle() { return false; } diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageSmallBorder.java b/src/com/android/gallery3d/filtershow/imageshow/ImageSmallBorder.java index 0cf6389ce..d6d3c86d4 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageSmallBorder.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageSmallBorder.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.imageshow; @@ -30,7 +45,7 @@ public class ImageSmallBorder extends ImageSmallFilter { @Override public void onDraw(Canvas canvas) { - getFilteredImage(); + requestFilteredImages(); canvas.drawColor(mBackgroundColor); // TODO: simplify & make faster... RectF border = new RectF(mMargin, 2*mMargin, getWidth() - mMargin - 1, getWidth()); @@ -53,7 +68,7 @@ public class ImageSmallBorder extends ImageSmallFilter { canvas.translate(mMargin + 1, 2*mMargin + 1); canvas.scale(mImageScaleFactor, mImageScaleFactor); Rect d = new Rect(0, 0, getWidth(), getWidth()); - drawImage(canvas, mFilteredImage, d); + drawImage(canvas, getFilteredImage(), d); canvas.restore(); } diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java b/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java index 698c4ea7a..53e51ae13 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.imageshow; @@ -18,7 +33,7 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener private static final String LOGTAG = "ImageSmallFilter"; private FilterShowActivity mController = null; - private ImageFilter mImageFilter = null; + protected ImageFilter mImageFilter = null; private boolean mShowTitle = true; private boolean mSetBorder = false; protected final Paint mPaint = new Paint(); @@ -93,18 +108,10 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener } @Override - public void updateImage() { + public boolean updateGeometryFlags() { // We don't want to warn listeners here that the image size has changed, because // we'll be working with the small image... - mForegroundImage = getOriginalFrontBitmap(); - } - - @Override - protected Bitmap getOriginalFrontBitmap() { - if (mImageLoader == null) { - return null; - } - return mImageLoader.getOriginalBitmapSmall(); + return false; } public void setShowTitle(boolean value) { @@ -128,8 +135,21 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener } @Override + public ImagePreset getImagePreset() { + return mImagePreset; + } + + @Override + public void updateImagePresets(boolean force) { + ImagePreset preset = getImagePreset(); + if (preset == null) { + return; + } + } + + @Override public void onDraw(Canvas canvas) { - getFilteredImage(); + requestFilteredImages(); canvas.drawColor(mBackgroundColor); float textWidth = mPaint.measureText(mImageFilter.getName()); int h = mTextSize + 2 * mTextPadding; @@ -140,7 +160,7 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener canvas.drawRect(0, mMargin, getWidth(), getWidth() + mMargin, mPaint); } Rect destination = new Rect(mMargin, 2*mMargin, getWidth() - mMargin, getWidth()); - drawImage(canvas, mFilteredImage, destination); + drawImage(canvas, getFilteredImage(), destination); mPaint.setTextSize(mTextSize); mPaint.setColor(mTextColor); canvas.drawText(mImageFilter.getName(), x, y - mTextMargin, mPaint); diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java b/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java index 2666cb73d..a332fa72a 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageWithIcon.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.android.gallery3d.filtershow.imageshow; import android.content.Context; diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageZoom.java b/src/com/android/gallery3d/filtershow/imageshow/ImageZoom.java index 4e2ccc3eb..e659e900a 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageZoom.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageZoom.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.android.gallery3d.filtershow.imageshow; import android.content.Context; @@ -58,8 +74,8 @@ public class ImageZoom extends ImageSlave { if ((mZoomedIn ||mTouchDown) && mImageLoader != null) { filteredImage = mImageLoader.getScaleOneImageForPreset(this, getImagePreset(), mZoomBounds, false); } else { - getFilteredImage(); - filteredImage = mFilteredImage; + requestFilteredImages(); + filteredImage = getFilteredImage(); } drawImage(canvas, filteredImage); if (showControls()) { diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java index cbb14300d..87e1934fd 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.presets; @@ -27,6 +42,9 @@ public class ImagePreset { private String mHistoryName = "Original"; protected boolean mIsFxPreset = false; + private boolean mDoApplyGeometry = true; + private boolean mDoApplyFilters = true; + public final GeometryMetadata mGeoData = new GeometryMetadata(); enum FullRotate { @@ -70,6 +88,14 @@ public class ImagePreset { mGeoData.set(source.mGeoData); } + public void setDoApplyGeometry(boolean value) { + mDoApplyGeometry = value; + } + + public void setDoApplyFilters(boolean value) { + mDoApplyFilters = value; + } + public boolean hasModifications() { if (mImageBorder != null && !mImageBorder.isNil()) { return true; @@ -102,7 +128,6 @@ public class ImagePreset { return true; } - public void setGeometry(GeometryMetadata m) { mGeoData.set(m); } @@ -144,7 +169,11 @@ public class ImagePreset { return false; } - if (!mGeoData.equals(preset.mGeoData)) { + if (mDoApplyGeometry != preset.mDoApplyGeometry) { + return false; + } + + if (mDoApplyGeometry && !mGeoData.equals(preset.mGeoData)) { return false; } @@ -156,13 +185,21 @@ public class ImagePreset { return false; } - for (int i = 0; i < preset.mFilters.size(); i++) { - ImageFilter a = preset.mFilters.elementAt(i); - ImageFilter b = mFilters.elementAt(i); - if (!a.same(b)) { + if (mDoApplyFilters != preset.mDoApplyFilters) { + if (mFilters.size() > 0 || preset.mFilters.size() > 0) { return false; } } + + if (mDoApplyFilters && preset.mDoApplyFilters) { + for (int i = 0; i < preset.mFilters.size(); i++) { + ImageFilter a = preset.mFilters.elementAt(i); + ImageFilter b = mFilters.elementAt(i); + if (!a.same(b)) { + return false; + } + } + } return true; } @@ -238,11 +275,17 @@ public class ImagePreset { public Bitmap apply(Bitmap original) { // First we apply any transform -- 90 rotate, flip, straighten, crop - Bitmap bitmap = mGeoData.apply(original, mScaleFactor, mIsHighQuality); + Bitmap bitmap = original; - for (int i = 0; i < mFilters.size(); i++) { - ImageFilter filter = mFilters.elementAt(i); - bitmap = filter.apply(bitmap, mScaleFactor, mIsHighQuality); + if (mDoApplyGeometry) { + bitmap = mGeoData.apply(original, mScaleFactor, mIsHighQuality); + } + + if (mDoApplyFilters) { + for (int i = 0; i < mFilters.size(); i++) { + ImageFilter filter = mFilters.elementAt(i); + bitmap = filter.apply(bitmap, mScaleFactor, mIsHighQuality); + } } if (mImageBorder != null) { @@ -252,6 +295,7 @@ public class ImagePreset { if (mEndPoint != null) { mEndPoint.updateFilteredImage(bitmap); } + return bitmap; } diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java index f5eeb78fd..bfa6dacc7 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.presets; diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java index 97d21e1e6..5d56aa1cd 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.presets; diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java index 26588b9ac..d1b4e5d78 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.presets; diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java index 299621edf..9653bed57 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.presets; diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetFX.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetFX.java index fa207a6d0..95edc5d15 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePresetFX.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetFX.java @@ -1,15 +1,30 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.presets; import android.graphics.Bitmap; -import com.android.gallery3d.filtershow.filters.ImageFilterBWRed; import com.android.gallery3d.filtershow.filters.ImageFilterFx; public class ImagePresetFX extends ImagePreset { String name; Bitmap fxBitmap; + @Override public String name() { return name; } @@ -20,6 +35,7 @@ public class ImagePresetFX extends ImagePreset { setup(); } + @Override public void setup() { if (fxBitmap != null) { mFilters.add(new ImageFilterFx(fxBitmap,name)); diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetOld.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetOld.java index 56e1dab45..5e1db8336 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePresetOld.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetOld.java @@ -1,16 +1,33 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.presets; -import com.android.gallery3d.filtershow.filters.ImageFilterGradient; - import android.graphics.Color; +import com.android.gallery3d.filtershow.filters.ImageFilterGradient; + public class ImagePresetOld extends ImagePreset { + @Override public String name() { return "Old"; } + @Override public void setup() { ImageFilterGradient filter = new ImageFilterGradient(); filter.addColor(Color.BLACK, 0.0f); diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetSaturated.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetSaturated.java index 1a84bbf5d..ddfca7508 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePresetSaturated.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetSaturated.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.presets; diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetXProcessing.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetXProcessing.java index 3e744be77..7957b5e7c 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePresetXProcessing.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetXProcessing.java @@ -1,16 +1,33 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.presets; -import com.android.gallery3d.filtershow.filters.ImageFilterGradient; - import android.graphics.Color; +import com.android.gallery3d.filtershow.filters.ImageFilterGradient; + public class ImagePresetXProcessing extends ImagePreset { + @Override public String name() { return "X-Process"; } + @Override public void setup() { ImageFilterGradient filter = new ImageFilterGradient(); filter.addColor(Color.BLACK, 0.0f); diff --git a/src/com/android/gallery3d/filtershow/provider/SharedImageProvider.java b/src/com/android/gallery3d/filtershow/provider/SharedImageProvider.java index dff15164b..bc17a6e03 100644 --- a/src/com/android/gallery3d/filtershow/provider/SharedImageProvider.java +++ b/src/com/android/gallery3d/filtershow/provider/SharedImageProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.provider; @@ -11,11 +26,9 @@ import android.os.ParcelFileDescriptor; import android.provider.BaseColumns; import android.provider.MediaStore; import android.provider.OpenableColumns; -import android.util.Log; import java.io.File; import java.io.FileNotFoundException; -import java.util.Arrays; public class SharedImageProvider extends ContentProvider { @@ -107,6 +120,7 @@ public class SharedImageProvider extends ContentProvider { return cursor; } + @Override public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { String uriPath = uri.getLastPathSegment(); diff --git a/src/com/android/gallery3d/filtershow/ui/ControlPoint.java b/src/com/android/gallery3d/filtershow/ui/ControlPoint.java index 0c08e76fd..73589d373 100644 --- a/src/com/android/gallery3d/filtershow/ui/ControlPoint.java +++ b/src/com/android/gallery3d/filtershow/ui/ControlPoint.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.ui; diff --git a/src/com/android/gallery3d/filtershow/ui/FramedTextButton.java b/src/com/android/gallery3d/filtershow/ui/FramedTextButton.java index 43f97d285..4abd7c075 100644 --- a/src/com/android/gallery3d/filtershow/ui/FramedTextButton.java +++ b/src/com/android/gallery3d/filtershow/ui/FramedTextButton.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.android.gallery3d.filtershow.ui; import android.content.Context; diff --git a/src/com/android/gallery3d/filtershow/ui/ImageButtonTitle.java b/src/com/android/gallery3d/filtershow/ui/ImageButtonTitle.java index 3d43dc7dd..bb37751bf 100644 --- a/src/com/android/gallery3d/filtershow/ui/ImageButtonTitle.java +++ b/src/com/android/gallery3d/filtershow/ui/ImageButtonTitle.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.ui; diff --git a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java b/src/com/android/gallery3d/filtershow/ui/ImageCurves.java index 81da9f80e..c4ca900e1 100644 --- a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java +++ b/src/com/android/gallery3d/filtershow/ui/ImageCurves.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.ui; @@ -89,8 +104,8 @@ public class ImageCurves extends ImageSlave { gPaint.setAntiAlias(true); - if (getImagePreset() != mLastPreset) { - new ComputeHistogramTask().execute(mFilteredImage); + if (getImagePreset() != mLastPreset && getFilteredImage() != null) { + new ComputeHistogramTask().execute(getFilteredImage()); mLastPreset = getImagePreset(); } @@ -185,12 +200,16 @@ public class ImageCurves extends ImageSlave { return true; } + if (curves() == null) { + return true; + } + Spline spline = getSpline(mCurrentCurveIndex); int pick = pickControlPoint(posX, posY); if (mCurrentControlPoint == null) { if (pick == -1) { mCurrentControlPoint = new ControlPoint(posX, posY); - spline.addPoint(mCurrentControlPoint); + pick = spline.addPoint(mCurrentControlPoint); mDidAddPoint = true; } else { mCurrentControlPoint = spline.getPoint(pick); @@ -198,21 +217,21 @@ public class ImageCurves extends ImageSlave { } if (spline.isPointContained(posX, pick)) { - mCurrentControlPoint.x = posX; - mCurrentControlPoint.y = posY; spline.didMovePoint(mCurrentControlPoint); + spline.movePoint(pick, posX, posY); } else if (pick != -1 && spline.getNbPoints() > 2) { spline.deletePoint(pick); mDidDelete = true; } updateCachedImage(); + invalidate(); return true; } public synchronized void updateCachedImage() { // update image if (getImagePreset() != null) { - mImageLoader.resetImageForPreset(getImagePreset(), this); + resetImageCaches(this); invalidate(); } } diff --git a/src/com/android/gallery3d/filtershow/ui/SliderController.java b/src/com/android/gallery3d/filtershow/ui/SliderController.java index 99f66b185..7139acebb 100644 --- a/src/com/android/gallery3d/filtershow/ui/SliderController.java +++ b/src/com/android/gallery3d/filtershow/ui/SliderController.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.ui; diff --git a/src/com/android/gallery3d/filtershow/ui/SliderListener.java b/src/com/android/gallery3d/filtershow/ui/SliderListener.java index b11966ece..6d4718d87 100644 --- a/src/com/android/gallery3d/filtershow/ui/SliderListener.java +++ b/src/com/android/gallery3d/filtershow/ui/SliderListener.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.ui; diff --git a/src/com/android/gallery3d/filtershow/ui/Spline.java b/src/com/android/gallery3d/filtershow/ui/Spline.java index 67840dc23..dd9aac1be 100644 --- a/src/com/android/gallery3d/filtershow/ui/Spline.java +++ b/src/com/android/gallery3d/filtershow/ui/Spline.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android.gallery3d.filtershow.ui; @@ -68,6 +83,15 @@ public class Spline { mCurrentControlPoint = point; } + public void movePoint(int pick, float x, float y) { + if (pick < 0 || pick > mPoints.size() - 1) { + return; + } + ControlPoint point = mPoints.elementAt(pick); + point.x = x; + point.y = y; + } + public boolean isOriginal() { if (this.getNbPoints() > 2) { return false; @@ -324,13 +348,14 @@ public class Spline { return solution; } - public void addPoint(float x, float y) { - addPoint(new ControlPoint(x, y)); + public int addPoint(float x, float y) { + return addPoint(new ControlPoint(x, y)); } - public void addPoint(ControlPoint v) { + public int addPoint(ControlPoint v) { mPoints.add(v); Collections.sort(mPoints); + return mPoints.indexOf(v); } public void deletePoint(int n) { |