OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkRSXform_DEFINED |
| 9 #define SkRSXform_DEFINED |
| 10 |
| 11 #include "SkScalar.h" |
| 12 |
| 13 /** |
| 14 * A compressed form of a rotation+scale matrix. |
| 15 * |
| 16 * [ fSCos -fSSin fTx ] |
| 17 * [ fSSin fSCos fTy ] |
| 18 * [ 0 0 1 ] |
| 19 */ |
| 20 struct SkRSXform { |
| 21 SkScalar fSCos; |
| 22 SkScalar fSSin; |
| 23 SkScalar fTx; |
| 24 SkScalar fTy; |
| 25 |
| 26 bool rectStaysRect() const { |
| 27 return 0 == fSCos || 0 == fSSin; |
| 28 } |
| 29 |
| 30 void setIdentity() { |
| 31 fSCos = 1; |
| 32 fSSin = fTx = fTy = 0; |
| 33 } |
| 34 |
| 35 void set(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty) { |
| 36 fSCos = scos; |
| 37 fSSin = ssin; |
| 38 fTx = tx; |
| 39 fTy = ty; |
| 40 } |
| 41 |
| 42 void toQuad(SkScalar width, SkScalar height, SkPoint quad[4]) const; |
| 43 void toQuad(const SkSize& size, SkPoint quad[4]) const { |
| 44 this->toQuad(size.width(), size.height(), quad); |
| 45 } |
| 46 }; |
| 47 |
| 48 #endif |
| 49 |
OLD | NEW |