[go: nahoru, domu]

tree: e175ba414726cc881ec1a779bde579fc9494689a [path history] [tgz]
  1. chromium/
  2. account_circle.icon
  3. account_circle_chrome_refresh.icon
  4. account_circle_off_chrome_refresh.icon
  5. add_chrome_refresh.icon
  6. ads.icon
  7. ads_chrome_refresh.icon
  8. ads_click.icon
  9. ads_off_chrome_refresh.icon
  10. aggregate_vector_icons.py
  11. arrow_back.icon
  12. arrow_back_chrome_refresh.icon
  13. back_arrow.icon
  14. back_arrow_chrome_refresh.icon
  15. back_to_tab.icon
  16. back_to_tab_chrome_refresh.icon
  17. blocked_badge.icon
  18. bluetooth.icon
  19. bluetooth_chrome_refresh.icon
  20. bluetooth_connected.icon
  21. bluetooth_off_chrome_refresh.icon
  22. bluetooth_scanning.icon
  23. bluetooth_scanning_chrome_refresh.icon
  24. BUILD.gn
  25. business.icon
  26. business_chrome_refresh.icon
  27. call.icon
  28. call_end.icon
  29. call_refresh.icon
  30. cancel.icon
  31. cancel_chrome_refresh.icon
  32. capture.icon
  33. cardboard.icon
  34. caret_down.icon
  35. caret_up.icon
  36. cc_macros.h
  37. celebration.icon
  38. certificate.icon
  39. certificate_chrome_refresh.icon
  40. certificate_off_chrome_refresh.icon
  41. check_circle.icon
  42. close.icon
  43. close_chrome_refresh.icon
  44. close_rounded.icon
  45. cloud_download.icon
  46. code.icon
  47. code_chrome_refresh.icon
  48. code_off_chrome_refresh.icon
  49. COMMON_METADATA
  50. content_copy.icon
  51. content_paste.icon
  52. content_paste_chrome_refresh.icon
  53. content_paste_off.icon
  54. content_paste_off_chrome_refresh.icon
  55. cookie.icon
  56. cookie_chrome_refresh.icon
  57. cookie_off_chrome_refresh.icon
  58. dangerous.icon
  59. dangerous_chrome_refresh.icon
  60. database.icon
  61. database_off.icon
  62. DEPS
  63. description.icon
  64. devices.icon
  65. devices_chrome_refresh.icon
  66. devices_off.icon
  67. devices_off_chrome_refresh.icon
  68. DIR_METADATA
  69. document_scanner.icon
  70. dogfood.icon
  71. edit.icon
  72. edit_chrome_refresh.icon
  73. email.icon
  74. email_outline.icon
  75. error.icon
  76. error_outline.icon
  77. ethernet.icon
  78. expand_more.icon
  79. extension.icon
  80. extension_chrome_refresh.icon
  81. extension_off.icon
  82. extension_on.icon
  83. family_link.icon
  84. feed.icon
  85. file_download.icon
  86. file_download_chrome_refresh.icon
  87. file_download_off.icon
  88. file_download_off_chrome_refresh.icon
  89. folder.icon
  90. folder_chrome_refresh.icon
  91. folder_managed.icon
  92. folder_managed_refresh.icon
  93. folder_managed_touch.icon
  94. folder_open.icon
  95. folder_touch.icon
  96. font_download.icon
  97. font_download_chrome_refresh.icon
  98. font_download_off_chrome_refresh.icon
  99. forward_arrow.icon
  100. forward_arrow_chrome_refresh.icon
  101. google_color.icon
  102. gpp_maybe.icon
  103. groups.icon
  104. headset.icon
  105. help.icon
  106. help_outline.icon
  107. history.icon
  108. history_chrome_refresh.icon
  109. https_valid.icon
  110. https_valid_chrome_refresh.icon
  111. iframe.icon
  112. iframe_off.icon
  113. image_search.icon
  114. info_outline.icon
  115. info_refresh.icon
  116. insert_drive_file_outline.icon
  117. keyboard.icon
  118. launch.icon
  119. launch_chrome_refresh.icon
  120. launch_off_chrome_refresh.icon
  121. lightbulb_outline.icon
  122. lightbulb_outline_chrome_refresh.icon
  123. link.icon
  124. live_caption_off.icon
  125. live_caption_on.icon
  126. location_off.icon
  127. location_off_chrome_refresh.icon
  128. location_on.icon
  129. location_on_chrome_refresh.icon
  130. lock.icon
  131. magic_button.icon
  132. media_next_track.icon
  133. media_previous_track.icon
  134. media_router_active.icon
  135. media_router_active_chrome_refresh.icon
  136. media_router_error.icon
  137. media_router_idle.icon
  138. media_router_idle_chrome_refresh.icon
  139. media_router_paused.icon
  140. media_router_warning.icon
  141. media_router_warning_chrome_refresh.icon
  142. media_seek_backward.icon
  143. media_seek_forward.icon
  144. mic.icon
  145. mic_chrome_refresh.icon
  146. mic_off.icon
  147. mic_off_chrome_refresh.icon
  148. midi.icon
  149. midi_chrome_refresh.icon
  150. midi_off.icon
  151. midi_off_chrome_refresh.icon
  152. not_secure_warning.icon
  153. not_secure_warning_chrome_refresh.icon
  154. not_secure_warning_off_chrome_refresh.icon
  155. notification_warning.icon
  156. notifications.icon
  157. notifications_chrome_refresh.icon
  158. notifications_off.icon
  159. notifications_off_chrome_refresh.icon
  160. OWNERS
  161. page_info_content_paste.icon
  162. page_info_content_paste_chrome_refresh.icon
  163. page_info_content_paste_off_chrome_refresh.icon
  164. passkey.icon
  165. pause.icon
  166. pause_chrome_refresh.icon
  167. photo.icon
  168. photo_chrome_refresh.icon
  169. photo_off_chrome_refresh.icon
  170. picture_in_picture.icon
  171. picture_in_picture_alt.icon
  172. play_arrow.icon
  173. play_arrow_chrome_refresh.icon
  174. privacy_sandbox.icon
  175. protected_content.icon
  176. protocol_handler.icon
  177. protocol_handler_chrome_refresh.icon
  178. protocol_handler_off_chrome_refresh.icon
  179. radio_button_checked.icon
  180. README.md
  181. reload.icon
  182. reload_chrome_refresh.icon
  183. replay.icon
  184. screen_share.icon
  185. search.icon
  186. search_chrome_refresh.icon
  187. select_window.icon
  188. select_window_chrome_refresh.icon
  189. select_window_off_chrome_refresh.icon
  190. sensors.icon
  191. sensors_chrome_refresh.icon
  192. sensors_off_chrome_refresh.icon
  193. serial_port.icon
  194. serial_port_chrome_refresh.icon
  195. serial_port_off_chrome_refresh.icon
  196. settings.icon
  197. settings_chrome_refresh.icon
  198. settings_outline.icon
  199. shopping_bag.icon
  200. shopping_bag_refresh.icon
  201. sms.icon
  202. storage_access.icon
  203. storage_access_off.icon
  204. submenu_arrow.icon
  205. submenu_arrow_chrome_refresh.icon
  206. sync.icon
  207. sync_chrome_refresh.icon
  208. sync_off_chrome_refresh.icon
  209. sync_problem_chrome_refresh.icon
  210. tenancy.icon
  211. troubleshoot.icon
  212. undo.icon
  213. usb.icon
  214. usb_chrome_refresh.icon
  215. usb_off_chrome_refresh.icon
  216. vector_icons.cc.template
  217. vector_icons.gni
  218. vector_icons.h.template
  219. videocam.icon
  220. videocam_chrome_refresh.icon
  221. videocam_off.icon
  222. videocam_off_chrome_refresh.icon
  223. videogame_asset.icon
  224. videogame_asset_chrome_refresh.icon
  225. videogame_asset_off_chrome_refresh.icon
  226. videogame_asset_outline.icon
  227. view_in_ar_chrome_refresh.icon
  228. view_in_ar_off_chrome_refresh.icon
  229. volume_off.icon
  230. volume_off_chrome_refresh.icon
  231. volume_up.icon
  232. volume_up_chrome_refresh.icon
  233. vr_headset.icon
  234. vr_headset_chrome_refresh.icon
  235. vr_headset_off.icon
  236. vr_headset_off_chrome_refresh.icon
  237. warning.icon
  238. warning_outline.icon
