OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/gfx/skia_utils_mac.h" | 5 #include "base/gfx/skia_utils_mac.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "SkMatrix.h" |
8 #include "SkRect.h" | 9 #include "SkRect.h" |
9 | 10 |
10 namespace gfx { | 11 namespace gfx { |
11 | 12 |
| 13 CGAffineTransform SkMatrixToCGAffineTransform(const SkMatrix& matrix) { |
| 14 // CGAffineTransforms don't support perspective transforms, so make sure |
| 15 // we don't get those. |
| 16 DCHECK(matrix[SkMatrix::kMPersp0] == 0.0f); |
| 17 DCHECK(matrix[SkMatrix::kMPersp1] == 0.0f); |
| 18 DCHECK(matrix[SkMatrix::kMPersp2] == 1.0f); |
| 19 |
| 20 return CGAffineTransformMake(matrix[SkMatrix::kMScaleX], |
| 21 matrix[SkMatrix::kMSkewY], |
| 22 matrix[SkMatrix::kMSkewX], |
| 23 matrix[SkMatrix::kMScaleY], |
| 24 matrix[SkMatrix::kMTransX], |
| 25 matrix[SkMatrix::kMTransY]); |
| 26 } |
| 27 |
12 SkIRect CGRectToSkIRect(const CGRect& rect) { | 28 SkIRect CGRectToSkIRect(const CGRect& rect) { |
13 SkIRect sk_rect = { | 29 SkIRect sk_rect = { |
14 SkScalarRound(rect.origin.x), | 30 SkScalarRound(rect.origin.x), |
15 SkScalarRound(rect.origin.y), | 31 SkScalarRound(rect.origin.y), |
16 SkScalarRound(rect.origin.x + rect.size.width), | 32 SkScalarRound(rect.origin.x + rect.size.width), |
17 SkScalarRound(rect.origin.y + rect.size.height) | 33 SkScalarRound(rect.origin.y + rect.size.height) |
18 }; | 34 }; |
19 return sk_rect; | 35 return sk_rect; |
20 } | 36 } |
21 | 37 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // Converts ARGB to CGColorRef. | 74 // Converts ARGB to CGColorRef. |
59 CGColorRef SkColorToCGColorRef(SkColor color) { | 75 CGColorRef SkColorToCGColorRef(SkColor color) { |
60 return CGColorCreateGenericRGB(SkColorGetR(color) / 255.0, | 76 return CGColorCreateGenericRGB(SkColorGetR(color) / 255.0, |
61 SkColorGetG(color) / 255.0, | 77 SkColorGetG(color) / 255.0, |
62 SkColorGetB(color) / 255.0, | 78 SkColorGetB(color) / 255.0, |
63 SkColorGetA(color) / 255.0); | 79 SkColorGetA(color) / 255.0); |
64 } | 80 } |
65 | 81 |
66 } // namespace gfx | 82 } // namespace gfx |
67 | 83 |
OLD | NEW |