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

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

Issue 10701063: Cleanup gfx::Canvas now that 10562027 has landed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 SkBitmap GtkThemeService::GenerateFrameImage( 1001 SkBitmap GtkThemeService::GenerateFrameImage(
1002 int color_id, 1002 int color_id,
1003 const char* gradient_name) const { 1003 const char* gradient_name) const {
1004 // We use two colors: the main color (passed in) and a lightened version of 1004 // We use two colors: the main color (passed in) and a lightened version of
1005 // that color (which is supposed to match the light gradient at the top of 1005 // that color (which is supposed to match the light gradient at the top of
1006 // several GTK+ themes, such as Ambiance, Clearlooks or Bluebird). 1006 // several GTK+ themes, such as Ambiance, Clearlooks or Bluebird).
1007 ColorMap::const_iterator it = colors_.find(color_id); 1007 ColorMap::const_iterator it = colors_.find(color_id);
1008 DCHECK(it != colors_.end()); 1008 DCHECK(it != colors_.end());
1009 SkColor base = it->second; 1009 SkColor base = it->second;
1010 1010
1011 gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), true); 1011 gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight),
1012 ui::SCALE_FACTOR_100P, true);
1012 1013
1013 int gradient_size; 1014 int gradient_size;
1014 GdkColor* gradient_top_color = NULL; 1015 GdkColor* gradient_top_color = NULL;
1015 gtk_widget_style_get(GTK_WIDGET(fake_frame_), 1016 gtk_widget_style_get(GTK_WIDGET(fake_frame_),
1016 "frame-gradient-size", &gradient_size, 1017 "frame-gradient-size", &gradient_size,
1017 gradient_name, &gradient_top_color, 1018 gradient_name, &gradient_top_color,
1018 NULL); 1019 NULL);
1019 if (gradient_size) { 1020 if (gradient_size) {
1020 SkColor lighter = gradient_top_color ? 1021 SkColor lighter = gradient_top_color ?
1021 gfx::GdkColorToSkColor(*gradient_top_color) : 1022 gfx::GdkColorToSkColor(*gradient_top_color) :
1022 color_utils::HSLShift(base, kGtkFrameShift); 1023 color_utils::HSLShift(base, kGtkFrameShift);
1023 if (gradient_top_color) 1024 if (gradient_top_color)
1024 gdk_color_free(gradient_top_color); 1025 gdk_color_free(gradient_top_color);
1025 SkShader* shader = gfx::CreateGradientShader( 1026 SkShader* shader = gfx::CreateGradientShader(
1026 0, gradient_size, lighter, base); 1027 0, gradient_size, lighter, base);
1027 SkPaint paint; 1028 SkPaint paint;
1028 paint.setStyle(SkPaint::kFill_Style); 1029 paint.setStyle(SkPaint::kFill_Style);
1029 paint.setAntiAlias(true); 1030 paint.setAntiAlias(true);
1030 paint.setShader(shader); 1031 paint.setShader(shader);
1031 shader->unref(); 1032 shader->unref();
1032 1033
1033 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint); 1034 canvas.DrawRect(gfx::Rect(0, 0, kToolbarImageWidth, gradient_size), paint);
1034 } 1035 }
1035 1036
1036 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth, 1037 canvas.FillRect(gfx::Rect(0, gradient_size, kToolbarImageWidth,
1037 kToolbarImageHeight - gradient_size), base); 1038 kToolbarImageHeight - gradient_size), base);
1038 return canvas.ExtractBitmap(); 1039 return canvas.ExtractImageRep.sk_bitmap()();
1039 } 1040 }
1040 1041
1041 SkBitmap GtkThemeService::GenerateTabImage(int base_id) const { 1042 SkBitmap GtkThemeService::GenerateTabImage(int base_id) const {
1042 SkBitmap* base_image = GetBitmapNamed(base_id); 1043 SkBitmap* base_image = GetBitmapNamed(base_id);
1043 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( 1044 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap(
1044 *base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB)); 1045 *base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB));
1045 return SkBitmapOperations::CreateTiledBitmap( 1046 return SkBitmapOperations::CreateTiledBitmap(
1046 bg_tint, 0, 0, bg_tint.width(), bg_tint.height()); 1047 bg_tint, 0, 0, bg_tint.width(), bg_tint.height());
1047 } 1048 }
1048 1049
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 cairo_new_path(cr); 1147 cairo_new_path(cr);
1147 cairo_set_line_width(cr, 1.0); 1148 cairo_set_line_width(cr, 1.0);
1148 cairo_move_to(cr, start_x, allocation.y); 1149 cairo_move_to(cr, start_x, allocation.y);
1149 cairo_line_to(cr, start_x, allocation.y + allocation.height); 1150 cairo_line_to(cr, start_x, allocation.y + allocation.height);
1150 cairo_stroke(cr); 1151 cairo_stroke(cr);
1151 cairo_destroy(cr); 1152 cairo_destroy(cr);
1152 cairo_pattern_destroy(pattern); 1153 cairo_pattern_destroy(pattern);
1153 1154
1154 return TRUE; 1155 return TRUE;
1155 } 1156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698