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

Side by Side Diff: chrome/browser/ui/gtk/gtk_theme_service.cc

Issue 10332163: Revert 137075 - Get rid of Image::Image(SkBitmap*) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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/gtk/gtk_theme_service.h" 5 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 return out_color; 932 return out_color;
933 } 933 }
934 934
935 void GtkThemeService::FreeIconSets() { 935 void GtkThemeService::FreeIconSets() {
936 if (fullscreen_icon_set_) { 936 if (fullscreen_icon_set_) {
937 gtk_icon_set_unref(fullscreen_icon_set_); 937 gtk_icon_set_unref(fullscreen_icon_set_);
938 fullscreen_icon_set_ = NULL; 938 fullscreen_icon_set_ = NULL;
939 } 939 }
940 } 940 }
941 941
942 SkBitmap GtkThemeService::GenerateGtkThemeBitmap(int id) const { 942 SkBitmap* GtkThemeService::GenerateGtkThemeBitmap(int id) const {
943 switch (id) { 943 switch (id) {
944 case IDR_THEME_TOOLBAR: { 944 case IDR_THEME_TOOLBAR: {
945 GtkStyle* style = gtk_rc_get_style(fake_window_); 945 GtkStyle* style = gtk_rc_get_style(fake_window_);
946 GdkColor* color = &style->bg[GTK_STATE_NORMAL]; 946 GdkColor* color = &style->bg[GTK_STATE_NORMAL];
947 SkBitmap bitmap; 947 SkBitmap* bitmap = new SkBitmap;
948 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 948 bitmap->setConfig(SkBitmap::kARGB_8888_Config,
949 kToolbarImageWidth, kToolbarImageHeight); 949 kToolbarImageWidth, kToolbarImageHeight);
950 bitmap.allocPixels(); 950 bitmap->allocPixels();
951 bitmap.eraseRGB(color->red >> 8, color->green >> 8, color->blue >> 8); 951 bitmap->eraseRGB(color->red >> 8, color->green >> 8, color->blue >> 8);
952 return bitmap; 952 return bitmap;
953 } 953 }
954 case IDR_THEME_TAB_BACKGROUND: 954 case IDR_THEME_TAB_BACKGROUND:
955 return GenerateTabImage(IDR_THEME_FRAME); 955 return GenerateTabImage(IDR_THEME_FRAME);
956 case IDR_THEME_TAB_BACKGROUND_INCOGNITO: 956 case IDR_THEME_TAB_BACKGROUND_INCOGNITO:
957 return GenerateTabImage(IDR_THEME_FRAME_INCOGNITO); 957 return GenerateTabImage(IDR_THEME_FRAME_INCOGNITO);
958 case IDR_THEME_FRAME: 958 case IDR_THEME_FRAME:
959 return GenerateFrameImage(ThemeService::COLOR_FRAME, 959 return GenerateFrameImage(ThemeService::COLOR_FRAME,
960 "frame-gradient-color"); 960 "frame-gradient-color");
961 case IDR_THEME_FRAME_INACTIVE: 961 case IDR_THEME_FRAME_INACTIVE:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 case IDR_OMNIBOX_STAR_DARK: 994 case IDR_OMNIBOX_STAR_DARK:
995 case IDR_OMNIBOX_TTS_DARK: { 995 case IDR_OMNIBOX_TTS_DARK: {
996 return GenerateTintedIcon(id, selected_entry_tint_); 996 return GenerateTintedIcon(id, selected_entry_tint_);
997 } 997 }
998 default: { 998 default: {
999 return GenerateTintedIcon(id, button_tint_); 999 return GenerateTintedIcon(id, button_tint_);
1000 } 1000 }
1001 } 1001 }
1002 } 1002 }
1003 1003
1004 SkBitmap GtkThemeService::GenerateFrameImage( 1004 SkBitmap* GtkThemeService::GenerateFrameImage(
1005 int color_id, 1005 int color_id,
1006 const char* gradient_name) const { 1006 const char* gradient_name) const {
1007 // We use two colors: the main color (passed in) and a lightened version of 1007 // We use two colors: the main color (passed in) and a lightened version of
1008 // that color (which is supposed to match the light gradient at the top of 1008 // that color (which is supposed to match the light gradient at the top of
1009 // several GTK+ themes, such as Ambiance, Clearlooks or Bluebird). 1009 // several GTK+ themes, such as Ambiance, Clearlooks or Bluebird).
1010 ColorMap::const_iterator it = colors_.find(color_id); 1010 ColorMap::const_iterator it = colors_.find(color_id);
1011 DCHECK(it != colors_.end()); 1011 DCHECK(it != colors_.end());
1012 SkColor base = it->second; 1012 SkColor base = it->second;
1013 1013
1014 gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), true); 1014 gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), true);
(...skipping 16 matching lines...) Expand all
1031 paint.setStyle(SkPaint::kFill_Style); 1031 paint.setStyle(SkPaint::kFill_Style);
1032 paint.setAntiAlias(true); 1032 paint.setAntiAlias(true);
1033 paint.setShader(shader); 1033 paint.setShader(shader);
1034 shader->unref(); 1034 shader->unref();
1035 1035
1036 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); 1036 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint);
1037 } 1037 }
1038 1038
1039 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth, 1039 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth,
1040 kToolbarImageHeight - gradient_size), base); 1040 kToolbarImageHeight - gradient_size), base);
1041 return canvas.ExtractBitmap(); 1041 return new SkBitmap(canvas.ExtractBitmap());
1042 } 1042 }
1043 1043
1044 SkBitmap GtkThemeService::GenerateTabImage(int base_id) const { 1044 SkBitmap* GtkThemeService::GenerateTabImage(int base_id) const {
1045 SkBitmap* base_image = GetBitmapNamed(base_id); 1045 SkBitmap* base_image = GetBitmapNamed(base_id);
1046 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( 1046 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap(
1047 *base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB)); 1047 *base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB));
1048 return SkBitmapOperations::CreateTiledBitmap( 1048 return new SkBitmap(SkBitmapOperations::CreateTiledBitmap(
1049 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); 1049 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()));
1050 } 1050 }
1051 1051
1052 SkBitmap GtkThemeService::GenerateTintedIcon( 1052 SkBitmap* GtkThemeService::GenerateTintedIcon(
1053 int base_id, 1053 int base_id,
1054 const color_utils::HSL& tint) const { 1054 const color_utils::HSL& tint) const {
1055 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1055 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1056 return SkBitmapOperations::CreateHSLShiftedBitmap( 1056 return new SkBitmap(SkBitmapOperations::CreateHSLShiftedBitmap(
1057 *rb.GetBitmapNamed(base_id), tint); 1057 *rb.GetBitmapNamed(base_id), tint));
1058 } 1058 }
1059 1059
1060 void GtkThemeService::GetNormalButtonTintHSL( 1060 void GtkThemeService::GetNormalButtonTintHSL(
1061 color_utils::HSL* tint) const { 1061 color_utils::HSL* tint) const {
1062 GtkStyle* window_style = gtk_rc_get_style(fake_window_); 1062 GtkStyle* window_style = gtk_rc_get_style(fake_window_);
1063 const GdkColor accent_gdk_color = window_style->bg[GTK_STATE_SELECTED]; 1063 const GdkColor accent_gdk_color = window_style->bg[GTK_STATE_SELECTED];
1064 const GdkColor base_color = window_style->base[GTK_STATE_NORMAL]; 1064 const GdkColor base_color = window_style->base[GTK_STATE_NORMAL];
1065 1065
1066 GtkStyle* label_style = gtk_rc_get_style(fake_label_.get()); 1066 GtkStyle* label_style = gtk_rc_get_style(fake_label_.get());
1067 const GdkColor text_color = label_style->fg[GTK_STATE_NORMAL]; 1067 const GdkColor text_color = label_style->fg[GTK_STATE_NORMAL];
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 cairo_new_path(cr); 1149 cairo_new_path(cr);
1150 cairo_set_line_width(cr, 1.0); 1150 cairo_set_line_width(cr, 1.0);
1151 cairo_move_to(cr, start_x, allocation.y); 1151 cairo_move_to(cr, start_x, allocation.y);
1152 cairo_line_to(cr, start_x, allocation.y + allocation.height); 1152 cairo_line_to(cr, start_x, allocation.y + allocation.height);
1153 cairo_stroke(cr); 1153 cairo_stroke(cr);
1154 cairo_destroy(cr); 1154 cairo_destroy(cr);
1155 cairo_pattern_destroy(pattern); 1155 cairo_pattern_destroy(pattern);
1156 1156
1157 return TRUE; 1157 return TRUE;
1158 } 1158 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/gtk_theme_service.h ('k') | chrome/browser/ui/intents/web_intent_picker_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698