| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/data_pack.h" | 7 #include "base/data_pack.h" |
| 8 #include "base/lock.h" | 8 #include "base/lock.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "gfx/codec/png_codec.h" | 12 #include "gfx/codec/png_codec.h" |
| 13 #include "gfx/font.h" | 13 #include "gfx/font.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 | 15 |
| 16 namespace { |
| 17 |
| 18 // Font sizes relative to base font. |
| 19 #if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI) |
| 20 const int kSmallFontSizeDelta = -3; |
| 21 const int kMediumFontSizeDelta = 2; |
| 22 const int kLargeFontSizeDelta = 7; |
| 23 #else |
| 24 const int kSmallFontSizeDelta = -2; |
| 25 const int kMediumFontSizeDelta = 3; |
| 26 const int kLargeFontSizeDelta = 8; |
| 27 #endif |
| 28 |
| 29 } // namespace |
| 30 |
| 16 ResourceBundle* ResourceBundle::g_shared_instance_ = NULL; | 31 ResourceBundle* ResourceBundle::g_shared_instance_ = NULL; |
| 17 | 32 |
| 18 /* static */ | 33 /* static */ |
| 19 // TODO(glen): Finish moving these into theme provider (dialogs still | 34 // TODO(glen): Finish moving these into theme provider (dialogs still |
| 20 // depend on these colors). | 35 // depend on these colors). |
| 21 const SkColor ResourceBundle::frame_color = | 36 const SkColor ResourceBundle::frame_color = |
| 22 SkColorSetRGB(66, 116, 201); | 37 SkColorSetRGB(66, 116, 201); |
| 23 const SkColor ResourceBundle::frame_color_inactive = | 38 const SkColor ResourceBundle::frame_color_inactive = |
| 24 SkColorSetRGB(161, 182, 228); | 39 SkColorSetRGB(161, 182, 228); |
| 25 const SkColor ResourceBundle::frame_color_app_panel = | 40 const SkColor ResourceBundle::frame_color_app_panel = |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 void ResourceBundle::LoadFontsIfNecessary() { | 183 void ResourceBundle::LoadFontsIfNecessary() { |
| 169 AutoLock lock_scope(*lock_); | 184 AutoLock lock_scope(*lock_); |
| 170 if (!base_font_.get()) { | 185 if (!base_font_.get()) { |
| 171 base_font_.reset(new gfx::Font()); | 186 base_font_.reset(new gfx::Font()); |
| 172 | 187 |
| 173 bold_font_.reset(new gfx::Font()); | 188 bold_font_.reset(new gfx::Font()); |
| 174 *bold_font_ = | 189 *bold_font_ = |
| 175 base_font_->DeriveFont(0, base_font_->GetStyle() | gfx::Font::BOLD); | 190 base_font_->DeriveFont(0, base_font_->GetStyle() | gfx::Font::BOLD); |
| 176 | 191 |
| 177 small_font_.reset(new gfx::Font()); | 192 small_font_.reset(new gfx::Font()); |
| 178 *small_font_ = base_font_->DeriveFont(-2); | 193 *small_font_ = base_font_->DeriveFont(kSmallFontSizeDelta); |
| 179 | 194 |
| 180 medium_font_.reset(new gfx::Font()); | 195 medium_font_.reset(new gfx::Font()); |
| 181 *medium_font_ = base_font_->DeriveFont(3); | 196 *medium_font_ = base_font_->DeriveFont(kMediumFontSizeDelta); |
| 182 | 197 |
| 183 medium_bold_font_.reset(new gfx::Font()); | 198 medium_bold_font_.reset(new gfx::Font()); |
| 184 *medium_bold_font_ = | 199 *medium_bold_font_ = |
| 185 base_font_->DeriveFont(3, base_font_->GetStyle() | gfx::Font::BOLD); | 200 base_font_->DeriveFont(kMediumFontSizeDelta, |
| 201 base_font_->GetStyle() | gfx::Font::BOLD); |
| 186 | 202 |
| 187 large_font_.reset(new gfx::Font()); | 203 large_font_.reset(new gfx::Font()); |
| 188 *large_font_ = base_font_->DeriveFont(8); | 204 *large_font_ = base_font_->DeriveFont(kLargeFontSizeDelta); |
| 189 } | 205 } |
| 190 } | 206 } |
| 191 | 207 |
| 192 const gfx::Font& ResourceBundle::GetFont(FontStyle style) { | 208 const gfx::Font& ResourceBundle::GetFont(FontStyle style) { |
| 193 LoadFontsIfNecessary(); | 209 LoadFontsIfNecessary(); |
| 194 switch (style) { | 210 switch (style) { |
| 195 case BoldFont: | 211 case BoldFont: |
| 196 return *bold_font_; | 212 return *bold_font_; |
| 197 case SmallFont: | 213 case SmallFont: |
| 198 return *small_font_; | 214 return *small_font_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 253 |
| 238 bool ResourceBundle::LoadedDataPack::GetStringPiece( | 254 bool ResourceBundle::LoadedDataPack::GetStringPiece( |
| 239 int resource_id, base::StringPiece* data) const { | 255 int resource_id, base::StringPiece* data) const { |
| 240 return data_pack_->GetStringPiece(static_cast<uint32>(resource_id), data); | 256 return data_pack_->GetStringPiece(static_cast<uint32>(resource_id), data); |
| 241 } | 257 } |
| 242 | 258 |
| 243 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory( | 259 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory( |
| 244 int resource_id) const { | 260 int resource_id) const { |
| 245 return data_pack_->GetStaticMemory(resource_id); | 261 return data_pack_->GetStaticMemory(resource_id); |
| 246 } | 262 } |
| OLD | NEW |