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

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

Issue 2902153002: arc: Support non-standard display scale factors. (Closed)
Patch Set: comment updated Created 3 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
« ui/gfx/image/image_skia.h ('K') | « ui/gfx/image/image_skia.h ('k') | no next file » | 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 20349b4baf14c71cd7fd7200697b559abc4fcf84..9c4ef646ecac6af3b4e0bd1ca98911e7b67b621e 100644
--- a/ui/gfx/image/image_skia.cc
+++ b/ui/gfx/image/image_skia.cc
@@ -219,18 +219,8 @@ std::vector<ImageSkiaRep>::iterator ImageSkiaStorage::FindRepresentation(
ImageSkiaRep image;
float resource_scale = scale;
- if (!HasRepresentationAtAllScales() && g_supported_scales) {
- if (g_supported_scales->back() <= scale) {
- resource_scale = g_supported_scales->back();
- } else {
- for (size_t i = 0; i < g_supported_scales->size(); ++i) {
- if ((*g_supported_scales)[i] + kFallbackToSmallerScaleDiff >= scale) {
- resource_scale = (*g_supported_scales)[i];
- break;
- }
- }
- }
- }
+ if (!HasRepresentationAtAllScales() && g_supported_scales)
+ resource_scale = ImageSkia::MapToSupportedScale(scale);
if (scale != resource_scale) {
std::vector<ImageSkiaRep>::iterator iter =
FindRepresentation(resource_scale, fetch_new_image);
@@ -331,6 +321,15 @@ float ImageSkia::GetMaxSupportedScale() {
}
// static
+float ImageSkia::MapToSupportedScale(float scale) {
+ for (float supported_scale : *g_supported_scales) {
+ if (supported_scale + kFallbackToSmallerScaleDiff >= scale)
+ return supported_scale;
+ }
+ return g_supported_scales->back();
+}
+
+// static
ImageSkia ImageSkia::CreateFrom1xBitmap(const SkBitmap& bitmap) {
return ImageSkia(ImageSkiaRep(bitmap, 0.0f));
}
« ui/gfx/image/image_skia.h ('K') | « ui/gfx/image/image_skia.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698