bug 721216 - Bitmap compression on main thread causes the tab strip to take a long time to appear r=pcwalton

This commit is contained in:
Brad Lassey 2012-01-25 18:36:03 -05:00
parent 24036897e7
commit e94153995b
3 changed files with 12 additions and 9 deletions

View File

@ -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);

View File

@ -288,8 +288,12 @@ public class Tabs implements GeckoEventListener {
}
public void refreshThumbnails() {
Iterator<Tab> iterator = tabs.values().iterator();
while (iterator.hasNext())
GeckoApp.mAppContext.getAndProcessThumbnailForTab(iterator.next());
GeckoAppShell.getHandler().post(new Runnable() {
public void run() {
Iterator<Tab> iterator = tabs.values().iterator();
while (iterator.hasNext())
GeckoApp.mAppContext.getAndProcessThumbnailForTab(iterator.next());
}
});
}
}

View File

@ -91,8 +91,8 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
}
});
Tabs.getInstance().refreshThumbnails();
GeckoApp.registerOnTabsChangedListener(this);
Tabs.getInstance().refreshThumbnails();
onTabsChanged(null);
}