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

Unified Diff: chrome/browser/themes/browser_theme_pack.cc

Issue 10245003: Makes ImageSkia more like SkBitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/themes/browser_theme_pack.cc
diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc
index 0ae08955094d0335c4f5f3619dc16c39a36e042a..b5f17ebf5f8abbf679317f5382e96e817af3a23b 100644
--- a/chrome/browser/themes/browser_theme_pack.cc
+++ b/chrome/browser/themes/browser_theme_pack.cc
@@ -311,15 +311,18 @@ base::RefCountedMemory* ReadFileData(const FilePath& path) {
// the returned image.
gfx::Image* CreateHSLShiftedImage(const gfx::Image& image,
const color_utils::HSL& hsl_shift) {
- const std::vector<const SkBitmap*>& src_bitmaps =
- image.ToImageSkia()->bitmaps();
- std::vector<const SkBitmap*> dst_bitmaps;
+ const gfx::ImageSkia* src_image = image.ToImageSkia();
+ const std::vector<SkBitmap> src_bitmaps = src_image->bitmaps();
+ gfx::ImageSkia dst_image;
for (size_t i = 0; i < src_bitmaps.size(); ++i) {
- const SkBitmap* bitmap = src_bitmaps[i];
- dst_bitmaps.push_back(new SkBitmap(
- SkBitmapOperations::CreateHSLShiftedBitmap(*bitmap, hsl_shift)));
+ const SkBitmap& bitmap = src_bitmaps[i];
+ float scale_factor =
+ static_cast<float>(bitmap.width()) / src_image->width();
+ dst_image.AddBitmapForScale(
+ SkBitmapOperations::CreateHSLShiftedBitmap(bitmap, hsl_shift),
+ scale_factor);
}
- return new gfx::Image(dst_bitmaps);
+ return new gfx::Image(dst_image);
}
} // namespace
@@ -992,32 +995,32 @@ void BrowserThemePack::GenerateTabBackgroundImages(ImageCache* bitmaps) const {
// with a PRS_THEME_FRAME.
ImageCache::const_iterator it = bitmaps->find(prs_base_id);
if (it != bitmaps->end()) {
- const gfx::Image& image_to_tint = *(it->second);
- const std::vector<const SkBitmap*>& bitmaps_to_tint =
- image_to_tint.ToImageSkia()->bitmaps();
- std::vector<const SkBitmap*> tinted_bitmaps;
+ const gfx::ImageSkia* image_to_tint = (it->second)->ToImageSkia();
+ const std::vector<SkBitmap> bitmaps_to_tint = image_to_tint->bitmaps();
+ gfx::ImageSkia tinted_image;
for (size_t j = 0; j < bitmaps_to_tint.size(); ++j) {
SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap(
- *bitmaps_to_tint[j], GetTintInternal(
+ bitmaps_to_tint[j], GetTintInternal(
ThemeService::TINT_BACKGROUND_TAB));
int vertical_offset = bitmaps->count(prs_id)
? kRestoredTabVerticalOffset : 0;
- SkBitmap* bg_tab = new SkBitmap(SkBitmapOperations::CreateTiledBitmap(
- bg_tint, 0, vertical_offset, bg_tint.width(), bg_tint.height()));
+ SkBitmap bg_tab = SkBitmapOperations::CreateTiledBitmap(
+ bg_tint, 0, vertical_offset, bg_tint.width(), bg_tint.height());
// If they've provided a custom image, overlay it.
ImageCache::const_iterator overlay_it = bitmaps->find(prs_id);
if (overlay_it != bitmaps->end()) {
const SkBitmap* overlay = overlay_it->second->ToSkBitmap();
- SkCanvas canvas(*bg_tab);
- for (int x = 0; x < bg_tab->width(); x += overlay->width())
+ SkCanvas canvas(bg_tab);
+ for (int x = 0; x < bg_tab.width(); x += overlay->width())
canvas.drawBitmap(*overlay, static_cast<SkScalar>(x), 0, NULL);
}
- tinted_bitmaps.push_back(bg_tab);
+ float scale_factor =
+ static_cast<float>(bg_tab.width()) / image_to_tint->width();
+ tinted_image.AddBitmapForScale(bg_tab, scale_factor);
}
- gfx::Image* tinted_image = new gfx::Image(tinted_bitmaps);
- temp_output[prs_id] = tinted_image;
+ temp_output[prs_id] = new gfx::Image(tinted_image);
}
}
« no previous file with comments | « chrome/browser/extensions/image_loading_tracker_unittest.cc ('k') | chrome/browser/web_applications/web_app_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698