summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 04:36:28 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 04:36:28 +0000
commita3533897de5e550356474514f9be0a5b65584950 (patch)
treea3fac3675d0f3935fdd01612055b32b76ca9ddfa /chrome
parent84a860d5da29aeb8b6229bb220f544505607a791 (diff)
downloadchromium_src-a3533897de5e550356474514f9be0a5b65584950.zip
chromium_src-a3533897de5e550356474514f9be0a5b65584950.tar.gz
chromium_src-a3533897de5e550356474514f9be0a5b65584950.tar.bz2
Tweaks to tab overview to get it performant:
. Delay getting thumnbails until 300ms after the window is shown. This is necessary as getting the thumnbails is very expensive. . Configure the thumnbail for one cell at a time. For same reason as last one. . Don't show new tab window widget as we don't yet have the type set up. BUG=none TEST=none Review URL: http://codereview.chromium.org/147174 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19340 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/tabs/tab_overview_cell.cc3
-rw-r--r--chrome/browser/views/tabs/tab_overview_cell.h6
-rw-r--r--chrome/browser/views/tabs/tab_overview_controller.cc39
-rw-r--r--chrome/browser/views/tabs/tab_overview_controller.h26
-rw-r--r--chrome/browser/views/tabs/tab_overview_message_listener.cc3
5 files changed, 71 insertions, 6 deletions
diff --git a/chrome/browser/views/tabs/tab_overview_cell.cc b/chrome/browser/views/tabs/tab_overview_cell.cc
index b0b5f9f..0dc46e5 100644
--- a/chrome/browser/views/tabs/tab_overview_cell.cc
+++ b/chrome/browser/views/tabs/tab_overview_cell.cc
@@ -25,7 +25,7 @@ static const int kThumbnailWidth = 220;
// Padding between favicon/title and thumbnail.
static const int kVerticalPadding = 10;
-TabOverviewCell::TabOverviewCell() {
+TabOverviewCell::TabOverviewCell() : configured_thumbnail_(false) {
title_label_ = new views::Label();
title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
@@ -69,6 +69,7 @@ void TabOverviewCell::SetThumbnail(const SkBitmap& thumbnail) {
// input bitmap isn't guaranteed to have any specific resolution.
thumbnail_view_->SetImage(skia::ImageOperations::DownsampleByTwoUntilSize(
thumbnail, kThumbnailWidth, kThumbnailHeight));
+ configured_thumbnail_ = true;
}
void TabOverviewCell::SetTitle(const string16& title) {
diff --git a/chrome/browser/views/tabs/tab_overview_cell.h b/chrome/browser/views/tabs/tab_overview_cell.h
index 9411cec..08c0055 100644
--- a/chrome/browser/views/tabs/tab_overview_cell.h
+++ b/chrome/browser/views/tabs/tab_overview_cell.h
@@ -35,6 +35,10 @@ class TabOverviewCell : public views::View {
// the thumbnail.
bool IsPointInThumbnail(const gfx::Point& point);
+ // Has the thumbnail been configured? This is true after SetThumbnail
+ // is invoked.
+ bool configured_thumbnail() const { return configured_thumbnail_; }
+
// View overrides.
virtual gfx::Size GetPreferredSize();
@@ -46,6 +50,8 @@ class TabOverviewCell : public views::View {
// Specific preferred size. See set_preferred_size() for details.
gfx::Size preferred_size_;
+ bool configured_thumbnail_;
+
DISALLOW_COPY_AND_ASSIGN(TabOverviewCell);
};
diff --git a/chrome/browser/views/tabs/tab_overview_controller.cc b/chrome/browser/views/tabs/tab_overview_controller.cc
index fd4e403..f4027b3 100644
--- a/chrome/browser/views/tabs/tab_overview_controller.cc
+++ b/chrome/browser/views/tabs/tab_overview_controller.cc
@@ -38,7 +38,8 @@ TabOverviewController::TabOverviewController(
shown_(false),
horizontal_center_(0),
change_window_bounds_on_animate_(false),
- mutating_grid_(false) {
+ mutating_grid_(false),
+ show_thumbnails_(false) {
grid_ = new TabOverviewGrid(this);
// Determine the max size for the overview.
@@ -108,6 +109,9 @@ void TabOverviewController::Show() {
shown_ = true;
DCHECK(model()); // The model needs to be set before showing.
host_->Show();
+ delay_timer_.Start(
+ base::TimeDelta::FromMilliseconds(350), this,
+ &TabOverviewController::StartConfiguring);
}
void TabOverviewController::ConfigureCell(TabOverviewCell* cell,
@@ -116,14 +120,21 @@ void TabOverviewController::ConfigureCell(TabOverviewCell* cell,
cell->SetTitle(contents->GetTitle());
cell->SetFavIcon(contents->GetFavIcon());
- ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator();
- cell->SetThumbnail(
- generator->GetThumbnailForRenderer(contents->render_view_host()));
-
+ if (show_thumbnails_) {
+ ThumbnailGenerator* generator =
+ g_browser_process->GetThumbnailGenerator();
+ cell->SetThumbnail(
+ generator->GetThumbnailForRenderer(contents->render_view_host()));
+ }
cell->SchedulePaint();
} else {
// Need to figure out under what circumstances this is null and deal.
NOTIMPLEMENTED();
+
+ // Make sure we set the thumbnail, otherwise configured_thumbnail
+ // remains false and ConfigureNextUnconfiguredCell would get stuck.
+ if (show_thumbnails_)
+ cell->SetThumbnail(SkBitmap());
}
}
@@ -309,3 +320,21 @@ gfx::Rect TabOverviewController::CalculateHostBounds() {
kWindowToOverviewPadding - max_height, max_width,
max_height);
}
+
+void TabOverviewController::StartConfiguring() {
+ show_thumbnails_ = true;
+ configure_timer_.Start(
+ base::TimeDelta::FromMilliseconds(10), this,
+ &TabOverviewController::ConfigureNextUnconfiguredCell);
+}
+
+void TabOverviewController::ConfigureNextUnconfiguredCell() {
+ for (int i = 0; i < grid_->GetChildViewCount(); ++i) {
+ TabOverviewCell* cell = grid_->GetTabOverviewCellAt(i);
+ if (!cell->configured_thumbnail()) {
+ ConfigureCell(cell, i);
+ return;
+ }
+ }
+ configure_timer_.Stop();
+}
diff --git a/chrome/browser/views/tabs/tab_overview_controller.h b/chrome/browser/views/tabs/tab_overview_controller.h
index 494f01c..15b13f5 100644
--- a/chrome/browser/views/tabs/tab_overview_controller.h
+++ b/chrome/browser/views/tabs/tab_overview_controller.h
@@ -7,6 +7,7 @@
#include "base/gfx/rect.h"
#include "base/scoped_ptr.h"
+#include "base/timer.h"
#include "chrome/browser/tabs/tab_strip_model.h"
class Animation;
@@ -28,6 +29,13 @@ class Widget;
// size of the host window is created at the largest possible size the
// window can be and the bounds of the container are changed during the
// animation.
+//
+// As obtaining and setting thumbnails is expensive we delay setting the
+// thumbnail. The delay is controlled by delay_timer_. Once the timer fires
+// another timer is started (configure_timer_). This timer invokes
+// ConfigureNextUnconfiguredCell, which obtains and sets the thumbnail of
+// the next uncofigured cell. ConfigureNextUnconfiguredCell only configures
+// one cell at a time.
class TabOverviewController : public TabStripModelObserver {
public:
// Creates a TabOverviewController that will be shown on the monitor
@@ -110,6 +118,14 @@ class TabOverviewController : public TabStripModelObserver {
// See comment above class description for more details.
gfx::Rect CalculateHostBounds();
+ // Invoked by delay_timer_. Sets show_thumbnails_ to true and starts
+ // configure_timer_.
+ void StartConfiguring();
+
+ // Finds the first cell with no thumbnail and invokes ConfigureCell for
+ // it. If all the thumnbails have been set configure_timer_ is stopped.
+ void ConfigureNextUnconfiguredCell();
+
// The widget showing the view.
views::Widget* host_;
@@ -152,6 +168,16 @@ class TabOverviewController : public TabStripModelObserver {
// bounds when we're responsible for the mutation.
bool mutating_grid_;
+ // Should we set the thumbnails? This is initially false, then set to true
+ // by StartConfiguring.
+ bool show_thumbnails_;
+
+ // See description above class for details.
+ base::OneShotTimer<TabOverviewController> delay_timer_;
+
+ // See description above class for details.
+ base::RepeatingTimer<TabOverviewController> configure_timer_;
+
DISALLOW_COPY_AND_ASSIGN(TabOverviewController);
};
diff --git a/chrome/browser/views/tabs/tab_overview_message_listener.cc b/chrome/browser/views/tabs/tab_overview_message_listener.cc
index 63dff1f..0f3b1f3 100644
--- a/chrome/browser/views/tabs/tab_overview_message_listener.cc
+++ b/chrome/browser/views/tabs/tab_overview_message_listener.cc
@@ -60,6 +60,8 @@ void TabOverviewMessageListener::ProcessMessage(
}
case TabOverviewTypes::Message::CHROME_NOTIFY_LAYOUT_MODE: {
+ // TODO: enable this once we have type.
+#if 0
if (message.param(0) == 0) {
new_browser_window_.reset(NULL);
} else if (BrowserList::size() > 0) {
@@ -67,6 +69,7 @@ void TabOverviewMessageListener::ProcessMessage(
new_browser_window_.reset(
new NewBrowserWindowWidget(browser->profile()));
}
+#endif
break;
}