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 #include "ui/gfx/image/image_skia.h" | 5 #include "ui/gfx/image/image_skia.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 216 } |
217 | 217 |
218 ImageSkia& ImageSkia::operator=(const ImageSkia& other) { | 218 ImageSkia& ImageSkia::operator=(const ImageSkia& other) { |
219 storage_ = other.storage_; | 219 storage_ = other.storage_; |
220 return *this; | 220 return *this; |
221 } | 221 } |
222 | 222 |
223 ImageSkia::~ImageSkia() { | 223 ImageSkia::~ImageSkia() { |
224 } | 224 } |
225 | 225 |
226 ImageSkia ImageSkia::DeepCopy() const { | 226 scoped_ptr<ImageSkia> ImageSkia::DeepCopy() const { |
227 ImageSkia copy; | 227 ImageSkia* copy = new ImageSkia; |
228 if (isNull()) | 228 if (isNull()) |
229 return copy; | 229 return scoped_ptr<ImageSkia>(copy); |
230 | 230 |
231 CHECK(CanRead()); | 231 CHECK(CanRead()); |
232 | 232 |
233 std::vector<gfx::ImageSkiaRep>& reps = storage_->image_reps(); | 233 std::vector<gfx::ImageSkiaRep>& reps = storage_->image_reps(); |
234 for (std::vector<gfx::ImageSkiaRep>::iterator iter = reps.begin(); | 234 for (std::vector<gfx::ImageSkiaRep>::iterator iter = reps.begin(); |
235 iter != reps.end(); ++iter) { | 235 iter != reps.end(); ++iter) { |
236 copy.AddRepresentation(*iter); | 236 copy->AddRepresentation(*iter); |
237 } | 237 } |
238 // The copy has its own storage. Detach the copy from the current | 238 // The copy has its own storage. Detach the copy from the current |
239 // thread so that other thread can use this. | 239 // thread so that other thread can use this. |
240 if (!copy.isNull()) | 240 if (!copy->isNull()) |
241 copy.storage_->DetachFromThread(); | 241 copy->storage_->DetachFromThread(); |
242 return copy; | 242 return scoped_ptr<ImageSkia>(copy); |
243 } | 243 } |
244 | 244 |
245 bool ImageSkia::BackedBySameObjectAs(const gfx::ImageSkia& other) const { | 245 bool ImageSkia::BackedBySameObjectAs(const gfx::ImageSkia& other) const { |
246 return storage_.get() == other.storage_.get(); | 246 return storage_.get() == other.storage_.get(); |
247 } | 247 } |
248 | 248 |
249 void ImageSkia::AddRepresentation(const ImageSkiaRep& image_rep) { | 249 void ImageSkia::AddRepresentation(const ImageSkiaRep& image_rep) { |
250 DCHECK(!image_rep.is_null()); | 250 DCHECK(!image_rep.is_null()); |
251 | 251 |
252 // TODO(oshima): This method should be called |SetRepresentation| | 252 // TODO(oshima): This method should be called |SetRepresentation| |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 bool ImageSkia::CanModify() const { | 401 bool ImageSkia::CanModify() const { |
402 return !storage_ || storage_->CanModify(); | 402 return !storage_ || storage_->CanModify(); |
403 } | 403 } |
404 | 404 |
405 void ImageSkia::DetachStorageFromThread() { | 405 void ImageSkia::DetachStorageFromThread() { |
406 if (storage_) | 406 if (storage_) |
407 storage_->DetachFromThread(); | 407 storage_->DetachFromThread(); |
408 } | 408 } |
409 | 409 |
410 } // namespace gfx | 410 } // namespace gfx |
OLD | NEW |