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

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

Issue 277773002: Add ImageSkiaRep::unscaled that tells if the image is for unscaled image. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « no previous file | ui/base/resource/resource_bundle_unittest.cc » ('j') | 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 f70a1f700b389b6d94b1bbf7d50da97cc79d66d9..bdb919e0b10b87f3e4bfe1af89601558a1380f04 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -105,6 +105,13 @@ class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource {
ScaleFactor scale_factor = GetSupportedScaleFactor(scale);
bool found = rb_->LoadBitmap(resource_id_, &scale_factor,
&image, &fell_back_to_1x);
+ // If the resource is in the package with SCALE_FACTOR_NONE, it
+ // can be used in any scale factor. The image is maked as "unscaled"
+ // so that the ImageSkia do not automatically scale.
+ bool unscaled = scale_factor == ui::SCALE_FACTOR_NONE;
+ if (unscaled)
+ scale_factor = ui::SCALE_FACTOR_100P;
+
if (!found)
return gfx::ImageSkiaRep();
@@ -115,12 +122,12 @@ class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource {
skia::ImageOperations::RESIZE_LANCZOS3,
gfx::ToCeiledInt(image.width() * scale),
gfx::ToCeiledInt(image.height() * scale));
- } else {
+ } else if (!unscaled) {
image = PlatformScaleImage(image,
ui::GetScaleForScaleFactor(scale_factor),
scale);
}
- return gfx::ImageSkiaRep(image, scale);
+ return gfx::ImageSkiaRep(image, unscaled ? 0.0f : scale);
}
private:
@@ -728,13 +735,10 @@ bool ResourceBundle::LoadBitmap(int resource_id,
bool* fell_back_to_1x) const {
DCHECK(fell_back_to_1x);
for (size_t i = 0; i < data_packs_.size(); ++i) {
- // If the resource is in the package with SCALE_FACTOR_NONE, it
- // can be used in any scale factor, but set 100P in ImageSkia so
- // that it will be scaled property.
if (data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_NONE &&
LoadBitmap(*data_packs_[i], resource_id, bitmap, fell_back_to_1x)) {
- *scale_factor = ui::SCALE_FACTOR_100P;
DCHECK(!*fell_back_to_1x);
+ *scale_factor = ui::SCALE_FACTOR_NONE;
return true;
}
if (data_packs_[i]->GetScaleFactor() == *scale_factor &&
« no previous file with comments | « no previous file | ui/base/resource/resource_bundle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698