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

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

Issue 1508893003: Use proper namespace in skia/ext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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
« no previous file with comments | « ui/gfx/image/image_skia_util_ios.mm ('k') | ui/gfx/image/image_unittest_util.cc » ('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 (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 "ui/gfx/image/image_skia_util_mac.h" 5 #include "ui/gfx/image/image_skia_util_mac.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #import <AppKit/AppKit.h> 10 #import <AppKit/AppKit.h>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 gfx::ImageSkia image_skia; 62 gfx::ImageSkia image_skia;
63 for (size_t i = 0; i < supported_scales.size(); ++i) { 63 for (size_t i = 0; i < supported_scales.size(); ++i) {
64 float scale = supported_scales[i]; 64 float scale = supported_scales[i];
65 NSSize desired_size_for_scale = NSMakeSize(desired_size.width * scale, 65 NSSize desired_size_for_scale = NSMakeSize(desired_size.width * scale,
66 desired_size.height * scale); 66 desired_size.height * scale);
67 NSImageRep* ns_image_rep = GetNSImageRepWithPixelSize(image, 67 NSImageRep* ns_image_rep = GetNSImageRepWithPixelSize(image,
68 desired_size_for_scale); 68 desired_size_for_scale);
69 69
70 // TODO(dcheng): Should this function take a color space argument? 70 // TODO(dcheng): Should this function take a color space argument?
71 SkBitmap bitmap(gfx::NSImageRepToSkBitmapWithColorSpace(ns_image_rep, 71 SkBitmap bitmap(skia::NSImageRepToSkBitmapWithColorSpace(ns_image_rep,
72 desired_size_for_scale, false, base::mac::GetGenericRGBColorSpace())); 72 desired_size_for_scale, false, base::mac::GetGenericRGBColorSpace()));
73 if (bitmap.isNull()) 73 if (bitmap.isNull())
74 continue; 74 continue;
75 75
76 image_skia.AddRepresentation(gfx::ImageSkiaRep(bitmap, scale)); 76 image_skia.AddRepresentation(gfx::ImageSkiaRep(bitmap, scale));
77 } 77 }
78 return image_skia; 78 return image_skia;
79 } 79 }
80 80
81 NSImage* NSImageFromImageSkia(const gfx::ImageSkia& image_skia) { 81 NSImage* NSImageFromImageSkia(const gfx::ImageSkia& image_skia) {
82 if (image_skia.isNull()) 82 if (image_skia.isNull())
83 return nil; 83 return nil;
84 84
85 base::scoped_nsobject<NSImage> image([[NSImage alloc] init]); 85 base::scoped_nsobject<NSImage> image([[NSImage alloc] init]);
86 image_skia.EnsureRepsForSupportedScales(); 86 image_skia.EnsureRepsForSupportedScales();
87 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps(); 87 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps();
88 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin(); 88 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin();
89 it != image_reps.end(); ++it) { 89 it != image_reps.end(); ++it) {
90 [image addRepresentation: 90 [image addRepresentation:
91 gfx::SkBitmapToNSBitmapImageRep(it->sk_bitmap())]; 91 skia::SkBitmapToNSBitmapImageRep(it->sk_bitmap())];
92 } 92 }
93 93
94 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; 94 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())];
95 return [image.release() autorelease]; 95 return [image.release() autorelease];
96 } 96 }
97 97
98 NSImage* NSImageFromImageSkiaWithColorSpace(const gfx::ImageSkia& image_skia, 98 NSImage* NSImageFromImageSkiaWithColorSpace(const gfx::ImageSkia& image_skia,
99 CGColorSpaceRef color_space) { 99 CGColorSpaceRef color_space) {
100 if (image_skia.isNull()) 100 if (image_skia.isNull())
101 return nil; 101 return nil;
102 102
103 base::scoped_nsobject<NSImage> image([[NSImage alloc] init]); 103 base::scoped_nsobject<NSImage> image([[NSImage alloc] init]);
104 image_skia.EnsureRepsForSupportedScales(); 104 image_skia.EnsureRepsForSupportedScales();
105 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps(); 105 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps();
106 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin(); 106 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin();
107 it != image_reps.end(); ++it) { 107 it != image_reps.end(); ++it) {
108 [image addRepresentation: 108 [image addRepresentation:
109 gfx::SkBitmapToNSBitmapImageRepWithColorSpace(it->sk_bitmap(), 109 skia::SkBitmapToNSBitmapImageRepWithColorSpace(it->sk_bitmap(),
110 color_space)]; 110 color_space)];
111 } 111 }
112 112
113 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; 113 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())];
114 return [image.release() autorelease]; 114 return [image.release() autorelease];
115 } 115 }
116 116
117 } // namespace gfx 117 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia_util_ios.mm ('k') | ui/gfx/image/image_unittest_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698