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 "third_party/skia/include/core/SkBitmap.h" | 7 #include "third_party/skia/include/core/SkBitmap.h" |
8 #include "third_party/skia/include/core/SkColorFilter.h" | 8 #include "third_party/skia/include/core/SkColorFilter.h" |
9 #include "third_party/skia/include/core/SkColorPriv.h" | 9 #include "third_party/skia/include/core/SkColorPriv.h" |
10 #include "third_party/skia/include/core/SkUnPreMultiply.h" | 10 #include "third_party/skia/include/core/SkUnPreMultiply.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 SkFloatToScalar(rect.height())); | 40 SkFloatToScalar(rect.height())); |
41 } | 41 } |
42 | 42 |
43 RectF SkRectToRectF(const SkRect& rect) { | 43 RectF SkRectToRectF(const SkRect& rect) { |
44 return RectF(SkScalarToFloat(rect.x()), | 44 return RectF(SkScalarToFloat(rect.x()), |
45 SkScalarToFloat(rect.y()), | 45 SkScalarToFloat(rect.y()), |
46 SkScalarToFloat(rect.width()), | 46 SkScalarToFloat(rect.width()), |
47 SkScalarToFloat(rect.height())); | 47 SkScalarToFloat(rect.height())); |
48 } | 48 } |
49 | 49 |
| 50 SkSize SizeToSkSize(const Size& size) { |
| 51 return SkSize::Make(SkIntToScalar(size.width()), |
| 52 SkIntToScalar(size.height())); |
| 53 } |
| 54 |
| 55 Size SkSizeToSize(const SkSize& size) { |
| 56 return Size(SkScalarTruncToInt(size.width()), |
| 57 SkScalarTruncToInt(size.height())); |
| 58 } |
| 59 |
50 void TransformToFlattenedSkMatrix(const gfx::Transform& transform, | 60 void TransformToFlattenedSkMatrix(const gfx::Transform& transform, |
51 SkMatrix* flattened) { | 61 SkMatrix* flattened) { |
52 // Convert from 4x4 to 3x3 by dropping the third row and column. | 62 // Convert from 4x4 to 3x3 by dropping the third row and column. |
53 flattened->set(0, SkMScalarToScalar(transform.matrix().get(0, 0))); | 63 flattened->set(0, SkMScalarToScalar(transform.matrix().get(0, 0))); |
54 flattened->set(1, SkMScalarToScalar(transform.matrix().get(0, 1))); | 64 flattened->set(1, SkMScalarToScalar(transform.matrix().get(0, 1))); |
55 flattened->set(2, SkMScalarToScalar(transform.matrix().get(0, 3))); | 65 flattened->set(2, SkMScalarToScalar(transform.matrix().get(0, 3))); |
56 flattened->set(3, SkMScalarToScalar(transform.matrix().get(1, 0))); | 66 flattened->set(3, SkMScalarToScalar(transform.matrix().get(1, 0))); |
57 flattened->set(4, SkMScalarToScalar(transform.matrix().get(1, 1))); | 67 flattened->set(4, SkMScalarToScalar(transform.matrix().get(1, 1))); |
58 flattened->set(5, SkMScalarToScalar(transform.matrix().get(1, 3))); | 68 flattened->set(5, SkMScalarToScalar(transform.matrix().get(1, 3))); |
59 flattened->set(6, SkMScalarToScalar(transform.matrix().get(3, 0))); | 69 flattened->set(6, SkMScalarToScalar(transform.matrix().get(3, 0))); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } else { | 194 } else { |
185 rgba[i + 0] = SkGetPackedR32(pixel_in); | 195 rgba[i + 0] = SkGetPackedR32(pixel_in); |
186 rgba[i + 1] = SkGetPackedG32(pixel_in); | 196 rgba[i + 1] = SkGetPackedG32(pixel_in); |
187 rgba[i + 2] = SkGetPackedB32(pixel_in); | 197 rgba[i + 2] = SkGetPackedB32(pixel_in); |
188 rgba[i + 3] = alpha; | 198 rgba[i + 3] = alpha; |
189 } | 199 } |
190 } | 200 } |
191 } | 201 } |
192 | 202 |
193 } // namespace gfx | 203 } // namespace gfx |
OLD | NEW |