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