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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.h

Issue 1869693002: Theme suppliers: Avoid all Image copying. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 7 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
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 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 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // BuildFromDataPack(). Often (but not always) called from the file thread; 77 // BuildFromDataPack(). Often (but not always) called from the file thread;
78 // implementation should be threadsafe because neither thread will write to 78 // implementation should be threadsafe because neither thread will write to
79 // |image_memory_| and the worker thread will keep a reference to prevent 79 // |image_memory_| and the worker thread will keep a reference to prevent
80 // destruction. 80 // destruction.
81 bool WriteToDisk(const base::FilePath& path) const; 81 bool WriteToDisk(const base::FilePath& path) const;
82 82
83 // Overridden from CustomThemeSupplier: 83 // Overridden from CustomThemeSupplier:
84 bool GetTint(int id, color_utils::HSL* hsl) const override; 84 bool GetTint(int id, color_utils::HSL* hsl) const override;
85 bool GetColor(int id, SkColor* color) const override; 85 bool GetColor(int id, SkColor* color) const override;
86 bool GetDisplayProperty(int id, int* result) const override; 86 bool GetDisplayProperty(int id, int* result) const override;
87 gfx::Image GetImageNamed(int id) override; 87 const gfx::Image& GetImageNamed(int id) override;
88 base::RefCountedMemory* GetRawData(int id, ui::ScaleFactor scale_factor) 88 base::RefCountedMemory* GetRawData(int id, ui::ScaleFactor scale_factor)
89 const override; 89 const override;
90 bool HasCustomImage(int id) const override; 90 bool HasCustomImage(int id) const override;
91 91
92 private: 92 private:
93 friend class BrowserThemePackTest; 93 friend class BrowserThemePackTest;
94 94
95 // Cached images. 95 // Cached images.
96 typedef std::map<int, gfx::Image> ImageCache; 96 typedef std::map<int, gfx::Image> ImageCache;
97 97
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // in |images|. Must be called after GenerateFrameImages(). 174 // in |images|. Must be called after GenerateFrameImages().
175 void CreateTabBackgroundImages(ImageCache* images) const; 175 void CreateTabBackgroundImages(ImageCache* images) const;
176 176
177 // Takes all the SkBitmaps in |images|, encodes them as PNGs and places 177 // Takes all the SkBitmaps in |images|, encodes them as PNGs and places
178 // them in |reencoded_images|. 178 // them in |reencoded_images|.
179 void RepackImages(const ImageCache& images, 179 void RepackImages(const ImageCache& images,
180 RawImages* reencoded_images) const; 180 RawImages* reencoded_images) const;
181 181
182 // Takes all images in |source| and puts them in |destination|, freeing any 182 // Takes all images in |source| and puts them in |destination|, freeing any
183 // image already in |destination| that |source| would overwrite. 183 // image already in |destination| that |source| would overwrite.
184 void MergeImageCaches(const ImageCache& source, 184 void MergeImageCaches(ImageCache source, ImageCache* destination) const;
185 ImageCache* destination) const;
186 185
187 // Copies images from |source| to |destination| such that the lifetimes of 186 // Copies images from |source| to |destination| such that the lifetimes of
188 // the images in |destination| are not affected by the lifetimes of the 187 // the images in |destination| are not affected by the lifetimes of the
189 // images in |source|. 188 // images in |source|.
190 void CopyImagesTo(const ImageCache& source, ImageCache* destination) const; 189 void CopyImagesTo(const ImageCache& source, ImageCache* destination) const;
191 190
192 // Changes the RefCountedMemory based |images| into StringPiece data in |out|. 191 // Changes the RefCountedMemory based |images| into StringPiece data in |out|.
193 void AddRawImagesTo(const RawImages& images, RawDataForWriting* out) const; 192 void AddRawImagesTo(const RawImages& images, RawDataForWriting* out) const;
194 193
195 // Retrieves the tint OR the default tint. Unlike the public interface, we 194 // Retrieves the tint OR the default tint. Unlike the public interface, we
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // Cache of images created in BuildFromExtension(). Once the theme pack is 269 // Cache of images created in BuildFromExtension(). Once the theme pack is
271 // created, this cache should only be accessed on the file thread. There 270 // created, this cache should only be accessed on the file thread. There
272 // should be no IDs in |image_memory_| that are in |images_on_file_thread_| 271 // should be no IDs in |image_memory_| that are in |images_on_file_thread_|
273 // or vice versa. 272 // or vice versa.
274 ImageCache images_on_file_thread_; 273 ImageCache images_on_file_thread_;
275 274
276 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); 275 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack);
277 }; 276 };
278 277
279 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ 278 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_
OLDNEW
« no previous file with comments | « chrome/browser/supervised_user/supervised_user_theme.cc ('k') | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698