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

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

Issue 2825018: 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::Canvas canvas(width(), height(), false); 622 gfx::CanvasSkia 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::Canvas canvas(width(), height(), false); 628 gfx::CanvasSkia 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->save(); 807 canvas->AsCanvasSkia()->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->DrawGdkPixbuf(favicon, favicon_bounds_.x(), 821 canvas->AsCanvasSkia()->DrawGdkPixbuf(
822 favicon_bounds_.y() + fav_icon_hiding_offset_); 822 favicon, favicon_bounds_.x(),
823 favicon_bounds_.y() + fav_icon_hiding_offset_);
823 } else { 824 } else {
824 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch 825 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch
825 // to using that class to render the favicon). 826 // to using that class to render the favicon).
826 canvas->DrawBitmapInt(data_.favicon, 0, 0, 827 canvas->DrawBitmapInt(data_.favicon, 0, 0,
827 data_.favicon.width(), 828 data_.favicon.width(),
828 data_.favicon.height(), 829 data_.favicon.height(),
829 favicon_bounds_.x(), 830 favicon_bounds_.x(),
830 favicon_bounds_.y() + fav_icon_hiding_offset_, 831 favicon_bounds_.y() + fav_icon_hiding_offset_,
831 kFavIconSize, kFavIconSize, 832 kFavIconSize, kFavIconSize,
832 true); 833 true);
833 } 834 }
834 } 835 }
835 } 836 }
836 canvas->restore(); 837 canvas->AsCanvasSkia()->restore();
837 } 838 }
838 } 839 }
839 840
840 void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) { 841 void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) {
841 if (IsSelected()) { 842 if (IsSelected()) {
842 PaintActiveTabBackground(canvas); 843 PaintActiveTabBackground(canvas);
843 } else { 844 } else {
844 PaintInactiveTabBackground(canvas); 845 PaintInactiveTabBackground(canvas);
845 846
846 double throb_value = GetThrobValue(); 847 double throb_value = GetThrobValue();
847 if (throb_value > 0) { 848 if (throb_value > 0) {
848 SkRect bounds; 849 SkRect bounds;
849 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height())); 850 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
850 canvas->saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff), 851 canvas->AsCanvasSkia()->saveLayerAlpha(
851 SkCanvas::kARGB_ClipLayer_SaveFlag); 852 &bounds, static_cast<int>(throb_value * 0xff),
852 canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); 853 SkCanvas::kARGB_ClipLayer_SaveFlag);
854 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
855 SkXfermode::kClear_Mode);
853 PaintActiveTabBackground(canvas); 856 PaintActiveTabBackground(canvas);
854 canvas->restore(); 857 canvas->AsCanvasSkia()->restore();
855 } 858 }
856 } 859 }
857 } 860 }
858 861
859 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) { 862 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) {
860 bool is_otr = data_.off_the_record; 863 bool is_otr = data_.off_the_record;
861 864
862 // The tab image needs to be lined up with the background image 865 // The tab image needs to be lined up with the background image
863 // so that it feels partially transparent. 866 // so that it feels partially transparent.
864 int offset_x = background_offset_x_; 867 int offset_x = background_offset_x_;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 // Force the font size to 9pt, which matches Windows' default font size 1062 // Force the font size to 9pt, which matches Windows' default font size
1060 // (taken from the system). 1063 // (taken from the system).
1061 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); 1064 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
1062 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); 1065 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9));
1063 title_font_height_ = title_font_->height(); 1066 title_font_height_ = title_font_->height();
1064 1067
1065 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); 1068 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON);
1066 1069
1067 initialized_ = true; 1070 initialized_ = true;
1068 } 1071 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698