| 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/skia_util.h" | 5 #include "ui/gfx/skia_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 skia::RefPtr<SkShader> CreateGradientShader(int start_point, | 123 skia::RefPtr<SkShader> CreateGradientShader(int start_point, |
| 124 int end_point, | 124 int end_point, |
| 125 SkColor start_color, | 125 SkColor start_color, |
| 126 SkColor end_color) { | 126 SkColor end_color) { |
| 127 SkColor grad_colors[2] = { start_color, end_color}; | 127 SkColor grad_colors[2] = { start_color, end_color}; |
| 128 SkPoint grad_points[2]; | 128 SkPoint grad_points[2]; |
| 129 grad_points[0].iset(0, start_point); | 129 grad_points[0].iset(0, start_point); |
| 130 grad_points[1].iset(0, end_point); | 130 grad_points[1].iset(0, end_point); |
| 131 | 131 |
| 132 return skia::AdoptRef(SkGradientShader::CreateLinear( | 132 return skia::AdoptRef(SkGradientShader::CreateLinear( |
| 133 grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode)); | 133 grad_points, grad_colors, NULL, 2, SkShader::kClamp_TileMode)); |
| 134 } | 134 } |
| 135 | 135 |
| 136 static SkScalar RadiusToSigma(double radius) { | 136 static SkScalar RadiusToSigma(double radius) { |
| 137 // This captures historically what skia did under the hood. Now skia accepts | 137 // This captures historically what skia did under the hood. Now skia accepts |
| 138 // sigma, not radius, so we perform the conversion. | 138 // sigma, not radius, so we perform the conversion. |
| 139 return radius > 0 ? SkDoubleToScalar(0.57735f * radius + 0.5) : 0; | 139 return radius > 0 ? SkDoubleToScalar(0.57735f * radius + 0.5) : 0; |
| 140 } | 140 } |
| 141 | 141 |
| 142 skia::RefPtr<SkDrawLooper> CreateShadowDrawLooper( | 142 skia::RefPtr<SkDrawLooper> CreateShadowDrawLooper( |
| 143 const std::vector<ShadowValue>& shadows) { | 143 const std::vector<ShadowValue>& shadows) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 static const SkScalar kSkToHbRatio = SK_Scalar1 / kHbUnit1; | 238 static const SkScalar kSkToHbRatio = SK_Scalar1 / kHbUnit1; |
| 239 return kSkToHbRatio * value; | 239 return kSkToHbRatio * value; |
| 240 } | 240 } |
| 241 | 241 |
| 242 float HarfBuzzUnitsToFloat(int value) { | 242 float HarfBuzzUnitsToFloat(int value) { |
| 243 static const float kFloatToHbRatio = 1.0f / kHbUnit1; | 243 static const float kFloatToHbRatio = 1.0f / kHbUnit1; |
| 244 return kFloatToHbRatio * value; | 244 return kFloatToHbRatio * value; |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace gfx | 247 } // namespace gfx |
| OLD | NEW |