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

Side by Side Diff: chrome/browser/favicon/favicon_util.cc

Issue 330603004: Rename FaviconBitmapXxx to FaviconRawBitmapXxx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android Created 6 years, 6 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
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 "chrome/browser/favicon/favicon_util.h" 5 #include "chrome/browser/favicon/favicon_util.h"
6 6
7 #include "components/favicon_base/favicon_types.h" 7 #include "components/favicon_base/favicon_types.h"
8 #include "components/favicon_base/select_favicon_frames.h" 8 #include "components/favicon_base/select_favicon_frames.h"
9 #include "skia/ext/image_operations.h" 9 #include "skia/ext/image_operations.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
11 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "ui/gfx/codec/png_codec.h" 12 #include "ui/gfx/codec/png_codec.h"
13 #include "ui/gfx/favicon_size.h" 13 #include "ui/gfx/favicon_size.h"
14 #include "ui/gfx/image/image_png_rep.h" 14 #include "ui/gfx/image/image_png_rep.h"
15 #include "ui/gfx/image/image_skia.h" 15 #include "ui/gfx/image/image_skia.h"
16 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
17 17
18 #if defined(OS_MACOSX) && !defined(OS_IOS) 18 #if defined(OS_MACOSX) && !defined(OS_IOS)
19 #include "base/mac/mac_util.h" 19 #include "base/mac/mac_util.h"
20 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 20 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
21 21
22 namespace { 22 namespace {
23 23
24 // Creates image reps of DIP size |favicon_size| for the subset of 24 // Creates image reps of DIP size |favicon_size| for the subset of
25 // |scale_factors| for which the image reps can be created without resizing 25 // |scale_factors| for which the image reps can be created without resizing
26 // or decoding the bitmap data. 26 // or decoding the bitmap data.
27 std::vector<gfx::ImagePNGRep> SelectFaviconFramesFromPNGsWithoutResizing( 27 std::vector<gfx::ImagePNGRep> SelectFaviconFramesFromPNGsWithoutResizing(
28 const std::vector<favicon_base::FaviconBitmapResult>& png_data, 28 const std::vector<favicon_base::FaviconRawBitmapResult>& png_data,
29 const std::vector<ui::ScaleFactor>& scale_factors, 29 const std::vector<ui::ScaleFactor>& scale_factors,
30 int favicon_size) { 30 int favicon_size) {
31 std::vector<gfx::ImagePNGRep> png_reps; 31 std::vector<gfx::ImagePNGRep> png_reps;
32 if (png_data.empty()) 32 if (png_data.empty())
33 return png_reps; 33 return png_reps;
34 34
35 // A |favicon_size| of 0 indicates that the largest frame is desired. 35 // A |favicon_size| of 0 indicates that the largest frame is desired.
36 if (favicon_size == 0) { 36 if (favicon_size == 0) {
37 int maximum_area = 0; 37 int maximum_area = 0;
38 scoped_refptr<base::RefCountedMemory> best_candidate; 38 scoped_refptr<base::RefCountedMemory> best_candidate;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 // static 167 // static
168 void FaviconUtil::SetFaviconColorSpace(gfx::Image* image) { 168 void FaviconUtil::SetFaviconColorSpace(gfx::Image* image) {
169 #if defined(OS_MACOSX) && !defined(OS_IOS) 169 #if defined(OS_MACOSX) && !defined(OS_IOS)
170 image->SetSourceColorSpace(base::mac::GetSystemColorSpace()); 170 image->SetSourceColorSpace(base::mac::GetSystemColorSpace());
171 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 171 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
172 } 172 }
173 173
174 // static 174 // static
175 gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs( 175 gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs(
176 const std::vector<favicon_base::FaviconBitmapResult>& png_data, 176 const std::vector<favicon_base::FaviconRawBitmapResult>& png_data,
177 const std::vector<ui::ScaleFactor>& scale_factors, 177 const std::vector<ui::ScaleFactor>& scale_factors,
178 int favicon_size) { 178 int favicon_size) {
179 // Create image reps for as many scale factors as possible without resizing 179 // Create image reps for as many scale factors as possible without resizing
180 // the bitmap data or decoding it. FaviconHandler stores already resized 180 // the bitmap data or decoding it. FaviconHandler stores already resized
181 // favicons into history so no additional resizing should be needed in the 181 // favicons into history so no additional resizing should be needed in the
182 // common case. 182 // common case.
183 // Creating the gfx::Image from |png_data| without resizing or decoding if 183 // Creating the gfx::Image from |png_data| without resizing or decoding if
184 // possible is important because: 184 // possible is important because:
185 // - Sync does a byte-to-byte comparison of gfx::Image::As1xPNGBytes() to 185 // - Sync does a byte-to-byte comparison of gfx::Image::As1xPNGBytes() to
186 // the data it put into the database in order to determine whether any 186 // the data it put into the database in order to determine whether any
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 scoped_refptr<base::RefCountedBytes> png_bytes(new base::RefCountedBytes()); 245 scoped_refptr<base::RefCountedBytes> png_bytes(new base::RefCountedBytes());
246 if (gfx::PNGCodec::EncodeBGRASkBitmap( 246 if (gfx::PNGCodec::EncodeBGRASkBitmap(
247 resized_image_skia_reps[i].sk_bitmap(), false, &png_bytes->data())) { 247 resized_image_skia_reps[i].sk_bitmap(), false, &png_bytes->data())) {
248 png_reps.push_back(gfx::ImagePNGRep(png_bytes, 248 png_reps.push_back(gfx::ImagePNGRep(png_bytes,
249 resized_image_skia_reps[i].scale())); 249 resized_image_skia_reps[i].scale()));
250 } 250 }
251 } 251 }
252 252
253 return gfx::Image(png_reps); 253 return gfx::Image(png_reps);
254 } 254 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_util.h ('k') | chrome/browser/history/android/android_provider_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698