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

Unified Diff: trunk/src/ui/gfx/image/image_ios.mm

Issue 24262008: Revert 224473 "Remove dependency on ui::ScaleFactor from ui/gfx" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 | « trunk/src/ui/gfx/image/image.cc ('k') | trunk/src/ui/gfx/image/image_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ui/gfx/image/image_ios.mm
===================================================================
--- trunk/src/ui/gfx/image/image_ios.mm (revision 224498)
+++ trunk/src/ui/gfx/image/image_ios.mm (working copy)
@@ -48,7 +48,7 @@
// Converts from ImagePNGRep to UIImage.
UIImage* CreateUIImageFromImagePNGRep(const gfx::ImagePNGRep& image_png_rep) {
- float scale = image_png_rep.scale;
+ float scale = ui::GetScaleFactorScale(image_png_rep.scale_factor);
scoped_refptr<base::RefCountedMemory> png = image_png_rep.raw_data;
CHECK(png.get());
NSData* data = [NSData dataWithBytes:png->front() length:png->size()];
@@ -74,16 +74,17 @@
UIImage* CreateUIImageFromPNG(
const std::vector<gfx::ImagePNGRep>& image_png_reps) {
- float ideal_scale = ImageSkia::GetMaxSupportedScale();
+ ui::ScaleFactor ideal_scale_factor = ui::GetMaxScaleFactor();
+ float ideal_scale = ui::GetScaleFactorScale(ideal_scale_factor);
if (image_png_reps.empty())
return CreateErrorUIImage(ideal_scale);
- // Find best match for |ideal_scale|.
+ // Find best match for |ideal_scale_factor|.
float smallest_diff = std::numeric_limits<float>::max();
size_t closest_index = 0u;
for (size_t i = 0; i < image_png_reps.size(); ++i) {
- float scale = image_png_reps[i].scale;
+ float scale = ui::GetScaleFactorScale(image_png_reps[i].scale_factor);
float diff = std::abs(ideal_scale - scale);
if (diff < smallest_diff) {
smallest_diff = diff;
@@ -101,8 +102,9 @@
// TODO(rohitrao): Rewrite the callers of this function to save the UIImage
// representation in the gfx::Image. If we're generating it, we might as well
// hold on to it.
- const gfx::ImageSkiaRep& image_skia_rep = skia->GetRepresentation(1.0f);
- if (image_skia_rep.scale() != 1.0f)
+ const gfx::ImageSkiaRep& image_skia_rep = skia->GetRepresentation(
+ ui::SCALE_FACTOR_100P);
+ if (image_skia_rep.scale_factor() != ui::SCALE_FACTOR_100P)
return NULL;
UIImage* image = UIImageFromImageSkiaRep(image_skia_rep);
@@ -117,8 +119,8 @@
for (size_t i = 0; i < image_png_reps.size(); ++i) {
base::scoped_nsobject<UIImage> uiimage(
CreateUIImageFromImagePNGRep(image_png_reps[i]));
- gfx::ImageSkiaRep image_skia_rep = ImageSkiaRepOfScaleFromUIImage(
- uiimage, image_png_reps[i].scale);
+ gfx::ImageSkiaRep image_skia_rep = ImageSkiaRepOfScaleFactorFromUIImage(
+ uiimage, image_png_reps[i].scale_factor);
if (!image_skia_rep.is_null())
image_skia->AddRepresentation(image_skia_rep);
}
« no previous file with comments | « trunk/src/ui/gfx/image/image.cc ('k') | trunk/src/ui/gfx/image/image_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698