diff options
Diffstat (limited to 'src')
5 files changed, 65 insertions, 13 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 99449a45e..1824e7fd0 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -122,6 +122,7 @@ import com.android.gallery3d.filtershow.tools.XmpPresets; import com.android.gallery3d.filtershow.tools.XmpPresets.XMresults; import com.android.gallery3d.filtershow.ui.ExportDialog; import com.android.gallery3d.filtershow.ui.FramedTextButton; +import com.android.gallery3d.mpo.MpoParser; import com.android.gallery3d.util.GalleryUtils; import com.android.photos.data.GalleryBitmapPool; import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine; @@ -165,6 +166,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private LoadBitmapTask mLoadBitmapTask; private LoadHighresBitmapTask mHiResBitmapTask; + private ParseMpoDataTask mParseMpoTask; private LoadMpoDataTask mLoadMpoTask; private Uri mOriginalImageUri = null; @@ -767,8 +769,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL mLoadBitmapTask.execute(uri); if(DualCameraNativeEngine.getInstance().isLibLoaded()) { - mLoadMpoTask = new LoadMpoDataTask(); - mLoadMpoTask.execute(); + mParseMpoTask = new ParseMpoDataTask(); + mParseMpoTask.execute(); } else { MasterImage.getImage().setDepthMapLoadingStatus(DdmStatus.DDM_FAILED); } @@ -877,6 +879,11 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL return; } + if (representation.getFilterType() == FilterRepresentation.TYPE_DUALCAM && + MasterImage.getImage().getDepthMapLoadingStatus() == DdmStatus.DDM_FAILED) { + Toast.makeText(this, getString(R.string.dualcam_filter_not_supported), Toast.LENGTH_SHORT).show(); + return; + } if (representation instanceof FilterRotateRepresentation) { FilterRotateRepresentation r = (FilterRotateRepresentation) representation; r.rotateCW(); @@ -995,15 +1002,28 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } - private class LoadMpoDataTask extends AsyncTask<Void, Void, Boolean> { + private class ParseMpoDataTask extends AsyncTask<Void, Void, byte[]> { @Override - protected Boolean doInBackground(Void... params) { - return MasterImage.getImage().loadMpo(); + protected void onPreExecute() { + MasterImage.getImage().setDepthMapLoadingStatus(DdmStatus.DDM_PARSING); } @Override - protected void onPostExecute(Boolean result) { - MasterImage.getImage().setDepthMapLoadingStatus(result?DdmStatus.DDM_LOADED:DdmStatus.DDM_FAILED); + protected byte[] doInBackground(Void... params) { + MpoParser parser = MpoParser.parse(FilterShowActivity.this, MasterImage.getImage().getUri()); + return parser.readImgData(false); + } + + @Override + protected void onPostExecute(byte[] result) { + if(result == null) { + // parse failed + MasterImage.getImage().setDepthMapLoadingStatus(DdmStatus.DDM_FAILED); + } else { + mLoadMpoTask = new LoadMpoDataTask(); + mLoadMpoTask.execute(result); + } + Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); if (currentPanel instanceof MainPanel) { MainPanel mainPanel = (MainPanel) currentPanel; @@ -1012,6 +1032,24 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } + private class LoadMpoDataTask extends AsyncTask<byte[], Void, Boolean> { + @Override + protected void onPreExecute() { + MasterImage.getImage().setDepthMapLoadingStatus(DdmStatus.DDM_LOADING); + } + + @Override + protected Boolean doInBackground(byte[]... params) { + return MasterImage.getImage().loadMpo(params[0]); + } + + @Override + protected void onPostExecute(Boolean result) { + MasterImage.getImage().setDepthMapLoadingStatus(result?DdmStatus.DDM_LOADED:DdmStatus.DDM_FAILED); + stopLoadingIndicator(); + } + } + public boolean isLoadingVisible() { if(mLoadingDialog != null) { return mLoadingDialog.isShowing(); @@ -1168,6 +1206,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL mHiResBitmapTask.cancel(false); } + if(mParseMpoTask != null) { + mParseMpoTask.cancel(false); + } + if(mLoadMpoTask != null) { mLoadMpoTask.cancel(false); } diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java index e10dd51b2..0d7d6f6ce 100644 --- a/src/com/android/gallery3d/filtershow/category/MainPanel.java +++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java @@ -329,6 +329,12 @@ public class MainPanel extends Fragment { setCategoryFragment(categoryPanel, fromRight); mCurrentSelected = DUALCAM; selection(mCurrentSelected, true); + + if(MasterImage.getImage().isDepthMapLoadingDone() == false) { + FilterShowActivity activity = (FilterShowActivity) getActivity(); + if(activity.isLoadingVisible() == false) + activity.startLoadingIndicator(); + } } public void showPanel(int currentPanel) { @@ -430,7 +436,8 @@ public class MainPanel extends Fragment { public void updateDualCameraButton() { if(dualCamButton != null) { DdmStatus status = MasterImage.getImage().getDepthMapLoadingStatus(); - boolean enable = (status == DdmStatus.DDM_LOADED); + boolean enable = (status == DdmStatus.DDM_LOADING || + 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 58bddce65..d6f7e228b 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java @@ -275,7 +275,7 @@ public class ImageShow extends View implements OnGestureListener, if(img.getLoadedPreset() != null && !img.getLoadedPreset().equals(img.getCurrentPreset())) { return; - } else if (img.isDepthMapLoadingDone()) { + } else if (img.isDepthMapParsingDone()) { mActivity.stopLoadingIndicator(); } } diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java index 85f7a664d..ec0b1476c 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java +++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java @@ -922,10 +922,8 @@ public class MasterImage implements RenderingRequestCaller { return mPreset.contains(FilterRepresentation.TYPE_TINYPLANET); } - public boolean loadMpo() { + public boolean loadMpo(byte[] auxiliaryMpoData) { boolean loaded = false; - MpoParser parser = MpoParser.parse(getActivity(), getUri()); - byte[] auxiliaryMpoData = parser.readImgData(false); if(auxiliaryMpoData != null) { Bitmap primaryBm = ImageLoader.loadBitmap(getActivity(), getUri(), null); @@ -938,7 +936,6 @@ public class MasterImage implements RenderingRequestCaller { String mpoFilepath = ImageLoader.getLocalPathFromUri(getActivity(), getUri()); // read auxiliary image and generate depth map. Bitmap auxiliaryBm = BitmapFactory.decodeByteArray(auxiliaryMpoData, 0, auxiliaryMpoData.length); - auxiliaryMpoData = null; if(auxiliaryBm == null) { primaryBm.recycle(); @@ -1007,6 +1004,11 @@ public class MasterImage implements RenderingRequestCaller { return mImageBounds; } + public boolean isDepthMapParsingDone() { + return (mDepthMapLoadingStatus == DdmStatus.DDM_LOADING || + mDepthMapLoadingStatus == DdmStatus.DDM_FAILED); + } + public boolean isDepthMapLoadingDone() { return (mDepthMapLoadingStatus == DdmStatus.DDM_LOADED || mDepthMapLoadingStatus == DdmStatus.DDM_FAILED); diff --git a/src/com/android/gallery3d/filtershow/tools/DualCameraNativeEngine.java b/src/com/android/gallery3d/filtershow/tools/DualCameraNativeEngine.java index 5a8581ff1..902f54070 100644 --- a/src/com/android/gallery3d/filtershow/tools/DualCameraNativeEngine.java +++ b/src/com/android/gallery3d/filtershow/tools/DualCameraNativeEngine.java @@ -52,6 +52,7 @@ public class DualCameraNativeEngine { // Status of Depth Map loading for current image public static enum DdmStatus { DDM_IDLE, + DDM_PARSING, DDM_LOADING, DDM_LOADED, DDM_FAILED |
