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 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 5 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // such as theme graphics. Every resource is loaded only once. | 43 // such as theme graphics. Every resource is loaded only once. |
44 class UI_BASE_EXPORT ResourceBundle { | 44 class UI_BASE_EXPORT ResourceBundle { |
45 public: | 45 public: |
46 // Legacy font size deltas. Consider these to be magic numbers. New code | 46 // Legacy font size deltas. Consider these to be magic numbers. New code |
47 // should declare their own size delta constant using an identifier that | 47 // should declare their own size delta constant using an identifier that |
48 // imparts some semantic meaning. | 48 // imparts some semantic meaning. |
49 static const int kSmallFontDelta = -1; | 49 static const int kSmallFontDelta = -1; |
50 static const int kMediumFontDelta = 3; | 50 static const int kMediumFontDelta = 3; |
51 static const int kLargeFontDelta = 8; | 51 static const int kLargeFontDelta = 8; |
52 | 52 |
| 53 static constexpr const char* CUSTOM_GZIP_HEADER = "\xff\x1f\x8b"; |
| 54 |
53 // Legacy font style mappings. TODO(tapted): Phase these out in favour of | 55 // Legacy font style mappings. TODO(tapted): Phase these out in favour of |
54 // client code providing their own constant with the desired font size delta. | 56 // client code providing their own constant with the desired font size delta. |
55 enum FontStyle { | 57 enum FontStyle { |
56 SmallFont, | 58 SmallFont, |
57 SmallBoldFont, | 59 SmallBoldFont, |
58 BaseFont, | 60 BaseFont, |
59 BoldFont, | 61 BoldFont, |
60 MediumFont, | 62 MediumFont, |
61 MediumBoldFont, | 63 MediumBoldFont, |
62 LargeFont, | 64 LargeFont, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // Loads the raw bytes of a data resource nearest the scale factor | 223 // Loads the raw bytes of a data resource nearest the scale factor |
222 // |scale_factor| into |bytes|, without doing any processing or | 224 // |scale_factor| into |bytes|, without doing any processing or |
223 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE | 225 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE |
224 // for scale independent image resources (such as wallpaper). | 226 // for scale independent image resources (such as wallpaper). |
225 // Returns NULL if we fail to read the resource. | 227 // Returns NULL if we fail to read the resource. |
226 base::RefCountedMemory* LoadDataResourceBytesForScale( | 228 base::RefCountedMemory* LoadDataResourceBytesForScale( |
227 int resource_id, | 229 int resource_id, |
228 ScaleFactor scale_factor) const; | 230 ScaleFactor scale_factor) const; |
229 | 231 |
230 // Return the contents of a scale independent resource in a | 232 // Return the contents of a scale independent resource in a |
231 // StringPiece given the resource id | 233 // StringPiece given the resource id. |
232 base::StringPiece GetRawDataResource(int resource_id) const; | 234 base::StringPiece GetRawDataResource(int resource_id) const; |
233 | 235 |
234 // Return the contents of a resource in a StringPiece given the resource id | 236 // Return the contents of a resource in a StringPiece given the resource id |
235 // nearest the scale factor |scale_factor|. | 237 // nearest the scale factor |scale_factor|. |
236 // Use ResourceHandle::SCALE_FACTOR_NONE for scale independent image resources | 238 // Use ResourceHandle::SCALE_FACTOR_NONE for scale independent image resources |
237 // (such as wallpaper). | 239 // (such as wallpaper). |
238 base::StringPiece GetRawDataResourceForScale(int resource_id, | 240 base::StringPiece GetRawDataResourceForScale(int resource_id, |
239 ScaleFactor scale_factor) const; | 241 ScaleFactor scale_factor) const; |
240 | 242 |
241 // Get a localized string given a message id. Returns an empty | 243 // Get a localized string given a message id. Returns an empty |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 377 |
376 // Fills the |bitmap| given the |resource_id| and |scale_factor|. | 378 // Fills the |bitmap| given the |resource_id| and |scale_factor|. |
377 // Returns false if the resource does not exist. This may fall back to | 379 // Returns false if the resource does not exist. This may fall back to |
378 // the data pack with SCALE_FACTOR_NONE, and when this happens, | 380 // the data pack with SCALE_FACTOR_NONE, and when this happens, |
379 // |scale_factor| will be set to SCALE_FACTOR_100P. | 381 // |scale_factor| will be set to SCALE_FACTOR_100P. |
380 bool LoadBitmap(int resource_id, | 382 bool LoadBitmap(int resource_id, |
381 ScaleFactor* scale_factor, | 383 ScaleFactor* scale_factor, |
382 SkBitmap* bitmap, | 384 SkBitmap* bitmap, |
383 bool* fell_back_to_1x) const; | 385 bool* fell_back_to_1x) const; |
384 | 386 |
| 387 // Loads the raw bytes of a data resource nearest the scale factor |
| 388 // |scale_factor| into |bytes|, without doing any processing or |
| 389 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE |
| 390 // for scale independent image resources (such as wallpaper). |
| 391 // Returns NULL if we fail to read the resource. |
| 392 base::StringPiece GetRawDataResourceForScaleImpl( |
| 393 int resource_id, |
| 394 ScaleFactor scale_factor) const; |
| 395 |
385 // Returns true if missing scaled resources should be visually indicated when | 396 // Returns true if missing scaled resources should be visually indicated when |
386 // drawing the fallback (e.g., by tinting the image). | 397 // drawing the fallback (e.g., by tinting the image). |
387 static bool ShouldHighlightMissingScaledResources(); | 398 static bool ShouldHighlightMissingScaledResources(); |
388 | 399 |
389 // Returns true if the data in |buf| is a PNG that has the special marker | 400 // Returns true if the data in |buf| is a PNG that has the special marker |
390 // added by GRIT that indicates that the image is actually 1x data. | 401 // added by GRIT that indicates that the image is actually 1x data. |
391 static bool PNGContainsFallbackMarker(const unsigned char* buf, size_t size); | 402 static bool PNGContainsFallbackMarker(const unsigned char* buf, size_t size); |
392 | 403 |
393 // A wrapper for PNGCodec::Decode that returns information about custom | 404 // A wrapper for PNGCodec::Decode that returns information about custom |
394 // chunks. For security reasons we can't alter PNGCodec to return this | 405 // chunks. For security reasons we can't alter PNGCodec to return this |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 454 |
444 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 455 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
445 }; | 456 }; |
446 | 457 |
447 } // namespace ui | 458 } // namespace ui |
448 | 459 |
449 // TODO(beng): Someday, maybe, get rid of this. | 460 // TODO(beng): Someday, maybe, get rid of this. |
450 using ui::ResourceBundle; | 461 using ui::ResourceBundle; |
451 | 462 |
452 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 463 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
OLD | NEW |