| 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 <limits> | 7 #include <limits> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 } | 767 } |
| 768 return false; | 768 return false; |
| 769 } | 769 } |
| 770 | 770 |
| 771 gfx::Image& ResourceBundle::GetEmptyImage() { | 771 gfx::Image& ResourceBundle::GetEmptyImage() { |
| 772 base::AutoLock lock(*images_and_fonts_lock_); | 772 base::AutoLock lock(*images_and_fonts_lock_); |
| 773 | 773 |
| 774 if (empty_image_.IsEmpty()) { | 774 if (empty_image_.IsEmpty()) { |
| 775 // The placeholder bitmap is bright red so people notice the problem. | 775 // The placeholder bitmap is bright red so people notice the problem. |
| 776 SkBitmap bitmap; | 776 SkBitmap bitmap; |
| 777 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); | 777 bitmap.allocN32Pixels(32, 32); |
| 778 bitmap.allocPixels(); | |
| 779 bitmap.eraseARGB(255, 255, 0, 0); | 778 bitmap.eraseARGB(255, 255, 0, 0); |
| 780 empty_image_ = gfx::Image::CreateFrom1xBitmap(bitmap); | 779 empty_image_ = gfx::Image::CreateFrom1xBitmap(bitmap); |
| 781 } | 780 } |
| 782 return empty_image_; | 781 return empty_image_; |
| 783 } | 782 } |
| 784 | 783 |
| 785 // static | 784 // static |
| 786 bool ResourceBundle::PNGContainsFallbackMarker(const unsigned char* buf, | 785 bool ResourceBundle::PNGContainsFallbackMarker(const unsigned char* buf, |
| 787 size_t size) { | 786 size_t size) { |
| 788 if (size < arraysize(kPngMagic) || | 787 if (size < arraysize(kPngMagic) || |
| (...skipping 30 matching lines...) Expand all Loading... |
| 819 // static | 818 // static |
| 820 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 819 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 821 size_t size, | 820 size_t size, |
| 822 SkBitmap* bitmap, | 821 SkBitmap* bitmap, |
| 823 bool* fell_back_to_1x) { | 822 bool* fell_back_to_1x) { |
| 824 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 823 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 825 return gfx::PNGCodec::Decode(buf, size, bitmap); | 824 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 826 } | 825 } |
| 827 | 826 |
| 828 } // namespace ui | 827 } // namespace ui |
| OLD | NEW |