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

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

Issue 10780010: Introduces ImageSkia::GetRepresentations() for Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/gfx/image/image_skia.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('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 fadd2e606236a00ef3e76e9d5bda7804067e8778..ec11272817b15b7fb2cfda9a4f07a5664f6188fd 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_; }
@@ -213,6 +215,39 @@ const ImageSkiaRep& ImageSkia::GetRepresentation(
return *it;
}
+#if defined(OS_MACOSX)
+
+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;
+}
+
+#endif // OS_MACOSX
+
bool ImageSkia::empty() const {
return isNull() || storage_->size().IsEmpty();
}
« no previous file with comments | « ui/gfx/image/image_skia.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698