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

Side by Side Diff: ui/views/painter.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/views/painter.h ('k') | ui/views/style/mac/dialog_button_border_mac_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/views/painter.h" 5 #include "ui/views/painter.h"
6 6
7 #include <memory>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/ptr_util.h"
10 #include "third_party/skia/include/effects/SkGradientShader.h" 12 #include "third_party/skia/include/effects/SkGradientShader.h"
11 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/geometry/insets.h" 15 #include "ui/gfx/geometry/insets.h"
14 #include "ui/gfx/geometry/point.h" 16 #include "ui/gfx/geometry/point.h"
15 #include "ui/gfx/geometry/rect_f.h" 17 #include "ui/gfx/geometry/rect_f.h"
16 #include "ui/gfx/geometry/size.h" 18 #include "ui/gfx/geometry/size.h"
17 #include "ui/gfx/geometry/size_f.h" 19 #include "ui/gfx/geometry/size_f.h"
18 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
19 #include "ui/gfx/image/image_skia.h" 21 #include "ui/gfx/image/image_skia.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 ~GradientPainter() override; 144 ~GradientPainter() override;
143 145
144 // Painter: 146 // Painter:
145 gfx::Size GetMinimumSize() const override; 147 gfx::Size GetMinimumSize() const override;
146 void Paint(gfx::Canvas* canvas, const gfx::Size& size) override; 148 void Paint(gfx::Canvas* canvas, const gfx::Size& size) override;
147 149
148 private: 150 private:
149 // If |horizontal_| is true then the gradient is painted horizontally. 151 // If |horizontal_| is true then the gradient is painted horizontally.
150 bool horizontal_; 152 bool horizontal_;
151 // The gradient colors. 153 // The gradient colors.
152 scoped_ptr<SkColor[]> colors_; 154 std::unique_ptr<SkColor[]> colors_;
153 // The relative positions of the corresponding gradient colors. 155 // The relative positions of the corresponding gradient colors.
154 scoped_ptr<SkScalar[]> pos_; 156 std::unique_ptr<SkScalar[]> pos_;
155 // The number of elements in |colors_| and |pos_|. 157 // The number of elements in |colors_| and |pos_|.
156 size_t count_; 158 size_t count_;
157 159
158 DISALLOW_COPY_AND_ASSIGN(GradientPainter); 160 DISALLOW_COPY_AND_ASSIGN(GradientPainter);
159 }; 161 };
160 162
161 GradientPainter::GradientPainter(bool horizontal, 163 GradientPainter::GradientPainter(bool horizontal,
162 SkColor* colors, 164 SkColor* colors,
163 SkScalar* pos, 165 SkScalar* pos,
164 size_t count) 166 size_t count)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // Constructs an ImagePainter with the specified image and insets. 211 // Constructs an ImagePainter with the specified image and insets.
210 ImagePainter(const gfx::ImageSkia& image, const gfx::Insets& insets); 212 ImagePainter(const gfx::ImageSkia& image, const gfx::Insets& insets);
211 213
212 ~ImagePainter() override; 214 ~ImagePainter() override;
213 215
214 // Painter: 216 // Painter:
215 gfx::Size GetMinimumSize() const override; 217 gfx::Size GetMinimumSize() const override;
216 void Paint(gfx::Canvas* canvas, const gfx::Size& size) override; 218 void Paint(gfx::Canvas* canvas, const gfx::Size& size) override;
217 219
218 private: 220 private:
219 scoped_ptr<gfx::NineImagePainter> nine_painter_; 221 std::unique_ptr<gfx::NineImagePainter> nine_painter_;
220 222
221 DISALLOW_COPY_AND_ASSIGN(ImagePainter); 223 DISALLOW_COPY_AND_ASSIGN(ImagePainter);
222 }; 224 };
223 225
224 ImagePainter::ImagePainter(const int image_ids[]) 226 ImagePainter::ImagePainter(const int image_ids[])
225 : nine_painter_(ui::CreateNineImagePainter(image_ids)) { 227 : nine_painter_(ui::CreateNineImagePainter(image_ids)) {
226 } 228 }
227 229
228 ImagePainter::ImagePainter(const gfx::ImageSkia& image, 230 ImagePainter::ImagePainter(const gfx::ImageSkia& image,
229 const gfx::Insets& insets) 231 const gfx::Insets& insets)
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 const gfx::Insets& insets) { 308 const gfx::Insets& insets) {
307 return new ImagePainter(image, insets); 309 return new ImagePainter(image, insets);
308 } 310 }
309 311
310 // static 312 // static
311 Painter* Painter::CreateImageGridPainter(const int image_ids[]) { 313 Painter* Painter::CreateImageGridPainter(const int image_ids[]) {
312 return new ImagePainter(image_ids); 314 return new ImagePainter(image_ids);
313 } 315 }
314 316
315 // static 317 // static
316 scoped_ptr<Painter> Painter::CreateDashedFocusPainter() { 318 std::unique_ptr<Painter> Painter::CreateDashedFocusPainter() {
317 return make_scoped_ptr(new DashedFocusPainter(gfx::Insets())); 319 return base::WrapUnique(new DashedFocusPainter(gfx::Insets()));
318 } 320 }
319 321
320 // static 322 // static
321 scoped_ptr<Painter> Painter::CreateDashedFocusPainterWithInsets( 323 std::unique_ptr<Painter> Painter::CreateDashedFocusPainterWithInsets(
322 const gfx::Insets& insets) { 324 const gfx::Insets& insets) {
323 return make_scoped_ptr(new DashedFocusPainter(insets)); 325 return base::WrapUnique(new DashedFocusPainter(insets));
324 } 326 }
325 327
326 // static 328 // static
327 scoped_ptr<Painter> Painter::CreateSolidFocusPainter( 329 std::unique_ptr<Painter> Painter::CreateSolidFocusPainter(
328 SkColor color, 330 SkColor color,
329 const gfx::Insets& insets) { 331 const gfx::Insets& insets) {
330 return make_scoped_ptr(new SolidFocusPainter(color, insets)); 332 return base::WrapUnique(new SolidFocusPainter(color, insets));
331 } 333 }
332 334
333 // HorizontalPainter ---------------------------------------------------------- 335 // HorizontalPainter ----------------------------------------------------------
334 336
335 HorizontalPainter::HorizontalPainter(const int image_resource_names[]) { 337 HorizontalPainter::HorizontalPainter(const int image_resource_names[]) {
336 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 338 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
337 for (int i = 0; i < 3; ++i) 339 for (int i = 0; i < 3; ++i)
338 images_[i] = rb.GetImageNamed(image_resource_names[i]).ToImageSkia(); 340 images_[i] = rb.GetImageNamed(image_resource_names[i]).ToImageSkia();
339 DCHECK_EQ(images_[LEFT]->height(), images_[CENTER]->height()); 341 DCHECK_EQ(images_[LEFT]->height(), images_[CENTER]->height());
340 DCHECK_EQ(images_[LEFT]->height(), images_[RIGHT]->height()); 342 DCHECK_EQ(images_[LEFT]->height(), images_[RIGHT]->height());
(...skipping 15 matching lines...) Expand all
356 canvas->DrawImageInt(*images_[LEFT], 0, 0); 358 canvas->DrawImageInt(*images_[LEFT], 0, 0);
357 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(), 359 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(),
358 0); 360 0);
359 canvas->TileImageInt( 361 canvas->TileImageInt(
360 *images_[CENTER], images_[LEFT]->width(), 0, 362 *images_[CENTER], images_[LEFT]->width(), 0,
361 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), 363 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(),
362 images_[LEFT]->height()); 364 images_[LEFT]->height());
363 } 365 }
364 366
365 } // namespace views 367 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/painter.h ('k') | ui/views/style/mac/dialog_button_border_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698