summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/filtershow_activity.xml18
-rw-r--r--res/layout/filtershow_main_panel.xml1
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java54
-rw-r--r--src/com/android/gallery3d/filtershow/category/MainPanel.java14
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java10
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java78
-rw-r--r--src/com/android/gallery3d/filtershow/tools/DualCameraNativeEngine.java9
7 files changed, 102 insertions, 82 deletions
diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml
index 1340bc40d..d89f6b264 100644
--- a/res/layout/filtershow_activity.xml
+++ b/res/layout/filtershow_activity.xml
@@ -21,26 +21,11 @@
android:layout_height="match_parent"
android:background="#212121" >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
- <ProgressBar
- android:id="@+id/loading"
- style="@android:style/Widget.Holo.ProgressBar.Large"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:background="@null"
- android:indeterminate="true"
- android:indeterminateOnly="true" />
-
<RelativeLayout
android:id="@+id/imageContainer"
android:layout_width="match_parent"
@@ -90,7 +75,6 @@
android:layout_weight="1" />
</com.android.gallery3d.filtershow.CenteredLinearLayout>
</FrameLayout>
- </LinearLayout>
<com.android.gallery3d.filtershow.category.CategorySelected
android:id="@+id/categorySelectedIndicator"
@@ -98,4 +82,4 @@
android:layout_height="@dimen/category_panel_icon_size"
android:visibility="gone" />
-</FrameLayout> \ No newline at end of file
+</FrameLayout>
diff --git a/res/layout/filtershow_main_panel.xml b/res/layout/filtershow_main_panel.xml
index 7a0ead87c..d0e624665 100644
--- a/res/layout/filtershow_main_panel.xml
+++ b/res/layout/filtershow_main_panel.xml
@@ -108,6 +108,7 @@
android:background="@android:color/transparent"
android:padding="2dip"
android:scaleType="centerInside"
+ android:visibility="gone"
android:src="@drawable/dualcamera"/>
</LinearLayout>
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index 4ff3e2ff4..1fcb9a724 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -29,6 +29,7 @@ import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
@@ -115,6 +116,7 @@ import com.android.gallery3d.filtershow.presets.UserPresetsAdapter;
import com.android.gallery3d.filtershow.provider.SharedImageProvider;
import com.android.gallery3d.filtershow.state.StateAdapter;
import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine;
+import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine.DdmStatus;
import com.android.gallery3d.filtershow.tools.SaveImage;
import com.android.gallery3d.filtershow.tools.XmpPresets;
import com.android.gallery3d.filtershow.tools.XmpPresets.XMresults;
@@ -194,7 +196,6 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
private Menu mMenu;
private DialogInterface mCurrentDialog = null;
private PopupMenu mCurrentMenu = null;
- private boolean mLoadingVisible = true;
private boolean mReleaseDualCamOnDestory = true;
private FrameLayout mCategoryFragment;
private View mEffectsContainer;
@@ -205,6 +206,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
boolean isOrientationChanged;
private boolean isComingFromEditorScreen;
+ private ProgressDialog mLoadingDialog;
+
public ProcessingService getProcessingService() {
return mBoundService;
}
@@ -759,6 +762,13 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
mShowingTinyPlanet = false;
mLoadBitmapTask = new LoadBitmapTask();
mLoadBitmapTask.execute(uri);
+
+ if(DualCameraNativeEngine.getInstance().isLibLoaded()) {
+ LoadMpoDataTask mpoLoad = new LoadMpoDataTask();
+ mpoLoad.execute();
+ } else {
+ MasterImage.getImage().setDepthMapLoadingStatus(DdmStatus.DDM_FAILED);
+ }
}
private void fillBorders() {
@@ -978,10 +988,6 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
mBoundService.setHighresPreviewScaleFactor(highResPreviewScale);
}
- if(DualCameraNativeEngine.getInstance().isLibLoaded()) {
- LoadMpoDataTask mpoLoad = new LoadMpoDataTask();
- mpoLoad.execute();
- }
MasterImage.getImage().warnListeners();
}
}
@@ -994,31 +1000,47 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
@Override
protected void onPostExecute(Boolean result) {
- MasterImage.getImage().warnListeners();
-
+ MasterImage.getImage().setDepthMapLoadingStatus(result?DdmStatus.DDM_LOADED:DdmStatus.DDM_FAILED);
Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
if (currentPanel instanceof MainPanel) {
MainPanel mainPanel = (MainPanel) currentPanel;
- mainPanel.enableDualCameraButton(result);
+ mainPanel.updateDualCameraButton();
}
}
}
public boolean isLoadingVisible() {
- return mLoadingVisible;
+ if(mLoadingDialog != null) {
+ return mLoadingDialog.isShowing();
+ }
+
+ return false;
}
public void startLoadingIndicator() {
- final View loading = findViewById(R.id.loading);
- mLoadingVisible = true;
- loading.setVisibility(View.VISIBLE);
+ if(mLoadingDialog == null) {
+ mLoadingDialog = new ProgressDialog(this);
+ mLoadingDialog.setMessage(getString(R.string.loading_image));
+ mLoadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ mLoadingDialog.setIndeterminate(true);
+ mLoadingDialog.setCancelable(true);
+ mLoadingDialog.setCanceledOnTouchOutside(false);
+ mLoadingDialog.setOnCancelListener(new OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ finish();
+ }
+ });
+ }
+
+ mLoadingDialog.show();
}
public void stopLoadingIndicator() {
- final View loading = findViewById(R.id.loading);
- loading.setVisibility(View.GONE);
- mLoadingVisible = false;
- }
+ if(mLoadingDialog != null && mLoadingDialog.isShowing()) {
+ mLoadingDialog.dismiss();
+ }
+ }
private class LoadBitmapTask extends AsyncTask<Uri, Boolean, Boolean> {
int mBitmapSize;
diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java
index e7d686e4c..e10dd51b2 100644
--- a/src/com/android/gallery3d/filtershow/category/MainPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java
@@ -34,6 +34,7 @@ import com.android.gallery3d.filtershow.filters.SimpleMakeupImageFilter;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.state.StatePanel;
import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine;
+import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine.DdmStatus;
public class MainPanel extends Fragment {
@@ -57,9 +58,9 @@ public class MainPanel extends Fragment {
public static final int BORDERS = 1;
public static final int GEOMETRY = 2;
public static final int FILTERS = 3;
- public static final int DUALCAM = 4;
- public static final int VERSIONS = 5;
- public static final int MAKEUP = 6;
+ public static final int MAKEUP = 4;
+ public static final int DUALCAM = 5;
+ public static final int VERSIONS = 6;
private int mCurrentSelected = -1;
private int mPreviousToggleVersions = -1;
@@ -179,7 +180,8 @@ public class MainPanel extends Fragment {
showPanel(DUALCAM);
}
});
- enableDualCameraButton(DualCameraNativeEngine.getInstance().isLibLoaded());
+
+ updateDualCameraButton();
FilterShowActivity activity = (FilterShowActivity) getActivity();
//showImageStatePanel(activity.isShowingImageStatePanel());
@@ -425,8 +427,10 @@ public class MainPanel extends Fragment {
transaction.commit();
}
- public void enableDualCameraButton(boolean enable) {
+ public void updateDualCameraButton() {
if(dualCamButton != null) {
+ DdmStatus status = MasterImage.getImage().getDepthMapLoadingStatus();
+ boolean enable = (status == DdmStatus.DDM_LOADED);
dualCamButton.setVisibility(enable?View.VISIBLE:View.GONE);
TextView tvDualCam = (TextView) mEffectsTextContainer
.findViewById(R.id.tvDualCam);
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 261d43fb8..58bddce65 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -272,14 +272,12 @@ public class ImageShow extends View implements OnGestureListener,
MasterImage img = MasterImage.getImage();
// Hide the loading indicator as needed
if (mActivity.isLoadingVisible() && getFilteredImage() != null) {
- if ((img.getLoadedPreset() == null)
- || (img.getLoadedPreset() != null
- && img.getLoadedPreset().equals(img.getCurrentPreset()))) {
- mActivity.stopLoadingIndicator();
- } else if (img.getLoadedPreset() != null) {
+ if(img.getLoadedPreset() != null
+ && !img.getLoadedPreset().equals(img.getCurrentPreset())) {
return;
+ } else if (img.isDepthMapLoadingDone()) {
+ mActivity.stopLoadingIndicator();
}
- mActivity.stopLoadingIndicator();
}
Bitmap fusionUnderlay = MasterImage.getImage().getFusionUnderlay();
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index 9dc7d781c..9493ed716 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -16,8 +16,6 @@
package com.android.gallery3d.filtershow.imageshow;
-import java.io.File;
-import java.nio.ByteBuffer;
import java.util.List;
import java.util.Vector;
@@ -54,6 +52,7 @@ import com.android.gallery3d.filtershow.pipeline.SharedBuffer;
import com.android.gallery3d.filtershow.pipeline.SharedPreset;
import com.android.gallery3d.filtershow.state.StateAdapter;
import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine;
+import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine.DdmStatus;
import com.android.gallery3d.mpo.MpoParser;
public class MasterImage implements RenderingRequestCaller {
@@ -98,6 +97,7 @@ public class MasterImage implements RenderingRequestCaller {
private Bitmap mFusionUnderlay = null;
private Rect mImageBounds = null;
private Rect mFusionBounds = null;
+ private DualCameraNativeEngine.DdmStatus mDepthMapLoadingStatus = DdmStatus.DDM_IDLE;
private ValueAnimator mAnimator = null;
private float mMaskScale = 1;
@@ -878,58 +878,49 @@ public class MasterImage implements RenderingRequestCaller {
// check for pre-generated dm file
String mpoFilepath = ImageLoader.getLocalPathFromUri(getActivity(), getUri());
- String depthFilepath = MpoParser.getDepthmapFilepath(mpoFilepath);
- File depthFile = new File(depthFilepath);
- if(depthFile.exists()) {
- // TODO: read from depth map file and init DDM
- // ByteBuffer depthMap = MpoParser.readDepthMapFile(depthFilepath);
- //
- // DualCameraNativeEngine.getInstance().loadDepthMap(
- // mPrimaryMpoImg, primaryWidth, primaryHeight, primaryStride,
- // depthMap, depthMapWidth, depthMapHeight, depthMapStride);
-
- } else {
- // read auxiliary image and generate depth map.
- Bitmap auxiliaryBm = BitmapFactory.decodeByteArray(auxiliaryMpoData, 0, auxiliaryMpoData.length);
- auxiliaryMpoData = null;
-
- if(auxiliaryBm == null) {
- primaryBm.recycle();
- primaryBm = null;
- return false;
- }
-
- DualCameraNativeEngine.getInstance().initDepthMap(
- primaryBm, auxiliaryBm, mpoFilepath,
- DualCameraNativeEngine.getInstance().getCalibFilepath(mActivity));
+ // read auxiliary image and generate depth map.
+ Bitmap auxiliaryBm = BitmapFactory.decodeByteArray(auxiliaryMpoData, 0, auxiliaryMpoData.length);
+ auxiliaryMpoData = null;
+ if(auxiliaryBm == null) {
primaryBm.recycle();
primaryBm = null;
- auxiliaryBm.recycle();
- auxiliaryBm = null;
+ return false;
+ }
+
+ DualCameraNativeEngine.getInstance().initDepthMap(
+ primaryBm, auxiliaryBm, mpoFilepath,
+ DualCameraNativeEngine.getInstance().getCalibFilepath(mActivity));
+
+ primaryBm.recycle();
+ primaryBm = null;
+ auxiliaryBm.recycle();
+ auxiliaryBm = null;
- Point size = new Point();
- boolean result = DualCameraNativeEngine.getInstance().getDepthMapSize(size);
- if(result) {
- Log.v(LOGTAG, "get depthmapsize returned true. size: " + size.x + "x" + size.y);
+ Point size = new Point();
+ boolean result = DualCameraNativeEngine.getInstance().getDepthMapSize(size);
+ if(result) {
+ Log.v(LOGTAG, "get depthmapsize returned true. size: " + size.x + "x" + size.y);
+ if(size.x == 0 || size.y == 0) {
+ Log.v(LOGTAG, "invalid ddm size: " + size.x + "x" + size.y);
+ loaded = false;
+ } else {
Bitmap depthMap = Bitmap.createBitmap(size.x, size.y, Config.ALPHA_8);
if(DualCameraNativeEngine.getInstance().getDepthMap(depthMap)) {
loaded = true;
-
- // TODO: write and read depth map.
- // MpoParser.writeDepthMapFile(depthFilepath, depthMap);
} else {
Log.w(LOGTAG, "get depthmap returned false");
}
depthMap.recycle();
depthMap = null;
- } else {
- Log.w(LOGTAG, "get depthmapsize returned false");
}
+ } else {
+ Log.w(LOGTAG, "get depthmapsize returned false");
}
}
+
return loaded;
}
@@ -957,4 +948,17 @@ public class MasterImage implements RenderingRequestCaller {
public Rect getImageBounds() {
return mImageBounds;
}
+
+ public boolean isDepthMapLoadingDone() {
+ return (mDepthMapLoadingStatus == DdmStatus.DDM_LOADED ||
+ mDepthMapLoadingStatus == DdmStatus.DDM_FAILED);
+ }
+
+ public DdmStatus getDepthMapLoadingStatus() {
+ return mDepthMapLoadingStatus;
+ }
+
+ public void setDepthMapLoadingStatus(DdmStatus status) {
+ mDepthMapLoadingStatus = status;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/tools/DualCameraNativeEngine.java b/src/com/android/gallery3d/filtershow/tools/DualCameraNativeEngine.java
index e5f13b4ff..5a8581ff1 100644
--- a/src/com/android/gallery3d/filtershow/tools/DualCameraNativeEngine.java
+++ b/src/com/android/gallery3d/filtershow/tools/DualCameraNativeEngine.java
@@ -30,7 +30,6 @@
package com.android.gallery3d.filtershow.tools;
import java.io.File;
-import java.nio.ByteBuffer;
import android.content.Context;
import android.graphics.Bitmap;
@@ -50,6 +49,14 @@ public class DualCameraNativeEngine {
}
}
+ // Status of Depth Map loading for current image
+ public static enum DdmStatus {
+ DDM_IDLE,
+ DDM_LOADING,
+ DDM_LOADED,
+ DDM_FAILED
+ };
+
public static final String DEPTH_MAP_EXT = "dm";
private static final String CALIBRATION_FILENAME = "ddm_calib_file.dat";
private static boolean mLibLoaded;