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 "skia/ext/skia_utils_mac.h" | 5 #include "skia/ext/skia_utils_mac.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 DCHECK(matrix[SkMatrix::kMPersp2] == 1.0f); | 129 DCHECK(matrix[SkMatrix::kMPersp2] == 1.0f); |
130 | 130 |
131 return CGAffineTransformMake(matrix[SkMatrix::kMScaleX], | 131 return CGAffineTransformMake(matrix[SkMatrix::kMScaleX], |
132 matrix[SkMatrix::kMSkewY], | 132 matrix[SkMatrix::kMSkewY], |
133 matrix[SkMatrix::kMSkewX], | 133 matrix[SkMatrix::kMSkewX], |
134 matrix[SkMatrix::kMScaleY], | 134 matrix[SkMatrix::kMScaleY], |
135 matrix[SkMatrix::kMTransX], | 135 matrix[SkMatrix::kMTransX], |
136 matrix[SkMatrix::kMTransY]); | 136 matrix[SkMatrix::kMTransY]); |
137 } | 137 } |
138 | 138 |
139 SkIRect CGRectToSkIRect(const CGRect& rect) { | |
140 SkIRect sk_rect = { | |
141 SkScalarRound(rect.origin.x), | |
142 SkScalarRound(rect.origin.y), | |
143 SkScalarRound(rect.origin.x + rect.size.width), | |
144 SkScalarRound(rect.origin.y + rect.size.height) | |
145 }; | |
146 return sk_rect; | |
147 } | |
148 | |
149 SkRect CGRectToSkRect(const CGRect& rect) { | 139 SkRect CGRectToSkRect(const CGRect& rect) { |
150 SkRect sk_rect = { | 140 SkRect sk_rect = { |
151 rect.origin.x, | 141 rect.origin.x, |
152 rect.origin.y, | 142 rect.origin.y, |
153 rect.origin.x + rect.size.width, | 143 rect.origin.x + rect.size.width, |
154 rect.origin.y + rect.size.height, | 144 rect.origin.y + rect.size.height, |
155 }; | 145 }; |
156 return sk_rect; | 146 return sk_rect; |
157 } | 147 } |
158 | 148 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // Apply content matrix. | 350 // Apply content matrix. |
361 SkMatrix skMatrix = canvas_->getTotalMatrix(); | 351 SkMatrix skMatrix = canvas_->getTotalMatrix(); |
362 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY)); | 352 skMatrix.postTranslate(-SkIntToScalar(pt.fX), -SkIntToScalar(pt.fY)); |
363 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix); | 353 CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix); |
364 CGContextConcatCTM(cgContext_, affine); | 354 CGContextConcatCTM(cgContext_, affine); |
365 | 355 |
366 return cgContext_; | 356 return cgContext_; |
367 } | 357 } |
368 | 358 |
369 } // namespace gfx | 359 } // namespace gfx |
OLD | NEW |