blob: 60eb8e7db72b3d8d820ae88458668211f4cd10d8 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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.com8a1c16f2008-12-17 15:59:43 +00009
10#ifndef SkDrawMatrix_DEFINED
11#define SkDrawMatrix_DEFINED
12
reed986ca612014-11-26 08:50:45 -080013#include "SkADrawable.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000014#include "SkMatrix.h"
15#include "SkMemberInfo.h"
16#include "SkIntArray.h"
17
18class SkMatrixPart;
19
reed986ca612014-11-26 08:50:45 -080020class SkDrawMatrix : public SkADrawable {
reed@android.com8a1c16f2008-12-17 15:59:43 +000021 DECLARE_DRAW_MEMBER_INFO(Matrix);
22 SkDrawMatrix();
23 virtual ~SkDrawMatrix();
tfarina@chromium.org1d3c4112012-12-03 14:38:08 +000024 virtual bool addChild(SkAnimateMaker& , SkDisplayable* child) SK_OVERRIDE;
tfarina752e7eb2014-12-20 06:53:43 -080025 virtual bool childrenNeedDisposing() const SK_OVERRIDE;
26 virtual void dirty() SK_OVERRIDE;
27 virtual bool draw(SkAnimateMaker& ) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000028#ifdef SK_DUMP_ENABLED
tfarina752e7eb2014-12-20 06:53:43 -080029 virtual void dump(SkAnimateMaker* ) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000030#endif
31 SkMatrix& getMatrix();
tfarina752e7eb2014-12-20 06:53:43 -080032 virtual bool getProperty(int index, SkScriptValue* value) const SK_OVERRIDE;
33 virtual void initialize() SK_OVERRIDE;
34 virtual void onEndElement(SkAnimateMaker& ) SK_OVERRIDE;
35 virtual void setChildHasID() SK_OVERRIDE;
36 virtual bool setProperty(int index, SkScriptValue& ) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000037
38 void concat(SkMatrix& inMatrix) {
39 fConcat.preConcat(inMatrix);
40 }
41
tfarina752e7eb2014-12-20 06:53:43 -080042 virtual SkDisplayable* deepCopy(SkAnimateMaker* ) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000043
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 }
64private:
65 SkTDScalarArray matrix;
66 SkMatrix fConcat;
67 SkMatrix fMatrix;
68 SkTDMatrixPartArray fParts;
69 SkBool8 fChildHasID;
70 SkBool8 fDirty;
reed986ca612014-11-26 08:50:45 -080071 typedef SkADrawable INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +000072};
73
74#endif // SkDrawMatrix_DEFINED