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

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

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 612 }
613 613
614 if (!mini() || width() > kMiniTabRendererAsNormalTabWidth) 614 if (!mini() || width() > kMiniTabRendererAsNormalTabWidth)
615 PaintTitle(canvas); 615 PaintTitle(canvas);
616 616
617 if (show_icon) 617 if (show_icon)
618 PaintIcon(canvas); 618 PaintIcon(canvas);
619 } 619 }
620 620
621 SkBitmap TabRendererGtk::PaintBitmap() { 621 SkBitmap TabRendererGtk::PaintBitmap() {
622 gfx::CanvasSkia canvas(width(), height(), false); 622 gfx::Canvas canvas(width(), height(), false);
623 Paint(&canvas); 623 Paint(&canvas);
624 return canvas.ExtractBitmap(); 624 return canvas.ExtractBitmap();
625 } 625 }
626 626
627 cairo_surface_t* TabRendererGtk::PaintToSurface() { 627 cairo_surface_t* TabRendererGtk::PaintToSurface() {
628 gfx::CanvasSkia canvas(width(), height(), false); 628 gfx::Canvas canvas(width(), height(), false);
629 Paint(&canvas); 629 Paint(&canvas);
630 return cairo_surface_reference(cairo_get_target(canvas.beginPlatformPaint())); 630 return cairo_surface_reference(cairo_get_target(canvas.beginPlatformPaint()));
631 } 631 }
632 632
633 void TabRendererGtk::SchedulePaint() { 633 void TabRendererGtk::SchedulePaint() {
634 gtk_widget_queue_draw(tab_.get()); 634 gtk_widget_queue_draw(tab_.get());
635 } 635 }
636 636
637 gfx::Rect TabRendererGtk::GetLocalBounds() { 637 gfx::Rect TabRendererGtk::GetLocalBounds() {
638 return gfx::Rect(0, 0, bounds_.width(), bounds_.height()); 638 return gfx::Rect(0, 0, bounds_.width(), bounds_.height());
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 : unselected_title_color_; 797 : unselected_title_color_;
798 canvas->DrawStringInt(UTF16ToWideHack(title), *title_font_, title_color, 798 canvas->DrawStringInt(UTF16ToWideHack(title), *title_font_, title_color,
799 title_bounds_.x(), title_bounds_.y(), 799 title_bounds_.x(), title_bounds_.y(),
800 title_bounds_.width(), title_bounds_.height()); 800 title_bounds_.width(), title_bounds_.height());
801 } 801 }
802 802
803 void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) { 803 void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) {
804 if (loading_animation_.animation_state() != ANIMATION_NONE) { 804 if (loading_animation_.animation_state() != ANIMATION_NONE) {
805 PaintLoadingAnimation(canvas); 805 PaintLoadingAnimation(canvas);
806 } else { 806 } else {
807 canvas->AsCanvasSkia()->save(); 807 canvas->save();
808 canvas->ClipRectInt(0, 0, width(), height() - kFavIconTitleSpacing); 808 canvas->ClipRectInt(0, 0, width(), height() - kFavIconTitleSpacing);
809 if (should_display_crashed_favicon_) { 809 if (should_display_crashed_favicon_) {
810 canvas->DrawBitmapInt(*crashed_fav_icon, 0, 0, 810 canvas->DrawBitmapInt(*crashed_fav_icon, 0, 0,
811 crashed_fav_icon->width(), 811 crashed_fav_icon->width(),
812 crashed_fav_icon->height(), 812 crashed_fav_icon->height(),
813 favicon_bounds_.x(), 813 favicon_bounds_.x(),
814 favicon_bounds_.y() + fav_icon_hiding_offset_, 814 favicon_bounds_.y() + fav_icon_hiding_offset_,
815 kFavIconSize, kFavIconSize, 815 kFavIconSize, kFavIconSize,
816 true); 816 true);
817 } else { 817 } else {
818 if (!data_.favicon.isNull()) { 818 if (!data_.favicon.isNull()) {
819 if (data_.is_default_favicon && theme_provider_->UseGtkTheme()) { 819 if (data_.is_default_favicon && theme_provider_->UseGtkTheme()) {
820 GdkPixbuf* favicon = GtkThemeProvider::GetDefaultFavicon(true); 820 GdkPixbuf* favicon = GtkThemeProvider::GetDefaultFavicon(true);
821 canvas->AsCanvasSkia()->DrawGdkPixbuf( 821 canvas->DrawGdkPixbuf(favicon, favicon_bounds_.x(),
822 favicon, favicon_bounds_.x(), 822 favicon_bounds_.y() + fav_icon_hiding_offset_);
823 favicon_bounds_.y() + fav_icon_hiding_offset_);
824 } else { 823 } else {
825 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch 824 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch
826 // to using that class to render the favicon). 825 // to using that class to render the favicon).
827 canvas->DrawBitmapInt(data_.favicon, 0, 0, 826 canvas->DrawBitmapInt(data_.favicon, 0, 0,
828 data_.favicon.width(), 827 data_.favicon.width(),
829 data_.favicon.height(), 828 data_.favicon.height(),
830 favicon_bounds_.x(), 829 favicon_bounds_.x(),
831 favicon_bounds_.y() + fav_icon_hiding_offset_, 830 favicon_bounds_.y() + fav_icon_hiding_offset_,
832 kFavIconSize, kFavIconSize, 831 kFavIconSize, kFavIconSize,
833 true); 832 true);
834 } 833 }
835 } 834 }
836 } 835 }
837 canvas->AsCanvasSkia()->restore(); 836 canvas->restore();
838 } 837 }
839 } 838 }
840 839
841 void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) { 840 void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) {
842 if (IsSelected()) { 841 if (IsSelected()) {
843 PaintActiveTabBackground(canvas); 842 PaintActiveTabBackground(canvas);
844 } else { 843 } else {
845 PaintInactiveTabBackground(canvas); 844 PaintInactiveTabBackground(canvas);
846 845
847 double throb_value = GetThrobValue(); 846 double throb_value = GetThrobValue();
848 if (throb_value > 0) { 847 if (throb_value > 0) {
849 SkRect bounds; 848 SkRect bounds;
850 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height())); 849 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
851 canvas->AsCanvasSkia()->saveLayerAlpha( 850 canvas->saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff),
852 &bounds, static_cast<int>(throb_value * 0xff), 851 SkCanvas::kARGB_ClipLayer_SaveFlag);
853 SkCanvas::kARGB_ClipLayer_SaveFlag); 852 canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
854 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
855 SkXfermode::kClear_Mode);
856 PaintActiveTabBackground(canvas); 853 PaintActiveTabBackground(canvas);
857 canvas->AsCanvasSkia()->restore(); 854 canvas->restore();
858 } 855 }
859 } 856 }
860 } 857 }
861 858
862 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) { 859 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) {
863 bool is_otr = data_.off_the_record; 860 bool is_otr = data_.off_the_record;
864 861
865 // The tab image needs to be lined up with the background image 862 // The tab image needs to be lined up with the background image
866 // so that it feels partially transparent. 863 // so that it feels partially transparent.
867 int offset_x = background_offset_x_; 864 int offset_x = background_offset_x_;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 // Force the font size to 9pt, which matches Windows' default font size 1059 // Force the font size to 9pt, which matches Windows' default font size
1063 // (taken from the system). 1060 // (taken from the system).
1064 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); 1061 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
1065 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); 1062 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9));
1066 title_font_height_ = title_font_->height(); 1063 title_font_height_ = title_font_->height();
1067 1064
1068 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); 1065 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON);
1069 1066
1070 initialized_ = true; 1067 initialized_ = true;
1071 } 1068 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_util.cc ('k') | chrome/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698