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

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

Powered by Google App Engine
This is Rietveld 408576698