OSDN Git Service

Pinch to zoom refine
authornicolasroard <nicolasroard@google.com>
Thu, 21 Feb 2013 23:52:49 +0000 (15:52 -0800)
committernicolasroard <nicolasroard@google.com>
Fri, 22 Feb 2013 01:43:58 +0000 (17:43 -0800)
Change-Id: I538defa55a4ed898dd7c936ec813f052ac1b9e0a

src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
src/com/android/gallery3d/filtershow/presets/ImagePreset.java

index 6c83170..3511c67 100644 (file)
@@ -19,6 +19,7 @@ public class FilterCurvesRepresentation extends FilterRepresentation {
         setShowEditingControls(false);
         setShowParameterValue(false);
         setShowUtilityPanel(true);
+        setSupportsPartialRendering(true);
         for (int i = 0; i < mSplines.length; i++) {
             mSplines[i] = new Spline();
             mSplines[i].reset();
index 859bf32..d4128dc 100644 (file)
@@ -37,6 +37,7 @@ public class FilterFxRepresentation extends FilterRepresentation {
         setShowEditingControls(false);
         setShowParameterValue(false);
         setShowUtilityPanel(false);
+        setSupportsPartialRendering(true);
     }
 
     public String toString() {
index 513cdcd..83f2a1b 100644 (file)
@@ -25,6 +25,7 @@ public class FilterRepresentation implements Cloneable {
     private String mName;
     private int mPriority = TYPE_NORMAL;
     private Class mFilterClass;
+    private boolean mSupportsPartialRendering = false;
     private int mTextId = 0;
     private int mEditorId = BasicEditor.ID;
     private int mButtonId = 0;
@@ -52,6 +53,7 @@ public class FilterRepresentation implements Cloneable {
         representation.setName(getName());
         representation.setPriority(getPriority());
         representation.setFilterClass(getFilterClass());
+        representation.setSupportsPartialRendering(supportsPartialRendering());
         representation.setTextId(getTextId());
         representation.setEditorId(getEditorId());
         representation.setButtonId(getButtonId());
@@ -70,6 +72,7 @@ public class FilterRepresentation implements Cloneable {
         if (representation.mFilterClass == representation.mFilterClass
                 && representation.mName.equalsIgnoreCase(mName)
                 && representation.mPriority == mPriority
+                && representation.mSupportsPartialRendering == mSupportsPartialRendering
                 && representation.mTextId == mTextId
                 && representation.mEditorId == mEditorId
                 && representation.mButtonId == mButtonId
@@ -106,6 +109,14 @@ public class FilterRepresentation implements Cloneable {
         return false;
     }
 
+    public boolean supportsPartialRendering() {
+        return mSupportsPartialRendering;
+    }
+
+    public void setSupportsPartialRendering(boolean value) {
+        mSupportsPartialRendering = value;
+    }
+
     public void useParametersFrom(FilterRepresentation a) {
     }
 
index 84266c5..ae5a034 100644 (file)
@@ -17,6 +17,7 @@
 package com.android.gallery3d.filtershow.presets;
 
 import android.graphics.Bitmap;
+import android.graphics.Rect;
 import android.util.Log;
 
 import com.android.gallery3d.filtershow.ImageStateAdapter;
@@ -52,6 +53,8 @@ public class ImagePreset {
     private boolean mDoApplyFilters = true;
 
     public final GeometryMetadata mGeoData = new GeometryMetadata();
+    private boolean mPartialRendering = false;
+    private Rect mPartialRenderingBounds;
 
     public ImagePreset() {
         setup();
@@ -421,6 +424,22 @@ public class ImagePreset {
         return bitmap;
     }
 
+    public boolean canDoPartialRendering() {
+        if (mGeoData.hasModifications()) {
+            return false;
+        }
+        for (int i = 0; i < mFilters.size(); i++) {
+            FilterRepresentation representation = null;
+            synchronized (mFilters) {
+                representation = mFilters.elementAt(i);
+            }
+            if (!representation.supportsPartialRendering()) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     public void fillImageStateAdapter(ImageStateAdapter imageStateAdapter) {
         if (imageStateAdapter == null) {
             return;
@@ -446,4 +465,17 @@ public class ImagePreset {
     public void setScaleFactor(float value) {
         mScaleFactor = value;
     }
+
+    public void setPartialRendering(boolean partialRendering, Rect bounds) {
+        mPartialRendering = partialRendering;
+        mPartialRenderingBounds = bounds;
+    }
+
+    public boolean isPartialRendering() {
+        return mPartialRendering;
+    }
+
+    public Rect getPartialRenderingBounds() {
+        return mPartialRenderingBounds;
+    }
 }