| OLD | NEW |
| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // Returns a vector with the image reps contained in this object. | 143 // Returns a vector with the image reps contained in this object. |
| 144 // There is no guarantee that this will return all images rep for | 144 // There is no guarantee that this will return all images rep for |
| 145 // supported scale factors. | 145 // supported scale factors. |
| 146 std::vector<gfx::ImageSkiaRep> image_reps() const; | 146 std::vector<gfx::ImageSkiaRep> image_reps() const; |
| 147 | 147 |
| 148 // When the source is available, generates all ImageReps for | 148 // When the source is available, generates all ImageReps for |
| 149 // supported scale factors. This method is defined as const as | 149 // supported scale factors. This method is defined as const as |
| 150 // the state change in the storage is agnostic to the caller. | 150 // the state change in the storage is agnostic to the caller. |
| 151 void EnsureRepsForSupportedScales() const; | 151 void EnsureRepsForSupportedScales() const; |
| 152 | 152 |
| 153 // Clears cached representations for non-supported scale factors that are |
| 154 // based on |scale|. |
| 155 void RemoveUnsupportedRepresentationsForScale(float scale); |
| 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; |
| 164 | 168 |
| 165 // Checks if the current thread can read/modify the ImageSkia. | 169 // Checks if the current thread can read/modify the ImageSkia. |
| 166 bool CanRead() const; | 170 bool CanRead() const; |
| 167 bool CanModify() const; | 171 bool CanModify() const; |
| 168 | 172 |
| 169 // Detach the storage from the currently assinged thread | 173 // Detach the storage from the currently assinged thread |
| 170 // so that other thread can access the storage. | 174 // so that other thread can access the storage. |
| 171 void DetachStorageFromThread(); | 175 void DetachStorageFromThread(); |
| 172 | 176 |
| 173 // A refptr so that ImageRepSkia can be copied cheaply. | 177 // A refptr so that ImageRepSkia can be copied cheaply. |
| 174 scoped_refptr<internal::ImageSkiaStorage> storage_; | 178 scoped_refptr<internal::ImageSkiaStorage> storage_; |
| 175 }; | 179 }; |
| 176 | 180 |
| 177 } // namespace gfx | 181 } // namespace gfx |
| 178 | 182 |
| 179 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ | 183 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ |
| OLD | NEW |