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

Side by Side Diff: ui/gfx/image/image_skia_util_ios.mm

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix new usage of scale in FastShowPickler Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/image/image_skia_util_ios.h ('k') | ui/gfx/image/image_skia_util_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "ui/gfx/image/image_skia_util_ios.h" 5 #include "ui/gfx/image/image_skia_util_ios.h"
6 6
7 #include <UIKit/UIKit.h> 7 #include <UIKit/UIKit.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
11 #include "skia/ext/skia_utils_ios.h" 11 #include "skia/ext/skia_utils_ios.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/gfx/image/image_skia.h" 13 #include "ui/gfx/image/image_skia.h"
14 14
15 namespace gfx { 15 namespace gfx {
16 16
17 gfx::ImageSkia ImageSkiaFromUIImage(UIImage* image) { 17 gfx::ImageSkia ImageSkiaFromUIImage(UIImage* image) {
18 gfx::ImageSkia image_skia; 18 gfx::ImageSkia image_skia;
19 gfx::ImageSkiaRep image_skia_rep = ImageSkiaRepOfScaleFactorFromUIImage( 19 float max_scale = ImageSkia::GetSupportedScales().back();
20 image, ui::GetMaxScaleFactor()); 20 gfx::ImageSkiaRep image_skia_rep = ImageSkiaRepOfScaleFromUIImage(
21 image, max_scale);
21 if (!image_skia_rep.is_null()) 22 if (!image_skia_rep.is_null())
22 image_skia.AddRepresentation(image_skia_rep); 23 image_skia.AddRepresentation(image_skia_rep);
23 return image_skia; 24 return image_skia;
24 } 25 }
25 26
26 gfx::ImageSkiaRep ImageSkiaRepOfScaleFactorFromUIImage( 27 gfx::ImageSkiaRep ImageSkiaRepOfScaleFromUIImage(UIImage* image, float scale) {
27 UIImage* image,
28 ui::ScaleFactor scale_factor) {
29 if (!image) 28 if (!image)
30 return gfx::ImageSkiaRep(); 29 return gfx::ImageSkiaRep();
31 30
32 float scale = ui::GetScaleFactorScale(scale_factor);
33 CGSize size = image.size; 31 CGSize size = image.size;
34 CGSize desired_size_for_scale = 32 CGSize desired_size_for_scale =
35 CGSizeMake(size.width * scale, size.height * scale); 33 CGSizeMake(size.width * scale, size.height * scale);
36 SkBitmap bitmap(gfx::CGImageToSkBitmap(image.CGImage, 34 SkBitmap bitmap(gfx::CGImageToSkBitmap(image.CGImage,
37 desired_size_for_scale, 35 desired_size_for_scale,
38 false)); 36 false));
39 return gfx::ImageSkiaRep(bitmap, scale_factor); 37 return gfx::ImageSkiaRep(bitmap, scale);
40 } 38 }
41 39
42 UIImage* UIImageFromImageSkia(const gfx::ImageSkia& image_skia) { 40 UIImage* UIImageFromImageSkia(const gfx::ImageSkia& image_skia) {
43 return UIImageFromImageSkiaRep(image_skia.GetRepresentation( 41 return UIImageFromImageSkiaRep(
44 ui::GetMaxScaleFactor())); 42 image_skia.GetRepresentation(ImageSkia::GetSupportedScales().back()));
45 } 43 }
46 44
47 UIImage* UIImageFromImageSkiaRep(const gfx::ImageSkiaRep& image_skia_rep) { 45 UIImage* UIImageFromImageSkiaRep(const gfx::ImageSkiaRep& image_skia_rep) {
48 if (image_skia_rep.is_null()) 46 if (image_skia_rep.is_null())
49 return nil; 47 return nil;
50 48
51 float scale = ui::GetScaleFactorScale(image_skia_rep.scale_factor()); 49 float scale = image_skia_rep.scale();
52 base::ScopedCFTypeRef<CGColorSpaceRef> color_space( 50 base::ScopedCFTypeRef<CGColorSpaceRef> color_space(
53 CGColorSpaceCreateDeviceRGB()); 51 CGColorSpaceCreateDeviceRGB());
54 return gfx::SkBitmapToUIImageWithColorSpace(image_skia_rep.sk_bitmap(), scale, 52 return gfx::SkBitmapToUIImageWithColorSpace(image_skia_rep.sk_bitmap(), scale,
55 color_space); 53 color_space);
56 } 54 }
57 55
58 } // namespace gfx 56 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia_util_ios.h ('k') | ui/gfx/image/image_skia_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698