use of com.android.gallery3d.filtershow.imageshow.MasterImage in project android_packages_apps_Gallery2 by LineageOS.
the class StateView method onTouchEvent.
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean ret = super.onTouchEvent(event);
FilterShowActivity activity = (FilterShowActivity) getContext();
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
activity.startTouchAnimation(this, event.getX(), event.getY());
}
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mStartTouchY = event.getY();
mStartTouchX = event.getX();
if (mType == BEGIN) {
MasterImage.getImage().setShowsOriginal(true);
}
}
if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
setTranslationX(0);
setTranslationY(0);
MasterImage.getImage().setShowsOriginal(false);
if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_UP) {
setSelected(true);
FilterRepresentation representation = getState().getFilterRepresentation();
MasterImage image = MasterImage.getImage();
ImagePreset preset = image != null ? image.getCurrentPreset() : null;
if (getTranslationY() == 0 && image != null && preset != null && representation != image.getCurrentFilterRepresentation() && preset.getRepresentation(representation) != null) {
activity.showRepresentation(representation);
setSelected(false);
}
}
}
if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_MOVE) {
float delta = event.getY() - mStartTouchY;
if (Math.abs(delta) > mDeleteSlope) {
activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
}
}
return true;
}
use of com.android.gallery3d.filtershow.imageshow.MasterImage in project android_packages_apps_Gallery2 by LineageOS.
the class CachingPipeline method render.
public synchronized void render(RenderingRequest request) {
// TODO: cleanup/remove GEOMETRY / FILTERS paths
synchronized (CachingPipeline.class) {
if (getRenderScriptContext() == null) {
return;
}
if ((request.getType() != RenderingRequest.PARTIAL_RENDERING && request.getType() != RenderingRequest.ICON_RENDERING && request.getBitmap() == null) || request.getImagePreset() == null) {
return;
}
if (DEBUG) {
Log.v(LOGTAG, "render image of type " + getType(request));
}
Bitmap bitmap = request.getBitmap();
ImagePreset preset = request.getImagePreset();
setupEnvironment(preset, true);
mFiltersManager.freeFilterResources(preset);
if (request.getType() == RenderingRequest.PARTIAL_RENDERING) {
MasterImage master = MasterImage.getImage();
bitmap = ImageLoader.getScaleOneImageForPreset(master.getActivity(), mEnvironment.getBimapCache(), master.getUri(), request.getBounds(), request.getDestination());
if (bitmap == null) {
Log.w(LOGTAG, "could not get bitmap for: " + getType(request));
return;
}
}
if (request.getType() == RenderingRequest.FULL_RENDERING || request.getType() == RenderingRequest.GEOMETRY_RENDERING || request.getType() == RenderingRequest.FILTERS_RENDERING) {
updateOriginalAllocation(preset);
}
if (DEBUG && bitmap != null) {
Log.v(LOGTAG, "after update, req bitmap (" + bitmap.getWidth() + "x" + bitmap.getHeight() + " ? resizeOriginal (" + mResizedOriginalBitmap.getWidth() + "x" + mResizedOriginalBitmap.getHeight());
}
if (request.getType() == RenderingRequest.FULL_RENDERING || request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
mOriginalAllocation.copyTo(bitmap);
} else if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
mFiltersOnlyOriginalAllocation.copyTo(bitmap);
}
if (request.getType() == RenderingRequest.FULL_RENDERING || request.getType() == RenderingRequest.FILTERS_RENDERING || request.getType() == RenderingRequest.ICON_RENDERING || request.getType() == RenderingRequest.PARTIAL_RENDERING || request.getType() == RenderingRequest.STYLE_ICON_RENDERING) {
if (request.getType() == RenderingRequest.ICON_RENDERING) {
mEnvironment.setQuality(FilterEnvironment.QUALITY_ICON);
} else {
mEnvironment.setQuality(FilterEnvironment.QUALITY_PREVIEW);
}
if (request.getType() == RenderingRequest.ICON_RENDERING) {
Rect iconBounds = request.getIconBounds();
Bitmap source = MasterImage.getImage().getThumbnailBitmap();
if (iconBounds.width() > source.getWidth() * 2) {
source = MasterImage.getImage().getLargeThumbnailBitmap();
}
if (iconBounds != null) {
bitmap = mEnvironment.getBitmap(iconBounds.width(), iconBounds.height(), BitmapCache.ICON);
Canvas canvas = new Canvas(bitmap);
Matrix m = new Matrix();
float minSize = Math.min(source.getWidth(), source.getHeight());
float maxSize = Math.max(iconBounds.width(), iconBounds.height());
float scale = maxSize / minSize;
m.setScale(scale, scale);
float dx = (iconBounds.width() - (source.getWidth() * scale)) / 2.0f;
float dy = (iconBounds.height() - (source.getHeight() * scale)) / 2.0f;
m.postTranslate(dx, dy);
canvas.drawBitmap(source, m, new Paint(Paint.FILTER_BITMAP_FLAG));
} else {
bitmap = mEnvironment.getBitmapCopy(source, BitmapCache.ICON);
}
}
Bitmap bmp = preset.apply(bitmap, mEnvironment);
if (!mEnvironment.needsStop()) {
request.setBitmap(bmp);
}
mFiltersManager.freeFilterResources(preset);
}
}
}
use of com.android.gallery3d.filtershow.imageshow.MasterImage in project android_packages_apps_Gallery2 by LineageOS.
the class EditorPanel method cancelCurrentFilter.
public void cancelCurrentFilter() {
MasterImage masterImage = MasterImage.getImage();
HistoryManager adapter = masterImage.getHistory();
int position = adapter.undo();
masterImage.onHistoryItemClick(position);
((FilterShowActivity) getActivity()).invalidateViews();
}
use of com.android.gallery3d.filtershow.imageshow.MasterImage in project android_packages_apps_Gallery2 by LineageOS.
the class EditorRotate method reflectCurrentFilter.
@Override
public void reflectCurrentFilter() {
MasterImage master = MasterImage.getImage();
master.setCurrentFilterRepresentation(master.getPreset().getFilterWithSerializationName(FilterRotateRepresentation.SERIALIZATION_NAME));
super.reflectCurrentFilter();
FilterRepresentation rep = getLocalRepresentation();
if (rep == null || rep instanceof FilterRotateRepresentation) {
mImageRotate.setFilterRotateRepresentation((FilterRotateRepresentation) rep);
} else {
Log.w(TAG, "Could not reflect current filter, not of type: " + FilterRotateRepresentation.class.getSimpleName());
}
mImageRotate.invalidate();
}
Aggregations