| OLD | NEW |
| 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 #include "app/resource_bundle.h" | 5 #include "app/resource_bundle.h" |
| 6 | 6 |
| 7 #include "app/gfx/codec/png_codec.h" |
| 7 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
| 8 #include "base/gfx/png_decoder.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 "net/base/file_stream.h" | 11 #include "net/base/file_stream.h" |
| 12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 13 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 14 | 14 |
| 15 ResourceBundle* ResourceBundle::g_shared_instance_ = NULL; | 15 ResourceBundle* ResourceBundle::g_shared_instance_ = NULL; |
| 16 | 16 |
| 17 /* static */ | 17 /* static */ |
| 18 // TODO(glen): Finish moving these into theme provider (dialogs still | 18 // TODO(glen): Finish moving these into theme provider (dialogs still |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 bool success = false; | 73 bool success = false; |
| 74 | 74 |
| 75 if (!success) | 75 if (!success) |
| 76 success = LoadResourceBytes(data_handle, resource_id, &raw_data); | 76 success = LoadResourceBytes(data_handle, resource_id, &raw_data); |
| 77 if (!success) | 77 if (!success) |
| 78 return NULL; | 78 return NULL; |
| 79 | 79 |
| 80 // Decode the PNG. | 80 // Decode the PNG. |
| 81 int image_width; | 81 int image_width; |
| 82 int image_height; | 82 int image_height; |
| 83 if (!PNGDecoder::Decode(&raw_data.front(), raw_data.size(), | 83 if (!gfx::PNGCodec::Decode(&raw_data.front(), raw_data.size(), |
| 84 PNGDecoder::FORMAT_BGRA, | 84 gfx::PNGCodec::FORMAT_BGRA, |
| 85 &png_data, &image_width, &image_height)) { | 85 &png_data, &image_width, &image_height)) { |
| 86 NOTREACHED() << "Unable to decode image resource " << resource_id; | 86 NOTREACHED() << "Unable to decode image resource " << resource_id; |
| 87 return NULL; | 87 return NULL; |
| 88 } | 88 } |
| 89 | 89 |
| 90 return PNGDecoder::CreateSkBitmapFromBGRAFormat(png_data, | 90 return gfx::PNGCodec::CreateSkBitmapFromBGRAFormat(png_data, |
| 91 image_width, | 91 image_width, |
| 92 image_height); | 92 image_height); |
| 93 } | 93 } |
| 94 | 94 |
| 95 std::string ResourceBundle::GetDataResource(int resource_id) { | 95 std::string ResourceBundle::GetDataResource(int resource_id) { |
| 96 return GetRawDataResource(resource_id).as_string(); | 96 return GetRawDataResource(resource_id).as_string(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool ResourceBundle::LoadImageResourceBytes(int resource_id, | 99 bool ResourceBundle::LoadImageResourceBytes(int resource_id, |
| 100 std::vector<unsigned char>* bytes) { | 100 std::vector<unsigned char>* bytes) { |
| 101 return LoadResourceBytes(theme_data_, resource_id, bytes); | 101 return LoadResourceBytes(theme_data_, resource_id, bytes); |
| 102 } | 102 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 case MediumFont: | 193 case MediumFont: |
| 194 return *medium_font_; | 194 return *medium_font_; |
| 195 case MediumBoldFont: | 195 case MediumBoldFont: |
| 196 return *medium_bold_font_; | 196 return *medium_bold_font_; |
| 197 case LargeFont: | 197 case LargeFont: |
| 198 return *large_font_; | 198 return *large_font_; |
| 199 default: | 199 default: |
| 200 return *base_font_; | 200 return *base_font_; |
| 201 } | 201 } |
| 202 } | 202 } |
| OLD | NEW |