Chromium Code Reviews| Index: ui/gfx/image/image_skia.cc |
| diff --git a/ui/gfx/image/image_skia.cc b/ui/gfx/image/image_skia.cc |
| index a283117db2415488f3259cb3986fa956c0031a47..5b9f602d5b5158a110ad67b8f09f3bc8c4452f5c 100644 |
| --- a/ui/gfx/image/image_skia.cc |
| +++ b/ui/gfx/image/image_skia.cc |
| @@ -102,6 +102,21 @@ class ImageSkiaStorage : public base::RefCountedThreadSafe<ImageSkiaStorage>, |
| return (read_only_ && !source_.get()) || CalledOnValidThread(); |
| } |
| + // Add a new representation. If the storage contains unscaled |
| + // image rep, change it to scaled as this now contains |
| + // multiple reps. |
| + void AddRepresentation(const ImageSkiaRep& image) { |
| + for (ImageSkia::ImageSkiaReps::iterator it = image_reps_.begin(); |
| + it < image_reps_.end(); |
| + ++it) { |
| + if (it->unscaled()) { |
| + it->SetScaled(); |
| + break; |
| + } |
| + } |
| + image_reps_.push_back(image); |
| + } |
| + |
| // Returns the iterator of the image rep whose density best matches |
| // |scale|. If the image for the |scale| doesn't exist in the storage and |
| // |storage| is set, it fetches new image by calling |
| @@ -240,7 +255,7 @@ float ImageSkia::GetMaxSupportedScale() { |
| // static |
| ImageSkia ImageSkia::CreateFrom1xBitmap(const SkBitmap& bitmap) { |
| - return ImageSkia(ImageSkiaRep(bitmap, 1.0f)); |
| + return ImageSkia(ImageSkiaRep(bitmap, 0.0f)); |
|
Jun Mukai
2014/05/09 17:57:39
Doesn't this cause any other unexpected results?
T
oshima
2014/05/09 20:53:33
Yes, this is exactly what I wanted to guarantee ho
|
| } |
| scoped_ptr<ImageSkia> ImageSkia::DeepCopy() const { |
| @@ -278,7 +293,7 @@ void ImageSkia::AddRepresentation(const ImageSkiaRep& image_rep) { |
| Init(image_rep); |
| } else { |
| CHECK(CanModify()); |
| - storage_->image_reps().push_back(image_rep); |
| + storage_->AddRepresentation(image_rep); |
|
Jun Mukai
2014/05/09 17:57:39
Why only this has to be replaced by AddRepresentat
oshima
2014/05/09 20:53:33
I added the comment to explain why.
|
| } |
| } |