From c3ee6f79c78d6fcb470262afc140aad614b8624c Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Wed, 24 Jun 2009 22:36:15 +0000 Subject: Fix a bug generating thumbnails. We would only use a stashed thumbnail when it hadn't expired (5 seconds), even if there was no backing store. We now use the stashed one no matter what if there is no backing store to create a new one. Review URL: http://codereview.chromium.org/147087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19188 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/tab_contents/thumbnail_generator.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc index efc06ff..9f80c57 100755 --- a/chrome/browser/tab_contents/thumbnail_generator.cc +++ b/chrome/browser/tab_contents/thumbnail_generator.cc @@ -191,19 +191,26 @@ void ThumbnailGenerator::StartThumbnailing() { SkBitmap ThumbnailGenerator::GetThumbnailForRenderer( RenderWidgetHost* renderer) const { - // Return a cached one if we have it and it's still valid. This will only be - // valid when there used to be a backing store, but there isn't now. WidgetThumbnail* wt = GetDataForHost(renderer); + + BackingStore* backing_store = renderer->GetBackingStore(false); + if (!backing_store) { + // When we have no backing store, there's no choice in what to use. We + // have to return either the existing thumbnail or the empty one if there + // isn't a saved one. + return wt->thumbnail; + } + + // Now that we have a backing store, we have a choice to use it to make + // a new thumbnail, or use a previously stashed one if we have it. + // + // Return the previously-computed one if we have it and it hasn't expired. if (!wt->thumbnail.isNull() && (no_timeout_ || base::TimeTicks::Now() - base::TimeDelta::FromMilliseconds(kVisibilitySlopMS) < wt->last_shown)) return wt->thumbnail; - BackingStore* backing_store = renderer->GetBackingStore(false); - if (!backing_store) - return SkBitmap(); - // Save this thumbnail in case we need to use it again soon. It will be // invalidated on the next paint. wt->thumbnail = GetThumbnailForBackingStore(backing_store); -- cgit v1.1