| Index: ui/gfx/image/image_skia.cc
|
| diff --git a/ui/gfx/image/image_skia.cc b/ui/gfx/image/image_skia.cc
|
| index 9472cda8b6be4d26c4bc42e63e0a893e4536ff34..7dd1e78fe0420294ad516880bf1ef583f7742a54 100644
|
| --- a/ui/gfx/image/image_skia.cc
|
| +++ b/ui/gfx/image/image_skia.cc
|
| @@ -53,6 +53,8 @@ class ImageSkiaStorage : public base::RefCounted<ImageSkiaStorage> {
|
| size_(size) {
|
| }
|
|
|
| + bool has_source() const { return source_.get() != NULL; }
|
| +
|
| std::vector<gfx::ImageSkiaRep>& image_reps() { return image_reps_; }
|
|
|
| const gfx::Size& size() const { return size_; }
|
| @@ -191,7 +193,7 @@ void ImageSkia::RemoveRepresentation(ui::ScaleFactor scale_factor) {
|
| image_reps.erase(it);
|
| }
|
|
|
| -bool ImageSkia::HasRepresentation(ui::ScaleFactor scale_factor) {
|
| +bool ImageSkia::HasRepresentation(ui::ScaleFactor scale_factor) const {
|
| if (isNull())
|
| return false;
|
|
|
| @@ -213,6 +215,36 @@ const ImageSkiaRep& ImageSkia::GetRepresentation(
|
| return *it;
|
| }
|
|
|
| +std::vector<ImageSkiaRep> ImageSkia::GetRepresentations() const {
|
| + if (isNull())
|
| + return std::vector<ImageSkiaRep>();
|
| +
|
| + if (!storage_->has_source())
|
| + return image_reps();
|
| +
|
| + // Attempt to generate image reps for as many scale factors supported by
|
| + // this platform as possible.
|
| + // Do not build return array here because the mapping from scale factor to
|
| + // image rep is one to many in some cases.
|
| + std::vector<ui::ScaleFactor> supported_scale_factors =
|
| + ui::GetSupportedScaleFactors();
|
| + for (size_t i = 0; i < supported_scale_factors.size(); ++i) {
|
| + storage_->FindRepresentation(supported_scale_factors[i], true);
|
| + }
|
| +
|
| + ImageSkiaReps internal_image_reps = storage_->image_reps();
|
| + // Create list of image reps to return, skipping null image reps which were
|
| + // added for caching purposes only.
|
| + ImageSkiaReps image_reps;
|
| + for (ImageSkiaReps::iterator it = internal_image_reps.begin();
|
| + it != internal_image_reps.end(); ++it) {
|
| + if (!it->is_null())
|
| + image_reps.push_back(*it);
|
| + }
|
| +
|
| + return image_reps;
|
| +}
|
| +
|
| bool ImageSkia::empty() const {
|
| return isNull() || storage_->size().IsEmpty();
|
| }
|
| @@ -270,7 +302,9 @@ const SkBitmap* ImageSkia::bitmap() const {
|
| return &NullImageRep().sk_bitmap();
|
| }
|
|
|
| - return &storage_->image_reps()[0].sk_bitmap();
|
| + ImageSkiaReps::iterator it =
|
| + storage_->FindRepresentation(ui::SCALE_FACTOR_100P, true);
|
| + return &it->sk_bitmap();
|
| }
|
|
|
| void ImageSkia::Init(const ImageSkiaRep& image_rep) {
|
|
|