epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2006 The Android Open Source Project |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | |
| 10 | #ifndef SkDrawMatrix_DEFINED |
| 11 | #define SkDrawMatrix_DEFINED |
| 12 | |
reed | 986ca61 | 2014-11-26 08:50:45 -0800 | [diff] [blame] | 13 | #include "SkADrawable.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 14 | #include "SkMatrix.h" |
| 15 | #include "SkMemberInfo.h" |
| 16 | #include "SkIntArray.h" |
| 17 | |
| 18 | class SkMatrixPart; |
| 19 | |
reed | 986ca61 | 2014-11-26 08:50:45 -0800 | [diff] [blame] | 20 | class SkDrawMatrix : public SkADrawable { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | DECLARE_DRAW_MEMBER_INFO(Matrix); |
| 22 | SkDrawMatrix(); |
| 23 | virtual ~SkDrawMatrix(); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 24 | bool addChild(SkAnimateMaker& , SkDisplayable* child) override; |
| 25 | bool childrenNeedDisposing() const override; |
| 26 | void dirty() override; |
| 27 | bool draw(SkAnimateMaker& ) override; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 28 | #ifdef SK_DUMP_ENABLED |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 29 | void dump(SkAnimateMaker* ) override; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 30 | #endif |
| 31 | SkMatrix& getMatrix(); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 32 | bool getProperty(int index, SkScriptValue* value) const override; |
| 33 | void initialize() override; |
| 34 | void onEndElement(SkAnimateMaker& ) override; |
| 35 | void setChildHasID() override; |
| 36 | bool setProperty(int index, SkScriptValue& ) override; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | |
| 38 | void concat(SkMatrix& inMatrix) { |
| 39 | fConcat.preConcat(inMatrix); |
| 40 | } |
| 41 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 42 | SkDisplayable* deepCopy(SkAnimateMaker* ) override; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 43 | |
| 44 | |
| 45 | void rotate(SkScalar degrees, SkPoint& center) { |
| 46 | fMatrix.preRotate(degrees, center.fX, center.fY); |
| 47 | } |
| 48 | |
| 49 | void set(SkMatrix& src) { |
| 50 | fMatrix.preConcat(src); |
| 51 | } |
| 52 | |
| 53 | void scale(SkScalar scaleX, SkScalar scaleY, SkPoint& center) { |
| 54 | fMatrix.preScale(scaleX, scaleY, center.fX, center.fY); |
| 55 | } |
| 56 | |
| 57 | void skew(SkScalar skewX, SkScalar skewY, SkPoint& center) { |
| 58 | fMatrix.preSkew(skewX, skewY, center.fX, center.fY); |
| 59 | } |
| 60 | |
| 61 | void translate(SkScalar x, SkScalar y) { |
| 62 | fMatrix.preTranslate(x, y); |
| 63 | } |
| 64 | private: |
| 65 | SkTDScalarArray matrix; |
| 66 | SkMatrix fConcat; |
| 67 | SkMatrix fMatrix; |
| 68 | SkTDMatrixPartArray fParts; |
| 69 | SkBool8 fChildHasID; |
| 70 | SkBool8 fDirty; |
reed | 986ca61 | 2014-11-26 08:50:45 -0800 | [diff] [blame] | 71 | typedef SkADrawable INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | #endif // SkDrawMatrix_DEFINED |