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

Side by Side Diff: ui/gfx/image/image_skia.h

Issue 2902153002: arc: Support non-standard display scale factors. (Closed)
Patch Set: comment added Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_unittest.cc ('k') | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_IMAGE_IMAGE_SKIA_H_ 5 #ifndef UI_GFX_IMAGE_IMAGE_SKIA_H_
6 #define UI_GFX_IMAGE_IMAGE_SKIA_H_ 6 #define UI_GFX_IMAGE_IMAGE_SKIA_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Changes the value of GetSupportedScales() to |scales|. 68 // Changes the value of GetSupportedScales() to |scales|.
69 static void SetSupportedScales(const std::vector<float>& scales); 69 static void SetSupportedScales(const std::vector<float>& scales);
70 70
71 // Returns a vector with the scale factors which are supported by this 71 // Returns a vector with the scale factors which are supported by this
72 // platform, in ascending order. 72 // platform, in ascending order.
73 static const std::vector<float>& GetSupportedScales(); 73 static const std::vector<float>& GetSupportedScales();
74 74
75 // Returns the maximum scale supported by this platform. 75 // Returns the maximum scale supported by this platform.
76 static float GetMaxSupportedScale(); 76 static float GetMaxSupportedScale();
77 77
78 // Maps to the closest supported scale. In case scale is greater than the
msw 2017/05/24 21:44:18 nit: This is worded a bit awkwardly; consider some
khmel 2017/05/26 15:34:53 Done.
79 // nearest supported scale not more than 0.2 then lowest supported scale is
80 // used otherwise scale is mapped to upper supported scale.
81 static float MapToSupportedScale(float scale);
82
78 // Creates an image from the passed in bitmap. 83 // Creates an image from the passed in bitmap.
79 // DIP width and height are based on scale factor of 1x. 84 // DIP width and height are based on scale factor of 1x.
80 // Adds ref to passed in bitmap. 85 // Adds ref to passed in bitmap.
81 // WARNING: The resulting image will be pixelated when painted on a high 86 // WARNING: The resulting image will be pixelated when painted on a high
82 // density display. 87 // density display.
83 static ImageSkia CreateFrom1xBitmap(const SkBitmap& bitmap); 88 static ImageSkia CreateFrom1xBitmap(const SkBitmap& bitmap);
84 89
85 // Returns a deep copy of this ImageSkia which has its own storage with 90 // Returns a deep copy of this ImageSkia which has its own storage with
86 // the ImageSkiaRep instances that this ImageSkia currently has. 91 // the ImageSkiaRep instances that this ImageSkia currently has.
87 // This can be safely passed to and manipulated by another thread. 92 // This can be safely passed to and manipulated by another thread.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 gfx::Size size() const; 139 gfx::Size size() const;
135 140
136 // Returns pointer to 1x bitmap contained by this object. If there is no 1x 141 // Returns pointer to 1x bitmap contained by this object. If there is no 1x
137 // bitmap, the bitmap whose scale factor is closest to 1x is returned. 142 // bitmap, the bitmap whose scale factor is closest to 1x is returned.
138 // This function should only be used in unittests and on platforms which do 143 // This function should only be used in unittests and on platforms which do
139 // not support scale factors other than 1x. 144 // not support scale factors other than 1x.
140 // TODO(pkotwicz): Return null SkBitmap when the object has no 1x bitmap. 145 // TODO(pkotwicz): Return null SkBitmap when the object has no 1x bitmap.
141 const SkBitmap* bitmap() const { return &GetBitmap(); } 146 const SkBitmap* bitmap() const { return &GetBitmap(); }
142 147
143 // Returns a vector with the image reps contained in this object. 148 // Returns a vector with the image reps contained in this object.
144 // There is no guarantee that this will return all images rep for 149 // There is no guarantee that this will r+images rep for
msw 2017/05/24 21:44:18 fix
khmel 2017/05/26 15:34:53 Done.
145 // supported scale factors. 150 // supported scale factors.
146 std::vector<gfx::ImageSkiaRep> image_reps() const; 151 std::vector<gfx::ImageSkiaRep> image_reps() const;
147 152
148 // When the source is available, generates all ImageReps for 153 // When the source is available, generates all ImageReps for
149 // supported scale factors. This method is defined as const as 154 // supported scale factors. This method is defined as const as
150 // the state change in the storage is agnostic to the caller. 155 // the state change in the storage is agnostic to the caller.
151 void EnsureRepsForSupportedScales() const; 156 void EnsureRepsForSupportedScales() const;
152 157
153 private: 158 private:
154 friend class test::TestOnThread; 159 friend class test::TestOnThread;
(...skipping 15 matching lines...) Expand all
170 // so that other thread can access the storage. 175 // so that other thread can access the storage.
171 void DetachStorageFromThread(); 176 void DetachStorageFromThread();
172 177
173 // A refptr so that ImageRepSkia can be copied cheaply. 178 // A refptr so that ImageRepSkia can be copied cheaply.
174 scoped_refptr<internal::ImageSkiaStorage> storage_; 179 scoped_refptr<internal::ImageSkiaStorage> storage_;
175 }; 180 };
176 181
177 } // namespace gfx 182 } // namespace gfx
178 183
179 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ 184 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_unittest.cc ('k') | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698