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/gfx/shadow_value.h" | 5 #include "ui/gfx/shadow_value.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "ui/gfx/insets.h" | 10 #include "ui/gfx/insets.h" |
11 | 11 |
12 namespace gfx { | 12 namespace gfx { |
13 | 13 |
14 ShadowValue::ShadowValue() | 14 ShadowValue::ShadowValue() |
15 : blur_(0), | 15 : blur_(0), |
16 color_(0) { | 16 color_(0) { |
17 } | 17 } |
18 | 18 |
19 ShadowValue::ShadowValue(const gfx::Point& offset, | 19 ShadowValue::ShadowValue(const gfx::Point& offset, |
20 double blur, | 20 double blur, |
21 SkColor color) | 21 SkColor color) |
22 : offset_(offset), | 22 : offset_(offset), |
23 blur_(blur), | 23 blur_(blur), |
24 color_(color) { | 24 color_(color) { |
25 } | 25 } |
26 | 26 |
27 ShadowValue::~ShadowValue() { | 27 ShadowValue::~ShadowValue() { |
28 } | 28 } |
29 | 29 |
| 30 ShadowValue ShadowValue::Scale(float scale) const { |
| 31 return ShadowValue(offset_.Scale(scale), blur_ * scale, color_); |
| 32 } |
| 33 |
30 std::string ShadowValue::ToString() const { | 34 std::string ShadowValue::ToString() const { |
31 return base::StringPrintf( | 35 return base::StringPrintf( |
32 "(%d,%d),%.2f,rgba(%d,%d,%d,%d)", | 36 "(%d,%d),%.2f,rgba(%d,%d,%d,%d)", |
33 offset_.x(), offset_.y(), | 37 offset_.x(), offset_.y(), |
34 blur_, | 38 blur_, |
35 SkColorGetR(color_), | 39 SkColorGetR(color_), |
36 SkColorGetG(color_), | 40 SkColorGetG(color_), |
37 SkColorGetB(color_), | 41 SkColorGetB(color_), |
38 SkColorGetA(color_)); | 42 SkColorGetA(color_)); |
39 } | 43 } |
(...skipping 14 matching lines...) Expand all Loading... |
54 left = std::max(left, blur - shadow.x()); | 58 left = std::max(left, blur - shadow.x()); |
55 top = std::max(top, blur - shadow.y()); | 59 top = std::max(top, blur - shadow.y()); |
56 right = std::max(right, blur + shadow.x()); | 60 right = std::max(right, blur + shadow.x()); |
57 bottom = std::max(bottom, blur + shadow.y()); | 61 bottom = std::max(bottom, blur + shadow.y()); |
58 } | 62 } |
59 | 63 |
60 return Insets(-top, -left, -bottom, -right); | 64 return Insets(-top, -left, -bottom, -right); |
61 } | 65 } |
62 | 66 |
63 } // namespace gfx | 67 } // namespace gfx |
OLD | NEW |