blob: 4c4528ecd4bd817c3c4b42cad274774e5f551acf [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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
30namespace android {
31
32class Region;
33
34// ---------------------------------------------------------------------------
35
36class Transform
37{
38public:
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 bool transformed() const;
54 int32_t getOrientation() const;
55 bool preserveRects() const;
56
57 int tx() const;
58 int ty() const;
59
60 void reset();
61 void set(float xx, float xy, float yx, float yy);
62 void set(int tx, int ty);
Mathias Agopian0d1318b2009-03-27 17:58:20 -070063 void set(float radian, float x, float y);
64 void scale(float s, float x, float y);
65
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080066 Rect makeBounds(int w, int h) const;
67 void transform(GLfixed* point, int x, int y) const;
68 Region transform(const Region& reg) const;
69 Rect transform(const Rect& bounds) const;
70
71 Transform operator * (const Transform& rhs) const;
72 float operator [] (int i) const;
73
74 inline uint32_t getType() const { return type(); }
75
76 inline Transform(bool) : mType(0xFF) { };
77
78private:
79 uint8_t type() const;
80
81private:
82 SkMatrix mTransform;
83 mutable uint32_t mType;
84};
85
86// ---------------------------------------------------------------------------
87}; // namespace android
88
89#endif /* ANDROID_TRANSFORM_H */