| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // scaled image is not exactly |scale_factor| * the size of the 1x resource. | 120 // scaled image is not exactly |scale_factor| * the size of the 1x resource. |
| 121 // When --highlight-missing-scaled-resources flag is specified, scaled 1x images | 121 // When --highlight-missing-scaled-resources flag is specified, scaled 1x images |
| 122 // are higlighted by blending them with red. | 122 // are higlighted by blending them with red. |
| 123 class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource { | 123 class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource { |
| 124 public: | 124 public: |
| 125 ResourceBundleImageSource(ResourceBundle* rb, int resource_id) | 125 ResourceBundleImageSource(ResourceBundle* rb, int resource_id) |
| 126 : rb_(rb), resource_id_(resource_id) {} | 126 : rb_(rb), resource_id_(resource_id) {} |
| 127 virtual ~ResourceBundleImageSource() {} | 127 virtual ~ResourceBundleImageSource() {} |
| 128 | 128 |
| 129 // gfx::ImageSkiaSource overrides: | 129 // gfx::ImageSkiaSource overrides: |
| 130 virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { | 130 virtual gfx::ImageSkiaRep GetImageForScale(float scale) override { |
| 131 SkBitmap image; | 131 SkBitmap image; |
| 132 bool fell_back_to_1x = false; | 132 bool fell_back_to_1x = false; |
| 133 ScaleFactor scale_factor = GetSupportedScaleFactor(scale); | 133 ScaleFactor scale_factor = GetSupportedScaleFactor(scale); |
| 134 bool found = rb_->LoadBitmap(resource_id_, &scale_factor, | 134 bool found = rb_->LoadBitmap(resource_id_, &scale_factor, |
| 135 &image, &fell_back_to_1x); | 135 &image, &fell_back_to_1x); |
| 136 if (!found) | 136 if (!found) |
| 137 return gfx::ImageSkiaRep(); | 137 return gfx::ImageSkiaRep(); |
| 138 | 138 |
| 139 // If the resource is in the package with SCALE_FACTOR_NONE, it | 139 // If the resource is in the package with SCALE_FACTOR_NONE, it |
| 140 // can be used in any scale factor. The image is maked as "unscaled" | 140 // can be used in any scale factor. The image is maked as "unscaled" |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 // static | 856 // static |
| 857 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 857 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 858 size_t size, | 858 size_t size, |
| 859 SkBitmap* bitmap, | 859 SkBitmap* bitmap, |
| 860 bool* fell_back_to_1x) { | 860 bool* fell_back_to_1x) { |
| 861 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 861 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 862 return gfx::PNGCodec::Decode(buf, size, bitmap); | 862 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 863 } | 863 } |
| 864 | 864 |
| 865 } // namespace ui | 865 } // namespace ui |
| OLD | NEW |