Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 5 #ifndef CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
| 6 #define CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 6 #define CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 bool GetTint(int id, color_utils::HSL* hsl) const; | 68 bool GetTint(int id, color_utils::HSL* hsl) const; |
| 69 bool GetColor(int id, SkColor* color) const; | 69 bool GetColor(int id, SkColor* color) const; |
| 70 bool GetDisplayProperty(int id, int* result) const; | 70 bool GetDisplayProperty(int id, int* result) const; |
| 71 | 71 |
| 72 // Returns a bitmap if we have a custom image for |id|, otherwise NULL. Note | 72 // Returns a bitmap if we have a custom image for |id|, otherwise NULL. Note |
| 73 // that this is separate from HasCustomImage() which returns whether a custom | 73 // that this is separate from HasCustomImage() which returns whether a custom |
| 74 // image |id| was included in the unprocessed theme and is used as a proxy | 74 // image |id| was included in the unprocessed theme and is used as a proxy |
| 75 // for making layout decisions in the interface. | 75 // for making layout decisions in the interface. |
| 76 SkBitmap* GetBitmapNamed(int id) const; | 76 SkBitmap* GetBitmapNamed(int id) const; |
| 77 | 77 |
| 78 // Get bitmaps for the given |id|. This can be used for icons rendered at | |
| 79 // multiple resolutions. | |
| 80 bool GetBitmapsNamed(int id, std::vector<SkBitmap*>& bitmaps) const; | |
|
Nico
2011/04/14 18:28:54
Introduce a new class and have this return that. e
Robert Sesek
2011/04/14 18:42:44
If I'm understanding correctly, this is exactly wh
| |
| 81 | |
| 78 // Returns the raw PNG encoded data for IDR_THEME_NTP_*. This method is only | 82 // Returns the raw PNG encoded data for IDR_THEME_NTP_*. This method is only |
| 79 // supposed to work for the NTP attribution and background resources. | 83 // supposed to work for the NTP attribution and background resources. |
| 80 RefCountedMemory* GetRawData(int id) const; | 84 RefCountedMemory* GetRawData(int id) const; |
| 81 | 85 |
| 82 // Whether this theme provides an image for |id|. | 86 // Whether this theme provides an image for |id|. |
| 83 bool HasCustomImage(int id) const; | 87 bool HasCustomImage(int id) const; |
| 84 | 88 |
| 85 private: | 89 private: |
| 86 friend struct BrowserThread::DeleteOnThread<BrowserThread::FILE>; | 90 friend struct BrowserThread::DeleteOnThread<BrowserThread::FILE>; |
| 87 friend class DeleteTask<BrowserThemePack>; | 91 friend class DeleteTask<BrowserThemePack>; |
| 88 friend class BrowserThemePackTest; | 92 friend class BrowserThemePackTest; |
| 89 | 93 |
| 90 // Cached images. We cache all retrieved and generated bitmaps and keep | 94 // Cached images. We cache all retrieved and generated bitmaps and keep |
| 91 // track of the pointers. We own these and will delete them when we're done | 95 // track of the pointers. We own these and will delete them when we're done |
| 92 // using them. | 96 // using them. |
| 93 typedef std::map<int, SkBitmap*> ImageCache; | 97 typedef std::map<int, SkBitmap*> ImageCache; |
| 98 typedef std::map<int, std::vector<SkBitmap*>* > MultiResImageCache; | |
| 94 | 99 |
| 95 // The raw PNG memory associated with a certain id. | 100 // The raw PNG memory associated with a certain id. |
| 96 typedef std::map<int, scoped_refptr<RefCountedMemory> > RawImages; | 101 typedef std::map<int, scoped_refptr<RefCountedMemory> > RawImages; |
| 97 | 102 |
| 98 // The type passed to base::DataPack::WritePack. | 103 // The type passed to base::DataPack::WritePack. |
| 99 typedef std::map<uint32, base::StringPiece> RawDataForWriting; | 104 typedef std::map<uint32, base::StringPiece> RawDataForWriting; |
| 100 | 105 |
| 101 // An association between an id and the FilePath that has the image data. | 106 // An association between an id and the FilePath that has the image data. |
| 102 typedef std::map<int, FilePath> FilePathMap; | 107 typedef std::map<int, FilePath> FilePathMap; |
| 103 | 108 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 RawImages image_memory_; | 224 RawImages image_memory_; |
| 220 | 225 |
| 221 // An immutable cache of images generated in BuildFromExtension(). When this | 226 // An immutable cache of images generated in BuildFromExtension(). When this |
| 222 // BrowserThemePack is generated from BuildFromDataPack(), this cache is | 227 // BrowserThemePack is generated from BuildFromDataPack(), this cache is |
| 223 // empty. We separate the images from the images loaded from disk so that | 228 // empty. We separate the images from the images loaded from disk so that |
| 224 // WriteToDisk()'s implementation doesn't need locks. There should be no IDs | 229 // WriteToDisk()'s implementation doesn't need locks. There should be no IDs |
| 225 // in |image_memory_| that are in |prepared_images_| or vice versa. | 230 // in |image_memory_| that are in |prepared_images_| or vice versa. |
| 226 ImageCache prepared_images_; | 231 ImageCache prepared_images_; |
| 227 | 232 |
| 228 // Loaded images. These are loaded from |image_memory_| or the |data_pack_|. | 233 // Loaded images. These are loaded from |image_memory_| or the |data_pack_|. |
| 229 mutable ImageCache loaded_images_; | 234 mutable MultiResImageCache loaded_images_; |
| 230 | 235 |
| 231 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); | 236 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); |
| 232 }; | 237 }; |
| 233 | 238 |
| 234 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 239 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
| OLD | NEW |