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

Side by Side Diff: chrome/browser/gtk/tabs/tab_renderer_gtk.cc

Issue 179003: Add a fast path for tab strip expose. (Closed)
Patch Set: comment Created 11 years, 3 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/gtk/tabs/tab_renderer_gtk.h ('k') | chrome/browser/gtk/tabs/tab_strip_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/tabs/tab_renderer_gtk.h" 5 #include "chrome/browser/gtk/tabs/tab_renderer_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "app/gfx/canvas_paint.h" 10 #include "app/gfx/canvas_paint.h"
(...skipping 17 matching lines...) Expand all
28 28
29 const int kLeftPadding = 16; 29 const int kLeftPadding = 16;
30 const int kTopPadding = 6; 30 const int kTopPadding = 6;
31 const int kRightPadding = 15; 31 const int kRightPadding = 15;
32 const int kBottomPadding = 5; 32 const int kBottomPadding = 5;
33 const int kDropShadowHeight = 2; 33 const int kDropShadowHeight = 2;
34 const int kFavIconTitleSpacing = 4; 34 const int kFavIconTitleSpacing = 4;
35 const int kTitleCloseButtonSpacing = 5; 35 const int kTitleCloseButtonSpacing = 5;
36 const int kStandardTitleWidth = 175; 36 const int kStandardTitleWidth = 175;
37 const int kDropShadowOffset = 2; 37 const int kDropShadowOffset = 2;
38 const int kInactiveTabBackgroundOffsetY = 20;
38 // Preferred width of pinned tabs. 39 // Preferred width of pinned tabs.
39 const int kPinnedTabWidth = 56; 40 const int kPinnedTabWidth = 56;
40 // When a non-pinned tab is pinned the width of the tab animates. If the width 41 // When a non-pinned tab is pinned the width of the tab animates. If the width
41 // of a pinned tab is >= kPinnedTabRendererAsTabWidth then the tab is rendered 42 // of a pinned tab is >= kPinnedTabRendererAsTabWidth then the tab is rendered
42 // as a normal tab. This is done to avoid having the title immediately 43 // as a normal tab. This is done to avoid having the title immediately
43 // disappear when transitioning a tab from normal to pinned. 44 // disappear when transitioning a tab from normal to pinned.
44 const int kPinnedTabRendererAsTabWidth = kPinnedTabWidth + 30; 45 const int kPinnedTabRendererAsTabWidth = kPinnedTabWidth + 30;
45 46
46 // The tab images are designed to overlap the toolbar by 1 pixel. For now we 47 // The tab images are designed to overlap the toolbar by 1 pixel. For now we
47 // don't actually overlap the toolbar, so this is used to know how many pixels 48 // don't actually overlap the toolbar, so this is used to know how many pixels
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 gtk_widget_show(close_button_->widget()); 327 gtk_widget_show(close_button_->widget());
327 } else { 328 } else {
328 gtk_widget_hide_all(tab_.get()); 329 gtk_widget_hide_all(tab_.get());
329 } 330 }
330 } 331 }
331 332
332 bool TabRendererGtk::ValidateLoadingAnimation(AnimationState animation_state) { 333 bool TabRendererGtk::ValidateLoadingAnimation(AnimationState animation_state) {
333 return loading_animation_.ValidateLoadingAnimation(animation_state); 334 return loading_animation_.ValidateLoadingAnimation(animation_state);
334 } 335 }
335 336
337 void TabRendererGtk::PaintFavIconArea(GdkEventExpose* event) {
338 DCHECK(ShouldShowIcon());
339
340 // The paint area is the favicon bounds, but we're painting into the gdk
341 // window belonging to the tabstrip. So the coordinates are relative to the
342 // top left of the tab strip.
343 event->area.x = x() + favicon_bounds_.x();
344 event->area.y = y() + favicon_bounds_.y();
345 event->area.width = favicon_bounds_.width();
346 event->area.height = favicon_bounds_.height();
347 gfx::CanvasPaint canvas(event, false);
348
349 // The actual paint methods expect 0, 0 to be the tab top left (see
350 // PaintTab).
351 canvas.TranslateInt(x(), y());
352
353 // Paint the background behind the favicon.
354 int theme_id;
355 int offset_y = 0;
356 if (IsSelected()) {
357 theme_id = IDR_THEME_TOOLBAR;
358 } else {
359 if (!data_.off_the_record) {
360 theme_id = IDR_THEME_TAB_BACKGROUND;
361 } else {
362 theme_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO;
363 }
364 if (!theme_provider_->HasCustomImage(theme_id))
365 offset_y = kInactiveTabBackgroundOffsetY;
366 }
367 SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(theme_id);
368 canvas.TileImageInt(*tab_bg,
369 x() + favicon_bounds_.x(), offset_y + favicon_bounds_.y(),
370 favicon_bounds_.x(), favicon_bounds_.y(),
371 favicon_bounds_.width(), favicon_bounds_.height());
372
373 // Now paint the icon.
374 PaintIcon(&canvas);
375 }
376
336 // static 377 // static
337 gfx::Size TabRendererGtk::GetMinimumUnselectedSize() { 378 gfx::Size TabRendererGtk::GetMinimumUnselectedSize() {
338 InitResources(); 379 InitResources();
339 380
340 gfx::Size minimum_size; 381 gfx::Size minimum_size;
341 minimum_size.set_width(kLeftPadding + kRightPadding); 382 minimum_size.set_width(kLeftPadding + kRightPadding);
342 // Since we use bitmap images, the real minimum height of the image is 383 // Since we use bitmap images, the real minimum height of the image is
343 // defined most accurately by the height of the end cap images. 384 // defined most accurately by the height of the end cap images.
344 minimum_size.set_height(tab_active_.image_l->height() - kToolbarOverlap); 385 minimum_size.set_height(tab_active_.image_l->height() - kToolbarOverlap);
345 return minimum_size; 386 return minimum_size;
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 int offset_x = background_offset_x_; 786 int offset_x = background_offset_x_;
746 787
747 int tab_id = is_otr ? 788 int tab_id = is_otr ?
748 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; 789 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND;
749 790
750 SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(tab_id); 791 SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(tab_id);
751 792
752 // If the theme is providing a custom background image, then its top edge 793 // If the theme is providing a custom background image, then its top edge
753 // should be at the top of the tab. Otherwise, we assume that the background 794 // should be at the top of the tab. Otherwise, we assume that the background
754 // image is a composited foreground + frame image. 795 // image is a composited foreground + frame image.
755 int offset_y = theme_provider_->HasCustomImage(tab_id) ? 0 : 20; 796 int offset_y = theme_provider_->HasCustomImage(tab_id) ?
797 0 : kInactiveTabBackgroundOffsetY;
756 798
757 // Draw left edge. 799 // Draw left edge.
758 SkBitmap* theme_l = GetMaskedBitmap(tab_alpha_.image_l, tab_bg, offset_x, 800 SkBitmap* theme_l = GetMaskedBitmap(tab_alpha_.image_l, tab_bg, offset_x,
759 offset_y); 801 offset_y);
760 canvas->DrawBitmapInt(*theme_l, 0, 0); 802 canvas->DrawBitmapInt(*theme_l, 0, 0);
761 803
762 // Draw right edge. 804 // Draw right edge.
763 SkBitmap* theme_r = GetMaskedBitmap(tab_alpha_.image_r, tab_bg, 805 SkBitmap* theme_r = GetMaskedBitmap(tab_alpha_.image_r, tab_bg,
764 offset_x + width() - tab_active_.r_width, offset_y); 806 offset_x + width() - tab_active_.r_width, offset_y);
765 807
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 // Force the font size to 9pt, which matches Windows' default font size 988 // Force the font size to 9pt, which matches Windows' default font size
947 // (taken from the system). 989 // (taken from the system).
948 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont); 990 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont);
949 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); 991 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9));
950 title_font_height_ = title_font_->height(); 992 title_font_height_ = title_font_->height();
951 993
952 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); 994 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON);
953 995
954 initialized_ = true; 996 initialized_ = true;
955 } 997 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/tabs/tab_renderer_gtk.h ('k') | chrome/browser/gtk/tabs/tab_strip_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698