• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_TRANSFORM_H
18 #define ANDROID_TRANSFORM_H
19 
20 #include <stdint.h>
21 #include <sys/types.h>
22 
23 #include <ui/Point.h>
24 #include <ui/Rect.h>
25 
26 #include <GLES/gl.h>
27 
28 #include <core/SkMatrix.h>
29 
30 namespace android {
31 
32 class Region;
33 
34 // ---------------------------------------------------------------------------
35 
36 class Transform
37 {
38 public:
39                     Transform();
40                     Transform(const Transform&  other);
41                     ~Transform();
42 
43             enum orientation_flags {
44                 ROT_0   = 0x00000000,
45                 FLIP_H  = 0x00000001,
46                 FLIP_V  = 0x00000002,
47                 ROT_90  = 0x00000004,
48                 ROT_180 = FLIP_H|FLIP_V,
49                 ROT_270 = ROT_180|ROT_90,
50                 ROT_INVALID = 0x80000000
51             };
52 
53             enum type_mask {
54                 IDENTITY            = 0,
55                 TRANSLATE           = 0x1,
56                 SCALE               = 0x2,
57                 AFFINE              = 0x4,
58                 PERSPECTIVE         = 0x8
59             };
60 
61             bool    transformed() const;
62             int32_t getOrientation() const;
63             bool    preserveRects() const;
64 
65             int     tx() const;
66             int     ty() const;
67 
68             void    reset();
69             void    set(float xx, float xy, float yx, float yy);
70             void    set(int tx, int ty);
71             void    set(float radian, float x, float y);
72             void    scale(float s, float x, float y);
73 
74             Rect    makeBounds(int w, int h) const;
75             void    transform(GLfixed* point, int x, int y) const;
76             Region  transform(const Region& reg) const;
77             Rect    transform(const Rect& bounds) const;
78 
79             Transform operator * (const Transform& rhs) const;
80             float operator [] (int i) const;
81 
getType()82     inline uint32_t getType() const { return type(); }
83 
Transform(bool)84     inline Transform(bool) : mType(0xFF) { };
85 
86 private:
87     uint8_t     type() const;
88 
89 private:
90             SkMatrix    mTransform;
91     mutable uint32_t    mType;
92 };
93 
94 // ---------------------------------------------------------------------------
95 }; // namespace android
96 
97 #endif /* ANDROID_TRANSFORM_H */
98