--- /dev/null
+/*
+ * Copyright (C) 2013 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 interface GeometryListener {
+ public void geometryChanged();
+}
import android.graphics.Bitmap;
import android.graphics.RectF;
-import com.android.gallery3d.app.Log;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.HistoryAdapter;
import com.android.gallery3d.filtershow.ImageStateAdapter;
private Vector<ImageShow> mObservers = new Vector<ImageShow>();
private FilterRepresentation mCurrentFilterRepresentation;
+ private Vector<GeometryListener> mGeometryListeners = new Vector<GeometryListener>();
+
+ private GeometryMetadata mPreviousGeometry = null;
private MasterImage() {
}
mHistory.addHistoryItem(mPreset);
}
updatePresets(true);
+ GeometryMetadata geo = mPreset.mGeoData;
+ if (!geo.equals(mPreviousGeometry)) {
+ notifyGeometryChange();
+ }
+ mPreviousGeometry = new GeometryMetadata(geo);
}
private void setGeometry() {
public static void reset() {
sMasterImage = null;
}
+
+ public void addGeometryListener(GeometryListener listener) {
+ mGeometryListeners.add(listener);
+ }
+
+ public void notifyGeometryChange() {
+ for (GeometryListener listener : mGeometryListeners) {
+ listener.geometryChanged();
+ }
+ }
}
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
+import com.android.gallery3d.filtershow.imageshow.GeometryListener;
+import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.presets.ImagePreset;
-public class FilterIconButton extends IconButton implements View.OnClickListener, RenderingRequestCaller {
+public class FilterIconButton extends IconButton implements View.OnClickListener,
+ RenderingRequestCaller, GeometryListener {
private static final String LOGTAG = "FilterIconButton";
private Bitmap mOverlayBitmap = null;
private PanelController mController = null;
setText(text);
mParentContainer = parent;
super.setOnClickListener(this);
+ MasterImage.getImage().addGeometryListener(this);
invalidate();
}
if (mIconBitmap == null && mPreset == null) {
ImageLoader loader = MasterImage.getImage().getLoader();
if (loader != null) {
+ ImagePreset geoPreset = new ImagePreset(MasterImage.getImage().getGeometryPreset());
+ image = geoPreset.applyGeometry(image);
dst = super.drawImage(dst, image, destination);
ImagePreset mPreset = new ImagePreset();
mPreset.addFilter(mFilterRepresentation);
invalidate();
stale_icon = true;
}
+
+ @Override
+ public void geometryChanged() {
+ stale_icon = true;
+ mIconBitmap = null;
+ mPreset = null;
+ invalidate();
+ }
}