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

Side by Side Diff: ui/gfx/shadow_value.cc

Issue 884653003: gfx::ShadowValue: offset is a Vector2d, not Point. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile. Created 5 years, 9 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/gfx/shadow_value.h ('k') | ui/gfx/shadow_value_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/gfx/shadow_value.h" 5 #include "ui/gfx/shadow_value.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "ui/gfx/geometry/insets.h" 10 #include "ui/gfx/geometry/insets.h"
11 #include "ui/gfx/geometry/point_conversions.h" 11 #include "ui/gfx/geometry/vector2d_conversions.h"
12 12
13 namespace gfx { 13 namespace gfx {
14 14
15 ShadowValue::ShadowValue() 15 ShadowValue::ShadowValue()
16 : blur_(0), 16 : blur_(0),
17 color_(0) { 17 color_(0) {
18 } 18 }
19 19
20 ShadowValue::ShadowValue(const gfx::Point& offset, 20 ShadowValue::ShadowValue(const gfx::Vector2d& offset,
21 double blur, 21 double blur,
22 SkColor color) 22 SkColor color)
23 : offset_(offset), 23 : offset_(offset), blur_(blur), color_(color) {
24 blur_(blur),
25 color_(color) {
26 } 24 }
27 25
28 ShadowValue::~ShadowValue() { 26 ShadowValue::~ShadowValue() {
29 } 27 }
30 28
31 ShadowValue ShadowValue::Scale(float scale) const { 29 ShadowValue ShadowValue::Scale(float scale) const {
32 gfx::Point scaled_offset = 30 gfx::Vector2d scaled_offset =
33 gfx::ToFlooredPoint(gfx::ScalePoint(offset_, scale)); 31 gfx::ToFlooredVector2d(gfx::ScaleVector2d(offset_, scale));
34 return ShadowValue(scaled_offset, blur_ * scale, color_); 32 return ShadowValue(scaled_offset, blur_ * scale, color_);
35 } 33 }
36 34
37 std::string ShadowValue::ToString() const { 35 std::string ShadowValue::ToString() const {
38 return base::StringPrintf( 36 return base::StringPrintf(
39 "(%d,%d),%.2f,rgba(%d,%d,%d,%d)", 37 "(%d,%d),%.2f,rgba(%d,%d,%d,%d)",
40 offset_.x(), offset_.y(), 38 offset_.x(), offset_.y(),
41 blur_, 39 blur_,
42 SkColorGetR(color_), 40 SkColorGetR(color_),
43 SkColorGetG(color_), 41 SkColorGetG(color_),
(...skipping 17 matching lines...) Expand all
61 left = std::max(left, blur - shadow.x()); 59 left = std::max(left, blur - shadow.x());
62 top = std::max(top, blur - shadow.y()); 60 top = std::max(top, blur - shadow.y());
63 right = std::max(right, blur + shadow.x()); 61 right = std::max(right, blur + shadow.x());
64 bottom = std::max(bottom, blur + shadow.y()); 62 bottom = std::max(bottom, blur + shadow.y());
65 } 63 }
66 64
67 return Insets(-top, -left, -bottom, -right); 65 return Insets(-top, -left, -bottom, -right);
68 } 66 }
69 67
70 } // namespace gfx 68 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/shadow_value.h ('k') | ui/gfx/shadow_value_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698