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