OLD | NEW |
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/extensions/extension_icon_image.h" | 5 #include "chrome/browser/extensions/extension_icon_image.h" |
6 | 6 |
7 #include "base/json/json_file_value_serializer.h" | 7 #include "base/json/json_file_value_serializer.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "chrome/browser/extensions/image_loader.h" | 10 #include "chrome/browser/extensions/image_loader.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 using content::BrowserThread; | 25 using content::BrowserThread; |
26 using extensions::Extension; | 26 using extensions::Extension; |
27 using extensions::IconImage; | 27 using extensions::IconImage; |
28 using extensions::Manifest; | 28 using extensions::Manifest; |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 SkBitmap CreateBlankBitmapForScale(int size_dip, ui::ScaleFactor scale_factor) { | 32 SkBitmap CreateBlankBitmapForScale(int size_dip, ui::ScaleFactor scale_factor) { |
33 SkBitmap bitmap; | 33 SkBitmap bitmap; |
34 const float scale = ui::GetImageScale(scale_factor); | 34 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
35 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 35 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
36 static_cast<int>(size_dip * scale), | 36 static_cast<int>(size_dip * scale), |
37 static_cast<int>(size_dip * scale)); | 37 static_cast<int>(size_dip * scale)); |
38 bitmap.allocPixels(); | 38 bitmap.allocPixels(); |
39 bitmap.eraseColor(SkColorSetARGB(0, 0, 0, 0)); | 39 bitmap.eraseColor(SkColorSetARGB(0, 0, 0, 0)); |
40 return bitmap; | 40 return bitmap; |
41 } | 41 } |
42 | 42 |
43 SkBitmap EnsureBitmapSize(const SkBitmap& original, int size) { | 43 SkBitmap EnsureBitmapSize(const SkBitmap& original, int size) { |
44 if (original.width() == size && original.height() == size) | 44 if (original.width() == size && original.height() == size) |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 565 |
566 // When requesting another representation, we should not crash and return some | 566 // When requesting another representation, we should not crash and return some |
567 // image of the size. It could be blank or a rescale from the existing 1.0f | 567 // image of the size. It could be blank or a rescale from the existing 1.0f |
568 // icon. | 568 // icon. |
569 representation = image_skia.GetRepresentation(2.0f); | 569 representation = image_skia.GetRepresentation(2.0f); |
570 | 570 |
571 EXPECT_EQ(16, representation.GetWidth()); | 571 EXPECT_EQ(16, representation.GetWidth()); |
572 EXPECT_EQ(16, representation.GetHeight()); | 572 EXPECT_EQ(16, representation.GetHeight()); |
573 EXPECT_EQ(2.0f, representation.scale()); | 573 EXPECT_EQ(2.0f, representation.scale()); |
574 } | 574 } |
OLD | NEW |