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/native_theme/common_theme.h" | 5 #include "ui/native_theme/common_theme.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
9 #include "ui/base/material_design/material_design_controller.h" | 10 #include "ui/base/material_design/material_design_controller.h" |
10 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
12 #include "ui/gfx/color_palette.h" | 13 #include "ui/gfx/color_palette.h" |
13 #include "ui/gfx/color_utils.h" | 14 #include "ui/gfx/color_utils.h" |
14 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
15 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
16 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
17 #include "ui/resources/grit/ui_resources.h" | 18 #include "ui/resources/grit/ui_resources.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 429 } |
429 if (menu_item.corner_radius > 0) { | 430 if (menu_item.corner_radius > 0) { |
430 const SkScalar radius = SkIntToScalar(menu_item.corner_radius); | 431 const SkScalar radius = SkIntToScalar(menu_item.corner_radius); |
431 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint); | 432 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint); |
432 return; | 433 return; |
433 } | 434 } |
434 canvas->drawRect(gfx::RectToSkRect(rect), paint); | 435 canvas->drawRect(gfx::RectToSkRect(rect), paint); |
435 } | 436 } |
436 | 437 |
437 // static | 438 // static |
438 scoped_ptr<gfx::Canvas> CommonThemeCreateCanvas(SkCanvas* sk_canvas) { | 439 std::unique_ptr<gfx::Canvas> CommonThemeCreateCanvas(SkCanvas* sk_canvas) { |
439 // TODO(pkotwicz): Do something better and don't infer device | 440 // TODO(pkotwicz): Do something better and don't infer device |
440 // scale factor from canvas scale. | 441 // scale factor from canvas scale. |
441 SkMatrix m = sk_canvas->getTotalMatrix(); | 442 SkMatrix m = sk_canvas->getTotalMatrix(); |
442 float device_scale = static_cast<float>(SkScalarAbs(m.getScaleX())); | 443 float device_scale = static_cast<float>(SkScalarAbs(m.getScaleX())); |
443 return make_scoped_ptr(new gfx::Canvas(skia::SharePtr(sk_canvas), | 444 return base::WrapUnique( |
444 device_scale)); | 445 new gfx::Canvas(skia::SharePtr(sk_canvas), device_scale)); |
445 } | 446 } |
446 | 447 |
447 } // namespace ui | 448 } // namespace ui |
OLD | NEW |