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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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 | « ui/gfx/image/image_skia.h ('k') | ui/gfx/image/image_skia_unittest.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 #include "ui/gfx/image/image_skia.h" 5 #include "ui/gfx/image/image_skia.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <limits> 11 #include <limits>
12 #include <memory>
12 13
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/ptr_util.h"
16 #include "base/threading/non_thread_safe.h" 17 #include "base/threading/non_thread_safe.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/size.h" 20 #include "ui/gfx/geometry/size.h"
20 #include "ui/gfx/geometry/size_conversions.h" 21 #include "ui/gfx/geometry/size_conversions.h"
21 #include "ui/gfx/image/image_skia_operations.h" 22 #include "ui/gfx/image/image_skia_operations.h"
22 #include "ui/gfx/image/image_skia_source.h" 23 #include "ui/gfx/image/image_skia_source.h"
23 #include "ui/gfx/skia_util.h" 24 #include "ui/gfx/skia_util.h"
24 #include "ui/gfx/switches.h" 25 #include "ui/gfx/switches.h"
25 26
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 bool fetch_new_image) const; 115 bool fetch_new_image) const;
115 116
116 private: 117 private:
117 friend class base::RefCountedThreadSafe<ImageSkiaStorage>; 118 friend class base::RefCountedThreadSafe<ImageSkiaStorage>;
118 119
119 virtual ~ImageSkiaStorage(); 120 virtual ~ImageSkiaStorage();
120 121
121 // Vector of bitmaps and their associated scale. 122 // Vector of bitmaps and their associated scale.
122 std::vector<gfx::ImageSkiaRep> image_reps_; 123 std::vector<gfx::ImageSkiaRep> image_reps_;
123 124
124 scoped_ptr<ImageSkiaSource> source_; 125 std::unique_ptr<ImageSkiaSource> source_;
125 126
126 // Size of the image in DIP. 127 // Size of the image in DIP.
127 gfx::Size size_; 128 gfx::Size size_;
128 129
129 bool read_only_; 130 bool read_only_;
130 131
131 DISALLOW_COPY_AND_ASSIGN(ImageSkiaStorage); 132 DISALLOW_COPY_AND_ASSIGN(ImageSkiaStorage);
132 }; 133 };
133 134
134 ImageSkiaStorage::ImageSkiaStorage(ImageSkiaSource* source, 135 ImageSkiaStorage::ImageSkiaStorage(ImageSkiaSource* source,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // static 328 // static
328 float ImageSkia::GetMaxSupportedScale() { 329 float ImageSkia::GetMaxSupportedScale() {
329 return g_supported_scales->back(); 330 return g_supported_scales->back();
330 } 331 }
331 332
332 // static 333 // static
333 ImageSkia ImageSkia::CreateFrom1xBitmap(const SkBitmap& bitmap) { 334 ImageSkia ImageSkia::CreateFrom1xBitmap(const SkBitmap& bitmap) {
334 return ImageSkia(ImageSkiaRep(bitmap, 0.0f)); 335 return ImageSkia(ImageSkiaRep(bitmap, 0.0f));
335 } 336 }
336 337
337 scoped_ptr<ImageSkia> ImageSkia::DeepCopy() const { 338 std::unique_ptr<ImageSkia> ImageSkia::DeepCopy() const {
338 ImageSkia* copy = new ImageSkia; 339 ImageSkia* copy = new ImageSkia;
339 if (isNull()) 340 if (isNull())
340 return make_scoped_ptr(copy); 341 return base::WrapUnique(copy);
341 342
342 CHECK(CanRead()); 343 CHECK(CanRead());
343 344
344 std::vector<gfx::ImageSkiaRep>& reps = storage_->image_reps(); 345 std::vector<gfx::ImageSkiaRep>& reps = storage_->image_reps();
345 for (std::vector<gfx::ImageSkiaRep>::iterator iter = reps.begin(); 346 for (std::vector<gfx::ImageSkiaRep>::iterator iter = reps.begin();
346 iter != reps.end(); ++iter) { 347 iter != reps.end(); ++iter) {
347 copy->AddRepresentation(*iter); 348 copy->AddRepresentation(*iter);
348 } 349 }
349 // The copy has its own storage. Detach the copy from the current 350 // The copy has its own storage. Detach the copy from the current
350 // thread so that other thread can use this. 351 // thread so that other thread can use this.
351 if (!copy->isNull()) 352 if (!copy->isNull())
352 copy->storage_->DetachFromThread(); 353 copy->storage_->DetachFromThread();
353 return make_scoped_ptr(copy); 354 return base::WrapUnique(copy);
354 } 355 }
355 356
356 bool ImageSkia::BackedBySameObjectAs(const gfx::ImageSkia& other) const { 357 bool ImageSkia::BackedBySameObjectAs(const gfx::ImageSkia& other) const {
357 return storage_.get() == other.storage_.get(); 358 return storage_.get() == other.storage_.get();
358 } 359 }
359 360
360 void ImageSkia::AddRepresentation(const ImageSkiaRep& image_rep) { 361 void ImageSkia::AddRepresentation(const ImageSkiaRep& image_rep) {
361 DCHECK(!image_rep.is_null()); 362 DCHECK(!image_rep.is_null());
362 363
363 // TODO(oshima): This method should be called |SetRepresentation| 364 // TODO(oshima): This method should be called |SetRepresentation|
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 bool ImageSkia::CanModify() const { 518 bool ImageSkia::CanModify() const {
518 return !storage_.get() || storage_->CanModify(); 519 return !storage_.get() || storage_->CanModify();
519 } 520 }
520 521
521 void ImageSkia::DetachStorageFromThread() { 522 void ImageSkia::DetachStorageFromThread() {
522 if (storage_.get()) 523 if (storage_.get())
523 storage_->DetachFromThread(); 524 storage_->DetachFromThread();
524 } 525 }
525 526
526 } // namespace gfx 527 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698