blob: 8339d8ccd6aa3a4ea9ddc66534650fdb7591e8fc [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/* libs/graphics/animator/SkDrawMatrix.h
2**
3** Copyright 2006, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef SkDrawMatrix_DEFINED
19#define SkDrawMatrix_DEFINED
20
21#include "SkDrawable.h"
22#include "SkMatrix.h"
23#include "SkMemberInfo.h"
24#include "SkIntArray.h"
25
26class SkMatrixPart;
27
28class SkDrawMatrix : public SkDrawable {
29 DECLARE_DRAW_MEMBER_INFO(Matrix);
30 SkDrawMatrix();
31 virtual ~SkDrawMatrix();
32 virtual bool add(SkAnimateMaker& , SkDisplayable* child);
33 virtual bool childrenNeedDisposing() const;
34 virtual void dirty();
35 virtual bool draw(SkAnimateMaker& );
36#ifdef SK_DUMP_ENABLED
37 virtual void dump(SkAnimateMaker* );
38#endif
39 SkMatrix& getMatrix();
40 virtual bool getProperty(int index, SkScriptValue* value) const;
41 virtual void initialize();
42 virtual void onEndElement(SkAnimateMaker& );
43 virtual void setChildHasID();
44 virtual bool setProperty(int index, SkScriptValue& );
45
46 void concat(SkMatrix& inMatrix) {
47 fConcat.preConcat(inMatrix);
48 }
49
50 virtual SkDisplayable* deepCopy(SkAnimateMaker* );
51
52
53 void rotate(SkScalar degrees, SkPoint& center) {
54 fMatrix.preRotate(degrees, center.fX, center.fY);
55 }
56
57 void set(SkMatrix& src) {
58 fMatrix.preConcat(src);
59 }
60
61 void scale(SkScalar scaleX, SkScalar scaleY, SkPoint& center) {
62 fMatrix.preScale(scaleX, scaleY, center.fX, center.fY);
63 }
64
65 void skew(SkScalar skewX, SkScalar skewY, SkPoint& center) {
66 fMatrix.preSkew(skewX, skewY, center.fX, center.fY);
67 }
68
69 void translate(SkScalar x, SkScalar y) {
70 fMatrix.preTranslate(x, y);
71 }
72private:
73 SkTDScalarArray matrix;
74 SkMatrix fConcat;
75 SkMatrix fMatrix;
76 SkTDMatrixPartArray fParts;
77 SkBool8 fChildHasID;
78 SkBool8 fDirty;
79 typedef SkDrawable INHERITED;
80};
81
82#endif // SkDrawMatrix_DEFINED