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

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

Issue 2665623002: Fix Jumplist favicons to have high resolution in HDPI Windows displays (Closed)
Patch Set: Update comments and remove redundant .h files. Created 3 years, 10 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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 bool BackedBySameObjectAs(const gfx::ImageSkia& other) const; 96 bool BackedBySameObjectAs(const gfx::ImageSkia& other) const;
97 97
98 // Adds |image_rep| to the image reps contained by this object. 98 // Adds |image_rep| to the image reps contained by this object.
99 void AddRepresentation(const gfx::ImageSkiaRep& image_rep); 99 void AddRepresentation(const gfx::ImageSkiaRep& image_rep);
100 100
101 // Removes the image rep of |scale| if present. 101 // Removes the image rep of |scale| if present.
102 void RemoveRepresentation(float scale); 102 void RemoveRepresentation(float scale);
103 103
104 // Returns true if the object owns an image rep whose density matches 104 // Returns true if the object owns an image rep whose density matches
105 // |scale| exactly. 105 // |scale| exactly.
106 bool HasRepresentation(float scale) const; 106 bool HasRepresentation(float scale) const;
sky 2017/02/02 22:41:16 Can't you use HasRepresentation and GetRepresentat
chengx 2017/02/03 01:51:13 HasRepresentation() doesn't work here as it calls
107 107
108 // Returns the image rep whose density best matches |scale|. 108 // Returns the image rep whose density best matches |scale|.
109 // Returns a null image rep if the object contains no image reps. 109 // Returns a null image rep if the object contains no image reps.
110 const gfx::ImageSkiaRep& GetRepresentation(float scale) const; 110 const gfx::ImageSkiaRep& GetRepresentation(float scale) const;
111 111
112 // Make the ImageSkia instance read-only. Note that this only prevent 112 // Make the ImageSkia instance read-only. Note that this only prevent
113 // modification from client code, and the storage may still be 113 // modification from client code, and the storage may still be
114 // modified by the source if any (thus, it's not thread safe). This 114 // modified by the source if any (thus, it's not thread safe). This
115 // detaches the storage from currently accessing thread, so its safe 115 // detaches the storage from currently accessing thread, so its safe
116 // to pass it to other thread as long as it is accessed only by that 116 // to pass it to other thread as long as it is accessed only by that
(...skipping 16 matching lines...) Expand all
133 int height() const; 133 int height() const;
134 gfx::Size size() const; 134 gfx::Size size() const;
135 135
136 // Returns pointer to 1x bitmap contained by this object. If there is no 1x 136 // 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. 137 // 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 138 // This function should only be used in unittests and on platforms which do
139 // not support scale factors other than 1x. 139 // not support scale factors other than 1x.
140 // TODO(pkotwicz): Return null SkBitmap when the object has no 1x bitmap. 140 // TODO(pkotwicz): Return null SkBitmap when the object has no 1x bitmap.
141 const SkBitmap* bitmap() const { return &GetBitmap(); } 141 const SkBitmap* bitmap() const { return &GetBitmap(); }
142 142
143 // Returns pointer to 2x bitmap contained by this object. If there is no 2x
144 // bitmap, the bitmap whose scale factor is closest to 2x is returned.
145 const SkBitmap* bitmap2x() const { return &GetBitmap2x(); }
146
143 // Returns a vector with the image reps contained in this object. 147 // Returns a vector with the image reps contained in this object.
144 // There is no guarantee that this will return all images rep for 148 // There is no guarantee that this will return all images rep for
145 // supported scale factors. 149 // supported scale factors.
146 std::vector<gfx::ImageSkiaRep> image_reps() const; 150 std::vector<gfx::ImageSkiaRep> image_reps() const;
147 151
148 // When the source is available, generates all ImageReps for 152 // When the source is available, generates all ImageReps for
149 // supported scale factors. This method is defined as const as 153 // supported scale factors. This method is defined as const as
150 // the state change in the storage is agnostic to the caller. 154 // the state change in the storage is agnostic to the caller.
151 void EnsureRepsForSupportedScales() const; 155 void EnsureRepsForSupportedScales() const;
152 156
153 private: 157 private:
154 friend class test::TestOnThread; 158 friend class test::TestOnThread;
155 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, EmptyOnThreadTest); 159 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, EmptyOnThreadTest);
156 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, StaticOnThreadTest); 160 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, StaticOnThreadTest);
157 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, SourceOnThreadTest); 161 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, SourceOnThreadTest);
158 162
159 // Initialize ImageSkiaStorage with passed in parameters. 163 // Initialize ImageSkiaStorage with passed in parameters.
160 // If the image rep's bitmap is empty, ImageStorage is set to NULL. 164 // If the image rep's bitmap is empty, ImageStorage is set to NULL.
161 void Init(const gfx::ImageSkiaRep& image_rep); 165 void Init(const gfx::ImageSkiaRep& image_rep);
162 166
163 const SkBitmap& GetBitmap() const; 167 const SkBitmap& GetBitmap() const;
168 const SkBitmap& GetBitmap2x() const;
164 169
165 // Checks if the current thread can read/modify the ImageSkia. 170 // Checks if the current thread can read/modify the ImageSkia.
166 bool CanRead() const; 171 bool CanRead() const;
167 bool CanModify() const; 172 bool CanModify() const;
168 173
169 // Detach the storage from the currently assinged thread 174 // Detach the storage from the currently assinged thread
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

Powered by Google App Engine
This is Rietveld 408576698