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

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

Issue 2922463002: Replace deprecated base::NonThreadSafe in ui\gfx\image_skia.cc in favor of SequenceChecker. (Closed)
Patch Set: 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 | « no previous file | 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // |scale| exactly. 105 // |scale| exactly.
106 bool HasRepresentation(float scale) const; 106 bool HasRepresentation(float scale) const;
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 sequence, so its safe
116 // to pass it to other thread as long as it is accessed only by that 116 // to pass it to another sequence as long as it is accessed only by that
117 // thread. If this ImageSkia's storage will be accessed by multiple 117 // sequence. If this ImageSkia's storage will be accessed by multiple
118 // threads, use |MakeThreadSafe()| method. 118 // sequences, use |MakeThreadSafe()| method.
119 void SetReadOnly(); 119 void SetReadOnly();
120 120
121 // Make the image thread safe by making the storage read only and remove 121 // Make the image thread safe by making the storage read only and remove
122 // its source if any. All ImageSkia that shares the same storage will also 122 // its source if any. All ImageSkia that shares the same storage will also
123 // become thread safe. Note that in order to make it 100% thread safe, 123 // become thread safe. Note that in order to make it 100% thread safe,
124 // this must be called before it's been passed to anther thread. 124 // this must be called before it's been passed to another sequence.
125 void MakeThreadSafe(); 125 void MakeThreadSafe();
126 bool IsThreadSafe() const; 126 bool IsThreadSafe() const;
127 127
128 // Returns true if this is a null object. 128 // Returns true if this is a null object.
129 bool isNull() const { return storage_.get() == NULL; } 129 bool isNull() const { return storage_.get() == NULL; }
130 130
131 // Width and height of image in DIP coordinate system. 131 // Width and height of image in DIP coordinate system.
132 int width() const; 132 int width() const;
133 int height() const; 133 int height() const;
134 gfx::Size size() const; 134 gfx::Size size() const;
(...skipping 24 matching lines...) Expand all
159 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, EmptyOnThreadTest); 159 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, EmptyOnThreadTest);
160 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, StaticOnThreadTest); 160 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, StaticOnThreadTest);
161 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, SourceOnThreadTest); 161 FRIEND_TEST_ALL_PREFIXES(ImageSkiaTest, SourceOnThreadTest);
162 162
163 // Initialize ImageSkiaStorage with passed in parameters. 163 // Initialize ImageSkiaStorage with passed in parameters.
164 // 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.
165 void Init(const gfx::ImageSkiaRep& image_rep); 165 void Init(const gfx::ImageSkiaRep& image_rep);
166 166
167 const SkBitmap& GetBitmap() const; 167 const SkBitmap& GetBitmap() const;
168 168
169 // Checks if the current thread can read/modify the ImageSkia. 169 // Checks if the current sequence can read/modify the ImageSkia.
170 bool CanRead() const; 170 bool CanRead() const;
171 bool CanModify() const; 171 bool CanModify() const;
172 172
173 // Detach the storage from the currently assinged thread 173 // Detach the storage from the currently assigned sequence
174 // so that other thread can access the storage. 174 // so that other sequence can access the storage.
175 void DetachStorageFromThread(); 175 void DetachStorageFromSequence();
176 176
177 // A refptr so that ImageRepSkia can be copied cheaply. 177 // A refptr so that ImageRepSkia can be copied cheaply.
178 scoped_refptr<internal::ImageSkiaStorage> storage_; 178 scoped_refptr<internal::ImageSkiaStorage> storage_;
179 }; 179 };
180 180
181 } // namespace gfx 181 } // namespace gfx
182 182
183 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ 183 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698