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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.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/themes/browser_theme_pack.h" 5 #include "chrome/browser/themes/browser_theme_pack.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 for (size_t j = 0; j < image_reps_to_tint.size(); ++j) { 1004 for (size_t j = 0; j < image_reps_to_tint.size(); ++j) {
1005 gfx::ImageSkiaRep image_rep_to_tint = image_reps_to_tint[j]; 1005 gfx::ImageSkiaRep image_rep_to_tint = image_reps_to_tint[j];
1006 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( 1006 SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap(
1007 image_rep_to_tint.sk_bitmap(), GetTintInternal( 1007 image_rep_to_tint.sk_bitmap(), GetTintInternal(
1008 ThemeService::TINT_BACKGROUND_TAB)); 1008 ThemeService::TINT_BACKGROUND_TAB));
1009 gfx::Size bg_tint_dip_size(image_rep_to_tint.GetWidth(), 1009 gfx::Size bg_tint_dip_size(image_rep_to_tint.GetWidth(),
1010 image_rep_to_tint.GetHeight()); 1010 image_rep_to_tint.GetHeight());
1011 int vertical_offset = bitmaps->count(prs_id) 1011 int vertical_offset = bitmaps->count(prs_id)
1012 ? kRestoredTabVerticalOffset : 0; 1012 ? kRestoredTabVerticalOffset : 0;
1013 gfx::Canvas canvas(gfx::Size(bg_tint.width(), bg_tint.height()), 1013 gfx::Canvas canvas(gfx::Size(bg_tint.width(), bg_tint.height()),
1014 image_rep_to_tint.scale_factor(),
1014 false); 1015 false);
1015 SkScalar image_rep_to_tint_scale =
1016 SkFloatToScalar(image_rep_to_tint.GetScale());
1017 canvas.sk_canvas()->scale(image_rep_to_tint_scale,
1018 image_rep_to_tint_scale);
1019 canvas.TileImageInt(bg_tint, 0, vertical_offset, 1016 canvas.TileImageInt(bg_tint, 0, vertical_offset,
1020 bg_tint_dip_size.width(), bg_tint_dip_size.height()); 1017 bg_tint_dip_size.width(), bg_tint_dip_size.height());
1021 1018
1022 // If they've provided a custom image, overlay it. 1019 // If they've provided a custom image, overlay it.
1023 ImageCache::const_iterator overlay_it = bitmaps->find(prs_id); 1020 ImageCache::const_iterator overlay_it = bitmaps->find(prs_id);
1024 if (overlay_it != bitmaps->end()) { 1021 if (overlay_it != bitmaps->end()) {
1025 const gfx::ImageSkia* overlay = overlay_it->second->ToImageSkia(); 1022 const gfx::ImageSkia* overlay = overlay_it->second->ToImageSkia();
1026 canvas.TileImageInt(*overlay, 0, 0, bg_tint_dip_size.width(), 1023 canvas.TileImageInt(*overlay, 0, 0, bg_tint_dip_size.width(),
1027 overlay->height()); 1024 overlay->height());
1028 } 1025 }
1029 SkBitmap bg_tab = canvas.ExtractBitmap(); 1026 tinted_image.AddRepresentation(canvas.ExtractImageRep());
1030 tinted_image.AddRepresentation(gfx::ImageSkiaRep(bg_tab,
1031 image_rep_to_tint.scale_factor()));
1032 } 1027 }
1033 1028
1034 temp_output[prs_id] = new gfx::Image(tinted_image); 1029 temp_output[prs_id] = new gfx::Image(tinted_image);
1035 } 1030 }
1036 } 1031 }
1037 1032
1038 MergeImageCaches(temp_output, bitmaps); 1033 MergeImageCaches(temp_output, bitmaps);
1039 } 1034 }
1040 1035
1041 void BrowserThemePack::RepackImages(const ImageCache& images, 1036 void BrowserThemePack::RepackImages(const ImageCache& images,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 hsl.h = tints_[i].h; 1080 hsl.h = tints_[i].h;
1086 hsl.s = tints_[i].s; 1081 hsl.s = tints_[i].s;
1087 hsl.l = tints_[i].l; 1082 hsl.l = tints_[i].l;
1088 return hsl; 1083 return hsl;
1089 } 1084 }
1090 } 1085 }
1091 } 1086 }
1092 1087
1093 return ThemeService::GetDefaultTint(id); 1088 return ThemeService::GetDefaultTint(id);
1094 } 1089 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698