OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 int resource_id, | 399 int resource_id, |
400 ScaleFactor scale_factor) const { | 400 ScaleFactor scale_factor) const { |
401 base::RefCountedStaticMemory* bytes = NULL; | 401 base::RefCountedStaticMemory* bytes = NULL; |
402 if (delegate_) | 402 if (delegate_) |
403 bytes = delegate_->LoadDataResourceBytes(resource_id, scale_factor); | 403 bytes = delegate_->LoadDataResourceBytes(resource_id, scale_factor); |
404 | 404 |
405 if (!bytes) { | 405 if (!bytes) { |
406 base::StringPiece data = | 406 base::StringPiece data = |
407 GetRawDataResourceForScale(resource_id, scale_factor); | 407 GetRawDataResourceForScale(resource_id, scale_factor); |
408 if (!data.empty()) { | 408 if (!data.empty()) { |
409 bytes = new base::RefCountedStaticMemory( | 409 bytes = new base::RefCountedStaticMemory(data.data(), data.length()); |
410 reinterpret_cast<const unsigned char*>(data.data()), data.length()); | |
411 } | 410 } |
412 } | 411 } |
413 | 412 |
414 return bytes; | 413 return bytes; |
415 } | 414 } |
416 | 415 |
417 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const { | 416 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const { |
418 return GetRawDataResourceForScale(resource_id, ui::SCALE_FACTOR_NONE); | 417 return GetRawDataResourceForScale(resource_id, ui::SCALE_FACTOR_NONE); |
419 } | 418 } |
420 | 419 |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 // static | 798 // static |
800 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 799 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
801 size_t size, | 800 size_t size, |
802 SkBitmap* bitmap, | 801 SkBitmap* bitmap, |
803 bool* fell_back_to_1x) { | 802 bool* fell_back_to_1x) { |
804 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 803 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
805 return gfx::PNGCodec::Decode(buf, size, bitmap); | 804 return gfx::PNGCodec::Decode(buf, size, bitmap); |
806 } | 805 } |
807 | 806 |
808 } // namespace ui | 807 } // namespace ui |
OLD | NEW |