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 "ui/gfx/icon_util.h" | 5 #include "ui/gfx/icon_util.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/important_file_writer.h" | 8 #include "base/files/important_file_writer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 48, // Alt+Tab icon size. | 156 48, // Alt+Tab icon size. |
157 64, // Recommended by the MSDN as a nice to have icon size. | 157 64, // Recommended by the MSDN as a nice to have icon size. |
158 96, // Recommended by the MSDN as a nice to have icon size. | 158 96, // Recommended by the MSDN as a nice to have icon size. |
159 128, // Used by the Shell (e.g. for shortcuts). | 159 128, // Used by the Shell (e.g. for shortcuts). |
160 256 // Used by Vista onwards for large icons. | 160 256 // Used by Vista onwards for large icons. |
161 }; | 161 }; |
162 | 162 |
163 const size_t IconUtil::kNumIconDimensions = arraysize(kIconDimensions); | 163 const size_t IconUtil::kNumIconDimensions = arraysize(kIconDimensions); |
164 const size_t IconUtil::kNumIconDimensionsUpToMediumSize = 9; | 164 const size_t IconUtil::kNumIconDimensionsUpToMediumSize = 9; |
165 | 165 |
166 // VS 2015 and above allow these definitions and in this case require them. | |
167 #if !defined(_MSC_VER) || _MSC_VER >= 1900 | |
danakj
2015/10/30 20:40:37
Why is this !defined || VER >= 1900, but the one i
brucedawson
2015/10/30 20:51:37
The one in base is in a _win only file. But, I don
| |
168 const int IconUtil::kLargeIconSize; | |
169 const int IconUtil::kMediumIconSize; | |
170 #endif | |
171 | |
166 HICON IconUtil::CreateHICONFromSkBitmap(const SkBitmap& bitmap) { | 172 HICON IconUtil::CreateHICONFromSkBitmap(const SkBitmap& bitmap) { |
167 // Only 32 bit ARGB bitmaps are supported. We also try to perform as many | 173 // Only 32 bit ARGB bitmaps are supported. We also try to perform as many |
168 // validations as we can on the bitmap. | 174 // validations as we can on the bitmap. |
169 SkAutoLockPixels bitmap_lock(bitmap); | 175 SkAutoLockPixels bitmap_lock(bitmap); |
170 if ((bitmap.colorType() != kN32_SkColorType) || | 176 if ((bitmap.colorType() != kN32_SkColorType) || |
171 (bitmap.width() <= 0) || (bitmap.height() <= 0) || | 177 (bitmap.width() <= 0) || (bitmap.height() <= 0) || |
172 (bitmap.getPixels() == NULL)) | 178 (bitmap.getPixels() == NULL)) |
173 return NULL; | 179 return NULL; |
174 | 180 |
175 // We start by creating a DIB which we'll use later on in order to create | 181 // We start by creating a DIB which we'll use later on in order to create |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
694 // Once we compute the size for a singe AND mask scan line, we multiply that | 700 // Once we compute the size for a singe AND mask scan line, we multiply that |
695 // number by the image height in order to get the total number of bytes for | 701 // number by the image height in order to get the total number of bytes for |
696 // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes | 702 // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes |
697 // for the monochrome bitmap representing the AND mask. | 703 // for the monochrome bitmap representing the AND mask. |
698 size_t and_line_length = (bitmap.width() + 7) >> 3; | 704 size_t and_line_length = (bitmap.width() + 7) >> 3; |
699 and_line_length = (and_line_length + 3) & ~3; | 705 and_line_length = (and_line_length + 3) & ~3; |
700 size_t and_mask_size = and_line_length * bitmap.height(); | 706 size_t and_mask_size = and_line_length * bitmap.height(); |
701 size_t masks_size = *xor_mask_size + and_mask_size; | 707 size_t masks_size = *xor_mask_size + and_mask_size; |
702 *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER); | 708 *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER); |
703 } | 709 } |
OLD | NEW |