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

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

Issue 10820049: Load 2x resources on demand (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated comment Created 8 years, 4 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
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.h ('k') | chrome/browser/ui/app_list/extension_app_item.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a2672f77520aea90eed1443e661b2c4e71f8448e..c470ebd0a89ca0b1c0fa8fac031bd5861771f86d 100644
--- a/chrome/browser/themes/browser_theme_pack.cc
+++ b/chrome/browser/themes/browser_theme_pack.cc
@@ -436,11 +436,14 @@ scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension(
pack->CreateImages(&pack->images_on_ui_thread_);
pack->CreateImages(&pack->images_on_file_thread_);
- // For M22, as it is not possible to easily determine which scale factors are
- // in use, assume that the 1x scale factor is in use.
- std::vector<ui::ScaleFactor> scale_factors_in_use;
- scale_factors_in_use.push_back(ui::SCALE_FACTOR_100P);
- pack->GenerateImageReps(scale_factors_in_use);
+ // Make sure the |images_on_file_thread_| has bitmaps for supported
+ // scale factors before passing to FILE thread.
+ for (ImageCache::iterator it = pack->images_on_file_thread_.begin();
+ it != pack->images_on_file_thread_.end(); ++it) {
+ gfx::ImageSkia* image_skia =
+ const_cast<gfx::ImageSkia*>(it->second->ToImageSkia());
+ image_skia->MakeThreadSafe();
+ }
// The BrowserThemePack is now in a consistent state.
return pack;
@@ -1117,14 +1120,6 @@ void BrowserThemePack::RepackImages(const ImageCache& images,
it != images.end(); ++it) {
gfx::ImageSkia image_skia = *it->second->ToImageSkia();
- // Attempt to generate image reps for all supported scale factors.
- for (ScaleFactors::const_iterator factor_it = scale_factors_.begin();
- factor_it != scale_factors_.end(); ++factor_it) {
- // Ask for representation to force the representation to be generated
- // if it wasn't already.
- image_skia.GetRepresentation(*factor_it);
- }
-
typedef std::vector<gfx::ImageSkiaRep> ImageSkiaReps;
ImageSkiaReps image_reps = image_skia.image_reps();
if (image_reps.empty()) {
@@ -1145,34 +1140,6 @@ void BrowserThemePack::RepackImages(const ImageCache& images,
}
}
-void BrowserThemePack::GenerateImageReps(
- const std::vector<ui::ScaleFactor>& scale_factors) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- for (ImageCache::const_iterator it = images_on_ui_thread_.begin();
- it != images_on_ui_thread_.end();
- ++it) {
- const gfx::ImageSkia* image1 = it->second->ToImageSkia();
- const gfx::ImageSkia* image2 =
- images_on_file_thread_[it->first]->ToImageSkia();
-
- // Ensure that image reps are generated and cached in |image1| by
- // calling GetRepresentation().
- for (size_t i = 0; i < scale_factors.size(); ++i)
- image1->GetRepresentation(scale_factors[i]);
-
- // |image1| and |image2| have ImageSkiaSources which produce pixel
- // equivalent output. Instead of regenerating again, copy the image reps
- // which were generated for |image1| into |image2|.
- // Don't do a deep copy of the SkBitmaps as SkBitmap is thread safe.
- std::vector<gfx::ImageSkiaRep> image1_reps = image1->image_reps();
- for (size_t i = 0; i < image1_reps.size(); ++i) {
- gfx::ImageSkiaRep image1_rep = image1_reps[i];
- const_cast<gfx::ImageSkia*>(image2)->AddRepresentation(gfx::ImageSkiaRep(
- image1_rep.sk_bitmap(), image1_rep.scale_factor()));
- }
- }
-}
-
void BrowserThemePack::MergeImageCaches(
const ImageCache& source, ImageCache* destination) const {
for (ImageCache::const_iterator it = source.begin(); it != source.end();
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.h ('k') | chrome/browser/ui/app_list/extension_app_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698