components/vector_icons/README.md

Vectorized icons in native Chrome UI

Background

Chrome can draw vectorized images using Skia. Vector images have the advantages of looking better at different scale factors or sizes, can be easily colorized at runtime, and reduce the chrome binary size.

Chrome uses .icon files to describe vector icons. This is a bespoke file format which is actually a C++ array definition. At build time, the .icon files are composed into a .cc file which is compiled into the binary.

Vector icons can be found in various vector_icons subdirectories throughout the code base. Use components/vector_icons/ for generic icons shared among many directories and components, or more specific directories such as ui/views/vector_icons or ash/resources/vector_icons for less widely used icons.

Some of the .icon files have multiple variants of the same icon (contained within the same file). See Why do we need multiples sizes of vector icons.

Converting an SVG to .icon format

This tool generates .icon file output from SVGs. (If you want to contribute improvements, here's the project.)

It handles only a small subset of SVG (paths, circles, etc.) and it's finicky about what it expects as the format, but with a minor amount of manual intervention beforehand, it mostly spits out usable .icon output. It will often work better if you run the SVG through SVGO first, which is a separate project (an SVG minifier). Jake Archibald's SVGOMG is a web interface to SVGO. If any manual adjustments need to be made to the output, the SVG Path spec is a helpful reference; compare with the relevant Chromium drawing commands.

Some SVGs are already pretty minimal, like the ones at the Material Design Icon repository so they don't require much if any adjustment, but some SVG editing tools like Sketch leave a lot of random cruft so SVGOMG helps a lot. Take the output and insert into a .icon file.

Troubleshooting icon generation

  • My colors are inverted! There is probably a surplus square path encompassing your icon. For example, <path d="M0 0h16v16H0z"/>. Delete this and try again.

Using .icon files

Adding new icons

Once you have created an .icon file, place it in an appropriate vector_icon subdirectory and add the filename to the corresponding BUILD.gn. A constant is automatically generated so that the icon can be referenced at runtime. The icon file foo_bar.icon is mapped to the constant name of kFooBarIcon (‘k’ + camel-cased filename + ‘Icon’), which you can use to reference that icon in code. The icon‘s name should match its identifier on the MD icons site if that’s where it came from. For example, ic_accessibility would become accessibility.icon.

Make sure not to add trademarked resources such as Google product logos to the Chromium repo. The handful of vector icons that are trademarked live in //components/vector_icons/google_chrome with open-source counterparts in //components/vector_icons/chromium.

Icons with multiple definitions

To add multiple icon definitions to a single .icon file, place the definitions generated by Skiafy in descending order of size. Each definition after the first must start with a CANVAS_DIMENSIONS directive.

Your icon may not need multiple definitions. Don't add different sizes that are exact copies of one another with a scaling multiplier applied.

In code

A sample call site to create an icon for the foo_bar.icon file looks something like:

gfx::CreateVectorIcon(kFooBarIcon, 32, color_utils::DeriveDefaultIconColor(text_color));

If the size argument is unspecified, the size will be taken from the smallest icon size in the .icon file.

CreateVectorIcon() will use the icon definition that best matches the final pixel size required, which is the product of DIP and the device scale factor (DSF). For example, for a DIP size of 32 and DSF of 100%, a rep with CANVAS_DIMENSIONS, 32, would be used, whereas a configuration with DSF of 150% would prefer a rep with CANVAS_DIMENSIONS, 48.

FAQ

Where can I use vector icons?

Chrome's native UI on desktop platforms. Currently the vector icons are in extensive use on Views platforms, where Skia is the normal drawing tool. Mac uses them sometimes, but optimizing performance is still a TODO so many places stick with raster assets. The files in chrome/app/theme/default_*_percent/legacy are ones that have been switched to vector icons for Views but not yet for OS X. If you need to add raster assets (PNG) for mobile or OS X, please make sure to limit their inclusion to those platforms.

How can I preview vector icons?

Use this extension to preview icons in codesearch.

You can also use the Vector Icon Viewer extension for VS Code to preview icons in Visual Studio. This is especially helpful when adding new icons.

You can also build and run the views_examples_exe (or views_examples_with_content_exe) target and select “Vector Icons” from the dropdown menu. This loads a simple interface which allows you view a provided vector icon file at a specified size and color. Contributions to improve this interface are welcome (bug).

Can my vector icon have more than one color?

Yes. You can hard-code colors for specific path elements by adding a PATH_COLOR_ARGB command to the appropriate place within the .icon file. Any path elements which are not given a hard-coded color in this manner will use the color provided to CreateVectorIcon() at runtime.

When introducing a new icon, should I use a PNG or a vector icon?

Use a vector icon, unless the icon is extremely complex (e.g., a product logo). Also see above, “Where can I use vector icons?”

I see mentions of ‘.1x.icon’ files on the bug tracker. What are those?

A deprecated format where different icon representations were spread across different files.

Why do we need multiple sizes of vector icons?

Even though these icons are vector, sometimes they may still be blurry or fuzzy drawn at different sizes. This is due to the icon not being aligned to the pixel grid and is more obvious at small sizes. In these cases, it is better to design an additional icon specifically for that size. For larger icons, the line stroke width used is often thicker (e.g. 2px for 100%, 3px for 200%), or they may include more detail omitted from smaller ones.