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

Side by Side Diff: chrome/browser/ui/libgtk2ui/gtk2_ui.cc

Issue 10790128: Revert 147915 - Cleanup gfx::Canvas now that 10562027 has landed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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) 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
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), 743 gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), true);
744 ui::SCALE_FACTOR_100P, true);
745 744
746 int gradient_size; 745 int gradient_size;
747 GdkColor* gradient_top_color = NULL; 746 GdkColor* gradient_top_color = NULL;
748 gtk_widget_style_get(GTK_WIDGET(fake_frame_), 747 gtk_widget_style_get(GTK_WIDGET(fake_frame_),
749 "frame-gradient-size", &gradient_size, 748 "frame-gradient-size", &gradient_size,
750 gradient_name, &gradient_top_color, 749 gradient_name, &gradient_top_color,
751 NULL); 750 NULL);
752 if (gradient_size) { 751 if (gradient_size) {
753 SkColor lighter = gradient_top_color ? 752 SkColor lighter = gradient_top_color ?
754 GdkColorToSkColor(*gradient_top_color) : 753 GdkColorToSkColor(*gradient_top_color) :
755 color_utils::HSLShift(base, kGtkFrameShift); 754 color_utils::HSLShift(base, kGtkFrameShift);
756 if (gradient_top_color) 755 if (gradient_top_color)
757 gdk_color_free(gradient_top_color); 756 gdk_color_free(gradient_top_color);
758 SkShader* shader = gfx::CreateGradientShader( 757 SkShader* shader = gfx::CreateGradientShader(
759 0, gradient_size, lighter, base); 758 0, gradient_size, lighter, base);
760 SkPaint paint; 759 SkPaint paint;
761 paint.setStyle(SkPaint::kFill_Style); 760 paint.setStyle(SkPaint::kFill_Style);
762 paint.setAntiAlias(true); 761 paint.setAntiAlias(true);
763 paint.setShader(shader); 762 paint.setShader(shader);
764 shader->unref(); 763 shader->unref();
765 764
766 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); 765 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint);
767 } 766 }
768 767
769 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth, 768 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth,
770 kToolbarImageHeight - gradient_size), base); 769 kToolbarImageHeight - gradient_size), base);
771 return canvas.ExtractImageRep().sk_bitmap(); 770 return canvas.ExtractBitmap();
772 } 771 }
773 772
774 SkBitmap Gtk2UI::GenerateTabImage(int base_id) const { 773 SkBitmap Gtk2UI::GenerateTabImage(int base_id) const {
775 const SkBitmap* base_image = GetThemeImageNamed(base_id)->ToSkBitmap(); 774 const SkBitmap* base_image = GetThemeImageNamed(base_id)->ToSkBitmap();
776 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( 775 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap(
777 *base_image, GetDefaultTint(ThemeService::TINT_BACKGROUND_TAB)); 776 *base_image, GetDefaultTint(ThemeService::TINT_BACKGROUND_TAB));
778 return SkBitmapOperations::CreateTiledBitmap( 777 return SkBitmapOperations::CreateTiledBitmap(
779 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); 778 bg_tint, 0, 0, bg_tint.width(), bg_tint.height());
780 } 779 }
781 780
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 950
952 void Gtk2UI::ClearAllThemeData() { 951 void Gtk2UI::ClearAllThemeData() {
953 STLDeleteValues(&gtk_images_); 952 STLDeleteValues(&gtk_images_);
954 } 953 }
955 954
956 } // namespace libgtk2ui 955 } // namespace libgtk2ui
957 956
958 ui::LinuxUI* BuildGtk2UI() { 957 ui::LinuxUI* BuildGtk2UI() {
959 return new libgtk2ui::Gtk2UI; 958 return new libgtk2ui::Gtk2UI;
960 } 959 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc ('k') | chrome/browser/ui/panels/panel_browser_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698