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

Side by Side Diff: app/resource_bundle_win.cc

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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "app/resource_bundle.h" 5 #include "app/resource_bundle.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 8
9 #include "app/app_paths.h" 9 #include "app/app_paths.h"
10 #include "app/gfx/font.h" 10 #include "app/gfx/font.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 FilePath theme_data_path; 78 FilePath theme_data_path;
79 PathService::Get(app::DIR_THEMES, &theme_data_path); 79 PathService::Get(app::DIR_THEMES, &theme_data_path);
80 theme_data_path = theme_data_path.AppendASCII("default.dll"); 80 theme_data_path = theme_data_path.AppendASCII("default.dll");
81 81
82 // The dll should only have resources, not executable code. 82 // The dll should only have resources, not executable code.
83 theme_data_ = LoadLibraryEx(theme_data_path.value().c_str(), NULL, 83 theme_data_ = LoadLibraryEx(theme_data_path.value().c_str(), NULL,
84 GetDataDllLoadFlags()); 84 GetDataDllLoadFlags());
85 DCHECK(theme_data_ != NULL) << "unable to load " << theme_data_path.value(); 85 DCHECK(theme_data_ != NULL) << "unable to load " << theme_data_path.value();
86 } 86 }
87 87
88 /* static */ 88 // static
89 bool ResourceBundle::LoadResourceBytes( 89 RefCountedStaticMemory* ResourceBundle::LoadResourceBytes(
90 DataHandle module, 90 DataHandle module, int resource_id) {
91 int resource_id,
92 std::vector<unsigned char>* bytes) {
93 void* data_ptr; 91 void* data_ptr;
94 size_t data_size; 92 size_t data_size;
95 if (base::GetDataResourceFromModule(module, resource_id, &data_ptr, 93 if (base::GetDataResourceFromModule(module, resource_id, &data_ptr,
96 &data_size)) { 94 &data_size)) {
97 bytes->resize(data_size); 95 return new RefCountedStaticMemory(
98 memcpy(&(bytes->front()), data_ptr, data_size); 96 reinterpret_cast<const unsigned char*>(data_ptr), data_size);
99 return true;
100 } else { 97 } else {
101 return false; 98 return NULL;
102 } 99 }
103 } 100 }
104 101
105 HICON ResourceBundle::LoadThemeIcon(int icon_id) { 102 HICON ResourceBundle::LoadThemeIcon(int icon_id) {
106 return ::LoadIcon(theme_data_, MAKEINTRESOURCE(icon_id)); 103 return ::LoadIcon(theme_data_, MAKEINTRESOURCE(icon_id));
107 } 104 }
108 105
109 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) { 106 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) {
110 void* data_ptr; 107 void* data_ptr;
111 size_t data_size; 108 size_t data_size;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 message_id); 149 message_id);
153 if (!image) { 150 if (!image) {
154 StackTrace().PrintBacktrace(); // See http://crbug.com/21925. 151 StackTrace().PrintBacktrace(); // See http://crbug.com/21925.
155 NOTREACHED() << "unable to find resource: " << message_id; 152 NOTREACHED() << "unable to find resource: " << message_id;
156 return std::wstring(); 153 return std::wstring();
157 } 154 }
158 } 155 }
159 // Copy into a string16 and return. 156 // Copy into a string16 and return.
160 return string16(image->achString, image->nLength); 157 return string16(image->achString, image->nLength);
161 } 158 }
OLDNEW
« no previous file with comments | « app/resource_bundle_mac.mm ('k') | app/theme_provider.h » ('j') | base/ref_counted_memory.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698