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

Unified Diff: ui/base/resource/resource_bundle.cc

Issue 10387010: Select theme resources from ResourceBundle at requested scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« ui/base/resource/resource_bundle.h ('K') | « ui/base/resource/resource_bundle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle.cc
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 24c05606eead09f08c2297556732a361cfc9aa56..491d7dc25f3901706735a7b8887a34a53d038f8b 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -286,6 +286,33 @@ base::RefCountedStaticMemory* ResourceBundle::LoadDataResourceBytes(
return NULL;
}
+base::RefCountedStaticMemory* ResourceBundle::LoadImageResourceBytes(
+ int resource_id,
+ float scale_factor) const {
+ base::StringPiece data = GetRawImageResource(resource_id, scale_factor);
+ if (data.empty())
+ return NULL;
+
+ return new base::RefCountedStaticMemory(
+ reinterpret_cast<const unsigned char*>(data.data()), data.length());
+}
+
+base::StringPiece ResourceBundle::GetRawImageResource(
+ int resource_id,
+ float scale_factor) const {
+ base::StringPiece best_match;
+ float best_match_scale = 0;
+ for (size_t i = 0; i < data_packs_.size(); ++i) {
+ if (best_match.empty() ||
+ fabs(best_match_scale - scale_factor) >
+ fabs(data_packs_[i]->GetScaleFactor() - scale_factor)) {
+ if (data_packs_[i]->GetStringPiece(resource_id, &best_match))
sail 2012/05/09 16:09:41 Worse case this will cause StringPiece to be overw
flackr 2012/05/09 19:57:01 Done.
+ best_match_scale = data_packs_[i]->GetScaleFactor();
+ }
+ }
+ return best_match;
+}
+
base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const {
DCHECK(locale_resources_data_.get());
base::StringPiece data;
« ui/base/resource/resource_bundle.h ('K') | « ui/base/resource/resource_bundle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698