summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorPankaj Garg <pgarg@codeaurora.org>2015-12-01 15:24:21 -0800
committerjrizzoli <joey@cyanogenmoditalia.it>2015-12-03 19:57:05 +0100
commit4fded5d617a7934c3c8b15f92ad3e22f9627f4ef (patch)
tree21c64f70e442cf0d34e6190d649a8008f562ed79 /src/com
parenta3d93b1aa56fdd91c3ff98e12aa0b55a174f3e3b (diff)
downloadandroid_packages_apps_Gello-4fded5d617a7934c3c8b15f92ad3e22f9627f4ef.tar.gz
android_packages_apps_Gello-4fded5d617a7934c3c8b15f92ad3e22f9627f4ef.tar.bz2
android_packages_apps_Gello-4fded5d617a7934c3c8b15f92ad3e22f9627f4ef.zip
Reduce bitmap captures on EdgeNavigation
CR-Fixed: SWE-6185 Change-Id: I2609eed98b11733cae9be077a29e78e4ac9dc268
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/browser/EdgeSwipeModel.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/com/android/browser/EdgeSwipeModel.java b/src/com/android/browser/EdgeSwipeModel.java
index 2d8517bf..419e2652 100644
--- a/src/com/android/browser/EdgeSwipeModel.java
+++ b/src/com/android/browser/EdgeSwipeModel.java
@@ -37,8 +37,14 @@ import android.webkit.ValueCallback;
import org.codeaurora.swe.WebHistoryItem;
public class EdgeSwipeModel {
+ private static final int MS_TIME_BETWEEN_CAPTURES = 1000;
private SparseArray<Bitmap> mBitmaps;
private SparseArray<Integer> mColors;
+
+ private long mLastCaptureTime;
+ private int mLastCaptureIndex;
+ private Bitmap mLastBitmap;
+
private Tab mTab;
private TitleBar mBar;
@@ -49,6 +55,8 @@ public class EdgeSwipeModel {
public EdgeSwipeModel(Tab tab, TitleBar bar) {
mTab = tab;
mBar = bar;
+ mLastCaptureIndex = -1;
+ mLastCaptureTime = 0;
mBitmaps = new SparseArray<>();
mColors = new SparseArray<>();
}
@@ -58,7 +66,7 @@ public class EdgeSwipeModel {
return;
}
- int captureIndex = mTab.getCaptureIndex(index);
+ final int captureIndex = mTab.getCaptureIndex(index);
boolean bitmapExists = mTab.getWebView().hasSnapshot(captureIndex);
@@ -68,10 +76,14 @@ public class EdgeSwipeModel {
}
int progress = mBar.getProgressView().getProgressPercent();
+ long currentTime = System.currentTimeMillis();
- if (bitmapExists && progress < mMinProgress) {
- fetchSnapshot(index);
- return;
+ if (bitmapExists) {
+ if (progress < mMinProgress || (captureIndex == mLastCaptureIndex &&
+ (currentTime < (mLastCaptureTime + MS_TIME_BETWEEN_CAPTURES)))) {
+ fetchSnapshot(index);
+ return;
+ }
}
mTab.getWebView().captureSnapshot(captureIndex,
@@ -79,6 +91,9 @@ public class EdgeSwipeModel {
@Override
public void onReceiveValue(Bitmap value) {
mBitmaps.put(index, value);
+ mLastCaptureTime = System.currentTimeMillis();
+ mLastCaptureIndex = captureIndex;
+ mLastBitmap = value;
}
}
);
@@ -101,6 +116,12 @@ public class EdgeSwipeModel {
}
int captureIndex = mTab.getCaptureIndex(index);
+ long currentTime = System.currentTimeMillis();
+ if (captureIndex == mLastCaptureIndex &&
+ (currentTime < (mLastCaptureTime + MS_TIME_BETWEEN_CAPTURES))) {
+ mBitmaps.put(index, mLastBitmap);
+ return;
+ }
mTab.getWebView().getSnapshot(captureIndex,
new ValueCallback<Bitmap>() {