Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: ui/base/resource/resource_bundle.h

Issue 2149323003: Change the way that gzipped resources are loaded from resources.pak (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/grit/grit/node/include_unittest.py ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 BaseFont, 57 BaseFont,
60 BoldFont, 58 BoldFont,
61 MediumFont, 59 MediumFont,
62 MediumBoldFont, 60 MediumBoldFont,
63 LargeFont, 61 LargeFont,
64 }; 62 };
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 350
353 // Fills the |bitmap| given the |resource_id| and |scale_factor|. 351 // Fills the |bitmap| given the |resource_id| and |scale_factor|.
354 // Returns false if the resource does not exist. This may fall back to 352 // Returns false if the resource does not exist. This may fall back to
355 // the data pack with SCALE_FACTOR_NONE, and when this happens, 353 // the data pack with SCALE_FACTOR_NONE, and when this happens,
356 // |scale_factor| will be set to SCALE_FACTOR_100P. 354 // |scale_factor| will be set to SCALE_FACTOR_100P.
357 bool LoadBitmap(int resource_id, 355 bool LoadBitmap(int resource_id,
358 ScaleFactor* scale_factor, 356 ScaleFactor* scale_factor,
359 SkBitmap* bitmap, 357 SkBitmap* bitmap,
360 bool* fell_back_to_1x) const; 358 bool* fell_back_to_1x) const;
361 359
362 // Loads the raw bytes of a data resource nearest the scale factor
363 // |scale_factor| into |bytes|, without doing any processing or
364 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE
365 // for scale independent image resources (such as wallpaper).
366 // Returns NULL if we fail to read the resource.
367 base::StringPiece GetRawDataResourceForScaleImpl(
368 int resource_id,
369 ScaleFactor scale_factor) const;
370
371 // Returns true if missing scaled resources should be visually indicated when 360 // Returns true if missing scaled resources should be visually indicated when
372 // drawing the fallback (e.g., by tinting the image). 361 // drawing the fallback (e.g., by tinting the image).
373 static bool ShouldHighlightMissingScaledResources(); 362 static bool ShouldHighlightMissingScaledResources();
374 363
375 // Returns true if the data in |buf| is a PNG that has the special marker 364 // Returns true if the data in |buf| is a PNG that has the special marker
376 // added by GRIT that indicates that the image is actually 1x data. 365 // added by GRIT that indicates that the image is actually 1x data.
377 static bool PNGContainsFallbackMarker(const unsigned char* buf, size_t size); 366 static bool PNGContainsFallbackMarker(const unsigned char* buf, size_t size);
378 367
379 // A wrapper for PNGCodec::Decode that returns information about custom 368 // A wrapper for PNGCodec::Decode that returns information about custom
380 // chunks. For security reasons we can't alter PNGCodec to return this 369 // chunks. For security reasons we can't alter PNGCodec to return this
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 418
430 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); 419 DISALLOW_COPY_AND_ASSIGN(ResourceBundle);
431 }; 420 };
432 421
433 } // namespace ui 422 } // namespace ui
434 423
435 // TODO(beng): Someday, maybe, get rid of this. 424 // TODO(beng): Someday, maybe, get rid of this.
436 using ui::ResourceBundle; 425 using ui::ResourceBundle;
437 426
438 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 427 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
OLDNEW
« no previous file with comments | « tools/grit/grit/node/include_unittest.py ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698