| 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 #include "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 case BoldFont: | 170 case BoldFont: |
| 171 return *bold_font_; | 171 return *bold_font_; |
| 172 case SmallFont: | 172 case SmallFont: |
| 173 return *small_font_; | 173 return *small_font_; |
| 174 case MediumFont: | 174 case MediumFont: |
| 175 return *medium_font_; | 175 return *medium_font_; |
| 176 case MediumBoldFont: | 176 case MediumBoldFont: |
| 177 return *medium_bold_font_; | 177 return *medium_bold_font_; |
| 178 case LargeFont: | 178 case LargeFont: |
| 179 return *large_font_; | 179 return *large_font_; |
| 180 case LargeBoldFont: |
| 181 return *large_bold_font_; |
| 180 default: | 182 default: |
| 181 return *base_font_; | 183 return *base_font_; |
| 182 } | 184 } |
| 183 } | 185 } |
| 184 | 186 |
| 185 void ResourceBundle::ReloadFonts() { | 187 void ResourceBundle::ReloadFonts() { |
| 186 base::AutoLock lock_scope(*lock_); | 188 base::AutoLock lock_scope(*lock_); |
| 187 base_font_.reset(); | 189 base_font_.reset(); |
| 188 LoadFontsIfNecessary(); | 190 LoadFontsIfNecessary(); |
| 189 } | 191 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 216 medium_font_.reset(new gfx::Font()); | 218 medium_font_.reset(new gfx::Font()); |
| 217 *medium_font_ = base_font_->DeriveFont(kMediumFontSizeDelta); | 219 *medium_font_ = base_font_->DeriveFont(kMediumFontSizeDelta); |
| 218 | 220 |
| 219 medium_bold_font_.reset(new gfx::Font()); | 221 medium_bold_font_.reset(new gfx::Font()); |
| 220 *medium_bold_font_ = | 222 *medium_bold_font_ = |
| 221 base_font_->DeriveFont(kMediumFontSizeDelta, | 223 base_font_->DeriveFont(kMediumFontSizeDelta, |
| 222 base_font_->GetStyle() | gfx::Font::BOLD); | 224 base_font_->GetStyle() | gfx::Font::BOLD); |
| 223 | 225 |
| 224 large_font_.reset(new gfx::Font()); | 226 large_font_.reset(new gfx::Font()); |
| 225 *large_font_ = base_font_->DeriveFont(kLargeFontSizeDelta); | 227 *large_font_ = base_font_->DeriveFont(kLargeFontSizeDelta); |
| 228 |
| 229 large_bold_font_.reset(new gfx::Font()); |
| 230 *large_bold_font_ = |
| 231 base_font_->DeriveFont(kLargeFontSizeDelta, |
| 232 base_font_->GetStyle() | gfx::Font::BOLD); |
| 226 } | 233 } |
| 227 } | 234 } |
| 228 | 235 |
| 229 /* static */ | 236 /* static */ |
| 230 SkBitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id) { | 237 SkBitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id) { |
| 231 scoped_refptr<RefCountedMemory> memory( | 238 scoped_refptr<RefCountedMemory> memory( |
| 232 LoadResourceBytes(data_handle, resource_id)); | 239 LoadResourceBytes(data_handle, resource_id)); |
| 233 if (!memory) | 240 if (!memory) |
| 234 return NULL; | 241 return NULL; |
| 235 | 242 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } | 294 } |
| 288 | 295 |
| 289 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory( | 296 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory( |
| 290 int resource_id) const { | 297 int resource_id) const { |
| 291 if (!data_pack_.get()) | 298 if (!data_pack_.get()) |
| 292 return NULL; | 299 return NULL; |
| 293 return data_pack_->GetStaticMemory(resource_id); | 300 return data_pack_->GetStaticMemory(resource_id); |
| 294 } | 301 } |
| 295 | 302 |
| 296 } // namespace ui | 303 } // namespace ui |
| OLD | NEW |