OLD | NEW |
---|---|
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 pack->BuildSourceImagesArray(file_paths); | 429 pack->BuildSourceImagesArray(file_paths); |
430 | 430 |
431 if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_on_ui_thread_)) | 431 if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_on_ui_thread_)) |
432 return NULL; | 432 return NULL; |
433 | 433 |
434 pack->CopyImagesTo(pack->images_on_ui_thread_, &pack->images_on_file_thread_); | 434 pack->CopyImagesTo(pack->images_on_ui_thread_, &pack->images_on_file_thread_); |
435 | 435 |
436 pack->CreateImages(&pack->images_on_ui_thread_); | 436 pack->CreateImages(&pack->images_on_ui_thread_); |
437 pack->CreateImages(&pack->images_on_file_thread_); | 437 pack->CreateImages(&pack->images_on_file_thread_); |
438 | 438 |
439 // Make sure the images_on_file_thread_ has bitmaps for supported | |
440 // scale factors before passing to FILE thread. | |
441 for (ImageCache::iterator it = pack->images_on_file_thread_.begin(); | |
442 it != pack->images_on_file_thread_.end(); ++it) { | |
443 gfx::ImageSkia* image_skia = | |
444 const_cast<gfx::ImageSkia*>(it->second->ToImageSkia()); | |
445 image_skia->EnsureRepsForSupportedScaleFactors(); | |
446 image_skia->DeleteSource(); | |
447 } | |
pkotwicz
2012/08/23 16:58:48
Why don't you make images_on_ui_thread_ have image
oshima
2012/08/23 17:16:50
Because images in UI thread only needs scales that
| |
448 | |
439 // For M22, as it is not possible to easily determine which scale factors are | 449 // For M22, as it is not possible to easily determine which scale factors are |
440 // in use, assume that the 1x scale factor is in use. | 450 // in use, assume that the 1x scale factor is in use. |
441 std::vector<ui::ScaleFactor> scale_factors_in_use; | 451 std::vector<ui::ScaleFactor> scale_factors_in_use; |
442 scale_factors_in_use.push_back(ui::SCALE_FACTOR_100P); | 452 scale_factors_in_use.push_back(ui::SCALE_FACTOR_100P); |
443 pack->GenerateImageReps(scale_factors_in_use); | 453 pack->GenerateImageReps(scale_factors_in_use); |
444 | 454 |
445 // The BrowserThemePack is now in a consistent state. | 455 // The BrowserThemePack is now in a consistent state. |
446 return pack; | 456 return pack; |
447 } | 457 } |
448 | 458 |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1224 ui::ScaleFactor scale_factor) const { | 1234 ui::ScaleFactor scale_factor) const { |
1225 if (prs_id < 0) | 1235 if (prs_id < 0) |
1226 return -1; | 1236 return -1; |
1227 | 1237 |
1228 for (size_t i = 0; i < scale_factors_.size(); ++i) { | 1238 for (size_t i = 0; i < scale_factors_.size(); ++i) { |
1229 if (scale_factors_[i] == scale_factor) | 1239 if (scale_factors_[i] == scale_factor) |
1230 return static_cast<int>(kPersistingImagesLength * i) + prs_id; | 1240 return static_cast<int>(kPersistingImagesLength * i) + prs_id; |
1231 } | 1241 } |
1232 return -1; | 1242 return -1; |
1233 } | 1243 } |
OLD | NEW |