From e94153995bd4b1551d58d4f0e785c4bc631a18b1 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Wed, 25 Jan 2012 18:36:03 -0500 Subject: [PATCH] bug 721216 - Bitmap compression on main thread causes the tab strip to take a long time to appear r=pcwalton --- mobile/android/base/GeckoApp.java | 9 ++++----- mobile/android/base/Tabs.java | 10 +++++++--- mobile/android/base/TabsTray.java | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 734ce65c195..9571e629f1c 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -594,11 +594,10 @@ abstract public class GeckoApp } } - void getAndProcessThumbnailForTab(Tab tab) { - Bitmap bitmap = null; - if (Tabs.getInstance().isSelectedTab(tab)) - bitmap = mSoftwareLayerClient.getBitmap(); - + void getAndProcessThumbnailForTab(final Tab tab) { + final Bitmap bitmap = Tabs.getInstance().isSelectedTab(tab) ? + mSoftwareLayerClient.getBitmap() : null; + if (bitmap != null) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 0, bos); diff --git a/mobile/android/base/Tabs.java b/mobile/android/base/Tabs.java index f1511e385b7..4ccf6eb70d9 100644 --- a/mobile/android/base/Tabs.java +++ b/mobile/android/base/Tabs.java @@ -288,8 +288,12 @@ public class Tabs implements GeckoEventListener { } public void refreshThumbnails() { - Iterator iterator = tabs.values().iterator(); - while (iterator.hasNext()) - GeckoApp.mAppContext.getAndProcessThumbnailForTab(iterator.next()); + GeckoAppShell.getHandler().post(new Runnable() { + public void run() { + Iterator iterator = tabs.values().iterator(); + while (iterator.hasNext()) + GeckoApp.mAppContext.getAndProcessThumbnailForTab(iterator.next()); + } + }); } } diff --git a/mobile/android/base/TabsTray.java b/mobile/android/base/TabsTray.java index a67e2fc7276..f1bf9a317c1 100644 --- a/mobile/android/base/TabsTray.java +++ b/mobile/android/base/TabsTray.java @@ -91,8 +91,8 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener } }); - Tabs.getInstance().refreshThumbnails(); GeckoApp.registerOnTabsChangedListener(this); + Tabs.getInstance().refreshThumbnails(); onTabsChanged(null); }