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/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 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 SkBitmap GtkThemeService::GenerateFrameImage( | 1007 SkBitmap GtkThemeService::GenerateFrameImage( |
1008 int color_id, | 1008 int color_id, |
1009 const char* gradient_name) const { | 1009 const char* gradient_name) const { |
1010 // We use two colors: the main color (passed in) and a lightened version of | 1010 // We use two colors: the main color (passed in) and a lightened version of |
1011 // that color (which is supposed to match the light gradient at the top of | 1011 // that color (which is supposed to match the light gradient at the top of |
1012 // several GTK+ themes, such as Ambiance, Clearlooks or Bluebird). | 1012 // several GTK+ themes, such as Ambiance, Clearlooks or Bluebird). |
1013 ColorMap::const_iterator it = colors_.find(color_id); | 1013 ColorMap::const_iterator it = colors_.find(color_id); |
1014 DCHECK(it != colors_.end()); | 1014 DCHECK(it != colors_.end()); |
1015 SkColor base = it->second; | 1015 SkColor base = it->second; |
1016 | 1016 |
1017 gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), | 1017 gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), true); |
1018 ui::SCALE_FACTOR_100P, true); | |
1019 | 1018 |
1020 int gradient_size; | 1019 int gradient_size; |
1021 GdkColor* gradient_top_color = NULL; | 1020 GdkColor* gradient_top_color = NULL; |
1022 gtk_widget_style_get(GTK_WIDGET(fake_frame_), | 1021 gtk_widget_style_get(GTK_WIDGET(fake_frame_), |
1023 "frame-gradient-size", &gradient_size, | 1022 "frame-gradient-size", &gradient_size, |
1024 gradient_name, &gradient_top_color, | 1023 gradient_name, &gradient_top_color, |
1025 NULL); | 1024 NULL); |
1026 if (gradient_size) { | 1025 if (gradient_size) { |
1027 SkColor lighter = gradient_top_color ? | 1026 SkColor lighter = gradient_top_color ? |
1028 gfx::GdkColorToSkColor(*gradient_top_color) : | 1027 gfx::GdkColorToSkColor(*gradient_top_color) : |
1029 color_utils::HSLShift(base, kGtkFrameShift); | 1028 color_utils::HSLShift(base, kGtkFrameShift); |
1030 if (gradient_top_color) | 1029 if (gradient_top_color) |
1031 gdk_color_free(gradient_top_color); | 1030 gdk_color_free(gradient_top_color); |
1032 SkShader* shader = gfx::CreateGradientShader( | 1031 SkShader* shader = gfx::CreateGradientShader( |
1033 0, gradient_size, lighter, base); | 1032 0, gradient_size, lighter, base); |
1034 SkPaint paint; | 1033 SkPaint paint; |
1035 paint.setStyle(SkPaint::kFill_Style); | 1034 paint.setStyle(SkPaint::kFill_Style); |
1036 paint.setAntiAlias(true); | 1035 paint.setAntiAlias(true); |
1037 paint.setShader(shader); | 1036 paint.setShader(shader); |
1038 shader->unref(); | 1037 shader->unref(); |
1039 | 1038 |
1040 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); | 1039 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); |
1041 } | 1040 } |
1042 | 1041 |
1043 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth, | 1042 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth, |
1044 kToolbarImageHeight - gradient_size), base); | 1043 kToolbarImageHeight - gradient_size), base); |
1045 return canvas.ExtractImageRep().sk_bitmap(); | 1044 return canvas.ExtractBitmap(); |
1046 } | 1045 } |
1047 | 1046 |
1048 SkBitmap GtkThemeService::GenerateTabImage(int base_id) const { | 1047 SkBitmap GtkThemeService::GenerateTabImage(int base_id) const { |
1049 SkBitmap* base_image = GetBitmapNamed(base_id); | 1048 SkBitmap* base_image = GetBitmapNamed(base_id); |
1050 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( | 1049 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( |
1051 *base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB)); | 1050 *base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB)); |
1052 return SkBitmapOperations::CreateTiledBitmap( | 1051 return SkBitmapOperations::CreateTiledBitmap( |
1053 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); | 1052 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); |
1054 } | 1053 } |
1055 | 1054 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 cairo_new_path(cr); | 1152 cairo_new_path(cr); |
1154 cairo_set_line_width(cr, 1.0); | 1153 cairo_set_line_width(cr, 1.0); |
1155 cairo_move_to(cr, start_x, allocation.y); | 1154 cairo_move_to(cr, start_x, allocation.y); |
1156 cairo_line_to(cr, start_x, allocation.y + allocation.height); | 1155 cairo_line_to(cr, start_x, allocation.y + allocation.height); |
1157 cairo_stroke(cr); | 1156 cairo_stroke(cr); |
1158 cairo_destroy(cr); | 1157 cairo_destroy(cr); |
1159 cairo_pattern_destroy(pattern); | 1158 cairo_pattern_destroy(pattern); |
1160 | 1159 |
1161 return TRUE; | 1160 return TRUE; |
1162 } | 1161 } |
OLD | NEW |