| 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> |
| 8 |
| 7 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 8 #include "ui/gfx/insets.h" | 10 #include "ui/gfx/insets.h" |
| 9 | 11 |
| 10 namespace gfx { | 12 namespace gfx { |
| 11 | 13 |
| 12 ShadowValue::ShadowValue() | 14 ShadowValue::ShadowValue() |
| 13 : blur_(0), | 15 : blur_(0), |
| 14 color_(0) { | 16 color_(0) { |
| 15 } | 17 } |
| 16 | 18 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 30 "(%d,%d),%.2f,rgba(%d,%d,%d,%d)", | 32 "(%d,%d),%.2f,rgba(%d,%d,%d,%d)", |
| 31 offset_.x(), offset_.y(), | 33 offset_.x(), offset_.y(), |
| 32 blur_, | 34 blur_, |
| 33 SkColorGetR(color_), | 35 SkColorGetR(color_), |
| 34 SkColorGetG(color_), | 36 SkColorGetG(color_), |
| 35 SkColorGetB(color_), | 37 SkColorGetB(color_), |
| 36 SkColorGetA(color_)); | 38 SkColorGetA(color_)); |
| 37 } | 39 } |
| 38 | 40 |
| 39 // static | 41 // static |
| 40 Insets ShadowValue::GetMargin(const std::vector<ShadowValue>& shadows) { | 42 Insets ShadowValue::GetMargin(const ShadowValues& shadows) { |
| 41 int left = 0; | 43 int left = 0; |
| 42 int top = 0; | 44 int top = 0; |
| 43 int right = 0; | 45 int right = 0; |
| 44 int bottom = 0; | 46 int bottom = 0; |
| 45 | 47 |
| 46 for (size_t i = 0; i < shadows.size(); ++i) { | 48 for (size_t i = 0; i < shadows.size(); ++i) { |
| 47 const ShadowValue& shadow = shadows[i]; | 49 const ShadowValue& shadow = shadows[i]; |
| 48 | 50 |
| 49 // Add 0.5 to round up to the next integer. | 51 // Add 0.5 to round up to the next integer. |
| 50 int blur = static_cast<int>(shadow.blur() / 2 + 0.5); | 52 int blur = static_cast<int>(shadow.blur() / 2 + 0.5); |
| 51 | 53 |
| 52 left = std::max(left, blur - shadow.x()); | 54 left = std::max(left, blur - shadow.x()); |
| 53 top = std::max(top, blur - shadow.y()); | 55 top = std::max(top, blur - shadow.y()); |
| 54 right = std::max(right, blur + shadow.x()); | 56 right = std::max(right, blur + shadow.x()); |
| 55 bottom = std::max(bottom, blur + shadow.y()); | 57 bottom = std::max(bottom, blur + shadow.y()); |
| 56 } | 58 } |
| 57 | 59 |
| 58 return Insets(-top, -left, -bottom, -right); | 60 return Insets(-top, -left, -bottom, -right); |
| 59 } | 61 } |
| 60 | 62 |
| 61 } // namespace gfx | 63 } // namespace gfx |
| OLD | NEW |