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

Side by Side Diff: app/resource_bundle.h

Issue 288005: First fix to minimize copying of image data. (Closed)
Patch Set: Modify gyp Created 11 years, 2 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 | « no previous file | app/resource_bundle.cc » ('j') | base/ref_counted_memory.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 APP_RESOURCE_BUNDLE_H_ 5 #ifndef APP_RESOURCE_BUNDLE_H_
6 #define APP_RESOURCE_BUNDLE_H_ 6 #define APP_RESOURCE_BUNDLE_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
11 #include <windows.h> 11 #include <windows.h>
12 #endif 12 #endif
13 13
14 #include <map> 14 #include <map>
15 #include <string> 15 #include <string>
16 16
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/file_path.h" 18 #include "base/file_path.h"
19 #include "base/lock.h" 19 #include "base/lock.h"
20 #include "base/ref_counted_memory.h"
20 #include "base/scoped_ptr.h" 21 #include "base/scoped_ptr.h"
21 #include "base/string16.h" 22 #include "base/string16.h"
22 23
23 #if defined(USE_BASE_DATA_PACK) 24 #if defined(USE_BASE_DATA_PACK)
24 namespace base { 25 namespace base {
25 class DataPack; 26 class DataPack;
26 } 27 }
27 #endif 28 #endif
28 #if defined(USE_X11) 29 #if defined(USE_X11)
29 typedef struct _GdkPixbuf GdkPixbuf; 30 typedef struct _GdkPixbuf GdkPixbuf;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // 84 //
84 // The bitmap is assumed to exist. This function will log in release, and 85 // The bitmap is assumed to exist. This function will log in release, and
85 // assert in debug mode if it does not. On failure, this will return a 86 // assert in debug mode if it does not. On failure, this will return a
86 // pointer to a shared empty placeholder bitmap so it will be visible what 87 // pointer to a shared empty placeholder bitmap so it will be visible what
87 // is missing. 88 // is missing.
88 SkBitmap* GetBitmapNamed(int resource_id); 89 SkBitmap* GetBitmapNamed(int resource_id);
89 90
90 // Loads the raw bytes of an image resource into |bytes|, 91 // Loads the raw bytes of an image resource into |bytes|,
91 // without doing any processing or interpretation of 92 // without doing any processing or interpretation of
92 // the resource. Returns whether we successfully read the resource. 93 // the resource. Returns whether we successfully read the resource.
93 bool LoadImageResourceBytes(int resource_id, 94 RefCountedStaticMemory* LoadImageResourceBytes(int resource_id);
94 std::vector<unsigned char>* bytes);
95 95
96 // Loads the raw bytes of a data resource into |bytes|, 96 // Loads the raw bytes of a data resource into |bytes|,
97 // without doing any processing or interpretation of 97 // without doing any processing or interpretation of
98 // the resource. Returns whether we successfully read the resource. 98 // the resource. Returns whether we successfully read the resource.
99 bool LoadDataResourceBytes(int resource_id, 99 RefCountedStaticMemory* LoadDataResourceBytes(int resource_id);
100 std::vector<unsigned char>* bytes);
101 100
102 // Return the contents of a file in a string given the resource id. 101 // Return the contents of a file in a string given the resource id.
103 // This will copy the data from the resource and return it as a string. 102 // This will copy the data from the resource and return it as a string.
104 // TODO(port): deprecate this and replace with GetRawDataResource to avoid 103 // TODO(port): deprecate this and replace with GetRawDataResource to avoid
105 // needless copying. 104 // needless copying.
106 std::string GetDataResource(int resource_id); 105 std::string GetDataResource(int resource_id);
107 106
108 // Like GetDataResource(), but avoids copying the resource. Instead, it 107 // Like GetDataResource(), but avoids copying the resource. Instead, it
109 // returns a StringPiece which points into the actual resource in the image. 108 // returns a StringPiece which points into the actual resource in the image.
110 base::StringPiece GetRawDataResource(int resource_id); 109 base::StringPiece GetRawDataResource(int resource_id);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // external data module. 177 // external data module.
179 void LoadResources(const std::wstring& pref_locale); 178 void LoadResources(const std::wstring& pref_locale);
180 179
181 // Initialize all the gfx::Font members if they haven't yet been initialized. 180 // Initialize all the gfx::Font members if they haven't yet been initialized.
182 void LoadFontsIfNecessary(); 181 void LoadFontsIfNecessary();
183 182
184 // Returns the full pathname of the locale file to load. May return an empty 183 // Returns the full pathname of the locale file to load. May return an empty
185 // string if no locale data files are found. 184 // string if no locale data files are found.
186 FilePath GetLocaleFilePath(const std::wstring& pref_locale); 185 FilePath GetLocaleFilePath(const std::wstring& pref_locale);
187 186
188 // Loads the raw bytes of a resource from |module| into |bytes|, 187 // Returns a handle to bytes from the resource |module|, without doing any
189 // without doing any processing or interpretation of 188 // processing or interpretation of the resource. Returns whether we
190 // the resource. Returns whether we successfully read the resource. 189 // successfully read the resource. Caller does not own the data returned
191 static bool LoadResourceBytes(DataHandle module, 190 // through this method and must not modify the data pointed to by |bytes|.
192 int resource_id, 191 static RefCountedStaticMemory* LoadResourceBytes(DataHandle module,
193 std::vector<unsigned char>* bytes); 192 int resource_id);
194 193
195 // Creates and returns a new SkBitmap given the data file to look in and the 194 // Creates and returns a new SkBitmap given the data file to look in and the
196 // resource id. It's up to the caller to free the returned bitmap when 195 // resource id. It's up to the caller to free the returned bitmap when
197 // done. 196 // done.
198 static SkBitmap* LoadBitmap(DataHandle dll_inst, int resource_id); 197 static SkBitmap* LoadBitmap(DataHandle dll_inst, int resource_id);
199 198
200 // Class level lock. Used to protect internal data structures that may be 199 // Class level lock. Used to protect internal data structures that may be
201 // accessed from other threads (e.g., skia_images_). 200 // accessed from other threads (e.g., skia_images_).
202 Lock lock_; 201 Lock lock_;
203 202
(...skipping 18 matching lines...) Expand all
222 scoped_ptr<gfx::Font> medium_bold_font_; 221 scoped_ptr<gfx::Font> medium_bold_font_;
223 scoped_ptr<gfx::Font> large_font_; 222 scoped_ptr<gfx::Font> large_font_;
224 scoped_ptr<gfx::Font> web_font_; 223 scoped_ptr<gfx::Font> web_font_;
225 224
226 static ResourceBundle* g_shared_instance_; 225 static ResourceBundle* g_shared_instance_;
227 226
228 DISALLOW_EVIL_CONSTRUCTORS(ResourceBundle); 227 DISALLOW_EVIL_CONSTRUCTORS(ResourceBundle);
229 }; 228 };
230 229
231 #endif // APP_RESOURCE_BUNDLE_H_ 230 #endif // APP_RESOURCE_BUNDLE_H_
OLDNEW
« no previous file with comments | « no previous file | app/resource_bundle.cc » ('j') | base/ref_counted_memory.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698