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

Side by Side Diff: ui/native_theme/native_theme_base.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/native_theme/native_theme_base.h ('k') | ui/native_theme/native_theme_win.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/native_theme/native_theme_base.h" 5 #include "ui/native_theme/native_theme_base.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <memory>
8 9
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "third_party/skia/include/core/SkPaint.h" 12 #include "third_party/skia/include/core/SkPaint.h"
13 #include "third_party/skia/include/core/SkPath.h" 13 #include "third_party/skia/include/core/SkPath.h"
14 #include "third_party/skia/include/effects/SkGradientShader.h" 14 #include "third_party/skia/include/effects/SkGradientShader.h"
15 #include "ui/base/layout.h" 15 #include "ui/base/layout.h"
16 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/base/ui_base_switches.h" 17 #include "ui/base/ui_base_switches.h"
18 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/color_palette.h" 19 #include "ui/gfx/color_palette.h"
20 #include "ui/gfx/color_utils.h" 20 #include "ui/gfx/color_utils.h"
21 #include "ui/gfx/geometry/rect.h" 21 #include "ui/gfx/geometry/rect.h"
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 915
916 void NativeThemeBase::AdjustCheckboxRadioRectForPadding(SkRect* rect) const { 916 void NativeThemeBase::AdjustCheckboxRadioRectForPadding(SkRect* rect) const {
917 // By default we only take 1px from right and bottom for the drop shadow. 917 // By default we only take 1px from right and bottom for the drop shadow.
918 rect->iset(rect->x(), rect->y(), rect->right() - 1, rect->bottom() - 1); 918 rect->iset(rect->x(), rect->y(), rect->right() - 1, rect->bottom() - 1);
919 } 919 }
920 920
921 void NativeThemeBase::DrawImageInt( 921 void NativeThemeBase::DrawImageInt(
922 SkCanvas* sk_canvas, const gfx::ImageSkia& image, 922 SkCanvas* sk_canvas, const gfx::ImageSkia& image,
923 int src_x, int src_y, int src_w, int src_h, 923 int src_x, int src_y, int src_w, int src_h,
924 int dest_x, int dest_y, int dest_w, int dest_h) const { 924 int dest_x, int dest_y, int dest_w, int dest_h) const {
925 scoped_ptr<gfx::Canvas> canvas(CommonThemeCreateCanvas(sk_canvas)); 925 std::unique_ptr<gfx::Canvas> canvas(CommonThemeCreateCanvas(sk_canvas));
926 canvas->DrawImageInt(image, src_x, src_y, src_w, src_h, 926 canvas->DrawImageInt(image, src_x, src_y, src_w, src_h,
927 dest_x, dest_y, dest_w, dest_h, true); 927 dest_x, dest_y, dest_w, dest_h, true);
928 } 928 }
929 929
930 void NativeThemeBase::DrawTiledImage(SkCanvas* sk_canvas, 930 void NativeThemeBase::DrawTiledImage(SkCanvas* sk_canvas,
931 const gfx::ImageSkia& image, 931 const gfx::ImageSkia& image,
932 int src_x, int src_y, float tile_scale_x, float tile_scale_y, 932 int src_x, int src_y, float tile_scale_x, float tile_scale_y,
933 int dest_x, int dest_y, int w, int h) const { 933 int dest_x, int dest_y, int w, int h) const {
934 scoped_ptr<gfx::Canvas> canvas(CommonThemeCreateCanvas(sk_canvas)); 934 std::unique_ptr<gfx::Canvas> canvas(CommonThemeCreateCanvas(sk_canvas));
935 canvas->TileImageInt(image, src_x, src_y, tile_scale_x, 935 canvas->TileImageInt(image, src_x, src_y, tile_scale_x,
936 tile_scale_y, dest_x, dest_y, w, h); 936 tile_scale_y, dest_x, dest_y, w, h);
937 } 937 }
938 938
939 SkColor NativeThemeBase::SaturateAndBrighten(SkScalar* hsv, 939 SkColor NativeThemeBase::SaturateAndBrighten(SkScalar* hsv,
940 SkScalar saturate_amount, 940 SkScalar saturate_amount,
941 SkScalar brighten_amount) const { 941 SkScalar brighten_amount) const {
942 SkScalar color[3]; 942 SkScalar color[3];
943 color[0] = hsv[0]; 943 color[0] = hsv[0];
944 color[1] = Clamp(hsv[1] + saturate_amount, 0.0, 1.0); 944 color[1] = Clamp(hsv[1] + saturate_amount, 0.0, 1.0);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); 1025 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f);
1026 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); 1026 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
1027 1027
1028 if (hsv1[2] + hsv2[2] > 1.0) 1028 if (hsv1[2] + hsv2[2] > 1.0)
1029 diff = -diff; 1029 diff = -diff;
1030 1030
1031 return SaturateAndBrighten(hsv2, -0.2f, diff); 1031 return SaturateAndBrighten(hsv2, -0.2f, diff);
1032 } 1032 }
1033 1033
1034 } // namespace ui 1034 } // namespace ui
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme_base.h ('k') | ui/native_theme/native_theme_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698