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 | |
55 // Legacy font style mappings. TODO(tapted): Phase these out in favour of | 53 // Legacy font style mappings. TODO(tapted): Phase these out in favour of |
56 // client code providing their own constant with the desired font size delta. | 54 // client code providing their own constant with the desired font size delta. |
57 enum FontStyle { | 55 enum FontStyle { |
58 SmallFont, | 56 SmallFont, |
59 SmallBoldFont, | 57 SmallBoldFont, |
60 BaseFont, | 58 BaseFont, |
61 BoldFont, | 59 BoldFont, |
62 MediumFont, | 60 MediumFont, |
63 MediumBoldFont, | 61 MediumBoldFont, |
64 LargeFont, | 62 LargeFont, |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 379 |
382 // Fills the |bitmap| given the |resource_id| and |scale_factor|. | 380 // Fills the |bitmap| given the |resource_id| and |scale_factor|. |
383 // Returns false if the resource does not exist. This may fall back to | 381 // Returns false if the resource does not exist. This may fall back to |
384 // the data pack with SCALE_FACTOR_NONE, and when this happens, | 382 // the data pack with SCALE_FACTOR_NONE, and when this happens, |
385 // |scale_factor| will be set to SCALE_FACTOR_100P. | 383 // |scale_factor| will be set to SCALE_FACTOR_100P. |
386 bool LoadBitmap(int resource_id, | 384 bool LoadBitmap(int resource_id, |
387 ScaleFactor* scale_factor, | 385 ScaleFactor* scale_factor, |
388 SkBitmap* bitmap, | 386 SkBitmap* bitmap, |
389 bool* fell_back_to_1x) const; | 387 bool* fell_back_to_1x) const; |
390 | 388 |
391 // Loads the raw bytes of a data resource nearest the scale factor | |
392 // |scale_factor| into |bytes|, without doing any processing or | |
393 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE | |
394 // for scale independent image resources (such as wallpaper). | |
395 // Returns NULL if we fail to read the resource. | |
396 base::StringPiece GetRawDataResourceForScaleImpl( | |
397 int resource_id, | |
398 ScaleFactor scale_factor) const; | |
399 | |
400 // Returns true if missing scaled resources should be visually indicated when | 389 // Returns true if missing scaled resources should be visually indicated when |
401 // drawing the fallback (e.g., by tinting the image). | 390 // drawing the fallback (e.g., by tinting the image). |
402 static bool ShouldHighlightMissingScaledResources(); | 391 static bool ShouldHighlightMissingScaledResources(); |
403 | 392 |
404 // Returns true if the data in |buf| is a PNG that has the special marker | 393 // Returns true if the data in |buf| is a PNG that has the special marker |
405 // added by GRIT that indicates that the image is actually 1x data. | 394 // added by GRIT that indicates that the image is actually 1x data. |
406 static bool PNGContainsFallbackMarker(const unsigned char* buf, size_t size); | 395 static bool PNGContainsFallbackMarker(const unsigned char* buf, size_t size); |
407 | 396 |
408 // A wrapper for PNGCodec::Decode that returns information about custom | 397 // A wrapper for PNGCodec::Decode that returns information about custom |
409 // chunks. For security reasons we can't alter PNGCodec to return this | 398 // 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... |
458 | 447 |
459 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 448 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
460 }; | 449 }; |
461 | 450 |
462 } // namespace ui | 451 } // namespace ui |
463 | 452 |
464 // TODO(beng): Someday, maybe, get rid of this. | 453 // TODO(beng): Someday, maybe, get rid of this. |
465 using ui::ResourceBundle; | 454 using ui::ResourceBundle; |
466 | 455 |
467 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 456 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
OLD | NEW |