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

Side by Side Diff: ios/chrome/browser/suggestions/ios_image_decoder_impl.mm

Issue 2504683002: Adds a new constructor for gfx::Image on iOS. (Closed)
Patch Set: rebase Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/suggestions/ios_image_decoder_impl.h" 5 #include "ios/chrome/browser/suggestions/ios_image_decoder_impl.h"
6 6
7 #include <UIKit/UIKit.h> 7 #include <UIKit/UIKit.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 const image_fetcher::ImageDecodedCallback& callback, 141 const image_fetcher::ImageDecodedCallback& callback,
142 const base::scoped_nsobject<NSData>& image_data) { 142 const base::scoped_nsobject<NSData>& image_data) {
143 // Decode the image data using UIImage. 143 // Decode the image data using UIImage.
144 if (image_data) { 144 if (image_data) {
145 // "Most likely" always returns 1x images. 145 // "Most likely" always returns 1x images.
146 UIImage* ui_image = [UIImage imageWithData:image_data scale:1]; 146 UIImage* ui_image = [UIImage imageWithData:image_data scale:1];
147 if (ui_image) { 147 if (ui_image) {
148 // This constructor does not retain the image, but expects to take the 148 // This constructor does not retain the image, but expects to take the
149 // ownership, therefore, |ui_image| is retained here, but not released 149 // ownership, therefore, |ui_image| is retained here, but not released
150 // afterwards. 150 // afterwards.
151 gfx::Image gfx_image([ui_image retain]); 151 gfx::Image gfx_image(ui_image, base::scoped_policy::RETAIN);
152 callback.Run(gfx_image); 152 callback.Run(gfx_image);
153 return; 153 return;
154 } 154 }
155 } 155 }
156 gfx::Image empty_image; 156 gfx::Image empty_image;
157 callback.Run(empty_image); 157 callback.Run(empty_image);
158 } 158 }
159 159
160 std::unique_ptr<image_fetcher::ImageDecoder> CreateIOSImageDecoder( 160 std::unique_ptr<image_fetcher::ImageDecoder> CreateIOSImageDecoder(
161 scoped_refptr<base::TaskRunner> task_runner) { 161 scoped_refptr<base::TaskRunner> task_runner) {
162 return base::MakeUnique<IOSImageDecoderImpl>(std::move(task_runner)); 162 return base::MakeUnique<IOSImageDecoderImpl>(std::move(task_runner));
163 } 163 }
164 164
165 } // namespace suggestions 165 } // namespace suggestions
OLDNEW
« no previous file with comments | « ios/chrome/browser/suggestions/image_fetcher_impl.mm ('k') | ui/base/resource/resource_bundle_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698