Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: ui/gfx/image/image_skia.cc

Issue 277773002: Add ImageSkiaRep::unscaled that tells if the image is for unscaled image. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated comment Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/resource/resource_bundle_unittest.cc ('k') | ui/gfx/image/image_skia_rep.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
}
}
« no previous file with comments | « ui/base/resource/resource_bundle_unittest.cc ('k') | ui/gfx/image/image_skia_rep.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698