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

Side by Side Diff: components/favicon_base/favicon_util.cc

Issue 357213002: setConfig is deprecated, use setInfo or allocPixels instead (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « no previous file | components/favicon_base/select_favicon_frames.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/favicon_base/favicon_util.h" 5 #include "components/favicon_base/favicon_util.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "components/favicon_base/favicon_types.h" 9 #include "components/favicon_base/favicon_types.h"
10 #include "components/favicon_base/select_favicon_frames.h" 10 #include "components/favicon_base/select_favicon_frames.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 best_bitmap = input_bitmap; 109 best_bitmap = input_bitmap;
110 } 110 }
111 } 111 }
112 } 112 }
113 113
114 if (desired_size_in_pixel % best_bitmap.width() == 0 && 114 if (desired_size_in_pixel % best_bitmap.width() == 0 &&
115 desired_size_in_pixel % best_bitmap.height() == 0) { 115 desired_size_in_pixel % best_bitmap.height() == 0) {
116 // Use nearest neighbour resampling if upsampling by an integer. This 116 // Use nearest neighbour resampling if upsampling by an integer. This
117 // makes the result look similar to the result of SelectFaviconFrames(). 117 // makes the result look similar to the result of SelectFaviconFrames().
118 SkBitmap bitmap; 118 SkBitmap bitmap;
119 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 119 bitmap.allocN32Pixels(desired_size_in_pixel, desired_size_in_pixel);
120 desired_size_in_pixel,
121 desired_size_in_pixel);
122 bitmap.allocPixels();
123 if (!best_bitmap.isOpaque()) 120 if (!best_bitmap.isOpaque())
124 bitmap.eraseARGB(0, 0, 0, 0); 121 bitmap.eraseARGB(0, 0, 0, 0);
125 122
126 SkCanvas canvas(bitmap); 123 SkCanvas canvas(bitmap);
127 SkRect dest(SkRect::MakeWH(desired_size_in_pixel, desired_size_in_pixel)); 124 SkRect dest(SkRect::MakeWH(desired_size_in_pixel, desired_size_in_pixel));
128 canvas.drawBitmapRect(best_bitmap, NULL, dest); 125 canvas.drawBitmapRect(best_bitmap, NULL, dest);
129 return bitmap; 126 return bitmap;
130 } 127 }
131 return skia::ImageOperations::Resize(best_bitmap, 128 return skia::ImageOperations::Resize(best_bitmap,
132 skia::ImageOperations::RESIZE_LANCZOS3, 129 skia::ImageOperations::RESIZE_LANCZOS3,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 &png_bytes->data())) { 233 &png_bytes->data())) {
237 png_reps.push_back( 234 png_reps.push_back(
238 gfx::ImagePNGRep(png_bytes, resized_image_skia_reps[i].scale())); 235 gfx::ImagePNGRep(png_bytes, resized_image_skia_reps[i].scale()));
239 } 236 }
240 } 237 }
241 238
242 return gfx::Image(png_reps); 239 return gfx::Image(png_reps);
243 } 240 }
244 241
245 } // namespace favicon_base 242 } // namespace favicon_base
OLDNEW
« no previous file with comments | « no previous file | components/favicon_base/select_favicon_frames.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698