Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: chrome/browser/ui/touch/tabs/touch_tab.cc

Issue 7065052: Improve large tab strip by leveraging touch icons when present (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/touch/tabs/touch_tab.cc
diff --git a/chrome/browser/ui/touch/tabs/touch_tab.cc b/chrome/browser/ui/touch/tabs/touch_tab.cc
index dca408a783e84522e451556d230f89f5d80e80a8..f445eedf21984f609477d7a91ace4be867ae2a76 100644
--- a/chrome/browser/ui/touch/tabs/touch_tab.cc
+++ b/chrome/browser/ui/touch/tabs/touch_tab.cc
@@ -9,6 +9,7 @@
#include "grit/app_resources.h"
#include "grit/theme_resources.h"
#include "grit/theme_resources_standard.h"
+#include "skia/ext/image_operations.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/favicon_size.h"
@@ -19,10 +20,6 @@ static const int kLeftPadding = 16;
static const int kRightPadding = 15;
static const int kDropShadowHeight = 2;
-// The size of the favicon touch area. This generally would be the same as
-// kFaviconSize in ui/gfx/favicon_size.h
-static const int kTouchTabIconSize = 32;
-
TouchTab::TouchTabImage TouchTab::tab_alpha = {0};
TouchTab::TouchTabImage TouchTab::tab_active = {0};
TouchTab::TouchTabImage TouchTab::tab_inactive = {0};
@@ -180,7 +177,6 @@ void TouchTab::PaintActiveTabBackground(gfx::Canvas* canvas) {
}
void TouchTab::PaintIcon(gfx::Canvas* canvas) {
- // TODO(wyck): use thumbnailer to get better page images
int x = favicon_bounds_.x();
int y = favicon_bounds_.y();
@@ -190,23 +186,19 @@ void TouchTab::PaintIcon(gfx::Canvas* canvas) {
x += x_base;
if (base::i18n::IsRTL()) {
- x = width() - x -
- (data().favicon.isNull() ? kFaviconSize : data().favicon.width());
+ x = width() - x - (data().favicon.isNull()
+ ? kTouchTargetIconSize : data().favicon.width());
}
- int favicon_x = x;
- if (!data().favicon.isNull() && data().favicon.width() != kFaviconSize)
- favicon_x += (data().favicon.width() - kFaviconSize) / 2;
-
if (data().network_state != TabRendererData::NETWORK_STATE_NONE) {
ui::ThemeProvider* tp = GetThemeProvider();
SkBitmap frames(*tp->GetBitmapNamed(
- (data().network_state == TabRendererData::NETWORK_STATE_WAITING) ?
- IDR_THROBBER_WAITING : IDR_THROBBER));
+ (data().network_state == TabRendererData::NETWORK_STATE_WAITING)
+ ? IDR_THROBBER_WAITING : IDR_THROBBER));
int image_size = frames.height();
int image_offset = loading_animation_frame() * image_size;
- canvas->DrawBitmapInt(frames, image_offset, 0, image_size, image_size, x, y,
- kTouchTabIconSize, kTouchTabIconSize, false);
+ canvas->DrawBitmapInt(frames, image_offset, 0, image_size, image_size, x,
+ y, kTouchTargetIconSize, kTouchTargetIconSize, false);
} else {
canvas->Save();
canvas->ClipRectInt(0, 0, width(), height());
@@ -215,32 +207,25 @@ void TouchTab::PaintIcon(gfx::Canvas* canvas) {
SkBitmap crashed_favicon(*rb.GetBitmapNamed(IDR_SAD_FAVICON));
canvas->DrawBitmapInt(crashed_favicon, 0, 0, crashed_favicon.width(),
crashed_favicon.height(), x, y + favicon_hiding_offset(),
- kTouchTabIconSize, kTouchTabIconSize, true);
+ kTouchTargetIconSize, kTouchTargetIconSize, true);
} else {
if (!data().favicon.isNull()) {
-
- if ((data().favicon.width() == kTouchTabIconSize) &&
- (data().favicon.height() == kTouchTabIconSize)) {
- canvas->DrawBitmapInt(data().favicon, 0, 0,
- data().favicon.width(), data().favicon.height(),
- x, y + favicon_hiding_offset(),
- kTouchTabIconSize, kTouchTabIconSize, true);
+ // At this stage small favicons (16x16) are copied from NavigationEntry
+ // and need to be scaled every time, touch icons on the other hand
+ // should have been rescaled properly (to 32x32) in method:
+ // TouchTabStripController::OnTouchIconAvailable().
+ if (data().favicon.width() == kFaviconSize
+ && data().favicon.height() == kFaviconSize) {
sky 2011/06/16 15:43:41 && should be on the previous line. Also, you shoul
Emmanuel Saint-loubert-Bié 2011/06/17 00:01:44 Done.
+ SkBitmap scaled_image = skia::ImageOperations::Resize(data().favicon,
+ skia::ImageOperations::RESIZE_BEST, kTouchTargetIconSize,
+ kTouchTargetIconSize);
+ canvas->DrawBitmapInt(scaled_image, 0, 0, kTouchTargetIconSize,
+ kTouchTargetIconSize, x, y + favicon_hiding_offset(),
+ kTouchTargetIconSize, kTouchTargetIconSize, true);
} else {
- // Draw a background around target touch area in case the favicon
- // is smaller than touch area (e.g www.google.com is 16x16 now)
- canvas->DrawRectInt(
- GetThemeProvider()->GetColor(
- ThemeService::COLOR_BUTTON_BACKGROUND),
- x, y, kTouchTabIconSize, kTouchTabIconSize);
-
- // We center the image
- // TODO(saintlou): later request larger image from HistoryService
canvas->DrawBitmapInt(data().favicon, 0, 0, data().favicon.width(),
- data().favicon.height(),
- x + ((kTouchTabIconSize - data().favicon.width()) / 2),
- y + ((kTouchTabIconSize - data().favicon.height()) / 2) +
- favicon_hiding_offset(),
- data().favicon.width(), data().favicon.height(), true);
+ data().favicon.height(), x, y + favicon_hiding_offset(),
+ kTouchTargetIconSize, kTouchTargetIconSize, true);
}
}
}
@@ -260,7 +245,6 @@ void TouchTab::InitTabResources() {
LoadTabImages();
}
-
// static
void TouchTab::LoadTabImages() {
// We're not letting people override tab images just yet.

Powered by Google App Engine
This is Rietveld 408576698