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

Side by Side Diff: ui/views/painter.cc

Issue 2637383003: Change Painter factory functions to unique_ptr (Closed)
Patch Set: msw review Created 3 years, 11 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') | no next file » | 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> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 // static 291 // static
292 void Painter::PaintFocusPainter(View* view, 292 void Painter::PaintFocusPainter(View* view,
293 gfx::Canvas* canvas, 293 gfx::Canvas* canvas,
294 Painter* focus_painter) { 294 Painter* focus_painter) {
295 if (focus_painter && view->HasFocus()) 295 if (focus_painter && view->HasFocus())
296 PaintPainterAt(canvas, focus_painter, view->GetLocalBounds()); 296 PaintPainterAt(canvas, focus_painter, view->GetLocalBounds());
297 } 297 }
298 298
299 // static 299 // static
300 Painter* Painter::CreateSolidRoundRectPainter(SkColor color, float radius) { 300 std::unique_ptr<Painter> Painter::CreateSolidRoundRectPainter(SkColor color,
301 return new SolidRoundRectPainter(color, SK_ColorTRANSPARENT, radius); 301 float radius) {
302 return base::MakeUnique<SolidRoundRectPainter>(color, SK_ColorTRANSPARENT,
303 radius);
302 } 304 }
303 305
304 // static 306 // static
305 Painter* Painter::CreateRoundRectWith1PxBorderPainter(SkColor bg_color, 307 std::unique_ptr<Painter> Painter::CreateRoundRectWith1PxBorderPainter(
306 SkColor stroke_color, 308 SkColor bg_color,
307 float radius) { 309 SkColor stroke_color,
308 return new SolidRoundRectPainter(bg_color, stroke_color, radius); 310 float radius) {
311 return base::MakeUnique<SolidRoundRectPainter>(bg_color, stroke_color,
312 radius);
309 } 313 }
310 314
311 // static 315 // static
312 Painter* Painter::CreateHorizontalGradient(SkColor c1, SkColor c2) { 316 std::unique_ptr<Painter> Painter::CreateVerticalGradient(SkColor c1,
317 SkColor c2) {
313 SkColor colors[2]; 318 SkColor colors[2];
314 colors[0] = c1; 319 colors[0] = c1;
315 colors[1] = c2; 320 colors[1] = c2;
316 SkScalar pos[] = {0, 1}; 321 SkScalar pos[] = {0, 1};
317 return new GradientPainter(true, colors, pos, 2); 322 return base::MakeUnique<GradientPainter>(false, colors, pos, 2);
318 } 323 }
319 324
320 // static 325 // static
321 Painter* Painter::CreateVerticalGradient(SkColor c1, SkColor c2) { 326 std::unique_ptr<Painter> Painter::CreateImagePainter(
322 SkColor colors[2]; 327 const gfx::ImageSkia& image,
323 colors[0] = c1; 328 const gfx::Insets& insets) {
324 colors[1] = c2; 329 return base::MakeUnique<ImagePainter>(image, insets);
325 SkScalar pos[] = {0, 1};
326 return new GradientPainter(false, colors, pos, 2);
327 } 330 }
328 331
329 // static 332 // static
330 Painter* Painter::CreateVerticalMultiColorGradient(SkColor* colors, 333 std::unique_ptr<Painter> Painter::CreateImageGridPainter(
331 SkScalar* pos, 334 const int image_ids[]) {
332 size_t count) { 335 return base::MakeUnique<ImagePainter>(image_ids);
333 return new GradientPainter(false, colors, pos, count);
334 } 336 }
335 337
336 // static 338 // static
337 Painter* Painter::CreateImagePainter(const gfx::ImageSkia& image,
338 const gfx::Insets& insets) {
339 return new ImagePainter(image, insets);
340 }
341
342 // static
343 Painter* Painter::CreateImageGridPainter(const int image_ids[]) {
344 return new ImagePainter(image_ids);
345 }
346
347 // static
348 std::unique_ptr<Painter> Painter::CreateDashedFocusPainter() { 339 std::unique_ptr<Painter> Painter::CreateDashedFocusPainter() {
349 return base::MakeUnique<DashedFocusPainter>(gfx::Insets()); 340 return base::MakeUnique<DashedFocusPainter>(gfx::Insets());
350 } 341 }
351 342
352 // static 343 // static
353 std::unique_ptr<Painter> Painter::CreateDashedFocusPainterWithInsets( 344 std::unique_ptr<Painter> Painter::CreateDashedFocusPainterWithInsets(
354 const gfx::Insets& insets) { 345 const gfx::Insets& insets) {
355 return base::MakeUnique<DashedFocusPainter>(insets); 346 return base::MakeUnique<DashedFocusPainter>(insets);
356 } 347 }
357 348
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 canvas->DrawImageInt(*images_[LEFT], 0, 0); 394 canvas->DrawImageInt(*images_[LEFT], 0, 0);
404 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(), 395 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(),
405 0); 396 0);
406 canvas->TileImageInt( 397 canvas->TileImageInt(
407 *images_[CENTER], images_[LEFT]->width(), 0, 398 *images_[CENTER], images_[LEFT]->width(), 0,
408 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), 399 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(),
409 images_[LEFT]->height()); 400 images_[LEFT]->height());
410 } 401 }
411 402
412 } // namespace views 403 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/painter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698