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

Side by Side Diff: ui/views/controls/focusable_border.cc

Issue 2818713006: FocusableBorder/fractional scales: snap to different pixel (Closed)
Patch Set: Created 3 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 | « no previous file | 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/controls/focusable_border.h" 5 #include "ui/views/controls/focusable_border.h"
6 6
7 #include "cc/paint/paint_flags.h" 7 #include "cc/paint/paint_flags.h"
8 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
9 #include "ui/base/material_design/material_design_controller.h" 9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 gfx::ScopedCanvas scoped(canvas); 47 gfx::ScopedCanvas scoped(canvas);
48 float dsf = canvas->UndoDeviceScaleFactor(); 48 float dsf = canvas->UndoDeviceScaleFactor();
49 49
50 const int stroke_width_px = 50 const int stroke_width_px =
51 ui::MaterialDesignController::IsSecondaryUiMaterial() 51 ui::MaterialDesignController::IsSecondaryUiMaterial()
52 ? 1 52 ? 1
53 : gfx::ToFlooredInt(dsf); 53 : gfx::ToFlooredInt(dsf);
54 flags.setStrokeWidth(SkIntToScalar(stroke_width_px)); 54 flags.setStrokeWidth(SkIntToScalar(stroke_width_px));
55 55
56 // Scale the rect and snap to pixel boundaries. 56 // Scale the rect and snap to pixel boundaries.
57 gfx::RectF rect(gfx::ScaleToEnclosingRect(view.GetLocalBounds(), dsf)); 57 gfx::RectF rect(gfx::ScaleToEnclosedRect(view.GetLocalBounds(), dsf));
58 rect.Inset(gfx::InsetsF(stroke_width_px / 2.0f)); 58 rect.Inset(gfx::InsetsF(stroke_width_px / 2.0f));
59 59
60 SkPath path; 60 SkPath path;
61 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { 61 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
62 flags.setAntiAlias(true); 62 flags.setAntiAlias(true);
63 float corner_radius_px = kCornerRadiusDp * dsf; 63 float corner_radius_px = kCornerRadiusDp * dsf;
64 path.addRoundRect(gfx::RectFToSkRect(rect), corner_radius_px, 64 path.addRoundRect(gfx::RectFToSkRect(rect), corner_radius_px,
65 corner_radius_px); 65 corner_radius_px);
66 } else { 66 } else {
67 path.addRect(gfx::RectFToSkRect(rect), SkPath::kCW_Direction); 67 path.addRect(gfx::RectFToSkRect(rect), SkPath::kCW_Direction);
(...skipping 25 matching lines...) Expand all
93 SkColor color = view.GetNativeTheme()->GetSystemColor(color_id); 93 SkColor color = view.GetNativeTheme()->GetSystemColor(color_id);
94 if (ui::MaterialDesignController::IsSecondaryUiMaterial() && 94 if (ui::MaterialDesignController::IsSecondaryUiMaterial() &&
95 !view.enabled()) { 95 !view.enabled()) {
96 return color_utils::BlendTowardOppositeLuma(color, 96 return color_utils::BlendTowardOppositeLuma(color,
97 gfx::kDisabledControlAlpha); 97 gfx::kDisabledControlAlpha);
98 } 98 }
99 return color; 99 return color;
100 } 100 }
101 101
102 } // namespace views 102 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698