OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/libgtk2ui/gtk2_ui.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 SkBitmap Gtk2UI::GenerateFrameImage( | 733 SkBitmap Gtk2UI::GenerateFrameImage( |
734 int color_id, | 734 int color_id, |
735 const char* gradient_name) const { | 735 const char* gradient_name) const { |
736 // We use two colors: the main color (passed in) and a lightened version of | 736 // We use two colors: the main color (passed in) and a lightened version of |
737 // that color (which is supposed to match the light gradient at the top of | 737 // that color (which is supposed to match the light gradient at the top of |
738 // several GTK+ themes, such as Ambiance, Clearlooks or Bluebird). | 738 // several GTK+ themes, such as Ambiance, Clearlooks or Bluebird). |
739 ColorMap::const_iterator it = colors_.find(color_id); | 739 ColorMap::const_iterator it = colors_.find(color_id); |
740 DCHECK(it != colors_.end()); | 740 DCHECK(it != colors_.end()); |
741 SkColor base = it->second; | 741 SkColor base = it->second; |
742 | 742 |
743 gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), true); | 743 gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), |
| 744 ui::SCALE_FACTOR_100P, true); |
744 | 745 |
745 int gradient_size; | 746 int gradient_size; |
746 GdkColor* gradient_top_color = NULL; | 747 GdkColor* gradient_top_color = NULL; |
747 gtk_widget_style_get(GTK_WIDGET(fake_frame_), | 748 gtk_widget_style_get(GTK_WIDGET(fake_frame_), |
748 "frame-gradient-size", &gradient_size, | 749 "frame-gradient-size", &gradient_size, |
749 gradient_name, &gradient_top_color, | 750 gradient_name, &gradient_top_color, |
750 NULL); | 751 NULL); |
751 if (gradient_size) { | 752 if (gradient_size) { |
752 SkColor lighter = gradient_top_color ? | 753 SkColor lighter = gradient_top_color ? |
753 GdkColorToSkColor(*gradient_top_color) : | 754 GdkColorToSkColor(*gradient_top_color) : |
754 color_utils::HSLShift(base, kGtkFrameShift); | 755 color_utils::HSLShift(base, kGtkFrameShift); |
755 if (gradient_top_color) | 756 if (gradient_top_color) |
756 gdk_color_free(gradient_top_color); | 757 gdk_color_free(gradient_top_color); |
757 SkShader* shader = gfx::CreateGradientShader( | 758 SkShader* shader = gfx::CreateGradientShader( |
758 0, gradient_size, lighter, base); | 759 0, gradient_size, lighter, base); |
759 SkPaint paint; | 760 SkPaint paint; |
760 paint.setStyle(SkPaint::kFill_Style); | 761 paint.setStyle(SkPaint::kFill_Style); |
761 paint.setAntiAlias(true); | 762 paint.setAntiAlias(true); |
762 paint.setShader(shader); | 763 paint.setShader(shader); |
763 shader->unref(); | 764 shader->unref(); |
764 | 765 |
765 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); | 766 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); |
766 } | 767 } |
767 | 768 |
768 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth, | 769 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth, |
769 kToolbarImageHeight - gradient_size), base); | 770 kToolbarImageHeight - gradient_size), base); |
770 return canvas.ExtractBitmap(); | 771 return canvas.ExtractImageRep().sk_bitmap(); |
771 } | 772 } |
772 | 773 |
773 SkBitmap Gtk2UI::GenerateTabImage(int base_id) const { | 774 SkBitmap Gtk2UI::GenerateTabImage(int base_id) const { |
774 const SkBitmap* base_image = GetThemeImageNamed(base_id)->ToSkBitmap(); | 775 const SkBitmap* base_image = GetThemeImageNamed(base_id)->ToSkBitmap(); |
775 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( | 776 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( |
776 *base_image, GetDefaultTint(ThemeService::TINT_BACKGROUND_TAB)); | 777 *base_image, GetDefaultTint(ThemeService::TINT_BACKGROUND_TAB)); |
777 return SkBitmapOperations::CreateTiledBitmap( | 778 return SkBitmapOperations::CreateTiledBitmap( |
778 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); | 779 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); |
779 } | 780 } |
780 | 781 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 | 951 |
951 void Gtk2UI::ClearAllThemeData() { | 952 void Gtk2UI::ClearAllThemeData() { |
952 STLDeleteValues(>k_images_); | 953 STLDeleteValues(>k_images_); |
953 } | 954 } |
954 | 955 |
955 } // namespace libgtk2ui | 956 } // namespace libgtk2ui |
956 | 957 |
957 ui::LinuxUI* BuildGtk2UI() { | 958 ui::LinuxUI* BuildGtk2UI() { |
958 return new libgtk2ui::Gtk2UI; | 959 return new libgtk2ui::Gtk2UI; |
959 } | 960 } |
OLD | NEW |